Sqlite教程(3) SQlite Query
Configuration是属於util工具包。
把所有环境设置都定义在Configuration工具包里,那麽这个Configuration就是独立的单一入囗。
在架构上,可以提高耦合度,而且出Bug时也方便追纵。
更重要的是,假如表格的Name需要改变,那只要在Configuration里改一下变量就行,不用担心其他控件会因此出Bug。
这里第一部份定义了SQlite的Query,第二部份定义了okhttp的URL。
1. SQlite的Query
/*
* SQLite
*/
public static final String DB_NAME = "epdz.db";
public static int DB_VERSION = 23; /*
* SQLite [Table]User
*/
public static final String DB_USER = "epdz_user";
public static final String USER_ID = "id";
public static final String USER_USERID = "userId";
public static final String USER_NAME = "name";
public static final String USER_PASSWORD = "password";
public static final String USER_EMAIL = "email";
public static final String USER_DESCRIPTION = "description";
public static final String USER_TEAM = "team";
public static final String USER_ACADEMIC = "academic";
public static final String USER_PORTRAIT = "portrait";
public static final String USER_PORTRAIT_DATA = "portraitData";
public static final String USER_REGISTER_DATE = "registerDate"; /*
* SQLite [Table]Post
*/
public static final String DB_POST = "epdz_post";
public static final String POST_ID = "pid";
public static final String POST_POSTID = "id";
public static final String POST_CATEGORY = "category";
public static final String POST_DATE = "date";
public static final String POST_AUTHORID = "authorId";
public static final String POST_EDITORID = "editorId";
public static final String POST_TITLE = "title";
public static final String POST_ABSTRACT = "abstract";
public static final String POST_ABSTRACTIMG = "abstractImg";
public static final String POST_CONTEXT = "context";
public static final String POST_ISTOP = "isTop";
public static final String POST_VISITABLE = "visitable";
public static final String POST_AUTHORNAME = "authorName";
public static final String POST_EDITORNAME = "editorName";
public static final String POST_CATEGORYNAME = "categoryName"; /*
* SQlite [Table] Create user
*/
public static final String CREATE_USER_TABLE = " CREATE TABLE " +DB_USER+ " (" +
USER_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
USER_USERID + " VARCHAR(256) NOT NULL, " +
USER_NAME + " VARCHAR(256) NOT NULL, " +
USER_PASSWORD + " VARCHAR(256) NOT NULL, " +
USER_EMAIL + " VARCHAR(256), " +
USER_DESCRIPTION + " VARCHAR(512), " +
USER_TEAM + " VARCHAR(256), " +
USER_ACADEMIC + " VARCHAR(256), " +
USER_PORTRAIT + " VARCHAR(512), " +
USER_PORTRAIT_DATA + " BLOB, " +
USER_REGISTER_DATE + " VARCHAR(256) NOT NULL );"; /*
* SQlite [Table] Create post
*/
public static final String CREATE_POST_TABLE = " CREATE TABLE " +DB_POST+ " (" +
POST_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
POST_POSTID + " VARCHAR(32) NOT NULL, " +
POST_CATEGORY + " VARCHAR(32), " +
POST_CATEGORYNAME + " VARCHAR(32), " +
POST_DATE + " VARCHAR(32), " +
POST_AUTHORID + " VARCHAR(32), " +
POST_AUTHORNAME + " VARCHAR(32), " +
POST_EDITORID + " VARCHAR(32), " +
POST_EDITORNAME + " VARCHAR(32), " +
POST_TITLE + " VARCHAR(512), " +
POST_ABSTRACT + " VARCHAR(1024), " +
POST_ABSTRACTIMG + " VARCHAR(1024), " +
POST_CONTEXT + " VARCHAR(2048), " +
POST_ISTOP + " VARCHAR(32), " +
POST_VISITABLE + " VARCHAR(32) );";
2. okhttp的URL
/*
* login query
* @param [String] userNmae, [String] userPassword
* @return [BOOL]result, [String]userId
*/
public static String isUserExistURL(String userNmae, String userPassword)
{
return "http://e-pdz.com/epdz/router/mobile/userRouter.php?action=isUserExist&name="+userNmae+"&password="+userPassword;
} /*
* get user query
* @param [String]userId
* @return [array]user
*/
public static String getUserURL(String userId) {
return "http://e-pdz.com/epdz/router/mobile/userRouter.php?action=getUserByUserId&id="+userId;
} /*
* create user query
* @param [String] name, [String] password
* @return [BOOL]result
*/
public static String createUserURL(String name, String password) {
return "http://e-pdz.com/epdz/router/mobile/userRouter.php?action=register&name="+name+"&password="+password;
} /*
* update user query
* @param [UserDTO]userDTO
* @return [BOOL]result, [String]userId
*/
public static String updateUserURL(UserDTO userDTO) {
Integer id = userDTO.getId();
String name = userDTO.getName();
String password = userDTO.getPassword();
String description = userDTO.getDescription();
String team = userDTO.getTeam();
String academic = userDTO.getAcademic(); return "http://e-pdz.com/epdz/router/mobile/userRouter.php?action=updateUser&id="+id+"&name="+name+
"&password="+password+"&description="+description+"&team="+team+"&academic="+academic;
} /*
* get all post query
* @return [array] post
*/
public static String getAllPost = "http://e-pdz.com/epdz/router/mobile/postRouter.php?action=getAllPost"; /*
* get hot post query
* @return [array] post
*/
public static String getHotPost = "http://e-pdz.com/epdz/router/mobile/postRouter.php?action=getHotPost"; /*
* get hot post offset query
* @param [String]start, [String]amount
* @return [array]post
*/
public static String getHotPostByCursor(Integer start, Integer amount) {
return "http://e-pdz.com/epdz/router/mobile/postRouter.php?action=getHotPostByCursor&start="+start+
"&amount="+amount;
} /*
* get post query
* @param [String] category
* @return [array] post
*/
public static String getPostByCategoryURL(String Category) {
return "http://e-pdz.com/epdz/router/mobile/postRouter.php?action=getPostByCategory&category="+Category;
} /*
* get post query
* @param [String] postId
* @return [array] post
*/
public static String getPostByIdURL(String id) {
return "http://e-pdz.com/epdz/router/mobile/postRouter.php?action=getPostById&postId="+id;
} /*
* get post query
* @param [String] postId
* @return [html] post
*/
public static String getPostHhtmlByIdURL(String id) {
return "http://e-pdz.com/epdz/viewAndroid/post/post.php?id="+id;
} /*
* get user like post
* @param [String]userId
* @return [array]post
*/
public static String getLikePostByUserId(String id) {
return "http://e-pdz.com/epdz/router/mobile/userRouter.php?action=getLikePostByUserId&userId="+id;
} /*
* get user comment query
* @param [String]userId
* @return [array]post
*/
public static String getCommentByWriterId(String id) {
return "http://e-pdz.com/epdz/router/mobile/userRouter.php?action=getCommentByWriterId&userId="+id;
} /*
* get user message query
* @param [String]receiverId
* @return [array]Message
*/
public static String getMessageByReceiverId(String receiverId) {
return "http://e-pdz.com/epdz/router/mobile/userRouter.php?action=getMessageByReceiverId&receiverId="+receiverId;
} /*
* update portrait query
*
*/
public static String updatePortrait = "http://e-pdz.com/epdz/router/mobile/userRouter.php";
这里只出一部份代码供叁考。
Sqlite教程(3) SQlite Query的更多相关文章
- SQLite Learning、SQL Query Optimization In Multiple Rule
catalog . SQLite简介 . Sqlite安装 . SQLite Programing . SQLite statements 1. SQLite简介 SQLite是一款轻型的数据库,是遵 ...
- android安卓 SQLite教程:内部架构及SQLite使用办法
SQLite 介绍 SQLite一个非常流行的嵌入式数据库,它支持SQL语言,并且只利用很少的内存就有很好的性能.由于JDBC不适合手机这种内存受限设备,所以Android开发人员需要学习新的API ...
- sqlite3使用教程1 SQLite 命令
http://www.runoob.com/sqlite/sqlite-commands.html 本章将向您讲解 SQLite 编程人员所使用的简单却有用的命令.这些命令被称为 SQLite 的点命 ...
- Xamarin SQLite教程Xamarin.iOS项目添加引用
Xamarin SQLite教程Xamarin.iOS项目添加引用 使用直接方式访问SQLite数据库,需要将System.Data和Mono.Data.SQlite库导入到创建的项目中.下面将分别讲 ...
- Xamarin SQLite教程数据库访问与生成
Xamarin SQLite教程数据库访问与生成 在本教程中,我们将讲解如何开发SQLite相关的App.在编写程序前,首先需要做一些准备工作,如了解Xamarin数据库访问方式,添加引用,构建使用库 ...
- SQLite教程
SQLite教程 http://www.runoob.com/sqlite/sqlite-date-time.html SQLite管理工具http://www.sqliteexpert.com/do ...
- SQLite的使用--SQLite语句
一.SQLite的介绍 1.为什么要存储数据? 1.1 手机数据大多都是从网络加载的,不存储,每次滚动界面都要从新发送网络请求加载数据,浪费流量 1.2 当用户没网的时候, ...
- 纯 Swift 封装的 SQLite 框架:SQLite.swift
SQLite.swift 是一个使用纯 Swift 语言封装 SQLite3 的操作框架. 特性: 简单的查询和参数绑定接口 安全.自动类型数据访问 隐式提交和回滚接口 开发者友好的错误处理和调试 文 ...
- 【Android】13.3 使用SQLite.NET-PCL访问SQLite数据库
分类:C#.Android.VS2015: 创建日期:2016-02-26 一.简介 本章开头已经说过了,SQLite.NET-PCL用起来很爽,这一节咱们看看怎样使用吧. 二.示例3运行截图 下面左 ...
随机推荐
- 吴裕雄--天生自然 PHP开发学习:数据类型
<?php $x = "Hello world!"; echo $x; echo "<br>"; $x = 'Hello world!'; e ...
- salt教程1-理解saltstack
https://docs.saltstack.com/en/getstarted/system/index.html 1 基本介绍 通过观察它的实际运行,你可以大致理解salt如何工作.这意味着,在控 ...
- Neo4j--windows下安装neo4j
参考 https://www.cnblogs.com/ljhdo/archive/2017/05/19/5521577.html 安装包下载 https://neo4j.com/download-ce ...
- It can be a face application using SeetaFace and Qt.
之前编译了一下SeetaFace的库,用于人脸检测.特征点定位和人脸识别的功能,然后昨天就用Qt写了一个软件用于实现. 工程的文件还是比较简单的,一个界面类和一个SeetaFace的线程类而已.这里主 ...
- ubuntu服务器上配置tomcat
前言 嗯,最近想在自己的腾讯云服务器上跑个项目玩玩,由于服务器是重装的系统,所以,只能自己手动装tomcat. 不过,tomcat是基于java的,必须又java环境tomcat才能够使用,因此首先要 ...
- 关于图算法 & 图分析的基础知识概览
网址:https://learning.oreilly.com/library/view/graph-algorithms-/9781492060116/ 你肯定没有读过这本书,因为这本书的发布日期是 ...
- CSS 之pseudo-classes 与pseudo-element的异同
从W3School找到相关资料如下: 伪类: 伪类存在的意义是为了通过选择器找到那些不存在与DOM树中的信息以及不能被常规CSS选择器获取到的信息. 伪类由一个冒号:开头,冒号后面是伪类的名称和包含在 ...
- EL表达式和JSTL(三)——EL表达式
在JSP的开发中,为了获取Servlet中存储的数据,通常需要很多的Java代码,这样的做法使的JSP页面非常混乱,为此,JSP2.0中提供了一种EL规范,是一种简单的数据访问语言. 1.初识EL E ...
- day64-html-form表单
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8& ...
- Linux中的错误重定向你真的懂吗
在很多定时任务里.shell里我们往往能看到 "2>&1",却不知道这背后的原理. 举个例子: * 1 * * * test.sh > /dev/null 2& ...