diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java index b4a81ce53a..a7ae559a01 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java @@ -48,4 +48,9 @@ public interface StrConstant { * 中文顿号 */ String COMMA_ZH = "、"; + + /** + * 反斜杠 + */ + String SEPARATOR = "/"; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CommonOperateTypeEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CommonOperateTypeEnum.java new file mode 100644 index 0000000000..1dc0b571c5 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CommonOperateTypeEnum.java @@ -0,0 +1,42 @@ +package com.epmet.commons.tools.enums; + +/** + * 通用操作类型 枚举类 + * dev|test|prod + * + * @author jianjun liu + * @date 2020-07-03 11:14 + **/ +public enum CommonOperateTypeEnum { + ADD("add", "添加"), + EDIT("edit", "编辑"), + DEL("del", "删除"), + ; + + private String code; + private String desc; + + + CommonOperateTypeEnum(String code, String name) { + this.code = code; + this.desc = name; + } + + public static CommonOperateTypeEnum getEnum(String code) { + CommonOperateTypeEnum[] values = CommonOperateTypeEnum.values(); + for (CommonOperateTypeEnum 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-client/src/main/java/com/epmet/dto/PointRuleDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/PointRuleDTO.java deleted file mode 100644 index 25251dd36a..0000000000 --- a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/PointRuleDTO.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.dto; - -import java.io.Serializable; -import java.util.Date; -import lombok.Data; - - -/** - * 积分规则表 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-07-20 - */ -@Data -public class PointRuleDTO implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - private String id; - - /** - * 客户ID - */ - private String customerId; - - /** - * 规则名称 与事件名称保持一致即可 - */ - private String ruleName; - - /** - * 规则说明 事件说明 - */ - private String ruleDesc; - - /** - * 事件CODE 来自事件表 - */ - private String eventCode; - - /** - * 事件名称 来自事件表 - */ - private String eventName; - - /** - * 操作类型 加积分:add;减积分:subtract - */ - private String operateType; - - /** - * 积分上限 - */ - private Integer upLimit; - - /** - * 积分上限描述 - */ - private String upLimitDesc; - - /** - * 获得积分值 - */ - private Integer pointNum; - - /** - * 获得积分单位 次:time;分钟:minute;小时:hour - */ - private String pointUnit; - - /** - * 是否启用 0-否,1-是 - */ - private String enabledFlag; - - /** - * 删除标识 0-否,1-是 - */ - private String delFlag; - - /** - * 乐观锁 - */ - private Integer revision; - - /** - * 创建人 - */ - private String createdBy; - - /** - * 创建时间 - */ - private Date createdTime; - - /** - * 更新人 - */ - private String updatedBy; - - /** - * 更新时间 - */ - private Date updatedTime; - -} \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointDetailFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointDetailFormDTO.java new file mode 100644 index 0000000000..d8a7fee9cb --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointDetailFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** +* desc:积分规则Id详情获取 规则列表 + * @author jianjun liu + * @date 2020-07-22 15:28 + **/ +@Data +public class PointDetailFormDTO implements Serializable { + private static final long serialVersionUID = 7587939716742608164L; + /** + * 积分规则Id + */ + @NotBlank(message = "积分规则Id不能为空") + private String ruleId; +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointRuleFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointRuleFormDTO.java new file mode 100644 index 0000000000..fca065c9d6 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointRuleFormDTO.java @@ -0,0 +1,71 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * desc:积分规则保存/修改 规则列表 + * + * @author jianjun liu + * @date 2020-07-22 15:28 + **/ +@Data +public class PointRuleFormDTO implements Serializable { + private static final long serialVersionUID = -3228252683629912008L; + /** + * 积分规则Id + */ + @NotBlank(message = "积分规则Id不能为空", groups = UpdateGroup.class) + private String ruleId; + /** + * 积分 + */ + @NotBlank(message = "积分不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String point; + + /** + * 是否开启 + */ + @NotBlank(message = "是否开启不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String enabledFlag; + /** + * 上限开启 + */ + @NotBlank(message = "积分上限不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String upLimit; + + /** + * 积分规则Id + */ + @NotBlank(message = "客户Id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String customerId; + + //=======系统添加时的属性====== + /** + * 规则说明 事件说明 + */ + @NotBlank(message = "规则描述不能为空", groups = AddGroup.class) + private String ruleDesc; + + /** + * 事件CODE 来自事件表 + */ + @NotBlank(message = "事件code不能为空", groups = AddGroup.class) + private String eventCode; + + /** + * 操作类型 加积分:add;减积分:subtract + */ + @NotBlank(message = "操作类型不能为空", groups = AddGroup.class) + private String operateType; + /** + * 获得积分单位 次:time;分钟:minute;小时:hour + */ + @NotBlank(message = "积分单位不能为空", groups = AddGroup.class) + private String pointUnit; + +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointRuleListFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointRuleListFormDTO.java new file mode 100644 index 0000000000..93566a19b3 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointRuleListFormDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** +* desc:根据功能Id获取 规则列表 + * @author jianjun liu + * @date 2020-07-22 15:28 + **/ +@Data +public class PointRuleListFormDTO implements Serializable { + private static final long serialVersionUID = -1918653281170340608L; + /** + * 功能Id + */ + @NotBlank(message = "功能Id不能为空") + private String functionId; + @NotBlank(message = "客户Id不能为空") + private String customerId; +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/CustomerFunctionResultDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/CustomerFunctionResultDTO.java new file mode 100644 index 0000000000..817b94d7c1 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/CustomerFunctionResultDTO.java @@ -0,0 +1,18 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * desc:积分规则-获取客户功能列表 result + * @author jianjun liu + * @date 2020-07-22 14:43 + **/ +@Data +public class CustomerFunctionResultDTO implements Serializable { + private static final long serialVersionUID = -3761765064811136295L; + + private String functionId; + private String functionName; +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/PointDetailResultDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/PointDetailResultDTO.java new file mode 100644 index 0000000000..8ed856dc91 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/PointDetailResultDTO.java @@ -0,0 +1,24 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * desc:积分规则-详情 result + * @author jianjun liu + * @date 2020-07-22 14:43 + **/ +@Data +public class PointDetailResultDTO implements Serializable { + + private static final long serialVersionUID = 2426172750860788081L; + private String ruleId; + private String ruleName; + private String ruleDesc; + private Integer point; + private String pointUnit; + private String upLimit; + private String enabledFlag; + private String upLimitDesc; +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/PointRuleResultDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/PointRuleResultDTO.java new file mode 100644 index 0000000000..bf8e546806 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/PointRuleResultDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * desc:积分规则-列表 result + * @author jianjun liu + * @date 2020-07-22 14:43 + **/ +@Data +public class PointRuleResultDTO implements Serializable { + + private static final long serialVersionUID = -2327977101138032573L; + private String ruleId; + private String ruleName; + private String ruleDesc; + /** + * 拼接好的 积分值/单位 + */ + private String pointValue; +} diff --git a/epmet-module/epmet-point/epmet-point-server/pom.xml b/epmet-module/epmet-point/epmet-point-server/pom.xml index 49ccab5b90..a6eef46a98 100644 --- a/epmet-module/epmet-point/epmet-point-server/pom.xml +++ b/epmet-module/epmet-point/epmet-point-server/pom.xml @@ -69,6 +69,18 @@ 2.0.0 compile + + com.epmet + oper-customize-client + 2.0.0 + compile + + + com.epmet + epmet-user-client + 2.0.0 + compile + diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointUnitEnum.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointUnitEnum.java new file mode 100644 index 0000000000..ab1d97453c --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointUnitEnum.java @@ -0,0 +1,42 @@ +package com.epmet.common.enu; + +/** + * 系积分系统-积分单位枚举类 + * dev|test|prod + * + * @author jianjun liu + * @date 2020-07-03 11:14 + **/ +public enum PointUnitEnum { + TIME("time", "次"), + MINUTE("minute", "分种"), + HOUR("hour", "小时"), + ; + + private String code; + private String name; + + + PointUnitEnum(String code, String name) { + this.code = code; + this.name = name; + } + + public static PointUnitEnum getEnum(String code) { + PointUnitEnum[] values = PointUnitEnum.values(); + for (PointUnitEnum value : values) { + if (code != null && value.getCode().equals(code)) { + return value; + } + } + return null; + } + + public String getCode() { + return code; + } + + public String getName() { + return name; + } +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/SysResponseEnum.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/SysResponseEnum.java new file mode 100644 index 0000000000..e7ff400906 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/SysResponseEnum.java @@ -0,0 +1,43 @@ +package com.epmet.common.enu; + +/** + * @author jianjun liu + * @date 2020-06-04 21:39 + **/ +public enum SysResponseEnum { + /** + * + * 业务代码枚举类 + * + * 编码样式:【CCCBBOOXX】 + * 编码示例说明: + * CCC 中心编码&业务系统 (112(与端口号一致)-积分系统服务) + * BB 业务类型(00-默认 ) + * OO 操作类型(00-默认) + * XX 具体编码(00-成功,01-失败,02-参数错误,10-异常 99-系统错误) + * + */ + /*通用枚举 */ + EXCEPTION(10001,"系统异常"), + + + /*积分规则 业务 01*/ + THIRD_SERVICE_ERROR(112010001,"调用第三方接口异常"), + POINT_RULE_IS_NOT_EXIST(112010002,"积分规则不存在"), + ; + + private Integer code; + private String msg; + SysResponseEnum(Integer code, String msg){ + this.code = code; + this.msg = msg; + } + + public Integer getCode() { + return code; + } + + public String getMsg() { + return msg; + } +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java new file mode 100644 index 0000000000..9d2b01d291 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java @@ -0,0 +1,40 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.dto.form.PointRuleFormDTO; +import com.epmet.service.PointRuleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author jianjun liu + * @date 2020-06-04 20:39 + **/ +@RestController +@RequestMapping("opback") +public class BackDoorController { + @Autowired + private PointRuleService pointRuleService; + + /** + * desc:添加规则 + * + * @param formDTO + * @return + */ + @PostMapping(value = "sysadd") + public Result add(@RequestBody PointRuleFormDTO formDTO) { + TokenDto tokenDTO = new TokenDto(); + tokenDTO.setUserId("default"); + formDTO.setCustomerId(tokenDTO.getCustomerId()); + ValidatorUtils.validateEntity(formDTO, AddGroup.class); + pointRuleService.add(tokenDTO, formDTO); + return new Result().ok(true); + } +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointRuleController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointRuleController.java new file mode 100644 index 0000000000..a0c7f479dd --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointRuleController.java @@ -0,0 +1,100 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +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.dto.form.PointDetailFormDTO; +import com.epmet.dto.form.PointRuleFormDTO; +import com.epmet.dto.form.PointRuleListFormDTO; +import com.epmet.dto.result.CustomerFunctionResultDTO; +import com.epmet.dto.result.PointDetailResultDTO; +import com.epmet.dto.result.PointRuleResultDTO; +import com.epmet.service.PointRuleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 积分规则controller + * + * @author jianjun liu + * @date 2020-07-22 14:39 + **/ +@RestController +@RequestMapping("rule") +public class PointRuleController { + @Autowired + private PointRuleService pointRuleService; + + /** + * desc:积分规则-获取客户有积分规则的功能列表 + * + * @param tokenDTO + * @return + */ + @PostMapping(value = "functionlist") + public Result> getFunctionList(@LoginUser TokenDto tokenDTO) { + return new Result>().ok(pointRuleService.getFunctionList(tokenDTO.getCustomerId())); + } + + /** + * desc:根据功能id获取积分规则 + * + * @param tokenDTO + * @param formDTO + * @return + */ + @PostMapping(value = "list") + public Result> list(@LoginUser TokenDto tokenDTO, @RequestBody PointRuleListFormDTO formDTO) { + formDTO.setCustomerId(tokenDTO.getCustomerId()); + ValidatorUtils.validateEntity(formDTO); + return new Result>().ok(pointRuleService.list(formDTO)); + } + + /** + * desc:根据规则id获取积分规则 + * + * @param formDTO + * @return + */ + @PostMapping(value = "detail") + public Result detail(@RequestBody PointDetailFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(pointRuleService.detail(formDTO)); + } + + /** + * desc:根据功能id获取积分规则 + * + * @param formDTO + * @return + */ + @PostMapping(value = "update") + public Result update(@LoginUser TokenDto tokenDTO, @RequestBody PointRuleFormDTO formDTO) { + formDTO.setCustomerId(tokenDTO.getCustomerId()); + ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); + pointRuleService.update(tokenDTO,formDTO); + return new Result().ok(true); + } + + /** + * desc:添加规则 + * + * @param formDTO + * @return + */ + @PostMapping(value = "add") + public Result add(@LoginUser TokenDto tokenDTO, @RequestBody PointRuleFormDTO formDTO) { + formDTO.setCustomerId(tokenDTO.getCustomerId()); + ValidatorUtils.validateEntity(formDTO, AddGroup.class); + pointRuleService.add(tokenDTO,formDTO); + return new Result().ok(true); + } +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointRuleDao.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointRuleDao.java index 3ab8e48b42..2c8f5a214a 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointRuleDao.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointRuleDao.java @@ -18,8 +18,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.PointRuleListFormDTO; import com.epmet.entity.PointRuleEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 积分规则表 @@ -29,5 +33,22 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface PointRuleDao extends BaseDao { - + + /** + * desc:获取该客户下有规则的功能Id + * + * @param customerId + * @return + */ + List selectFunctionIds(@Param("customerId") String customerId); + + /** + * desc:获取该客户下有规则的功能Id + * + * @param formDTO + * @return + */ + List selectListByFunctionId(PointRuleListFormDTO formDTO); + + int updateByCustomerId(PointRuleEntity entity); } \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/SysOperateLogDao.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/RuleOperateLogDao.java similarity index 88% rename from epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/SysOperateLogDao.java rename to epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/RuleOperateLogDao.java index 2721c88716..a959af0219 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/SysOperateLogDao.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/RuleOperateLogDao.java @@ -18,7 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.entity.SysOperateLogEntity; +import com.epmet.entity.RuleOperateLogEntity; import org.apache.ibatis.annotations.Mapper; /** @@ -28,6 +28,6 @@ import org.apache.ibatis.annotations.Mapper; * @since v1.0.0 2020-07-20 */ @Mapper -public interface SysOperateLogDao extends BaseDao { +public interface RuleOperateLogDao extends BaseDao { } \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/PointRuleEntity.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/PointRuleEntity.java index affd55595e..c2132a4292 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/PointRuleEntity.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/PointRuleEntity.java @@ -18,12 +18,11 @@ package com.epmet.entity; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Date; +import java.util.Objects; /** * 积分规则表 @@ -58,11 +57,6 @@ public class PointRuleEntity extends BaseEpmetEntity { */ private String eventCode; - /** - * 事件名称 来自事件表 - */ - private String eventName; - /** * 操作类型 加积分:add;减积分:subtract */ @@ -81,7 +75,7 @@ public class PointRuleEntity extends BaseEpmetEntity { /** * 获得积分值 */ - private Integer pointNum; + private Integer point; /** * 获得积分单位 次:time;分钟:minute;小时:hour @@ -93,4 +87,26 @@ public class PointRuleEntity extends BaseEpmetEntity { */ private String enabledFlag; + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + PointRuleEntity entity = (PointRuleEntity) o; + return customerId.equals(entity.customerId) && + ruleName.equals(entity.ruleName) && + ruleDesc.equals(entity.ruleDesc) && + eventCode.equals(entity.eventCode) && + operateType.equals(entity.operateType) && + upLimit.equals(entity.upLimit) && + upLimitDesc.equals(entity.upLimitDesc) && + point.equals(entity.point) && + pointUnit.equals(entity.pointUnit) && + enabledFlag.equals(entity.enabledFlag); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), customerId, ruleName, ruleDesc, eventCode, operateType, upLimit, upLimitDesc, point, pointUnit, enabledFlag); + } } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/SysOperateLogEntity.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/RuleOperateLogEntity.java similarity index 88% rename from epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/SysOperateLogEntity.java rename to epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/RuleOperateLogEntity.java index 4068bba53b..573a9f52da 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/SysOperateLogEntity.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/RuleOperateLogEntity.java @@ -18,13 +18,10 @@ package com.epmet.entity; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Date; - /** * 积分系统操作记录表 * @@ -34,7 +31,7 @@ import java.util.Date; @Data @EqualsAndHashCode(callSuper=false) @TableName("sys_operate_log") -public class SysOperateLogEntity extends BaseEpmetEntity { +public class RuleOperateLogEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; @@ -44,14 +41,9 @@ public class SysOperateLogEntity extends BaseEpmetEntity { private String customerId; /** - * 操作对象ID - */ - private String objectId; - - /** - * 对象类型 规则:rule + * 规则ID */ - private String objectType; + private String ruleId; /** * 操作类型 新建:add,编辑:edit,删除:del; diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointRuleService.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointRuleService.java index 3c84c43cad..fa53b5be05 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointRuleService.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointRuleService.java @@ -18,12 +18,16 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; -import com.epmet.commons.tools.page.PageData; -import com.epmet.dto.PointRuleDTO; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.dto.form.PointDetailFormDTO; +import com.epmet.dto.form.PointRuleFormDTO; +import com.epmet.dto.form.PointRuleListFormDTO; +import com.epmet.dto.result.CustomerFunctionResultDTO; +import com.epmet.dto.result.PointDetailResultDTO; +import com.epmet.dto.result.PointRuleResultDTO; import com.epmet.entity.PointRuleEntity; import java.util.List; -import java.util.Map; /** * 积分规则表 @@ -34,62 +38,22 @@ import java.util.Map; public interface PointRuleService extends BaseService { /** - * 默认分页 - * - * @param params - * @return PageData - * @author generator - * @date 2020-07-20 + * desc:根据用户id获取积分规则-功能列表 + * @param customerId + * @return */ - PageData page(Map params); + List getFunctionList(String customerId); - /** - * 默认查询 - * - * @param params - * @return java.util.List - * @author generator - * @date 2020-07-20 - */ - List list(Map params); + /** + * desc:根据客户Id 及功能Id获取规则列表 + * @param formDTO + * @return + */ + List list(PointRuleListFormDTO formDTO); - /** - * 单条查询 - * - * @param id - * @return PointRuleDTO - * @author generator - * @date 2020-07-20 - */ - PointRuleDTO get(String id); + PointDetailResultDTO detail(PointDetailFormDTO formDTO); - /** - * 默认保存 - * - * @param dto - * @return void - * @author generator - * @date 2020-07-20 - */ - void save(PointRuleDTO dto); + void update(TokenDto tokenDTO, PointRuleFormDTO formDTO); - /** - * 默认更新 - * - * @param dto - * @return void - * @author generator - * @date 2020-07-20 - */ - void update(PointRuleDTO dto); - - /** - * 批量删除 - * - * @param ids - * @return void - * @author generator - * @date 2020-07-20 - */ - void delete(String[] ids); + void add(TokenDto tokenDTO, PointRuleFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/SysOperateLogService.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/SysOperateLogService.java index 962df38027..46e78037ec 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/SysOperateLogService.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/SysOperateLogService.java @@ -20,7 +20,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.SysOperateLogDTO; -import com.epmet.entity.SysOperateLogEntity; +import com.epmet.entity.RuleOperateLogEntity; import java.util.List; import java.util.Map; @@ -31,7 +31,7 @@ import java.util.Map; * @author generator generator@elink-cn.com * @since v1.0.0 2020-07-20 */ -public interface SysOperateLogService extends BaseService { +public interface SysOperateLogService extends BaseService { /** * 默认分页 diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java index c64ccfdc35..8e40169645 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java @@ -17,23 +17,40 @@ package com.epmet.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; +import com.alibaba.fastjson.JSON; +import com.epmet.common.enu.PointUnitEnum; +import com.epmet.common.enu.SysResponseEnum; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; -import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.enums.CommonOperateTypeEnum; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.security.dto.TokenDto; 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.PointRuleDao; -import com.epmet.dto.PointRuleDTO; +import com.epmet.dao.RuleOperateLogDao; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.form.CustomerFunctionListFormDTO; +import com.epmet.dto.form.PointDetailFormDTO; +import com.epmet.dto.form.PointRuleFormDTO; +import com.epmet.dto.form.PointRuleListFormDTO; +import com.epmet.dto.result.CustomerFunctionResultDTO; +import com.epmet.dto.result.DefaultFunctionListResultDTO; +import com.epmet.dto.result.PointDetailResultDTO; +import com.epmet.dto.result.PointRuleResultDTO; import com.epmet.entity.PointRuleEntity; +import com.epmet.entity.RuleOperateLogEntity; +import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.service.PointRuleService; -import org.apache.commons.lang3.StringUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; -import java.util.Arrays; +import java.util.ArrayList; import java.util.List; -import java.util.Map; +import java.util.stream.Collectors; /** * 积分规则表 @@ -41,60 +58,116 @@ import java.util.Map; * @author generator generator@elink-cn.com * @since v1.0.0 2020-07-20 */ +@Slf4j @Service public class PointRuleServiceImpl extends BaseServiceImpl implements PointRuleService { - - - @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, PointRuleDTO.class); - } - - @Override - public List list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); - - return ConvertUtils.sourceToTarget(entityList, PointRuleDTO.class); - } - - private QueryWrapper getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); - - return wrapper; - } - - @Override - public PointRuleDTO get(String id) { - PointRuleEntity entity = baseDao.selectById(id); - return ConvertUtils.sourceToTarget(entity, PointRuleDTO.class); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void save(PointRuleDTO dto) { - PointRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointRuleEntity.class); - insert(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(PointRuleDTO dto) { - PointRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointRuleEntity.class); - updateById(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - // 逻辑删除(@TableLogic 注解) - baseDao.deleteBatchIds(Arrays.asList(ids)); - } - + @Autowired + private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient; + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + @Autowired + private RuleOperateLogDao ruleOperateLogDao; + + @Override + public List getFunctionList(String customerId) { + List result = new ArrayList<>(); + CustomerFunctionListFormDTO formDTO = new CustomerFunctionListFormDTO(); + formDTO.setCustomerId(customerId); + Result> openedFunctionResult = operCustomizeOpenFeignClient.getOpenedFunctionList(formDTO); + if (!openedFunctionResult.success()) { + log.warn("getFunctionList getOpenedFunctionList fail,result:{}", JSON.toJSONString(openedFunctionResult)); + throw new RenException(SysResponseEnum.THIRD_SERVICE_ERROR.getCode(), SysResponseEnum.THIRD_SERVICE_ERROR.getMsg()); + } + List resultData = openedFunctionResult.getData(); + if (CollectionUtils.isEmpty(resultData)) { + log.warn("getFunctionList customerId:{} have opened any function", customerId); + return result; + } + List functionIds = baseDao.selectFunctionIds(customerId); + if (CollectionUtils.isEmpty(functionIds)) { + log.warn("getFunctionList customerId:{} have any pointRules", customerId); + return result; + } + return resultData.stream().filter(function -> functionIds.contains(function.getFunctionId())) + .map(fun -> ConvertUtils.sourceToTarget(fun, CustomerFunctionResultDTO.class)) + .collect(Collectors.toList()); + } + + @Override + public List list(PointRuleListFormDTO formDTO) { + List result = new ArrayList<>(); + List list = baseDao.selectListByFunctionId(formDTO); + if (CollectionUtils.isEmpty(list)) { + log.warn("list functionId:{} return empty", formDTO.getFunctionId()); + return result; + } + result = list.stream().map(pointRuleEntity -> { + PointRuleResultDTO resultDTO = new PointRuleResultDTO(); + resultDTO.setRuleId(pointRuleEntity.getId()); + resultDTO.setRuleName(pointRuleEntity.getRuleName()); + resultDTO.setRuleDesc(pointRuleEntity.getRuleDesc()); + PointUnitEnum pointUnitEnum = PointUnitEnum.getEnum(pointRuleEntity.getPointUnit()); + if (pointRuleEntity == null || pointRuleEntity.getPoint() == null) { + log.error("list ruleId:{} have not pointUnit or pointNum,pointRule:{}", JSON.toJSONString(pointRuleEntity)); + return null; + } + resultDTO.setPointValue(pointRuleEntity.getPoint().toString().concat(StrConstant.SEPARATOR).concat(pointUnitEnum.getCode())); + return resultDTO; + }).filter(fun -> fun != null).collect(Collectors.toList()); + return result; + } + + @Override + public PointDetailResultDTO detail(PointDetailFormDTO formDTO) { + PointRuleEntity pointRuleEntity = baseDao.selectById(formDTO.getRuleId()); + if (pointRuleEntity == null) { + throw new RenException(SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getCode(), SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getMsg()); + } + return ConvertUtils.sourceToTarget(pointRuleEntity, PointDetailResultDTO.class); + } + + @Override + public void update(TokenDto tokenDTO, PointRuleFormDTO formDTO) { + PointRuleEntity entityDB = baseDao.selectById(formDTO.getRuleId()); + //数据库不存在或者客户Id不相等 则抛出异常 + if (entityDB == null || !entityDB.getCustomerId().equals(formDTO.getCustomerId())) { + throw new RenException(SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getCode(), SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getMsg()); + } + PointRuleEntity entityNew = ConvertUtils.sourceToTarget(formDTO, PointRuleEntity.class); + if (entityDB.equals(entityNew)) { + log.warn("update ignore tow entity is same"); + return; + } + insertOperateRecord(tokenDTO, formDTO, entityDB, CommonOperateTypeEnum.EDIT.getCode()); + baseDao.updateByCustomerId(entityNew); + } + + @Override + public void add(TokenDto tokenDTO, PointRuleFormDTO formDTO) { + PointRuleEntity entity = ConvertUtils.sourceToTarget(formDTO, PointRuleEntity.class); + if (tokenDTO == null){ + insertOperateRecord(tokenDTO, formDTO, null, CommonOperateTypeEnum.ADD.getCode()); + } + baseDao.insert(entity); + } + + private void insertOperateRecord(TokenDto tokenDTO, PointRuleFormDTO formDTO, PointRuleEntity entityDB, String opType) { + CustomerStaffDTO userInfo = getCustomerStaff(tokenDTO.getUserId()); + RuleOperateLogEntity record = new RuleOperateLogEntity(); + record.setCustomerId(formDTO.getCustomerId()); + record.setRuleId(entityDB.getId()); + record.setOpType(opType); + record.setOpUser(userInfo.getRealName()); + record.setBefordData(JSON.toJSONString(entityDB)); + record.setAfterData(JSON.toJSONString(formDTO)); + ruleOperateLogDao.insert(record); + } + + private CustomerStaffDTO getCustomerStaff(String userId) { + Result resultStaff = epmetUserOpenFeignClient.getCustomerStaff(userId); + if (!resultStaff.success() || null == resultStaff.getData()) { + throw new RenException(SysResponseEnum.THIRD_SERVICE_ERROR.getMsg()); + } + return resultStaff.getData(); + } } \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/SysOperateLogServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/SysOperateLogServiceImpl.java index 59604433bf..b309d3f7a0 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/SysOperateLogServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/SysOperateLogServiceImpl.java @@ -20,12 +20,12 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; -import com.epmet.dao.SysOperateLogDao; +import com.epmet.dao.RuleOperateLogDao; import com.epmet.dto.SysOperateLogDTO; -import com.epmet.entity.SysOperateLogEntity; +import com.epmet.entity.RuleOperateLogEntity; import com.epmet.service.SysOperateLogService; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -42,11 +42,11 @@ import java.util.Map; * @since v1.0.0 2020-07-20 */ @Service -public class SysOperateLogServiceImpl extends BaseServiceImpl implements SysOperateLogService { +public class SysOperateLogServiceImpl extends BaseServiceImpl implements SysOperateLogService { @Override public PageData page(Map params) { - IPage page = baseDao.selectPage( + IPage page = baseDao.selectPage( getPage(params, FieldConstant.CREATED_TIME, false), getWrapper(params) ); @@ -55,15 +55,15 @@ public class SysOperateLogServiceImpl extends BaseServiceImpl list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); + List entityList = baseDao.selectList(getWrapper(params)); return ConvertUtils.sourceToTarget(entityList, SysOperateLogDTO.class); } - private QueryWrapper getWrapper(Map params){ + private QueryWrapper getWrapper(Map params){ String id = (String)params.get(FieldConstant.ID_HUMP); - QueryWrapper wrapper = new QueryWrapper<>(); + QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); return wrapper; @@ -71,21 +71,21 @@ public class SysOperateLogServiceImpl extends BaseServiceImpl - - + @@ -23,6 +22,18 @@ - - + + + + UPDATE point_rule + SET + POINT = #{point,jdbcType=INTEGER}, + ENABLED_FLAG = #{enabledFlag,jdbcType=VARCHAR}, + UP_LIMIT = #{upLimit,jdbcType=INTEGER} + WHERE id = #{id,jdbcType=VARCHAR} and CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} + \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/SysOperateLogDao.xml b/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/RuleOperateLogDao.xml similarity index 87% rename from epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/SysOperateLogDao.xml rename to epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/RuleOperateLogDao.xml index 0fe2621044..e20a977e8f 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/SysOperateLogDao.xml +++ b/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/RuleOperateLogDao.xml @@ -1,9 +1,9 @@ - + - + diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java index 9e81857ef7..8707b1cf55 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java @@ -1,9 +1,13 @@ package com.epmet.feign; -import org.springframework.cloud.openfeign.FeignClient; - import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.CustomerFunctionListFormDTO; +import com.epmet.dto.result.DefaultFunctionListResultDTO; import com.epmet.feign.fallback.OperCustomizeOpenFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; + +import java.util.List; /** * 本服务对外开放的API,其他服务通过引用此client调用该服务 @@ -13,5 +17,5 @@ import com.epmet.feign.fallback.OperCustomizeOpenFeignClientFallback; */ @FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeOpenFeignClientFallback.class) public interface OperCustomizeOpenFeignClient { - + Result> getOpenedFunctionList(CustomerFunctionListFormDTO formDTO); } diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java index 5c2271f1b3..d8e2fa7249 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java @@ -1,7 +1,16 @@ package com.epmet.feign.fallback; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.CustomerFunctionListFormDTO; +import com.epmet.dto.result.DefaultFunctionListResultDTO; import com.epmet.feign.OperCustomizeOpenFeignClient; +import org.springframework.http.MediaType; import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; /** * 本服务对外开放的API,其他服务通过引用此client调用该服务 @@ -12,10 +21,13 @@ import org.springframework.stereotype.Component; @Component public class OperCustomizeOpenFeignClientFallback implements OperCustomizeOpenFeignClient { /** - * 从缓存中查询已登录用户的基本信息以及角色等相关信息 + * 获取客户已开通的功能列表 * * @return */ - //@PostMapping(value = "/epmetuser/user/loginuserdetails", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) - //Result getLoginUserDetails(@RequestBody LoginUserDetailsFormDTO dto); + @Override + @PostMapping(value = "/oper/customize/customerfunction/getOpenedFunctionList", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + public Result> getOpenedFunctionList(CustomerFunctionListFormDTO formDTO){ + return ModuleUtils.feignConError(ServiceConstant.OPER_CUSTOMIZE_SERVER, "getOpenedFunctionList", formDTO); + } } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java index 7c2bbda050..71e165696b 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java @@ -133,8 +133,8 @@ public class CustomerFunctionController { * @param formDTO * @return */ - @PostMapping("customeropenedfunction") - public Result> customerOpenedFunction(@RequestBody CustomerFunctionListFormDTO formDTO) { - return new Result>().ok(customerFunctionService.customerOpenedFunction(formDTO)); + @PostMapping("openedfunctionlist") + public Result> getOpenedFunctionList(@RequestBody CustomerFunctionListFormDTO formDTO) { + return new Result>().ok(customerFunctionService.getOpenedFunctionList(formDTO)); } } \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFunctionService.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFunctionService.java index 17fcb2be66..70b5c55404 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFunctionService.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFunctionService.java @@ -118,5 +118,5 @@ public interface CustomerFunctionService extends BaseService customerOpenedFunction(CustomerFunctionListFormDTO formDTO); + List getOpenedFunctionList(CustomerFunctionListFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java index 7c68f32ec1..dadf4257ea 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java @@ -17,11 +17,13 @@ package com.epmet.service.impl; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; @@ -41,15 +43,15 @@ import com.epmet.entity.CustomerFunctionEntity; import com.epmet.feign.OperCrmFeignClient; import com.epmet.redis.CustomerFunctionRedis; import com.epmet.service.CustomerFunctionService; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; /** * 客户功能权限表 @@ -57,6 +59,7 @@ import java.util.Map; * @author generator generator@elink-cn.com * @since v1.0.0 2020-03-10 */ +@Slf4j @Service public class CustomerFunctionServiceImpl extends BaseServiceImpl implements CustomerFunctionService { @@ -211,8 +214,34 @@ public class CustomerFunctionServiceImpl extends BaseServiceImpl customerOpenedFunction(CustomerFunctionListFormDTO formDTO) { - return null; + public List getOpenedFunctionList(CustomerFunctionListFormDTO formDTO) { + if (StringUtils.isBlank(formDTO.getCustomerId())){ + throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); + } + List result = new ArrayList<>(); + //查询所有已上架功能列表(默认、定制功能) + List funList = functionDao.selectFunctionList(); + if(CollectionUtils.isEmpty(funList)){ + return result; + } + //查询当前客户已拥有的功能 + List openedList = baseDao.selectCustomerFunctionList(formDTO.getCustomerId()); + if(CollectionUtils.isEmpty(openedList)){ + log.warn("getOpenedFunctionList customerId:{} have any function",formDTO.getCustomerId()); + return result; + } + Set openedFunIdSet = openedList.stream().map(CustomerFunctionDTO::getFunctionId).collect(Collectors.toSet()); + for (FunctionDTO function : funList) { + if (openedFunIdSet.contains(function.getId())) { + DefaultFunctionListResultDTO resultDTO = ConvertUtils.sourceToTarget(function, DefaultFunctionListResultDTO.class); + if (resultDTO == null) { + log.error("getOpenedFunctionList convert return null,function:{}", JSON.toJSONString(function)); + continue; + } + result.add(resultDTO); + } + } + return result; } } \ No newline at end of file