1
0

Mall2PointsRulesController.java 4.9 KB

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