ViewController.java.vm 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #set($className = "${context.className}")
  2. #set($Name = "${className.substring(0,1).toUpperCase()}${className.substring(1)}")
  3. #set($name = "${className.substring(0,1).toLowerCase()}${className.substring(1)}")
  4. ## 获取列表信息
  5. #macro(GetList)
  6. /**
  7. * 列表
  8. *
  9. * @param ${name}Pagination
  10. * @return
  11. */
  12. @Operation(summary = "获取列表")
  13. @PostMapping("/getList")
  14. public ActionResult list(@RequestBody ${Name}Pagination ${name}Pagination) {
  15. PageListVO interfaceData = generaterSwapUtil.getInterfaceData(${name}Pagination, paramConst,#if(${context.hasPage}) true #else false#end,"$!{context.viewKey}");
  16. return ActionResult.success(interfaceData);
  17. }
  18. #end
  19. ## 导出
  20. #macro(ExportMethod)
  21. /**
  22. * 导出Excel
  23. *
  24. * @return
  25. */
  26. @Operation(summary = "导出Excel")
  27. @PostMapping("/Actions/Export")
  28. public ActionResult Export(@RequestBody ${Name}Pagination ${name}Pagination) {
  29. if (StringUtil.isEmpty(${name}Pagination.getSelectKey())){
  30. return ActionResult.fail("请选择导出字段");
  31. }
  32. DownloadVO vo = generaterSwapUtil.exportInterfaceData(${name}Pagination, paramConst,#if(${context.hasPage}) true #else false#end,"$!{context.viewKey}");
  33. return ActionResult.success(vo);
  34. }
  35. #end
  36. package ${context.package}.controller;
  37. import io.swagger.v3.oas.annotations.Operation;
  38. import io.swagger.v3.oas.annotations.tags.Tag;
  39. import jnpf.base.ActionResult;
  40. import jnpf.base.vo.DownloadVO;
  41. import jnpf.base.vo.PageListVO;
  42. import jnpf.model.$!{name.toLowerCase()}.$!{Name}Constant;
  43. import jnpf.model.$!{name.toLowerCase()}.$!{Name}Pagination;
  44. import jnpf.util.GeneraterSwapUtil;
  45. import jnpf.util.ServletUtil;
  46. import jnpf.util.StringUtil;
  47. import lombok.extern.slf4j.Slf4j;
  48. import org.springframework.beans.factory.annotation.Autowired;
  49. import org.springframework.web.bind.annotation.PostMapping;
  50. import org.springframework.web.bind.annotation.RequestBody;
  51. import org.springframework.web.bind.annotation.RequestMapping;
  52. import org.springframework.web.bind.annotation.RestController;
  53. /**
  54. * ${context.genInfo.description}
  55. * @版本: ${context.genInfo.version}
  56. * @版权: ${context.genInfo.copyright}
  57. * @作者: ${context.genInfo.createUser}
  58. * @日期: ${context.genInfo.createDate}
  59. */
  60. @Slf4j
  61. @RestController
  62. @Tag(name = "${context.genInfo.description}" , description = "${context.module}")
  63. #if(${context.isCloud}=="cloud")
  64. @RequestMapping("/${Name}")
  65. #else
  66. @RequestMapping("/api/${context.module}/${className}")
  67. #end
  68. public class ${className}Controller {
  69. private ${className}Constant paramConst = ${className}Constant.get();
  70. @Autowired
  71. private GeneraterSwapUtil generaterSwapUtil;
  72. ## 获取列表信息
  73. #GetList()
  74. ## 导出数据
  75. #if(${context.hasDownloadBtn})
  76. #ExportMethod()
  77. #end
  78. }