GoodsSpecTemplateController.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package com.zhongzheng.controller.goods;
  2. import java.util.List;
  3. import java.util.Arrays;
  4. import com.zhongzheng.modules.goods.bo.GoodsSpecAddBo;
  5. import com.zhongzheng.modules.goods.bo.GoodsSpecTemplateAddBo;
  6. import com.zhongzheng.modules.goods.bo.GoodsSpecTemplateEditBo;
  7. import com.zhongzheng.modules.goods.bo.GoodsSpecTemplateQueryBo;
  8. import com.zhongzheng.modules.goods.service.IGoodsSpecTemplateService;
  9. import com.zhongzheng.modules.goods.vo.GoodsSpecAttrDetailVo;
  10. import com.zhongzheng.modules.goods.vo.GoodsSpecAttrListVo;
  11. import com.zhongzheng.modules.goods.vo.GoodsSpecAttributeRelationVo;
  12. import com.zhongzheng.modules.goods.vo.GoodsSpecTemplateVo;
  13. import lombok.RequiredArgsConstructor;
  14. import org.springframework.security.access.prepost.PreAuthorize;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.web.bind.annotation.GetMapping;
  17. import org.springframework.web.bind.annotation.PostMapping;
  18. import org.springframework.web.bind.annotation.PutMapping;
  19. import org.springframework.web.bind.annotation.DeleteMapping;
  20. import org.springframework.web.bind.annotation.PathVariable;
  21. import org.springframework.web.bind.annotation.RequestBody;
  22. import org.springframework.web.bind.annotation.RequestMapping;
  23. import org.springframework.web.bind.annotation.RestController;
  24. import com.zhongzheng.common.annotation.Log;
  25. import com.zhongzheng.common.core.controller.BaseController;
  26. import com.zhongzheng.common.core.domain.AjaxResult;
  27. import com.zhongzheng.common.enums.BusinessType;
  28. import com.zhongzheng.common.utils.poi.ExcelUtil;
  29. import com.zhongzheng.common.core.page.TableDataInfo;
  30. import io.swagger.annotations.Api;
  31. import io.swagger.annotations.ApiOperation;
  32. /**
  33. * 【请填写功能名称】Controller
  34. *
  35. * @author ruoyi
  36. * @date 2022-09-29
  37. */
  38. @Api(value = "规格模板控制器", tags = {"规格模板管理"})
  39. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  40. @RestController
  41. @RequestMapping("/system/template")
  42. public class GoodsSpecTemplateController extends BaseController {
  43. private final IGoodsSpecTemplateService iGoodsSpecTemplateService;
  44. /**
  45. * 查询模板列表
  46. */
  47. @ApiOperation("查询模板列表")
  48. @GetMapping("/list")
  49. public TableDataInfo<GoodsSpecTemplateVo> list(GoodsSpecTemplateQueryBo bo) {
  50. startPage();
  51. List<GoodsSpecTemplateVo> list = iGoodsSpecTemplateService.queryList(bo);
  52. return getDataTable(list);
  53. }
  54. /**
  55. * 导出【请填写功能名称】列表
  56. */
  57. @ApiOperation("导出【请填写功能名称】列表")
  58. @PreAuthorize("@ss.hasPermi('system:template:export')")
  59. @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
  60. @GetMapping("/export")
  61. public AjaxResult<GoodsSpecTemplateVo> export(GoodsSpecTemplateQueryBo bo) {
  62. List<GoodsSpecTemplateVo> list = iGoodsSpecTemplateService.queryList(bo);
  63. ExcelUtil<GoodsSpecTemplateVo> util = new ExcelUtil<GoodsSpecTemplateVo>(GoodsSpecTemplateVo.class);
  64. return util.exportExcel(list, "【请填写功能名称】");
  65. }
  66. /**
  67. * 获取规格模板详细信息
  68. */
  69. @ApiOperation("获取规格模板详细信息")
  70. @GetMapping("/detail/{specTemplateId}")
  71. public AjaxResult<GoodsSpecTemplateVo> getInfo(@PathVariable("specTemplateId" ) Long specTemplateId) {
  72. return AjaxResult.success(iGoodsSpecTemplateService.queryById(specTemplateId));
  73. }
  74. /**
  75. * 新增【请填写功能名称】
  76. */
  77. @ApiOperation("新增【请填写功能名称】")
  78. @PreAuthorize("@ss.hasPermi('system:template:add')")
  79. @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
  80. @PostMapping()
  81. public AjaxResult<Void> add(@RequestBody GoodsSpecTemplateAddBo bo) {
  82. return toAjax(iGoodsSpecTemplateService.insertByAddBo(bo) ? 1 : 0);
  83. }
  84. /**
  85. * 新增规格模板
  86. */
  87. @ApiOperation("新增规格模板")
  88. @PostMapping("/addSpec")
  89. public AjaxResult<List<GoodsSpecAttributeRelationVo>> addSpec(@RequestBody GoodsSpecTemplateAddBo bo) {
  90. List<GoodsSpecAttributeRelationVo> vo = iGoodsSpecTemplateService.addSpec(bo);
  91. return AjaxResult.success(vo);
  92. }
  93. /**
  94. * 修改规格模板
  95. */
  96. @ApiOperation("修改规格模板")
  97. @PostMapping("/edit")
  98. public AjaxResult<List<GoodsSpecAttributeRelationVo>> edit(@RequestBody GoodsSpecTemplateEditBo bo) {
  99. List<GoodsSpecAttributeRelationVo> vo = iGoodsSpecTemplateService.updateByEditBo(bo);
  100. return AjaxResult.success(vo);
  101. }
  102. /**
  103. * 删除规格模板
  104. */
  105. @ApiOperation("删除规格模板")
  106. @GetMapping("/del/{specTemplateId}")
  107. public AjaxResult<Void> remove(@PathVariable Long specTemplateId) {
  108. return toAjax(iGoodsSpecTemplateService.deleteWithValidByIds(specTemplateId,false) ? 1 : 0);
  109. }
  110. }