package com.kmall.admin.controller.vip; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import com.kmall.admin.dto.Mall2RulesDto; import com.kmall.admin.entity.vip.Mall2DetilEntity; import com.kmall.common.constant.JxlsXmlTemplateName; import com.kmall.common.utils.PageUtils; import com.kmall.common.utils.Query; import com.kmall.common.utils.R; import com.kmall.common.utils.excel.ExcelUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import com.kmall.admin.entity.vip.Mall2PointsRulesEntity; import com.kmall.admin.service.vip.Mall2PointsRulesService; import org.springframework.web.multipart.MultipartFile; /** * 积分规则表Controller * * @author emato * @email admin@qhdswl.com * @date 2020-06-15 10:44:07 */ @Controller @RequestMapping("mall2pointsrules") public class Mall2PointsRulesController { @Autowired private Mall2PointsRulesService mall2PointsRulesService; @Autowired private ExcelUtil excelUtil; /** * 查看列表 */ @RequestMapping("/list") // @RequiresPermissions("mall2pointsrules:list") @ResponseBody public R list(@RequestParam Map params) { //查询列表数据 Query query = new Query(params); List mall2PointsRulesList = mall2PointsRulesService.queryList(query); int total = mall2PointsRulesService.queryTotal(query); PageUtils pageUtil = new PageUtils(mall2PointsRulesList, total, query.getLimit(), query.getPage()); return R.ok().put("page", pageUtil); } /** * 查看信息 */ @RequestMapping("/info/{mprId}") // @RequiresPermissions("mall2pointsrules:info") @ResponseBody public R info(@PathVariable("mprId") Integer mprId) { Mall2PointsRulesEntity mall2PointsRules = mall2PointsRulesService.queryObject(mprId); mall2PointsRules.setPointsTypeStr(mall2PointsRules.getPointsType()+""); return R.ok().put("mall2PointsRules", mall2PointsRules); } /** * 保存 */ @RequestMapping("/save") // @RequiresPermissions("mall2pointsrules:save") @ResponseBody public R save(@RequestBody Mall2PointsRulesEntity mall2PointsRules) { mall2PointsRulesService.save(mall2PointsRules); return R.ok(); } /** * 修改 */ @RequestMapping("/update") // @RequiresPermissions("mall2pointsrules:update") @ResponseBody public R update(@RequestBody Mall2PointsRulesEntity mall2PointsRules) { mall2PointsRulesService.update(mall2PointsRules); return R.ok(); } /** * 删除 */ @RequestMapping("/delete") // @RequiresPermissions("mall2pointsrules:delete") @ResponseBody public R delete(@RequestBody Integer[]mprIds) { mall2PointsRulesService.deleteBatch(mprIds); return R.ok(); } /** * 上传文件积分明细信息 */ @RequestMapping("/rulesUpload") @ResponseBody public R rulesUpload(@RequestParam("file") MultipartFile file, Long mkaId) { List mall2RulesDtoList = new ArrayList<>();//信息 try { Mall2RulesDto mall2RulesDto = new Mall2RulesDto(); Map beans = new HashMap<>(); beans.put("Mall2RulesDto", mall2RulesDto); beans.put("Mall2RulesDtoList", mall2RulesDtoList); if (file.isEmpty()) { return R.error("文件不能为空!"); } excelUtil.readExcel(JxlsXmlTemplateName.MALL_RULES_LIST, beans, file.getInputStream()); } catch (Exception e) { e.printStackTrace(); return R.error("导入失败!"); } mall2PointsRulesService.rulesUploadDetil(mall2RulesDtoList,mkaId); //上传文件 return R.ok("导入成功!"); } /** * 查看所有明细列表 */ @RequestMapping("/queryAll") @ResponseBody public R queryRulesDetilAll(@RequestParam Map params) { return R.ok().put("list", null); } /** * 查看积分列表详情 */ @RequestMapping("/detilList") @ResponseBody public R detilList(@RequestParam Map params) { //查询列表数据 Query query = new Query(params); List mall2PointsRulesList = mall2PointsRulesService.queryDetilList(query); int total = mall2PointsRulesService.querymall2PointsRulesDetilTotal(query); PageUtils pageUtil = new PageUtils(mall2PointsRulesList, total, query.getLimit(), query.getPage()); return R.ok().put("page", pageUtil); } /** * 删除列表详情 */ @RequestMapping("/deleteDetil/{mkaId}") @ResponseBody public R deleteDetil(@PathVariable("mkaId") Long typeId,@RequestBody Integer[]mprIds) { mall2PointsRulesService.deleteDetil(mprIds,typeId); return R.ok(); } }