Browse Source

积分规则接口测试

dev_shibei_match
jianjun 5 years ago
parent
commit
6471044f6e
  1. 10
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java
  2. 4
      epmet-gateway/pom.xml
  3. 2
      epmet-gateway/src/main/resources/bootstrap.yml
  4. 4
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/EventFormDTO.java
  5. 10
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java
  6. 5
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/EventEntity.java
  7. 6
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/enu/SysResponseEnum.java
  8. 11
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java
  9. 37
      epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/epmet_common_service.sql
  10. 2
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/EventDao.xml
  11. 40
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointRuleFormDTO.java
  12. 8
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointUnitEnum.java
  13. 1
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/SysResponseEnum.java
  14. 4
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java
  15. 23
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java
  16. 28
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/PointRuleEntity.java
  17. 4
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/RuleOperateLogEntity.java
  18. 47
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java
  19. 6
      epmet-module/epmet-point/epmet-point-server/src/main/resources/db/migration/epmet_point.sql
  20. 4
      epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointRuleDao.xml
  21. 5
      epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/RuleOperateLogDao.xml
  22. 6
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java
  23. 3
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java
  24. 2
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java
  25. 19
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java

10
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java

@ -53,4 +53,14 @@ public interface StrConstant {
* 反斜杠 * 反斜杠
*/ */
String SEPARATOR = "/"; String SEPARATOR = "/";
/**
* true
*/
String TRUE = "true";
/**
* true
*/
String FALSE = "false";
} }

4
epmet-gateway/pom.xml

@ -282,7 +282,7 @@
<!-- 32、 爱心互助 --> <!-- 32、 爱心互助 -->
<gateway.routes.epmet-heart-server.url>lb://epmet-heart-server</gateway.routes.epmet-heart-server.url> <gateway.routes.epmet-heart-server.url>lb://epmet-heart-server</gateway.routes.epmet-heart-server.url>
<!-- 33、积分银行 --> <!-- 33、积分银行 -->
<gateway.routes.epmet-point-server.url>http://127.0.0.1:8112</gateway.routes.epmet-point-server.url> <gateway.routes.epmet-point-server.url>lb://epmet-point-server</gateway.routes.epmet-point-server.url>
</properties> </properties>
</profile> </profile>
<profile> <profile>
@ -367,7 +367,7 @@
<!-- 32、 爱心互助 --> <!-- 32、 爱心互助 -->
<gateway.routes.epmet-heart-server.url>lb://epmet-heart-server</gateway.routes.epmet-heart-server.url> <gateway.routes.epmet-heart-server.url>lb://epmet-heart-server</gateway.routes.epmet-heart-server.url>
<!-- 33、 积分银行 --> <!-- 33、 积分银行 -->
<gateway.routes.epmet-point-server.url>http://127.0.0.1:8112</gateway.routes.epmet-point-server.url> <gateway.routes.epmet-point-server.url>lb://epmet-point-server</gateway.routes.epmet-point-server.url>
</properties> </properties>
</profile> </profile>
</profiles> </profiles>

2
epmet-gateway/src/main/resources/bootstrap.yml

@ -353,6 +353,8 @@ renren:
- /resi/group/** - /resi/group/**
- /resi/partymember/** - /resi/partymember/**
- /gov/grid/** - /gov/grid/**
- /heart/**
- /point/**
management: management:
endpoints: endpoints:
web: web:

4
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/EventFormDTO.java

@ -77,8 +77,8 @@ public class EventFormDTO implements Serializable {
/** /**
* 事件功能分组ID 来自oper_customize.customer_function表 * 事件功能分组ID 来自oper_customize.customer_function表
*/ */
@NotBlank(message = "事件功能分组ID不能为空",groups = {AddGroup.class}) @NotBlank(message = "功能分组ID不能为空",groups = {AddGroup.class})
private String eventGroupId; private String functionId;
/** /**
* 是否是通用事件 0-1-消息体内需要体现该字段通用则说明由业务系统自己计算分值 * 是否是通用事件 0-1-消息体内需要体现该字段通用则说明由业务系统自己计算分值

10
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java

@ -49,11 +49,11 @@ public class EventController {
* "classId":"epmet_heart", * "classId":"epmet_heart",
* "appId":"202007161443499985fa2d397436d10356542134c8f008c48", * "appId":"202007161443499985fa2d397436d10356542134c8f008c48",
* "appName":"党群e事通开发测试", * "appName":"党群e事通开发测试",
* "eventCode":"epmet_heart_active_send_point", * "eventCode":"register_volunteer",
* "eventName":"活动发放积分", * "eventName":"认证志愿者",
* "eventDesc":"给参加活动的人发放积分", * "eventDesc":"给注册志愿者的人发放积分",
* "eventGroupId":"1234", * "functionId":"43addd0735230c01eedbb38d721076b0",
* "isCommon":"1" * "isCommon":"0"
* } * }
*/ */
@PostMapping("addEvent") @PostMapping("addEvent")

