Mall2PointsRulesController.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. mall2PointsRulesService.save(mall2PointsRules);
  69. return R.ok();
  70. }
  71. /**
  72. * 修改
  73. */
  74. @RequestMapping("/update")
  75. // @RequiresPermissions("mall2pointsrules:update")
  76. @ResponseBody
  77. public R update(@RequestBody Mall2PointsRulesEntity mall2PointsRules) {
  78. mall2PointsRulesService.update(mall2PointsRules);
  79. return R.ok();
  80. }
  81. /**
  82. * 删除
  83. */
  84. @RequestMapping("/delete")
  85. @ResponseBody
  86. public R delete(@RequestBody Integer[]mprIds) {
  87. mall2PointsRulesService.deleteBatch(mprIds);
  88. return R.ok();
  89. }
  90. /**
  91. * 上传文件积分明细信息
  92. */
  93. @RequestMapping("/rulesUpload")
  94. @ResponseBody
  95. public R rulesUpload(@RequestParam("file") MultipartFile file, Long mkaId) {
  96. List<Mall2RulesDto> mall2RulesDtoList = new ArrayList<>();//信息
  97. try {
  98. Mall2RulesDto mall2RulesDto = new Mall2RulesDto();
  99. Map<String, Object> beans = new HashMap<>();
  100. beans.put("Mall2RulesDto", mall2RulesDto);
  101. beans.put("Mall2RulesDtoList", mall2RulesDtoList);
  102. if (file.isEmpty()) {
  103. return R.error("文件不能为空!");
  104. }
  105. excelUtil.readExcel(JxlsXmlTemplateName.MALL_RULES_LIST, beans, file.getInputStream());
  106. } catch (Exception e) {
  107. e.printStackTrace();
  108. return R.error("导入失败!");
  109. }
  110. return mall2PointsRulesService.rulesUploadDetil(mall2RulesDtoList,mkaId);
  111. }
  112. /**
  113. * 积分赠送规则查询积分类型
  114. */
  115. @RequestMapping("/getRulesDetilId")
  116. @ResponseBody
  117. public R getRulesDetilId(Long mkaId) {
  118. Integer rulesDetilId = mall2PointsRulesService.getRulesDetilId(mkaId);
  119. return R.ok(rulesDetilId.toString());
  120. }
  121. /**
  122. * 查看所有明细列表
  123. */
  124. @RequestMapping("/queryAll")
  125. @ResponseBody
  126. public R queryRulesDetilAll(@RequestParam Map<String, Object> params) {
  127. return R.ok().put("list", null);
  128. }
  129. /**
  130. * 查看积分列表详情
  131. */
  132. @RequestMapping("/detilList")
  133. @ResponseBody
  134. public R detilList(@RequestParam Map<String, Object> params) {
  135. //查询列表数据
  136. Query query = new Query(params);
  137. List<Mall2RulesDto> mall2PointsRulesList = mall2PointsRulesService.queryDetilList(query);
  138. int total = mall2PointsRulesService.querymall2PointsRulesDetilTotal(query);
  139. PageUtils pageUtil = new PageUtils(mall2PointsRulesList, total, query.getLimit(), query.getPage());
  140. return R.ok().put("page", pageUtil);
  141. }
  142. /**
  143. * 删除列表详情
  144. */
  145. @RequestMapping("/deleteDetil/{mkaId}")
  146. @ResponseBody
  147. public R deleteDetil(@PathVariable("mkaId") Long typeId,@RequestBody Integer[]mprIds) {
  148. mall2PointsRulesService.deleteDetil(mprIds,typeId);
  149. return R.ok();
  150. }
  151. }