[TOC]
## 顺序参数,按顺序一一对应
>[success]SQL:INSERT INTO `demo` (`id`,`s`,`i`,`t`) VALUES (8 , ? , ? , ?)
参数:abc(String), 1(Integer), a(String)
```
public void t1(){
BaseService service = Application.getService("demo");
service.setData("abc",1,'a').insert("s","i","t");
}
```
## map参数,map的键与insert的参数对应
>[success]SQL:INSERT INTO `demo` (`id`,`s`,`i`,`t`) VALUES (11 , ? , ? , ?)
参数:abcde(String), 1(Integer), s(String)
```
public void t2(){
BaseService service = Application.getService("demo");
HashMap<String, Object> map=new HashMap<>();
map.put("t", 's');
map.put("i", 1);
map.put("s", "abcde");
service.setData(map).insert("s","i","t");
}
```
## POJO参数,成员属性与表字段名对应
>[success]SQL:INSERT INTO `demo` (`id`,`i`,`s`,`t`) VALUES (12 , ? , ? , ?)
参数:55(Integer), aaa(String), n(String)
```
public void t3(){
BaseService service = Application.getService("demo");
DemoBean demo=new DemoBean();
demo.setI(55);
demo.setS("aaa");
demo.setT("n");
service.insert(demo);
}
```
## 插入POJO时,某些属性有值,但你不希望插入
>[success]SQL:INSERT INTO `demo` (`id`,`i`) VALUES (13 , ?)
参数:56(Integer)
```
public void t4(){
BaseService service = Application.getService("demo");
DemoBean demo=new DemoBean();
demo.setI(5);
demo.setS("aaa");
demo.setT("n");
//这里s跟t都不会被插入
service.insert(demo,"s,t");
}
```
## 获取自增ID
```
int insert_id = service.insert_id();
```
>[warning] 插入POJO时,自增的id会自动注入到属性中
## 多个主键,包括非整形主键,获取自动生成的值
```
Object insert_id = service.last_insert_id(“主键字段名”);
```
>[warning] 如果你参数里有主键且不为空,BaseService 将按普通字段处理,冲突时会报错;如果参数里没有主键,分为两种情况:1、整形主键,BaseService将自动递增一位数,并保存。2、非整形,BaseService将生成一个uuid,并保存
- 系统入门
- 系统简介
- 目录结构
- 系统配置
- 应用
- 应用
- 控制器
- 模板
- 自定义标签
- 用户信息
- 调试
- 调试模式
- 使用Vardump打印
- 访问数据库
- 数据库配置
- Dao模式
- BaseService模式
- 获取对象
- 插入
- 修改
- 删除
- 查询
- where方法
- column方法
- join方法
- 其他查询方法
- 操作集合
- sql方法
- 查询回调接口
- 使用别名
- 后台验证
- 同步表结构
- 使用事务
- 数据分页
- 通用视图模板
- CommonPageView
- CommonPageLayer
- CommonTreeView
- CommonEditView
- CommonEditLayer
- 日志管理
- 后台菜单
- 权限管理
- CMS
- CMS核心
- CMS仿站工具
- CMS采集工具
- websocket
- UI自动生成器
- 缓存
- 自定义缓存
- 生成静态页面
- 表单
- 上传文件
- 前端验证