5
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/EventEntity.java

@ -18,13 +18,10 @@
package com.epmet.entity; package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.Date;
/** /**
* 事件表 * 事件表
* *
@ -71,7 +68,7 @@ public class EventEntity extends BaseEpmetEntity {
/** /**
* 事件功能分组ID 来自oper_customize.customer_function表 * 事件功能分组ID 来自oper_customize.customer_function表
*/ */
private String eventGroupId; private String functionId;
/** /**
* 是否是通用事件 0-1-消息体内需要体现该字段通用则说明由业务系统自己计算分值 * 是否是通用事件 0-1-消息体内需要体现该字段通用则说明由业务系统自己计算分值

6
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/enu/SysResponseEnum.java

@ -11,17 +11,17 @@ public enum SysResponseEnum {
* *
* 编码样式CCCBBOOXX * 编码样式CCCBBOOXX
* 编码示例说明 * 编码示例说明
* CCC 中心编码&业务系统 (120-内容扫描服务中心服务) * CCC 中心编码&业务系统 (103-内容扫描服务中心服务)
* BB 业务类型00-默认 * BB 业务类型00-默认
* OO 操作类型00-默认 * OO 操作类型00-默认
* *
*/ */
/*通用枚举 */ /*通用枚举 */
EXCEPTION(12001,"系统异常"), EXCEPTION(10301,"系统异常"),
/*事件 业务 01*/ /*事件 业务 01*/
EVENT_HAS_ALREADY_EXIST(120010001,"事件已存在无需重复添加"), EVENT_HAS_ALREADY_EXIST(103010001,"事件已存在无需重复添加"),
; ;
private Integer code; private Integer code;

11
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java

@ -18,13 +18,10 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.EventDao; import com.epmet.dao.EventDao;
import com.epmet.dto.form.EventFormDTO; import com.epmet.dto.form.EventFormDTO;
import com.epmet.entity.EventEntity; import com.epmet.entity.EventEntity;
import com.epmet.enu.SysResponseEnum;
import com.epmet.service.EventService; import com.epmet.service.EventService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -41,15 +38,7 @@ public class EventServiceImpl extends BaseServiceImpl<EventDao, EventEntity> imp
@Override @Override
public void addEvent(EventFormDTO formDTO) { public void addEvent(EventFormDTO formDTO) {
if (baseDao.getCountByEventCode(formDTO.getEventCode()) > 0) {
log.warn("addEvent fail,msg:{}", SysResponseEnum.EVENT_HAS_ALREADY_EXIST.getMsg());
return;
}
EventEntity eventEntity = ConvertUtils.sourceToTarget(formDTO, EventEntity.class); EventEntity eventEntity = ConvertUtils.sourceToTarget(formDTO, EventEntity.class);
if (eventEntity == null) {
throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg());
}
baseDao.insert(eventEntity); baseDao.insert(eventEntity);
} }

37
epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/epmet_common_service.sql

