GoodsController.java 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. package com.zhongzheng.controller.goods;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.Arrays;
  5. import com.zhongzheng.modules.bank.bo.ExamQuestionQueryBo;
  6. import com.zhongzheng.modules.bank.vo.ExamQuestionVo;
  7. import com.zhongzheng.modules.goods.bo.*;
  8. import com.zhongzheng.modules.goods.domain.Goods;
  9. import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
  10. import com.zhongzheng.modules.goods.service.IGoodsAuditionConfigService;
  11. import com.zhongzheng.modules.goods.service.IGoodsService;
  12. import com.zhongzheng.modules.goods.vo.GoodsAttachedVo;
  13. import com.zhongzheng.modules.goods.vo.GoodsAuditionConfigVo;
  14. import com.zhongzheng.modules.goods.vo.GoodsVo;
  15. import lombok.RequiredArgsConstructor;
  16. import org.springframework.security.access.prepost.PreAuthorize;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.web.bind.annotation.GetMapping;
  19. import org.springframework.web.bind.annotation.PostMapping;
  20. import org.springframework.web.bind.annotation.PutMapping;
  21. import org.springframework.web.bind.annotation.DeleteMapping;
  22. import org.springframework.web.bind.annotation.PathVariable;
  23. import org.springframework.web.bind.annotation.RequestBody;
  24. import org.springframework.web.bind.annotation.RequestMapping;
  25. import org.springframework.web.bind.annotation.RestController;
  26. import com.zhongzheng.common.annotation.Log;
  27. import com.zhongzheng.common.core.controller.BaseController;
  28. import com.zhongzheng.common.core.domain.AjaxResult;
  29. import com.zhongzheng.common.enums.BusinessType;
  30. import com.zhongzheng.common.utils.poi.ExcelUtil;
  31. import com.zhongzheng.common.core.page.TableDataInfo;
  32. import io.swagger.annotations.Api;
  33. import io.swagger.annotations.ApiOperation;
  34. /**
  35. * 商品Controller
  36. *
  37. * @author hjl
  38. * @date 2021-10-12
  39. */
  40. @Api(value = "商品控制器", tags = {"商品管理"})
  41. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  42. @RestController
  43. @RequestMapping("/goods")
  44. public class GoodsController extends BaseController {
  45. private final IGoodsService iGoodsService;
  46. private final IGoodsAttachedService iGoodsAttachedService;
  47. @Autowired
  48. private IGoodsAuditionConfigService iGoodsAuditionConfigService;
  49. /**
  50. * 查询商品列表
  51. */
  52. @ApiOperation("查询商品列表")
  53. @PreAuthorize("@ss.hasPermi('system:goods:list')")
  54. @GetMapping("/list")
  55. public TableDataInfo<GoodsVo> list(GoodsQueryBo bo) {
  56. bo.setStatus(new ArrayList<Integer>(){{
  57. add(1);
  58. }});
  59. startPage();
  60. List<GoodsVo> list = iGoodsService.selectList(bo);
  61. return getDataTable(list);
  62. }
  63. /**
  64. * 导出商品列表
  65. */
  66. /*selectList*/
  67. /**
  68. * 获取商品详细信息
  69. */
  70. @ApiOperation("获取商品详细信息")
  71. @PreAuthorize("@ss.hasPermi('system:goods:query')")
  72. @GetMapping("/{goodsId}")
  73. public AjaxResult<GoodsVo> getInfo(@PathVariable("goodsId" ) Long goodsId) {
  74. return AjaxResult.success(iGoodsService.selectDetail(goodsId));
  75. }
  76. /**
  77. * 新增课程商品
  78. */
  79. @ApiOperation("新增课程商品")
  80. @PreAuthorize("@ss.hasPermi('system:goods:add')")
  81. @Log(title = "商品", businessType = BusinessType.INSERT)
  82. @PostMapping()
  83. public AjaxResult<Void> add(@RequestBody GoodsAddBo bo) {
  84. return toAjax(iGoodsService.insertByAddBo(bo) ? 1 : 0);
  85. }
  86. /**
  87. * 修改商品
  88. */
  89. @ApiOperation("修改商品")
  90. @PreAuthorize("@ss.hasPermi('system:goods:edit')")
  91. @Log(title = "商品", businessType = BusinessType.UPDATE)
  92. @PostMapping("/edit")
  93. public AjaxResult<Void> edit(@RequestBody GoodsEditBo bo) {
  94. return toAjax(iGoodsService.updateByEditBo(bo) ? 1 : 0);
  95. }
  96. /**
  97. * 删除商品
  98. */
  99. /* @ApiOperation("删除商品")
  100. @PreAuthorize("@ss.hasPermi('system:goods:remove')")
  101. @Log(title = "商品" , businessType = BusinessType.DELETE)
  102. @DeleteMapping("/{goodsIds}")
  103. public AjaxResult<Void> remove(@PathVariable Long[] goodsIds) {
  104. return toAjax(iGoodsService.deleteWithValidByIds(Arrays.asList(goodsIds), true) ? 1 : 0);
  105. }*/
  106. /**
  107. * 新增题库商品
  108. */
  109. @ApiOperation("新增题库商品")
  110. @PreAuthorize("@ss.hasPermi('system:goods:add')")
  111. @Log(title = "商品", businessType = BusinessType.INSERT)
  112. @PostMapping("/bank")
  113. public AjaxResult<Void> addBank(@RequestBody GoodsBankAddBo bo) {
  114. return toAjax(iGoodsService.insertBankByAddBo(bo) ? 1 : 0);
  115. }
  116. /**
  117. * 修改商品
  118. */
  119. @ApiOperation("修改题库商品")
  120. @PreAuthorize("@ss.hasPermi('system:goods:edit')")
  121. @Log(title = "题库商品", businessType = BusinessType.UPDATE)
  122. @PostMapping("/bank/edit")
  123. public AjaxResult<Void> editBank(@RequestBody GoodsBankEditBo bo) {
  124. return toAjax(iGoodsService.updateBankByEditBo(bo) ? 1 : 0);
  125. }
  126. /**
  127. * 查询题目业务层次关系列表
  128. */
  129. @ApiOperation("查询商品题库列表")
  130. @PreAuthorize("@ss.hasPermi('system:business:list')")
  131. @GetMapping("/bank/list")
  132. public AjaxResult<List<GoodsAttachedVo>> bankList(GoodsAttachedQueryBo bo) {
  133. List<GoodsAttachedVo> list = iGoodsAttachedService.selectList(bo);
  134. return AjaxResult.success(list);
  135. }
  136. /**
  137. * 新增课程商品
  138. */
  139. @ApiOperation("新增补考商品")
  140. @PreAuthorize("@ss.hasPermi('system:goods:add')")
  141. @Log(title = "商品", businessType = BusinessType.INSERT)
  142. @PostMapping("/make")
  143. public AjaxResult<Void> addMake(@RequestBody GoodsAddBo bo) {
  144. return toAjax(iGoodsService.insertMakeByAddBo(bo) ? 1 : 0);
  145. }
  146. /**
  147. * 修改商品
  148. */
  149. @ApiOperation("修改补考商品")
  150. @PreAuthorize("@ss.hasPermi('system:goods:edit')")
  151. @Log(title = "商品", businessType = BusinessType.UPDATE)
  152. @PostMapping("/make/edit")
  153. public AjaxResult<Void> editMake(@RequestBody GoodsEditBo bo) {
  154. return toAjax(iGoodsService.updateMakeByEditBo(bo) ? 1 : 0);
  155. }
  156. /**
  157. * 新增课程商品
  158. */
  159. @ApiOperation("新增前培商品")
  160. @PreAuthorize("@ss.hasPermi('system:goods:add')")
  161. @Log(title = "商品", businessType = BusinessType.INSERT)
  162. @PostMapping("/front")
  163. public AjaxResult<Void> addFront(@RequestBody GoodsAddBo bo) {
  164. return toAjax(iGoodsService.insertFrontByAddBo(bo) ? 1 : 0);
  165. }
  166. /**
  167. * 修改商品
  168. */
  169. @ApiOperation("修改前培商品")
  170. @PreAuthorize("@ss.hasPermi('system:goods:edit')")
  171. @Log(title = "商品", businessType = BusinessType.UPDATE)
  172. @PostMapping("/front/edit")
  173. public AjaxResult<Void> editFront(@RequestBody GoodsEditBo bo) {
  174. return toAjax(iGoodsService.updateFrontByEditBo(bo) ? 1 : 0);
  175. }
  176. }