123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- 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<String, Object> params) {
- //查询列表数据
- Query query = new Query(params);
- List<Mall2PointsRulesEntity> 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<Mall2RulesDto> mall2RulesDtoList = new ArrayList<>();//信息
- try {
- Mall2RulesDto mall2RulesDto = new Mall2RulesDto();
- Map<String, Object> 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<String, Object> params) {
- return R.ok().put("list", null);
- }
- /**
- * 查看积分列表详情
- */
- @RequestMapping("/detilList")
- @ResponseBody
- public R detilList(@RequestParam Map<String, Object> params) {
- //查询列表数据
- Query query = new Query(params);
- Map<String,Object> map = mall2PointsRulesService.queryDetilList(query);
- List<Mall2DetilEntity> mall2PointsRulesList = (List<Mall2DetilEntity>)map.get("list");
- int total = (int)map.get("total");
- 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();
- }
- }
|