From a2eb09de03e47e6f57115169a04452efe31dddf3 Mon Sep 17 00:00:00 2001 From: Jackwang Date: Wed, 15 Jun 2022 16:48:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=AF=E5=88=86=E8=A7=84=E5=88=99=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/CategorydetailResultDTO.java | 45 ++++++++++ .../epmet/dto/form/AddcategoryFormDTO.java | 32 +++++++ .../com/epmet/dto/form/AddruleFormDTO.java | 44 ++++++++++ .../com/epmet/dto/form/List4applyFormDTO.java | 36 ++++++++ .../com/epmet/dto/form/List4treeFormDTO.java | 27 ++++++ .../epmet/common/enu/PointAddRuleEnum.java | 41 +++++++++ .../PointAdditiveRuleController.java | 87 ++++++++++++++++++- .../com/epmet/dao/PointAdditiveRuleDao.java | 46 +++++++++- .../service/PointAdditiveRuleService.java | 62 ++++++++++++- .../impl/PointAdditiveRuleServiceImpl.java | 70 ++++++++++++++- .../resources/mapper/PointAdditiveRuleDao.xml | 56 +++++++++++- 11 files changed, 539 insertions(+), 7 deletions(-) create mode 100644 epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/CategorydetailResultDTO.java create mode 100644 epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AddcategoryFormDTO.java create mode 100644 epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AddruleFormDTO.java create mode 100644 epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/List4applyFormDTO.java create mode 100644 epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/List4treeFormDTO.java create mode 100644 epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointAddRuleEnum.java diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/CategorydetailResultDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/CategorydetailResultDTO.java new file mode 100644 index 0000000000..61bfbc41c6 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/CategorydetailResultDTO.java @@ -0,0 +1,45 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @program: epmet-cloud + * @description: + * @author: wangtong + * @create: 2022-06-15 10:44 + **/ +@Data +public class CategorydetailResultDTO implements Serializable { + + /** + *类别ID + */ + private String id; + + /** + *类别名 + */ + private String categoryName; + + /** + *上级类别ID + */ + private String pid; + + /** + *上级类别名 + */ + private String parentCategoryName; + + /** + *创建时间 + */ + private String createdTime; + + /** + *修改时间 + */ + private String updatedTime; +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AddcategoryFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AddcategoryFormDTO.java new file mode 100644 index 0000000000..41aecae242 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AddcategoryFormDTO.java @@ -0,0 +1,32 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @program: epmet-cloud + * @description: + * @author: wangtong + * @create: 2022-06-15 11:12 + **/ +@Data +public class AddcategoryFormDTO implements Serializable { + + /** + *类别名称 + */ + @NotNull(message = "类别名称不可为空") + private String categoryName; + + /** + *上级类别ID + */ + @NotNull(message = "上级类别不可为空") + private String pid; + + private String customerId; + + +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AddruleFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AddruleFormDTO.java new file mode 100644 index 0000000000..53dd15ca35 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AddruleFormDTO.java @@ -0,0 +1,44 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @program: epmet-cloud + * @description: + * @author: wangtong + * @create: 2022-06-15 11:12 + **/ +@Data +public class AddruleFormDTO implements Serializable { + + /** + *积分规则名称 + */ + @NotNull(message = "积分规则名称不可为空") + private String ruleName; + + /** + *上级类别ID + */ + @NotNull(message = "上级类别不可为空") + private String pid; + + /** + *分值,整数,可以为负数(表示减分) + */ + @NotNull(message = "分值不可为空") + private Integer pointValue; + + /** + *允许申请0,不允许申请1 + */ + @NotNull(message = "申请标记不可为空") + private String applyFlag; + + private String customerId; + + +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/List4applyFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/List4applyFormDTO.java new file mode 100644 index 0000000000..441bf8d353 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/List4applyFormDTO.java @@ -0,0 +1,36 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @program: epmet-cloud + * @description: + * @author: wangtong + * @create: 2022-06-15 16:23 + **/ +@Data +public class List4applyFormDTO implements Serializable { + + /** + *允许申请0,不允许申请1 + */ + private String applyFlag; + + /** + *类别 + */ + @NotNull(message = "类别不可为空") + private String categoryCode; + + /** + * 记录类型;分类:category;规则:rule + */ + private String type; + + + + private String customerId; +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/List4treeFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/List4treeFormDTO.java new file mode 100644 index 0000000000..2f3e912649 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/List4treeFormDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @program: epmet-cloud + * @description: + * @author: wangtong + * @create: 2022-06-15 10:10 + **/ +@Data +public class List4treeFormDTO implements Serializable { + + /** + * 类别名称 + */ + private String categoryName; + + /** + * 规则名称 + */ + private String ruleName; + + private String customerId; +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointAddRuleEnum.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointAddRuleEnum.java new file mode 100644 index 0000000000..91ced60017 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointAddRuleEnum.java @@ -0,0 +1,41 @@ +package com.epmet.common.enu; + +/** +* @describe: 积分规则枚举类 +* @author wangtong +* @date 2022/6/15 13:54 +*/ +public enum PointAddRuleEnum { + CATEGORY_TYPE("category", "分类"), + RULE_TYPE("rule", "规则"), + APPLY_ALLOW("0", "允许"), + APPLY_BAN("1", "禁止"), + ; + + private String code; + private String desc; + + + PointAddRuleEnum(String code, String name) { + this.code = code; + this.desc = name; + } + + public static PointAddRuleEnum getEnum(String code) { + PointAddRuleEnum[] values = PointAddRuleEnum.values(); + for (PointAddRuleEnum value : values) { + if (code != null && value.getCode().equals(code)) { + return value; + } + } + return null; + } + + public String getCode() { + return code; + } + + public String getDesc() { + return desc; + } +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointAdditiveRuleController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointAdditiveRuleController.java index 2e0e82bb8f..d5e75497d9 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointAdditiveRuleController.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointAdditiveRuleController.java @@ -1,15 +1,22 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.CategorydetailResultDTO; import com.epmet.dto.PointAdditiveRuleDTO; +import com.epmet.dto.form.AddcategoryFormDTO; +import com.epmet.dto.form.AddruleFormDTO; +import com.epmet.dto.form.List4applyFormDTO; +import com.epmet.dto.form.List4treeFormDTO; import com.epmet.excel.PointAdditiveRuleExcel; import com.epmet.service.PointAdditiveRuleService; import org.springframework.beans.factory.annotation.Autowired; @@ -27,7 +34,7 @@ import java.util.Map; * @since v1.0.0 2022-06-15 */ @RestController -@RequestMapping("pointAdditiveRule") +@RequestMapping("additiverule") public class PointAdditiveRuleController { @Autowired @@ -77,6 +84,82 @@ public class PointAdditiveRuleController { ExcelUtils.exportExcelToTarget(response, null, list, PointAdditiveRuleExcel.class); } + /** + * @describe: 查询积分类别规则列表 + * @author wangtong + * @date 2022/6/15 10:11 + * @params [dto] + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("list4tree") + public Result> list4tree(@LoginUser TokenDto tokenDto, @RequestBody List4treeFormDTO dto){ + dto.setCustomerId(tokenDto.getCustomerId()); + return pointAdditiveRuleService.list4tree(dto); + } + + /** + * @describe: 查询下级类别简要信息 + * @author wangtong + * @date 2022/6/15 10:23 + * @params [categoryId] + * @return com.epmet.commons.tools.utils.Result> + */ + @PostMapping("subcategory/listbrief/{categoryId}") + public Result> listbrief(@PathVariable("categoryId") String categoryId){ + return pointAdditiveRuleService.listbrief(categoryId); + } + /** + * @describe: 查询积分类别详情 + * @author wangtong + * @date 2022/6/15 10:23 + * @params [categoryId] + * @return com.epmet.commons.tools.utils.Result> + */ + @PostMapping("categorydetail/{categoryId}") + public Result categorydetail(@PathVariable("categoryId") String categoryId){ + return pointAdditiveRuleService.categorydetail(categoryId); + } + /** + * @describe: 添加积分类别 + * @author wangtong + * @date 2022/6/15 10:23 + * @params [categoryId] + * @return com.epmet.commons.tools.utils.Result> + */ + @PostMapping("addcategory") + public Result addcategory(@LoginUser TokenDto tokenDto,@RequestBody AddcategoryFormDTO dto){ + ValidatorUtils.validateEntity(dto); + dto.setCustomerId(tokenDto.getCustomerId()); + return pointAdditiveRuleService.addcategory(dto); + } + + /** + * @describe: 添加积分规则 + * @author wangtong + * @date 2022/6/15 10:23 + * @params [categoryId] + * @return com.epmet.commons.tools.utils.Result> + */ + @PostMapping("addrule") + public Result addrule(@LoginUser TokenDto tokenDto,@RequestBody AddruleFormDTO dto){ + ValidatorUtils.validateEntity(dto); + dto.setCustomerId(tokenDto.getCustomerId()); + return pointAdditiveRuleService.addrule(dto); + } + + /** + * @describe: [附加积分]获取允许申请的积分类别 + * @author wangtong + * @date 2022/6/15 10:23 + * @params [categoryId] + * @return com.epmet.commons.tools.utils.Result> + */ + @PostMapping("list4apply") + public Result> list4apply(@LoginUser TokenDto tokenDto,@RequestBody List4applyFormDTO dto){ + ValidatorUtils.validateEntity(dto); + dto.setCustomerId(tokenDto.getCustomerId()); + return pointAdditiveRuleService.list4apply(dto); + } } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointAdditiveRuleDao.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointAdditiveRuleDao.java index 2729a86c27..9d4da90278 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointAdditiveRuleDao.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointAdditiveRuleDao.java @@ -1,8 +1,15 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.CategorydetailResultDTO; +import com.epmet.dto.PointAdditiveRuleDTO; +import com.epmet.dto.form.List4applyFormDTO; +import com.epmet.dto.form.List4treeFormDTO; import com.epmet.entity.PointAdditiveRuleEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 附加积分规则 @@ -12,5 +19,40 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface PointAdditiveRuleDao extends BaseDao { - -} \ No newline at end of file + + /** + * @describe: 查询下级类别简要信息 + * @author wangtong + * @date 2022/6/15 10:30 + * @params [categoryId] + * @return java.util.List + */ + List selectListbrief(@Param("categoryId") String categoryId); + + /** + * @describe: 查询积分类别详情 + * @author wangtong + * @date 2022/6/15 10:52 + * @params [categoryId] + * @return com.epmet.dto.CategorydetailResultDTO + */ + CategorydetailResultDTO selectCategorydetail(@Param("categoryId") String categoryId); + + /** + * @describe: [附加积分]获取允许申请的积分类别 + * @author wangtong + * @date 2022/6/15 16:29 + * @params [dto] + * @return java.util.List + */ + List selectList4apply(List4applyFormDTO dto); + + /** + * @describe: 查询积分类别规则列表 + * @author wangtong + * @date 2022/6/15 16:43 + * @params [dto] + * @return java.util.List + */ + List selectList4tree(List4treeFormDTO dto); +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointAdditiveRuleService.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointAdditiveRuleService.java index 34fe5a1186..27f0546f84 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointAdditiveRuleService.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointAdditiveRuleService.java @@ -2,7 +2,13 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CategorydetailResultDTO; import com.epmet.dto.PointAdditiveRuleDTO; +import com.epmet.dto.form.AddcategoryFormDTO; +import com.epmet.dto.form.AddruleFormDTO; +import com.epmet.dto.form.List4applyFormDTO; +import com.epmet.dto.form.List4treeFormDTO; import com.epmet.entity.PointAdditiveRuleEntity; import java.util.List; @@ -75,4 +81,58 @@ public interface PointAdditiveRuleService extends BaseService> + */ + Result> listbrief(String categoryId); + + /** + * @describe: 查询积分类别详情 + * @author wangtong + * @date 2022/6/15 10:49 + * @params [categoryId] + * @return com.epmet.commons.tools.utils.Result + */ + Result categorydetail(String categoryId); + + /** + * @describe: 添加积分类别 + * @author wangtong + * @date 2022/6/15 11:14 + * @params [dto] + * @return com.epmet.commons.tools.utils.Result + */ + Result addcategory(AddcategoryFormDTO dto); + + /** + * @describe: 添加积分规则 + * @author wangtong + * @date 2022/6/15 10:23 + * @params [categoryId] + * @return com.epmet.commons.tools.utils.Result> + */ + Result addrule(AddruleFormDTO dto); + + /** + * @describe: [附加积分]获取允许申请的积分类别 + * @author wangtong + * @date 2022/6/15 10:23 + * @params [categoryId] + * @return com.epmet.commons.tools.utils.Result> + */ + Result> list4apply(List4applyFormDTO dto); + + /** + * @describe: 查询积分类别规则列表 + * @author wangtong + * @date 2022/6/15 10:11 + * @params [dto] + * @return com.epmet.commons.tools.utils.Result + */ + Result> list4tree(List4treeFormDTO dto); +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointAdditiveRuleServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointAdditiveRuleServiceImpl.java index fa426708a5..bae799657f 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointAdditiveRuleServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointAdditiveRuleServiceImpl.java @@ -2,12 +2,20 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.common.enu.PointAddRuleEnum; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.Result; import com.epmet.dao.PointAdditiveRuleDao; +import com.epmet.dto.CategorydetailResultDTO; import com.epmet.dto.PointAdditiveRuleDTO; +import com.epmet.dto.form.AddcategoryFormDTO; +import com.epmet.dto.form.AddruleFormDTO; +import com.epmet.dto.form.List4applyFormDTO; +import com.epmet.dto.form.List4treeFormDTO; import com.epmet.entity.PointAdditiveRuleEntity; import com.epmet.redis.PointAdditiveRuleRedis; import com.epmet.service.PointAdditiveRuleService; @@ -84,4 +92,64 @@ public class PointAdditiveRuleServiceImpl extends BaseServiceImpl> listbrief(String categoryId) { + List result = baseDao.selectListbrief(categoryId); + return new Result>().ok(result); + } + + @Override + public Result categorydetail(String categoryId) { + CategorydetailResultDTO result = baseDao.selectCategorydetail(categoryId); + return new Result().ok(result); + } + + @Override + public Result addcategory(AddcategoryFormDTO dto) { + PointAdditiveRuleEntity entity = new PointAdditiveRuleEntity(); + entity.setCustomerId(dto.getCustomerId()); + entity.setType(PointAddRuleEnum.CATEGORY_TYPE.getCode()); + entity.setApplyFlag(PointAddRuleEnum.APPLY_ALLOW.getCode()); + entity.setCategoryName(dto.getCategoryName()); + entity.setPid(dto.getPid()); + if(!NumConstant.ZERO_STR.equals(dto.getPid())){ + PointAdditiveRuleEntity parentEntity = baseDao.selectById(dto.getPid()); + entity.setPids(parentEntity.getPids()+":"+parentEntity.getId()); + entity.setCategoryCode(parentEntity.getCategoryCode()); + } + insert(entity); + return new Result().ok("新增成功!"); + } + + @Override + public Result addrule(AddruleFormDTO dto) { + PointAdditiveRuleEntity entity = new PointAdditiveRuleEntity(); + entity.setCustomerId(dto.getCustomerId()); + entity.setType(PointAddRuleEnum.RULE_TYPE.getCode()); + entity.setRuleName(dto.getRuleName()); + entity.setApplyFlag(dto.getApplyFlag()); + entity.setPointValue(dto.getPointValue()); + entity.setPid(dto.getPid()); + if(!NumConstant.ZERO_STR.equals(dto.getPid())){ + PointAdditiveRuleEntity parentEntity = baseDao.selectById(dto.getPid()); + entity.setCategoryCode(parentEntity.getCategoryCode()); + entity.setPids(parentEntity.getPids()+":"+parentEntity.getId()); + } + insert(entity); + return new Result().ok("新增成功!"); + } + + @Override + public Result> list4apply(List4applyFormDTO dto) { + dto.setType(PointAddRuleEnum.CATEGORY_TYPE.getCode()); + List result = baseDao.selectList4apply(dto); + return new Result>().ok(result); + } + + @Override + public Result> list4tree(List4treeFormDTO dto) { + List result = baseDao.selectList4tree(dto); + return new Result>().ok(result); + } + +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointAdditiveRuleDao.xml b/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointAdditiveRuleDao.xml index c490e974b4..78d24c5da2 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointAdditiveRuleDao.xml +++ b/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointAdditiveRuleDao.xml @@ -21,6 +21,60 @@ + + + + - \ No newline at end of file +