You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.7 KiB

3 years ago
  1. package ${package.Controller};
  2. import java.util.List;
  3. import com.iteaj.framework.result.Result;
  4. import org.apache.shiro.authz.annotation.Logical;
  5. import org.springframework.web.bind.annotation.*;
  6. import org.apache.shiro.authz.annotation.RequiresPermissions;
  7. import com.baomidou.mybatisplus.core.metadata.IPage;
  8. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  9. import ${package.Entity}.${entity};
  10. import ${package.Service}.${table.serviceName};
  11. #if(${restControllerStyle})
  12. #else
  13. import org.springframework.stereotype.Controller;
  14. #end
  15. #if(${superControllerClassPackage})
  16. import ${superControllerClassPackage};
  17. #end
  18. /**
  19. * <p>
  20. * $!{cfg.moduleName}管理
  21. * </p>
  22. *
  23. * @author ${author}
  24. * @since ${date}
  25. */
  26. #if(${restControllerStyle})
  27. @RestController
  28. #else
  29. @Controller
  30. #end
  31. @RequestMapping("#if(${package.ModuleName})/${package.ModuleName}#end/#if(${controllerMappingHyphenStyle})${controllerMappingHyphen}#else${table.entityPath}#end")
  32. #if(${kotlin})
  33. class ${table.controllerName}#if(${superControllerClass}) : ${superControllerClass}()#end
  34. #else
  35. #if(${superControllerClass})
  36. public class ${table.controllerName} extends ${superControllerClass} {
  37. #else
  38. public class ${table.controllerName} {
  39. #end
  40. private final ${table.serviceName} ${cfg.serviceName};
  41. public ${table.controllerName}(${table.serviceName} ${cfg.serviceName}) {
  42. this.${cfg.serviceName} = ${cfg.serviceName};
  43. }
  44. /**
  45. * 列表查询
  46. * @param page 分页
  47. * @param entity 搜索条件
  48. */
  49. @GetMapping("/view")
  50. @RequiresPermissions({"${package.ModuleName}:${table.entityPath}:view"})
  51. public Result<IPage<${entity}>> list(Page<${entity}> page, ${entity} entity) {
  52. return this.${cfg.serviceName}.page(page, entity);
  53. }
  54. /**
  55. * 获取编辑记录
  56. * @param id 记录id
  57. */
  58. @GetMapping("/edit")
  59. @RequiresPermissions({"${package.ModuleName}:${table.entityPath}:edit"})
  60. public Result<${entity}> getById(Long id) {
  61. return this.${cfg.serviceName}.getById(id);
  62. }
  63. /**
  64. * 新增或者更新记录
  65. * @param entity
  66. */
  67. @PostMapping("/saveOrUpdate")
  68. @RequiresPermissions(value = {"${package.ModuleName}:${table.entityPath}:edit", "${package.ModuleName}:${table.entityPath}:add"}, logical = Logical.OR)
  69. public Result<Boolean> save(@RequestBody ${entity} entity) {
  70. return this.${cfg.serviceName}.saveOrUpdate(entity);
  71. }
  72. /**
  73. * 删除指定记录
  74. * @param idList
  75. */
  76. @PostMapping("/del")
  77. @RequiresPermissions({"${package.ModuleName}:${table.entityPath}:del"})
  78. public Result<Boolean> remove(@RequestBody List<Long> idList) {
  79. return this.${cfg.serviceName}.removeByIds(idList);
  80. }
  81. }
  82. #end