基本总结
包: ${package.Entity} ${package.Controller} ${package.Service} ${package.Mapper} 类名: ${entity} ${table.controllerName} ${table.serviceName} ${table.mapperName} 注解: ${table.comment!} 表名注解 其他: ${author} 作者 ${date} 当前日期
controller层 文件名:controller.java.vm
package ${package.Controller}; import com.model.bean.ResultModel; import javax.annotation.Resource; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.validation.annotation.Validated; import ${package.Mapper}.${table.mapperName}; import ${package.Entity}.${entity}; import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springframework.web.bind.annotation.RequestParam; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * <p> * $!{table.comment} 前端控制器 * </p> * * @author ${author} * @since ${date} */ @RestController @RequestMapping("/${table.entityPath}") public class ${table.controllerName} { @Resource private ${table.mapperName} ${table.mapperName}; @RequestMapping("/save") public ResultModel save(@Validated ${entity} ${entity}) { int insert=${table.mapperName}.insert(${entity}); boolean bool = insert > 0; if(bool){ return ResultModel.ok("${table.comment}增加成功"); } return ResultModel.error("${table.comment}增加失败"); } @RequestMapping("/updateById") public ResultModel updateById(${entity} ${entity}) { int update = ${table.mapperName}.updateById(${entity}); boolean bool = update > 0; if(bool){ return ResultModel.ok("${table.comment}修改成功"); } return ResultModel.error("${table.comment}修改失败"); } @RequestMapping("/deleteById") public ResultModel delete(${entity} ${entity}) { int delete = ${table.mapperName}.deleteById(${entity}.getId()); boolean bool = delete > 0; if(bool){ return ResultModel.ok("${table.comment}删除成功"); } return ResultModel.error("${table.comment}删除失败"); } @RequestMapping("/deletelist") public ResultModel delete(List<Integer> ids) { int delete = ${table.mapperName}.deleteBatchIds(ids); boolean bool = delete > 0; if(bool){ return ResultModel.ok("${table.comment}删除成功"+delete+"条"); } return ResultModel.error("${table.comment}删除失败"); } public QueryWrapper<${entity}> getWrapper(${entity} ${entity}) { //取属性 QueryWrapper<${entity}> wrapper = new QueryWrapper<>(); //判断处理 return wrapper; } @RequestMapping("/select") public ResultModel select(${entity} ${entity}) { List<${entity}> ${entity}s = ${table.mapperName}.selectList(getWrapper(${entity})); return ResultModel.okData("${table.comment}查询成功",${entity}s); } @RequestMapping("/selectPage") public ResultModel selectpage(${entity} ${entity}, @RequestParam("page") Integer current, @RequestParam("limit") Integer size) { Page Page = new Page<>(); Page.setSize(size); Page.setCurrent(current); IPage<${entity}> ${entity}IPage = ${table.mapperName}.selectPage(Page, getWrapper(${entity})); List<${entity}> records = ${entity}IPage.getRecords(); long total = ${entity}IPage.getTotal(); Object[] data = {records, total}; return ResultModel.okData("${table.comment}查询成功",data); } }