Mall2PointsRulesController.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. package com.kmall.admin.controller.vip;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import com.kmall.admin.dto.Mall2RulesDto;
  7. import com.kmall.admin.entity.vip.Mall2DetilEntity;
  8. import com.kmall.common.constant.JxlsXmlTemplateName;
  9. import com.kmall.common.utils.PageUtils;
  10. import com.kmall.common.utils.Query;
  11. import com.kmall.common.utils.R;
  12. import com.kmall.common.utils.excel.ExcelUtil;
  13. import org.slf4j.Logger;
  14. import org.slf4j.LoggerFactory;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.stereotype.Controller;
  17. import org.springframework.web.bind.annotation.*;
  18. import com.kmall.admin.entity.vip.Mall2PointsRulesEntity;
  19. import com.kmall.admin.service.vip.Mall2PointsRulesService;
  20. import org.springframework.web.multipart.MultipartFile;
  21. /**
  22. * 积分规则表Controller
  23. *
  24. * @author emato
  25. * @email admin@qhdswl.com
  26. * @date 2020-06-15 10:44:07
  27. */
  28. @Controller
  29. @RequestMapping("mall2pointsrules")
  30. public class Mall2PointsRulesController {
  31. @Autowired
  32. private Mall2PointsRulesService mall2PointsRulesService;
  33. @Autowired
  34. private ExcelUtil excelUtil;
  35. private static final Logger log = LoggerFactory.getLogger(Mall2PointsRulesController.class);
  36. /**
  37. * 查看列表
  38. */
  39. @RequestMapping("/list")
  40. // @RequiresPermissions("mall2pointsrules:list")
  41. @ResponseBody
  42. public R list(@RequestParam Map<String, Object> params) {
  43. //查询列表数据
  44. Query query = new Query(params);
  45. List<Mall2PointsRulesEntity> mall2PointsRulesList = mall2PointsRulesService.queryList(query);
  46. int total = mall2PointsRulesService.queryTotal(query);
  47. PageUtils pageUtil = new PageUtils(mall2PointsRulesList, total, query.getLimit(), query.getPage());
  48. return R.ok().put("page", pageUtil);
  49. }
  50. /**
  51. * 查看信息
  52. */
  53. @RequestMapping("/info/{mprId}")
  54. // @RequiresPermissions("mall2pointsrules:info")
  55. @ResponseBody
  56. public R info(@PathVariable("mprId") Integer mprId) {
  57. Mall2PointsRulesEntity mall2PointsRules = mall2PointsRulesService.queryObject(mprId);
  58. mall2PointsRules.setPointsTypeStr(mall2PointsRules.getPointsType()+"");
  59. return R.ok().put("mall2PointsRules", mall2PointsRules);
  60. }
  61. /**
  62. * 保存
  63. */
  64. @RequestMapping("/save")
  65. // @RequiresPermissions("mall2pointsrules:save")
  66. @ResponseBody
  67. public R save(@RequestBody Mall2PointsRulesEntity mall2PointsRules) {
  68. return mall2PointsRulesService.save(mall2PointsRules);
  69. }
  70. /**
  71. * 修改
  72. */
  73. @RequestMapping("/update")
  74. // @RequiresPermissions("mall2pointsrules:update")
  75. @ResponseBody
  76. public R update(@RequestBody Mall2PointsRulesEntity mall2PointsRules) {
  77. return mall2PointsRulesService.update(mall2PointsRules);
  78. }
  79. /**
  80. * 删除
  81. */
  82. @RequestMapping("/delete")
  83. @ResponseBody
  84. public R delete(@RequestBody Integer[]mprIds) {
  85. mall2PointsRulesService.deleteBatch(mprIds);
  86. return R.ok();
  87. }
  88. /**
  89. * 上传文件积分明细信息
  90. */
  91. @RequestMapping("/rulesUpload")
  92. @ResponseBody
  93. public R rulesUpload(@RequestParam("file") MultipartFile file, Long mkaId) {
  94. List<Mall2RulesDto> mall2RulesDtoList = new ArrayList<>();//信息
  95. try {
  96. Mall2RulesDto mall2RulesDto = new Mall2RulesDto();
  97. Map<String, Object> beans = new HashMap<>();
  98. beans.put("Mall2RulesDto", mall2RulesDto);
  99. beans.put("Mall2RulesDtoList", mall2RulesDtoList);
  100. if (file.isEmpty()) {
  101. return R.error("文件不能为空!");
  102. }
  103. excelUtil.readExcel(JxlsXmlTemplateName.MALL_RULES_LIST, beans, file.getInputStream());
  104. } catch (Exception e) {
  105. e.printStackTrace();
  106. return R.error("导入失败!");
  107. }
  108. return mall2PointsRulesService.rulesUploadDetil(mall2RulesDtoList,mkaId,false);
  109. }
  110. /**
  111. * 积分赠送规则查询积分类型
  112. */
  113. @RequestMapping("/getRulesDetilId")
  114. @ResponseBody
  115. public R getRulesDetilId(Long mkaId) {
  116. Integer rulesDetilId = mall2PointsRulesService.getRulesDetilId(mkaId);
  117. return R.ok(rulesDetilId.toString());
  118. }
  119. /**
  120. * 查看所有明细列表
  121. */
  122. @RequestMapping("/queryAll")
  123. @ResponseBody
  124. public R queryRulesDetilAll(@RequestParam Map<String, Object> params) {
  125. return R.ok().put("list", null);
  126. }
  127. /**
  128. * 查看积分列表详情
  129. */
  130. @RequestMapping("/detilList")
  131. @ResponseBody
  132. public R detilList(@RequestParam Map<String, Object> params) {
  133. //查询列表数据
  134. Query query = new Query(params);
  135. List<Mall2RulesDto> mall2PointsRulesList = mall2PointsRulesService.queryDetilList(query);
  136. int total = mall2PointsRulesService.querymall2PointsRulesDetilTotal(query);
  137. PageUtils pageUtil = new PageUtils(mall2PointsRulesList, total, query.getLimit(), query.getPage());
  138. return R.ok().put("page", pageUtil);
  139. }
  140. /**
  141. * 删除列表详情
  142. */
  143. @RequestMapping("/deleteDetil/{mkaId}")
  144. @ResponseBody
  145. public R deleteDetil(@PathVariable("mkaId") Long typeId,@RequestBody Integer[]mprIds) {
  146. mall2PointsRulesService.deleteDetil(mprIds,typeId);
  147. return R.ok();
  148. }
  149. }