1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| package ${package.Controller};
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import ${package.Entity}.${entity}; import ${package.Service}.${table.serviceName};
#if(${restControllerStyle}) import org.springframework.web.bind.annotation.RestController; #else import org.springframework.stereotype.Controller; #end #if(${superControllerClassPackage}) import ${superControllerClassPackage}; #end
#if(${restControllerStyle}) @RestController #else @Controller #end @RequestMapping("#if(${package.ModuleName})/${package.ModuleName}#end/#if(${controllerMappingHyphenStyle})${controllerMappingHyphen}#else${table.entityPath}#end") #if(${kotlin}) class ${table.controllerName}#if(${superControllerClass}) : ${superControllerClass}()#end
#else #if(${superControllerClass}) public class ${table.controllerName} extends ${superControllerClass} { #else public class ${table.controllerName} { #end
@Resource private ${table.serviceName} ${table.entityPath}Service;
@PostMapping public boolean save(@RequestBody ${entity} ${table.entityPath}) { return ${table.entityPath}Service.saveOrUpdate(${table.entityPath}); }
@DeleteMapping("/{id}") public boolean deleteById(@PathVariable Integer id) { return ${table.entityPath}Service.removeById(id); }
@GetMapping public List<${entity}> findAll() { return ${table.entityPath}Service.list(); }
@GetMapping("/{id}") public ${entity} findById(@PathVariable Integer id) { return ${table.entityPath}Service.getById(id); }
@GetMapping("/page") public Page<${entity}> findPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize) { QueryWrapper<${entity}> wrapper=new QueryWrapper<>(); return ${table.entityPath}Service.page(new Page<>(pageNum, pageSize), wrapper); }
@DeleteMapping("del/batch") public boolean deleteBatchById(@RequestBody List<Integer> ids) { return ${table.entityPath}Service.removeBatchByIds(ids); }
}
#end
|