From 629d62e6b9c2ab20e3d08d4007010c10ee19f3bd Mon Sep 17 00:00:00 2001 From: Jackwang Date: Fri, 17 Jun 2022 18:07:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85PC=E7=AB=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/PointAdditiveRuleDTO.java | 2 + .../epmet/dto/form/PointModifyFormDTO.java | 63 +++++++++++++++++++ .../PointAdditiveRuleController.java | 30 +++++++-- .../com/epmet/dao/PointAdditiveRuleDao.java | 9 +++ .../service/PointAdditiveRuleService.java | 23 +++++-- .../impl/PointAdditiveRuleServiceImpl.java | 51 +++++++++++++-- .../resources/mapper/PointAdditiveRuleDao.xml | 13 ++++ 7 files changed, 179 insertions(+), 12 deletions(-) create mode 100644 epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointModifyFormDTO.java diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/PointAdditiveRuleDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/PointAdditiveRuleDTO.java index 3171aa9566..750bdaf71b 100644 --- a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/PointAdditiveRuleDTO.java +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/PointAdditiveRuleDTO.java @@ -37,6 +37,8 @@ public class PointAdditiveRuleDTO implements Serializable { */ private String applyFlag; + private String applyFlagName; + /** * 积分类别编码;德育积分moral_education;党建积分party_building */ diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointModifyFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointModifyFormDTO.java new file mode 100644 index 0000000000..71cff835cd --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointModifyFormDTO.java @@ -0,0 +1,63 @@ +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-17 17:48 + **/ +@Data +public class PointModifyFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @NotNull(message = "id不可为空") + private String id; + + private String customerId; + + + /** + * 记录类型;分类:category;规则:rule + */ + @NotNull(message = "类型不可为空") + private String type; + + /** + * 允许申请标记;允许0(type = category时,强制赋值为0),禁止1。 + */ + private String applyFlag; + + + /** + * 积分类别名称;type=category时必填 + */ + private String categoryName; + + /** + * 积分规则名称;type=rule时必填 + */ + private String ruleName; + + /** + * 上级节点ID;上级分类ID,顶级分类的PID为0 + */ + @NotNull(message = "pid不可为空") + private String pid; + + + /** + * 分值;正数加分,负数减分;type=rule时必填 + */ + private Integer pointValue; + + +} 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 6d1f168b1f..3f780d3ff9 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 @@ -13,10 +13,7 @@ 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.dto.form.*; import com.epmet.dto.result.List4ApplyResultDTO; import com.epmet.excel.PointAdditiveRuleExcel; import com.epmet.service.PointAdditiveRuleService; @@ -163,4 +160,29 @@ public class PointAdditiveRuleController { dto.setCustomerId(tokenDto.getCustomerId()); return pointAdditiveRuleService.list4apply(dto); } + + /** + * @describe: 查询积分规则详情 + * @author wangtong + * @date 2022/6/17 17:36 + * @params [categoryId] + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("ruledetail/{ruleId}") + public Result ruledetail(@PathVariable("ruleId") String ruleId){ + return pointAdditiveRuleService.ruledetail(ruleId); + } + + /** + * @describe: 修改积分分类/规则 + * @author wangtong + * @date 2022/6/17 17:51 + * @params [dto] + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("modify") + public Result modify(@LoginUser TokenDto tokenDto,@RequestBody PointModifyFormDTO dto){ + dto.setCustomerId(tokenDto.getCustomerId()); + return pointAdditiveRuleService.modify(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 5affc6761f..9e67740ec3 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 @@ -77,4 +77,13 @@ public interface PointAdditiveRuleDao extends BaseDao { PointAdditiveRuleEntity selectEntityByName(@Param("customerId") String customerId, @Param("categoryName") String categoryName, @Param("ruleName") String ruleName); + + /** + * @describe: 查询积分规则详情 + * @author wangtong + * @date 2022/6/17 17:40 + * @params [categoryId] + * @return com.epmet.dto.PointAdditiveRuleDTO + */ + PointAdditiveRuleDTO selectRuledetail(@Param("ruleId") String ruleId); } 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 62bb880715..4f9995158e 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 @@ -5,10 +5,7 @@ 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.dto.form.*; import com.epmet.dto.result.List4ApplyResultDTO; import com.epmet.entity.PointAdditiveRuleEntity; @@ -136,4 +133,22 @@ public interface PointAdditiveRuleService extends BaseService> list4tree(List4treeFormDTO dto); + + /** + * @describe: 查询积分规则详情 + * @author wangtong + * @date 2022/6/17 17:36 + * @params [categoryId] + * @return com.epmet.commons.tools.utils.Result + */ + Result ruledetail(String ruleId); + + /** + * @describe: 修改积分分类/规则 + * @author wangtong + * @date 2022/6/17 17:51 + * @params [dto] + * @return com.epmet.commons.tools.utils.Result + */ + Result modify(PointModifyFormDTO 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 9301f4fb7c..6a2607ed2f 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 @@ -14,10 +14,7 @@ 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.dto.form.*; import com.epmet.dto.result.List4ApplyResultDTO; import com.epmet.entity.PointAdditiveRuleEntity; import com.epmet.redis.PointAdditiveRuleRedis; @@ -202,4 +199,50 @@ public class PointAdditiveRuleServiceImpl extends BaseServiceImpl>().ok(result); } + @Override + public Result ruledetail(String ruleId) { + PointAdditiveRuleDTO result = baseDao.selectRuledetail(ruleId); + return new Result().ok(result); + } + + @Override + public Result modify(PointModifyFormDTO dto) { + PointAdditiveRuleEntity entity = baseDao.selectById(dto.getId()); + + if(PointAddRuleEnum.CATEGORY_TYPE.getCode().equals(dto.getType())){ + //类别 + PointAdditiveRuleEntity isExist = baseDao.selectEntityByName(dto.getCustomerId(),dto.getCategoryName(),null); + if(isExist != null){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "该名称已存在","该名称已存在"); + } + entity.setCategoryName(dto.getCategoryName()); + }else if(PointAddRuleEnum.RULE_TYPE.getCode().equals(dto.getType())){ + //规则 + PointAdditiveRuleEntity isExist = baseDao.selectEntityByName(dto.getCustomerId(),null,dto.getRuleName()); + if(isExist != null){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "该名称已存在","该名称已存在"); + } + entity.setRuleName(dto.getRuleName()); + entity.setPointValue(dto.getPointValue()); + entity.setApplyFlag(dto.getApplyFlag()); + }else{ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "type类型有误","type类型有误"); + } + + if(!NumConstant.ZERO_STR.equals(dto.getPid())){ + PointAdditiveRuleEntity parentEntity = baseDao.selectById(dto.getPid()); + if(null == parentEntity){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "未查到父节点信息","未查到父节点信息"); + } + entity.setPid(dto.getPid()); + if(StringUtils.isBlank(parentEntity.getPids())){ + entity.setPids(parentEntity.getId()); + }else{ + entity.setPids(parentEntity.getPids()+":"+parentEntity.getId()); + } + } + updateById(entity); + return new Result().ok("修改成功!"); + } + } 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 5bfb46e1d4..4b3c086d91 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 @@ -106,6 +106,19 @@ and RULE_NAME= #{ruleName} +