mybatis plus按时间段查询,Mybatis-plus查询语句使用

Mybatis-plus查询语句使用

Szx • 2020 年 05 月 14 日

根据id查询记录/**

* 通过id查询

* @param id

* @return

*/

@RequestMapping("selectById")

@ResponseBody

public User selectById(String id){

//通过id查询 mp自带

User user = userMapper.selectById(id);

return user;

}

通过多个id批量查询

/*** 通过多个id批量查询

* @param ids

* @return

*/

@RequestMapping("selectBatchId")

@ResponseBody

public List selectBatchId(@RequestParam List ids){

System.out.println("ids"+ids);

List users = userMapper.selectBatchIds(ids);

System.out.println(users+"users");

return users;

}

访问格式:ids=id,id,id 每个ID用逗号隔开,传递的是数组

例如:http://localhost:8888/selectBatchId?ids=1260510510135164930,1260601929550090242

3aff049be6a80449ca90ef180399f6ae.png

查询所有数据/**

* 查询所有方法

* @return list

*/

@RequestMapping("finAll")

@ResponseBody

public List finAll(){

//查询所有

List users = userMapper.selectList(null);

return users;

}

访问:http://localhost:8888/finAll

简单的条件查询/**

* 简单的多条件查询

* @param user

* @return

*/

@RequestMapping("SelectSimplenessWhere")

@ResponseBody

public List SelectSimplenessWhere(User user){

HashMap map = new HashMap<>();

map.put("name",user.getName());

map.put("age",user.getAge());

List users = userMapper.selectByMap(map);

return users;

}

74c13d2dd2bac0d41a3af7f621392eab.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值