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运行截图 下面左 ...
随机推荐
- awk 总结
说明:本文源于“朱双印博客”,原文地址:http://www.zsythink.net/archives/tag/awk awk 命令: 综合: awk功能是对“文本”进行格式化输出,形成报表:awk ...
- 备份mysql的批处理命令
需要工具mysqldump.exe的支持,安装mysql默认是带此工具的 批处理命令 set NOW_TIME_HH=%time:~0,2% if "%NOW_TIME_HH%" ...
- Zxing和QR Code生成和解析二维码
本文是学习慕课网课程<Java生成二维码>(http://www.imooc.com/learn/531)的笔记. 一.二维码的分类 线性堆叠式二维码.矩阵式二维码.邮政码. 二.二维码的 ...
- 云服务器Linux版本下---安装git
xshell进入云服务器: 按照git官网:https://git-scm.com/download/linux 的教程输入: apt-get install git 本地没有包????? 原来是 ...
- eclipse默认的WebContent目录修改为webRoot
从网上下载了个Java Web项目,导入Eclipse后在Tomcat中发布,发现在Tomcat的Webapps目录下没有JSP页面 到项目中去看才发现有两个目录,一个WebContent,一个Web ...
- 期末项目之 Json文件
Github上的json文件: https://raw.githubusercontent.com/color-me/first/master/b
- 题解 P4781 【【模板】拉格朗日插值】
题目 本蒟蒻看到一道数学题,就顺手切了.感觉单单对这一题而言,部分评论区的大佬过于复杂了 [分析] 先讲讲拉格朗日插值法: 对于给定的 \((n+1)\) 个点,我们可以确定唯一的一个 至多\(n\) ...
- cmd 进入指定文件夹
1.通常情况下,我们要进入其他盘符下的任意目录,需要在CMD窗口运行两次命令:第一次,进入盘符,第二次进入指定目录 #进入D盘 d: #进入D盘下的anaconda目录 cd anacond 2.通过 ...
- post表单、json接口
package com.lv.qggz.man.dhht.api.typesetting; import com.lv.qggz.man.dhht.api.typesetting.vo.UVO;imp ...
- tensorflow笔记(北大网课实战)
1. tf.multiply(x,y1) # 对应元素相乘 tf.matmul(x,y2) # 矩阵相乘 2.会话:执行计算图中的节点运算的. with tf.Session() as sess: p ...