2024年1月15日发(作者:三相异步专用电动机)
// 根据主键ID删除 @RequestMapping(value = "/delete/{id}", method = ) public boolean delete(@PathVariable("id") Long id) { return ById(id); }// 删除符合条件的数据// 删除username和id符合的数据 @RequestMapping(value = "/delete2", method = ) public boolean delete2(@RequestBody User user) { Map columnMap = new HashMap<>(); ("username", rname()); ("id", ()); return ByMap(columnMap); }// 批量删除 @RequestMapping(value = "/delete4", method = ) public boolean delete4(@RequestBody List ids) { return ByIds(ids); }// 删除id>10的数据 @RequestMapping(value = "/delete3", method = ) public boolean delete3() { QueryWrapper queryWrapper = new QueryWrapper(); ("id", 10); return (queryWrapper); }
修改Update// 根据 UpdateWrapper 条件,更新记录 需要设置sqlsetboolean update(Wrapper updateWrapper);// 根据 whereEntity 条件,更新记录boolean update(T entity, Wrapper updateWrapper);// 根据 ID 选择修改boolean updateById(T entity);// 根据ID 批量更新boolean updateBatchById(Collection entityList);// 根据ID 批量更新boolean updateBatchById(Collection entityList, int batchSize);
// 查询所有List list();// 查询列表List list(Wrapper queryWrapper);// 查询(根据ID 批量查询)Collection listByIds(Collection extends Serializable> idList);// 查询(根据 columnMap 条件)Collection listByMap(Map columnMap);// 查询所有列表List
@RequestMapping(value = "/count", method = ) public int count() { int count = (); return count; } @RequestMapping(value = "/count2", method = ) public int count2() { QueryWrapper queryWrapper = new QueryWrapper<>(); ("id", 10); int count = (queryWrapper); return count; }@RequestMapping(value = "/conditionQuery", method = )public IPage conditionQuery() { IPage page = new Page<>(); QueryWrapper queryWrapper = new QueryWrapper<>(); Date date = new Date(); ("create_time",date ).gt("update_time",date); IPage userIPage = (page,queryWrapper); return userIPage;}
发表评论