@ -418,21 +418,22 @@ INSERT INTO `calender` VALUES ('ffe45e7059c67874f88498cfcfd19b4c', 0, '20200424'
SET FOREIGN_KEY_CHECKS = 1; SET FOREIGN_KEY_CHECKS = 1;
#add by liujianjun 2020-07-16 #add by liujianjun 2020-07-16
CREATE TABLE event( CREATE TABLE `event` (
ID VARCHAR(64) NOT NULL COMMENT '主键' , `ID` varchar(64) NOT NULL COMMENT '主键',
CLASS_ID VARCHAR(32) COMMENT '消息网关事件类别ID 从消息网关获取事件类型Id' , `CLASS_ID` varchar(32) DEFAULT NULL COMMENT '消息网关事件类别ID 从消息网关获取事件类型Id',
APP_ID VARCHAR(128) COMMENT '消息网关APP_ID' , `APP_ID` varchar(128) DEFAULT NULL COMMENT '消息网关APP_ID',
APP_NAME VARCHAR(32) COMMENT '消息网关APP_NAME' , `APP_NAME` varchar(32) DEFAULT NULL COMMENT '消息网关APP_NAME',
EVENT_CODE VARCHAR(32) COMMENT '事件标识 与消息网关事件tag一致' , `EVENT_CODE` varchar(32) DEFAULT NULL COMMENT '事件标识 与消息网关事件tag一致',
EVENT_NAME VARCHAR(32) COMMENT '事件名称' , `EVENT_NAME` varchar(32) DEFAULT NULL COMMENT '事件名称',
EVENT_DESC VARCHAR(64) COMMENT '事件说明' , `EVENT_DESC` varchar(64) DEFAULT NULL COMMENT '事件说明',
EVENT_GROUP_ID VARCHAR(512) COMMENT '事件功能分组ID 来自oper_customize.customer_function表' , `FUNCTION_ID` varchar(64) DEFAULT NULL COMMENT '功能ID 来自oper_customize.customer_function表',
IS_COMMON VARCHAR(1) COMMENT '是否是通用事件 0-否,1-是;消息体内需要体现该字段,通用则说明由业务系统自己计算分值' , `IS_COMMON` varchar(1) DEFAULT NULL COMMENT '是否是通用事件 0-否,1-是;消息体内需要体现该字段,通用则说明由业务系统自己计算分值',
DEL_FLAG VARCHAR(1) COMMENT '删除标识 0-否,1-是' , `DEL_FLAG` varchar(1) DEFAULT NULL COMMENT '删除标识 0-否,1-是',
REVISION INT COMMENT '乐观锁 查询时添加版本号,新加的事件需要更新版本号' , `REVISION` int(11) DEFAULT NULL COMMENT '乐观锁 查询时添加版本号,新加的事件需要更新版本号',
CREATED_BY VARCHAR(32) COMMENT '创建人' , `CREATED_BY` varchar(32) DEFAULT NULL COMMENT '创建人',
CREATED_TIME DATETIME COMMENT '创建时间' , `CREATED_TIME` datetime DEFAULT NULL COMMENT '创建时间',
UPDATED_BY VARCHAR(32) COMMENT '更新人' , `UPDATED_BY` varchar(32) DEFAULT NULL COMMENT '更新人',
UPDATED_TIME DATETIME COMMENT '更新时间' , `UPDATED_TIME` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (ID) PRIMARY KEY (`ID`),
) COMMENT = '事件表'; UNIQUE KEY `unx_event_code` (`EVENT_CODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='事件表';

2
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/EventDao.xml

@ -11,7 +11,7 @@
<result property="eventCode" column="EVENT_CODE"/> <result property="eventCode" column="EVENT_CODE"/>
<result property="eventName" column="EVENT_NAME"/> <result property="eventName" column="EVENT_NAME"/>
<result property="eventDesc" column="EVENT_DESC"/> <result property="eventDesc" column="EVENT_DESC"/>
<result property="eventGroupId" column="EVENT_GROUP_ID"/> <result property="functionId" column="FUNCTION_ID"/>
<result property="isCommon" column="IS_COMMON"/> <result property="isCommon" column="IS_COMMON"/>
<result property="delFlag" column="DEL_FLAG"/> <result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/> <result property="revision" column="REVISION"/>

40
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointRuleFormDTO.java

@ -5,6 +5,7 @@ import com.epmet.commons.tools.validator.group.UpdateGroup;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -16,33 +17,51 @@ import java.io.Serializable;
@Data @Data
public class PointRuleFormDTO implements Serializable { public class PointRuleFormDTO implements Serializable {
private static final long serialVersionUID = -3228252683629912008L; private static final long serialVersionUID = -3228252683629912008L;
/**
* 客户Id
*/
@NotBlank(message = "客户Id不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String customerId;
/** /**
* 积分规则Id * 积分规则Id
*/ */
@NotBlank(message = "积分规则Id不能为空", groups = UpdateGroup.class) @NotBlank(message = "积分规则Id不能为空", groups = UpdateGroup.class)
private String ruleId; private String ruleId;
/**
* 功能Id
*/
@NotBlank(message = "功能Id不能为空", groups = {AddGroup.class})
private String functionId;
/**
* 积分规则名称
*/
@NotBlank(message = "积分规则名称不能为空", groups = AddGroup.class)
private String ruleName;
/** /**
* 积分 * 积分
*/ */
@NotBlank(message = "积分不能为空", groups = {AddGroup.class, UpdateGroup.class}) @NotNull(message = "积分不能为空", groups = {UpdateGroup.class})
private String point; private Integer point;
/** /**
* 是否开启 * 是否开启
*/ */
@NotBlank(message = "是否开启不能为空", groups = {AddGroup.class, UpdateGroup.class}) @NotBlank(message = "是否开启不能为空", groups = {UpdateGroup.class})
private String enabledFlag; private String enabledFlag;
/** /**
* 上限开启 * 是否启用
*/ */
@NotBlank(message = "积分上限不能为空", groups = {AddGroup.class, UpdateGroup.class}) @NotNull(message = "积分上限不能为空", groups = {UpdateGroup.class})
private String upLimit; private Integer upLimit;
/** /**
* 积分规则Id * 积分上限描述
*/ */
@NotBlank(message = "客户Id不能为空", groups = {AddGroup.class, UpdateGroup.class}) private String upLimitDesc;
private String customerId;
//=======系统添加时的属性====== //=======系统添加时的属性======
/** /**
@ -58,9 +77,8 @@ public class PointRuleFormDTO implements Serializable {
private String eventCode; private String eventCode;
/** /**
* 操作类型 加积分:add;减积分:subtract * 操作类型 加积分:plus;减积分:minus
*/ */
@NotBlank(message = "操作类型不能为空", groups = AddGroup.class)
private String operateType; private String operateType;
/** /**
* 获得积分单位 time分钟minute小时hour * 获得积分单位 time分钟minute小时hour

8
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointUnitEnum.java

@ -14,12 +14,12 @@ public enum PointUnitEnum {
; ;
private String code; private String code;
private String name; private String desc;
PointUnitEnum(String code, String name) { PointUnitEnum(String code, String name) {
this.code = code; this.code = code;
this.name = name; this.desc = name;
} }
public static PointUnitEnum getEnum(String code) { public static PointUnitEnum getEnum(String code) {
@ -36,7 +36,7 @@ public enum PointUnitEnum {
return code; return code;
} }
public String getName() { public String getDesc() {
return name; return desc;
} }
} }

1
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/SysResponseEnum.java

@ -24,6 +24,7 @@ public enum SysResponseEnum {
/*积分规则 业务 01*/ /*积分规则 业务 01*/
THIRD_SERVICE_ERROR(112010001,"调用第三方接口异常"), THIRD_SERVICE_ERROR(112010001,"调用第三方接口异常"),
POINT_RULE_IS_NOT_EXIST(112010002,"积分规则不存在"), POINT_RULE_IS_NOT_EXIST(112010002,"积分规则不存在"),
POINT_ENABLE_FLAG_PARAM_ERROR(112010003,"积分规则开启状态参数错误"),
; ;
private Integer code; private Integer code;

4
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java

@ -30,8 +30,8 @@ public class MqSubcribeConfig {
event.setBelongAppId("202007161443499985fa2d397436d10356542134c8f008c48"); event.setBelongAppId("202007161443499985fa2d397436d10356542134c8f008c48");
event.setEventClass("epmet_heart"); event.setEventClass("epmet_heart");
event.setEventTag("active_send_point"); event.setEventTag("active_send_point");
String callbackUrl = "http://192.168.51.49/point/callback/sendPoint"; String callbackUrl = "http://192.168.1.119/point/callback/sendPoint";
callbackUrl = ""; //callbackUrl = "";
event.setCallbackUrl(callbackUrl); event.setCallbackUrl(callbackUrl);
List<MqSubscribeFormDTO> subscribeFormDTOList = new ArrayList<>(); List<MqSubscribeFormDTO> subscribeFormDTOList = new ArrayList<>();
subscribeFormDTOList.add(event); subscribeFormDTOList.add(event);

23
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java

@ -1,6 +1,7 @@
package com.epmet.controller; package com.epmet.controller;
import com.epmet.commons.tools.security.dto.TokenDto; import com.alibaba.fastjson.JSON;
import com.epmet.common.enu.PointUnitEnum;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.AddGroup;
@ -28,13 +29,23 @@ public class BackDoorController {
* @param formDTO * @param formDTO
* @return * @return
*/ */
@PostMapping(value = "sysadd") @PostMapping(value = "addpointrule")
public Result<Boolean> add(@RequestBody PointRuleFormDTO formDTO) { public Result<Boolean> add(@RequestBody PointRuleFormDTO formDTO) {
TokenDto tokenDTO = new TokenDto();
tokenDTO.setUserId("default");
formDTO.setCustomerId(tokenDTO.getCustomerId());
ValidatorUtils.validateEntity(formDTO, AddGroup.class); ValidatorUtils.validateEntity(formDTO, AddGroup.class);
pointRuleService.add(tokenDTO, formDTO); pointRuleService.add(null, formDTO);
return new Result<Boolean>().ok(true); return new Result<Boolean>().ok(true);
} }
public static void main(String[] args) {
PointRuleFormDTO formDTO = new PointRuleFormDTO();
formDTO.setPoint(0);
formDTO.setUpLimit(0);
//微笑山东
formDTO.setCustomerId("57a648d230bf459b18ea23fc278c3de7");
formDTO.setRuleDesc("认证志愿者会获得积分");
formDTO.setEventCode("register_volunteer");
formDTO.setPointUnit(PointUnitEnum.TIME.getCode());
System.out.println(JSON.toJSONString(formDTO));
}
} }

28
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/PointRuleEntity.java

@ -57,6 +57,11 @@ public class PointRuleEntity extends BaseEpmetEntity {
*/ */
private String eventCode; private String eventCode;
/**
* 功能分组Id
*/
private String functionId;
/** /**
* 操作类型 加积分:add;减积分:subtract * 操作类型 加积分:add;减积分:subtract
*/ */
@ -93,20 +98,21 @@ public class PointRuleEntity extends BaseEpmetEntity {
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false; if (!super.equals(o)) return false;
PointRuleEntity entity = (PointRuleEntity) o; PointRuleEntity entity = (PointRuleEntity) o;
return customerId.equals(entity.customerId) && return Objects.equals(customerId, entity.customerId) &&
ruleName.equals(entity.ruleName) && Objects.equals(ruleName, entity.ruleName) &&
ruleDesc.equals(entity.ruleDesc) && Objects.equals(ruleDesc, entity.ruleDesc) &&
eventCode.equals(entity.eventCode) && Objects.equals(eventCode, entity.eventCode) &&
operateType.equals(entity.operateType) && Objects.equals(functionId, entity.functionId) &&
upLimit.equals(entity.upLimit) && Objects.equals(operateType, entity.operateType) &&
upLimitDesc.equals(entity.upLimitDesc) && Objects.equals(upLimit, entity.upLimit) &&
point.equals(entity.point) && Objects.equals(upLimitDesc, entity.upLimitDesc) &&
pointUnit.equals(entity.pointUnit) && Objects.equals(point, entity.point) &&
enabledFlag.equals(entity.enabledFlag); Objects.equals(pointUnit, entity.pointUnit) &&
Objects.equals(enabledFlag, entity.enabledFlag);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(super.hashCode(), customerId, ruleName, ruleDesc, eventCode, operateType, upLimit, upLimitDesc, point, pointUnit, enabledFlag); return Objects.hash(super.hashCode(), customerId, ruleName, ruleDesc, eventCode, functionId, operateType, upLimit, upLimitDesc, point, pointUnit, enabledFlag);
} }
} }

4
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/RuleOperateLogEntity.java

@ -30,7 +30,7 @@ import lombok.EqualsAndHashCode;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper=false) @EqualsAndHashCode(callSuper=false)
@TableName("sys_operate_log") @TableName("rule_operate_log")
public class RuleOperateLogEntity extends BaseEpmetEntity { public class RuleOperateLogEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -58,7 +58,7 @@ public class RuleOperateLogEntity extends BaseEpmetEntity {
/** /**
* 变更前数据 JSON串 * 变更前数据 JSON串
*/ */
private String befordData; private String beforeData;
/** /**
* 变更后数据 JSON串 * 变更后数据 JSON串

47
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java

@ -21,6 +21,8 @@ import com.alibaba.fastjson.JSON;
import com.epmet.common.enu.PointUnitEnum; import com.epmet.common.enu.PointUnitEnum;
import com.epmet.common.enu.SysResponseEnum; import com.epmet.common.enu.SysResponseEnum;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.enums.CommonOperateTypeEnum; import com.epmet.commons.tools.enums.CommonOperateTypeEnum;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
@ -44,8 +46,10 @@ import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient;
import com.epmet.service.PointRuleService; import com.epmet.service.PointRuleService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -111,7 +115,7 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
log.error("list ruleId:{} have not pointUnit or pointNum,pointRule:{}", JSON.toJSONString(pointRuleEntity)); log.error("list ruleId:{} have not pointUnit or pointNum,pointRule:{}", JSON.toJSONString(pointRuleEntity));
return null; return null;
} }
resultDTO.setPointValue(pointRuleEntity.getPoint().toString().concat(StrConstant.SEPARATOR).concat(pointUnitEnum.getCode())); resultDTO.setPointValue(pointRuleEntity.getPoint().toString().concat("分").concat(StrConstant.SEPARATOR).concat(pointUnitEnum.getDesc()));
return resultDTO; return resultDTO;
}).filter(fun -> fun != null).collect(Collectors.toList()); }).filter(fun -> fun != null).collect(Collectors.toList());
return result; return result;
@ -123,43 +127,60 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
if (pointRuleEntity == null) { if (pointRuleEntity == null) {
throw new RenException(SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getCode(), SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getMsg()); throw new RenException(SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getCode(), SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getMsg());
} }
return ConvertUtils.sourceToTarget(pointRuleEntity, PointDetailResultDTO.class); PointDetailResultDTO resultDTO = ConvertUtils.sourceToTarget(pointRuleEntity, PointDetailResultDTO.class);
resultDTO.setRuleId(pointRuleEntity.getId());
resultDTO.setEnabledFlag(NumConstant.ONE_STR.equals(pointRuleEntity.getEnabledFlag()) ? "true" : "false");
return resultDTO;
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void update(TokenDto tokenDTO, PointRuleFormDTO formDTO) { public void update(TokenDto tokenDTO, PointRuleFormDTO formDTO) {
validateEnableFlag(formDTO);
PointRuleEntity entityDB = baseDao.selectById(formDTO.getRuleId()); PointRuleEntity entityDB = baseDao.selectById(formDTO.getRuleId());
//数据库不存在或者客户Id不相等 则抛出异常 //数据库不存在或者客户Id不相等 则抛出异常
if (entityDB == null || !entityDB.getCustomerId().equals(formDTO.getCustomerId())) { 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()); throw new RenException(SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getCode(), SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getMsg());
} }
PointRuleEntity entityNew = ConvertUtils.sourceToTarget(formDTO, PointRuleEntity.class); PointRuleEntity entityNew = ConvertUtils.sourceToTarget(formDTO, PointRuleEntity.class);
entityNew.setId(formDTO.getRuleId());
entityNew.setEnabledFlag(StrConstant.TRUE.equals(formDTO.getEnabledFlag()) ? "1" : "0");
if (entityDB.equals(entityNew)) { if (entityDB.equals(entityNew)) {
log.warn("update ignore tow entity is same"); log.warn("update ignore tow entity is same");
return; return;
} }
insertOperateRecord(tokenDTO, formDTO, entityDB, CommonOperateTypeEnum.EDIT.getCode());
baseDao.updateByCustomerId(entityNew); baseDao.updateByCustomerId(entityNew);
insertOperateRecord(tokenDTO, entityNew, entityDB, CommonOperateTypeEnum.EDIT.getCode());
}
private void validateEnableFlag(PointRuleFormDTO formDTO) {
if (StringUtils.isNotBlank(formDTO.getEnabledFlag()) && !StrConstant.TRUE.equals(formDTO.getEnabledFlag()) && !StrConstant.FALSE.equals(formDTO.getEnabledFlag())) {
throw new RenException(SysResponseEnum.POINT_ENABLE_FLAG_PARAM_ERROR.getCode(), SysResponseEnum.POINT_ENABLE_FLAG_PARAM_ERROR.getMsg());
}
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void add(TokenDto tokenDTO, PointRuleFormDTO formDTO) { public void add(TokenDto tokenDTO, PointRuleFormDTO formDTO) {
validateEnableFlag(formDTO);
PointRuleEntity entity = ConvertUtils.sourceToTarget(formDTO, PointRuleEntity.class); PointRuleEntity entity = ConvertUtils.sourceToTarget(formDTO, PointRuleEntity.class);
if (tokenDTO == null){
insertOperateRecord(tokenDTO, formDTO, null, CommonOperateTypeEnum.ADD.getCode());
}
baseDao.insert(entity); baseDao.insert(entity);
insertOperateRecord(tokenDTO, entity, null, CommonOperateTypeEnum.ADD.getCode());
} }
private void insertOperateRecord(TokenDto tokenDTO, PointRuleFormDTO formDTO, PointRuleEntity entityDB, String opType) { private void insertOperateRecord(TokenDto tokenDTO, PointRuleEntity entityNew, PointRuleEntity entityDB, String opType) {
CustomerStaffDTO userInfo = getCustomerStaff(tokenDTO.getUserId());
RuleOperateLogEntity record = new RuleOperateLogEntity(); RuleOperateLogEntity record = new RuleOperateLogEntity();
record.setCustomerId(formDTO.getCustomerId()); if (tokenDTO != null) {
record.setRuleId(entityDB.getId()); CustomerStaffDTO userInfo = getCustomerStaff(tokenDTO.getUserId());
record.setOpType(opType);
record.setOpUser(userInfo.getRealName()); record.setOpUser(userInfo.getRealName());
record.setBefordData(JSON.toJSONString(entityDB)); } else {
record.setAfterData(JSON.toJSONString(formDTO)); record.setOpUser(Constant.APP_USER_FLAG);
}
record.setCustomerId(entityNew.getCustomerId());
record.setRuleId(entityNew.getId());
record.setOpType(opType);
record.setBeforeData(entityDB == null ? null : JSON.toJSONString(entityDB));
record.setAfterData(JSON.toJSONString(entityNew));
ruleOperateLogDao.insert(record); ruleOperateLogDao.insert(record);
} }

6
epmet-module/epmet-point/epmet-point-server/src/main/resources/db/migration/epmet_point.sql

@ -5,12 +5,12 @@ CREATE TABLE `point_rule` (
`RULE_DESC` varchar(32) DEFAULT NULL COMMENT '规则说明 事件说明', `RULE_DESC` varchar(32) DEFAULT NULL COMMENT '规则说明 事件说明',
`EVENT_CODE` varchar(32) DEFAULT NULL COMMENT '事件CODE 来自事件表', `EVENT_CODE` varchar(32) DEFAULT NULL COMMENT '事件CODE 来自事件表',
`FUNCTION_ID` varchar(32) DEFAULT NULL COMMENT '功能分组Id 来自customize.function', `FUNCTION_ID` varchar(32) DEFAULT NULL COMMENT '功能分组Id 来自customize.function',
`OPERATE_TYPE` varchar(32) DEFAULT NULL COMMENT '操作类型 加积分:add;减积分:subtract', `OPERATE_TYPE` varchar(32) DEFAULT 'plus' COMMENT '操作类型 加积分:plus;减积分:minus',
`UP_LIMIT` int(11) DEFAULT NULL COMMENT '积分上限', `UP_LIMIT` int(11) DEFAULT '-1' COMMENT '积分上限 -1不限制;',
`UP_LIMIT_DESC` varchar(64) DEFAULT NULL COMMENT '积分上限描述', `UP_LIMIT_DESC` varchar(64) DEFAULT NULL COMMENT '积分上限描述',
`POINT` int(11) DEFAULT '0' COMMENT '单位积分值', `POINT` int(11) DEFAULT '0' COMMENT '单位积分值',
`POINT_UNIT` varchar(32) DEFAULT NULL COMMENT '获得积分单位 次:time;分钟:minute;小时:hour', `POINT_UNIT` varchar(32) DEFAULT NULL COMMENT '获得积分单位 次:time;分钟:minute;小时:hour',
`ENABLED_FLAG` varchar(1) DEFAULT NULL COMMENT '是否启用 0-否,1-是', `ENABLED_FLAG` varchar(1) DEFAULT '0' COMMENT '是否启用 0-否,1-是',
`DEL_FLAG` varchar(1) DEFAULT NULL COMMENT '删除标识 0-否,1-是', `DEL_FLAG` varchar(1) DEFAULT NULL COMMENT '删除标识 0-否,1-是',
`REVISION` int(11) DEFAULT NULL COMMENT '乐观锁', `REVISION` int(11) DEFAULT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(32) DEFAULT NULL COMMENT '创建人', `CREATED_BY` varchar(32) DEFAULT NULL COMMENT '创建人',

4
epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointRuleDao.xml

@ -23,10 +23,10 @@
<result property="updatedTime" column="UPDATED_TIME"/> <result property="updatedTime" column="UPDATED_TIME"/>
</resultMap> </resultMap>
<select id="selectFunctionIds" resultType="java.lang.String"> <select id="selectFunctionIds" resultType="java.lang.String">
SELECT DISTINCT FUNCTION_ID FROM point_rule WHERE CUSTOMSER_ID = #{customerId,jdbcType=VARCHAR} SELECT DISTINCT FUNCTION_ID FROM point_rule WHERE CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
</select> </select>
<select id="selectListByFunctionId" resultMap="pointRuleMap"> <select id="selectListByFunctionId" resultMap="pointRuleMap">
SELECT ID,RULE_NAME,RULE_DESC,POINT_NUM,POINT_UNIT FROM point_rule WHERE CUSTOMSER_ID = #{customerId,jdbcType=VARCHAR} SELECT ID,RULE_NAME,RULE_DESC,POINT,POINT_UNIT FROM point_rule WHERE CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
</select> </select>
<update id="updateByCustomerId"> <update id="updateByCustomerId">
UPDATE point_rule UPDATE point_rule

5
epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/RuleOperateLogDao.xml

@ -6,11 +6,10 @@
<resultMap type="com.epmet.entity.RuleOperateLogEntity" id="sysOperateLogMap"> <resultMap type="com.epmet.entity.RuleOperateLogEntity" id="sysOperateLogMap">
<result property="id" column="ID"/> <result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/> <result property="customerId" column="CUSTOMER_ID"/>
<result property="objectId" column="OBJECT_ID"/> <result property="ruleId" column="RULE_ID"/>
<result property="objectType" column="OBJECT_TYPE"/>
<result property="opType" column="OP_TYPE"/> <result property="opType" column="OP_TYPE"/>
<result property="opUser" column="OP_USER"/> <result property="opUser" column="OP_USER"/>
<result property="befordData" column="BEFORD_DATA"/> <result property="beforeData" column="BEFORD_DATA"/>
<result property="afterData" column="AFTER_DATA"/> <result property="afterData" column="AFTER_DATA"/>
<result property="delFlag" column="DEL_FLAG"/> <result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/> <result property="revision" column="REVISION"/>

6
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java

@ -6,6 +6,9 @@ import com.epmet.dto.form.CustomerFunctionListFormDTO;
import com.epmet.dto.result.DefaultFunctionListResultDTO; import com.epmet.dto.result.DefaultFunctionListResultDTO;
import com.epmet.feign.fallback.OperCustomizeOpenFeignClientFallback; import com.epmet.feign.fallback.OperCustomizeOpenFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List; import java.util.List;
@ -17,5 +20,6 @@ import java.util.List;
*/ */
@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeOpenFeignClientFallback.class) @FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeOpenFeignClientFallback.class)
public interface OperCustomizeOpenFeignClient { public interface OperCustomizeOpenFeignClient {
Result<List<DefaultFunctionListResultDTO>> getOpenedFunctionList(CustomerFunctionListFormDTO formDTO); @PostMapping(value = "/oper/customize/customerfunction/getOpenedFunctionList", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
Result<List<DefaultFunctionListResultDTO>> getOpenedFunctionList(@RequestBody CustomerFunctionListFormDTO formDTO);
} }

3
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java

@ -6,9 +6,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.CustomerFunctionListFormDTO; import com.epmet.dto.form.CustomerFunctionListFormDTO;
import com.epmet.dto.result.DefaultFunctionListResultDTO; import com.epmet.dto.result.DefaultFunctionListResultDTO;
import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List; import java.util.List;
@ -26,7 +24,6 @@ public class OperCustomizeOpenFeignClientFallback implements OperCustomizeOpenFe
* @return * @return
*/ */
@Override @Override
@PostMapping(value = "/oper/customize/customerfunction/getOpenedFunctionList", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Result<List<DefaultFunctionListResultDTO>> getOpenedFunctionList(CustomerFunctionListFormDTO formDTO){ public Result<List<DefaultFunctionListResultDTO>> getOpenedFunctionList(CustomerFunctionListFormDTO formDTO){
return ModuleUtils.feignConError(ServiceConstant.OPER_CUSTOMIZE_SERVER, "getOpenedFunctionList", formDTO); return ModuleUtils.feignConError(ServiceConstant.OPER_CUSTOMIZE_SERVER, "getOpenedFunctionList", formDTO);
} }

2
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java

@ -133,7 +133,7 @@ public class CustomerFunctionController {
* @param formDTO * @param formDTO
* @return * @return
*/ */
@PostMapping("openedfunctionlist") @PostMapping("getOpenedFunctionList")
public Result<List<DefaultFunctionListResultDTO>> getOpenedFunctionList(@RequestBody CustomerFunctionListFormDTO formDTO) { public Result<List<DefaultFunctionListResultDTO>> getOpenedFunctionList(@RequestBody CustomerFunctionListFormDTO formDTO) {
return new Result<List<DefaultFunctionListResultDTO>>().ok(customerFunctionService.getOpenedFunctionList(formDTO)); return new Result<List<DefaultFunctionListResultDTO>>().ok(customerFunctionService.getOpenedFunctionList(formDTO));
} }

19
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java

@ -17,7 +17,6 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -231,17 +230,13 @@ public class CustomerFunctionServiceImpl extends BaseServiceImpl<CustomerFunctio
return result; return result;
} }
Set<String> openedFunIdSet = openedList.stream().map(CustomerFunctionDTO::getFunctionId).collect(Collectors.toSet()); Set<String> openedFunIdSet = openedList.stream().map(CustomerFunctionDTO::getFunctionId).collect(Collectors.toSet());
for (FunctionDTO function : funList) { return funList.stream().filter(fun -> openedFunIdSet.contains(fun.getId()))
if (openedFunIdSet.contains(function.getId())) { .map(fun -> {
DefaultFunctionListResultDTO resultDTO = ConvertUtils.sourceToTarget(function, DefaultFunctionListResultDTO.class); DefaultFunctionListResultDTO resultDTO = new DefaultFunctionListResultDTO();
if (resultDTO == null) { resultDTO.setFunctionId(fun.getId());
log.error("getOpenedFunctionList convert return null,function:{}", JSON.toJSONString(function)); resultDTO.setFunctionName(fun.getFunctionName());
continue; return resultDTO;
} }).collect(Collectors.toList());
result.add(resultDTO);
}
}
return result;
} }
} }
Loading…
Cancel
Save