From 6b919f334b37ecb3cb6240733876cbb621e070e9 Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 16 Jul 2020 15:06:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=8B=E4=BB=B6=E8=A1=A8?= =?UTF-8?q?=E5=8F=8A=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dto/form/EventFormDTO.java | 119 ++++++++++++++++++ .../com/epmet/constant/ProjectConstant.java | 11 ++ .../com/epmet/controller/EventController.java | 79 ++++++++++++ .../src/main/java/com/epmet/dao/EventDao.java | 35 ++++++ .../java/com/epmet/entity/EventEntity.java | 81 ++++++++++++ .../java/com/epmet/enu/SysResponseEnum.java | 41 ++++++ .../java/com/epmet/service/EventService.java | 35 ++++++ .../epmet/service/impl/EventServiceImpl.java | 60 +++++++++ .../db/migration/epmet_common_service.sql | 20 +++ .../src/main/resources/mapper/EventDao.xml | 28 +++++ .../resources/db/migration/epmet_point.sql | 39 ++++++ 11 files changed, 548 insertions(+) create mode 100644 epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/EventFormDTO.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/ProjectConstant.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/EventDao.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/EventEntity.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/enu/SysResponseEnum.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/EventService.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/EventDao.xml create mode 100644 epmet-module/epmet-point/epmet-point-server/src/main/resources/db/migration/epmet_point.sql diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/EventFormDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/EventFormDTO.java new file mode 100644 index 0000000000..2c72dd5e4b --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/EventFormDTO.java @@ -0,0 +1,119 @@ +/** + * 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.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; +import java.util.Date; + + +/** + * 事件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-16 + */ +@Data +public class EventFormDTO implements Serializable { + + + private static final long serialVersionUID = -5890535035537229696L; + /** + * 主键 + */ + private String id; + + /** + * 消息网关事件类别ID 从消息网关获取事件类型Id + */ + private String classId; + + /** + * 消息网关APP_ID + */ + private String appId; + + /** + * 消息网关APP_NAME + */ + private String appName; + + /** + * 事件标识 与消息网关事件tag一致 + */ + @NotBlank(message = "事件标识不能为空",groups = {AddGroup.class, UpdateGroup.class}) + private String eventCode; + + /** + * 事件名称 + */ + @NotBlank(message = "事件名称不能为空",groups = {AddGroup.class}) + private String eventName; + + /** + * 事件说明 + */ + private String eventDesc; + + /** + * 事件功能分组ID 来自oper_customize.customer_function表 + */ + @NotBlank(message = "事件功能分组ID不能为空",groups = {AddGroup.class}) + private String eventGroupId; + + /** + * 是否是通用事件 0-否,1-是;消息体内需要体现该字段,通用则说明由业务系统自己计算分值 + */ + @NotBlank(message = "是否是通用事件不能为空",groups = {AddGroup.class}) + private String isCommon; + + /** + * 删除标识 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-common-service/common-service-server/src/main/java/com/epmet/constant/ProjectConstant.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/ProjectConstant.java new file mode 100644 index 0000000000..8aa3dc2fc1 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/ProjectConstant.java @@ -0,0 +1,11 @@ +package com.epmet.constant; + +/** + * desc:项目常量 + */ +public interface ProjectConstant { + /** + * 时间已存在 + */ + +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java new file mode 100644 index 0000000000..f07730295b --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java @@ -0,0 +1,79 @@ +/** + * 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.controller; + +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.EventFormDTO; +import com.epmet.service.EventService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 事件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-16 + */ +@RestController +@RequestMapping("event") +public class EventController { + + @Autowired + private EventService eventService; + + /** + * desc:添加事件,如果已存在则不作任何改动,直接返回成功 + * + * @param formDTO + * @return + * json:{ + * "classId":"epmet_heart", + * "appId":"202007161443499985fa2d397436d10356542134c8f008c48", + * "appName":"党群e事通开发测试", + * "eventCode":"epmet_heart_active_send_point", + * "eventName":"活动发放积分", + * "eventDesc":"给参加活动的人发放积分", + * "eventGroupId":"1234", + * "isCommon":"1" + * } + */ + @PostMapping("addEvent") + public Result addEvent(@RequestBody EventFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, AddGroup.class); + eventService.addEvent(formDTO); + return new Result().ok(true); + } + + /** + * desc:修改事件,如果已存在则不作任何改动,直接返回成功 + * + * @param formDTO + * @return + */ + @GetMapping("updateEvent") + public Result updateEvent(@RequestBody EventFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); + eventService.updateEvent(formDTO); + return new Result().ok(true); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/EventDao.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/EventDao.java new file mode 100644 index 0000000000..4db69553ec --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/EventDao.java @@ -0,0 +1,35 @@ +/** + * 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.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.EventEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 事件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-16 + */ +@Mapper +public interface EventDao extends BaseDao { + + int getCountByEventCode(@Param("eventCode") String eventCode); +} \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/EventEntity.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/EventEntity.java new file mode 100644 index 0000000000..391b11ad40 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/EventEntity.java @@ -0,0 +1,81 @@ +/** + * 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.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 事件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-16 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("event") +public class EventEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 消息网关事件类别ID 从消息网关获取事件类型Id + */ + private String classId; + + /** + * 消息网关APP_ID + */ + private String appId; + + /** + * 消息网关APP_NAME + */ + private String appName; + + /** + * 事件标识 与消息网关事件tag一致 + */ + private String eventCode; + + /** + * 事件名称 + */ + private String eventName; + + /** + * 事件说明 + */ + private String eventDesc; + + /** + * 事件功能分组ID 来自oper_customize.customer_function表 + */ + private String eventGroupId; + + /** + * 是否是通用事件 0-否,1-是;消息体内需要体现该字段,通用则说明由业务系统自己计算分值 + */ + private String isCommon; + +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/enu/SysResponseEnum.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/enu/SysResponseEnum.java new file mode 100644 index 0000000000..a34883da65 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/enu/SysResponseEnum.java @@ -0,0 +1,41 @@ +package com.epmet.enu; + +/** + * @author jianjun liu + * @date 2020-06-04 21:39 + **/ +public enum SysResponseEnum { + /** + * + * 业务代码枚举类 + * + * 编码样式:【CCCBBOOXX】 + * 编码示例说明: + * CCC 中心编码&业务系统 (120-内容扫描服务中心服务) + * BB 业务类型(00-默认 ) + * OO 操作类型(00-默认) + * + */ + /*通用枚举 */ + EXCEPTION(12001,"系统异常"), + + + /*事件 业务 01*/ + EVENT_HAS_ALREADY_EXIST(120010001,"事件已存在无需重复添加"), + ; + + 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-common-service/common-service-server/src/main/java/com/epmet/service/EventService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/EventService.java new file mode 100644 index 0000000000..fc60058fc2 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/EventService.java @@ -0,0 +1,35 @@ +/** + * 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.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.dto.form.EventFormDTO; +import com.epmet.entity.EventEntity; + +/** + * 事件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-16 + */ +public interface EventService extends BaseService { + + void addEvent(EventFormDTO formDTO); + + void updateEvent(EventFormDTO formDTO); +} \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java new file mode 100644 index 0000000000..fed5a58ed3 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java @@ -0,0 +1,60 @@ +/** + * 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.service.impl; + +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.dao.EventDao; +import com.epmet.dto.form.EventFormDTO; +import com.epmet.entity.EventEntity; +import com.epmet.enu.SysResponseEnum; +import com.epmet.service.EventService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * 事件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-16 + */ +@Slf4j +@Service +public class EventServiceImpl extends BaseServiceImpl implements EventService { + + @Override + 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); + if (eventEntity == null) { + throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); + } + baseDao.insert(eventEntity); + } + + @Override + public void updateEvent(EventFormDTO formDTO) { + //baseDao.update(eventEntity); + } +} \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/epmet_common_service.sql b/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/epmet_common_service.sql index 1e2005a491..bcf0b493c7 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/epmet_common_service.sql +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/epmet_common_service.sql @@ -416,3 +416,23 @@ INSERT INTO `calender` VALUES ('ff7e08ece3008eeb1661a2b1d8b4e20e', 0, '20200711' INSERT INTO `calender` VALUES ('ffe45e7059c67874f88498cfcfd19b4c', 0, '20200424', '2020-04-24', 5, '', '', '', '1', '工作日', '无', 'Friday', '周五', 0, 0, 'APP_USER', '2020-05-12 01:32:25', 'APP_USER', '2020-05-12 10:05:11'); SET FOREIGN_KEY_CHECKS = 1; + +#add by liujianjun 2020-07-16 +CREATE TABLE event( + ID VARCHAR(64) NOT NULL COMMENT '主键' , + CLASS_ID VARCHAR(32) COMMENT '消息网关事件类别ID 从消息网关获取事件类型Id' , + APP_ID VARCHAR(128) COMMENT '消息网关APP_ID' , + APP_NAME VARCHAR(32) COMMENT '消息网关APP_NAME' , + EVENT_CODE VARCHAR(32) COMMENT '事件标识 与消息网关事件tag一致' , + EVENT_NAME VARCHAR(32) COMMENT '事件名称' , + EVENT_DESC VARCHAR(64) COMMENT '事件说明' , + EVENT_GROUP_ID VARCHAR(512) COMMENT '事件功能分组ID 来自oper_customize.customer_function表' , + IS_COMMON VARCHAR(1) COMMENT '是否是通用事件 0-否,1-是;消息体内需要体现该字段,通用则说明由业务系统自己计算分值' , + DEL_FLAG VARCHAR(1) COMMENT '删除标识 0-否,1-是' , + REVISION INT COMMENT '乐观锁 查询时添加版本号,新加的事件需要更新版本号' , + CREATED_BY VARCHAR(32) COMMENT '创建人' , + CREATED_TIME DATETIME COMMENT '创建时间' , + UPDATED_BY VARCHAR(32) COMMENT '更新人' , + UPDATED_TIME DATETIME COMMENT '更新时间' , + PRIMARY KEY (ID) +) COMMENT = '事件表'; diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/EventDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/EventDao.xml new file mode 100644 index 0000000000..9865ab0efa --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/EventDao.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/resources/db/migration/epmet_point.sql b/epmet-module/epmet-point/epmet-point-server/src/main/resources/db/migration/epmet_point.sql new file mode 100644 index 0000000000..af08a35db6 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-server/src/main/resources/db/migration/epmet_point.sql @@ -0,0 +1,39 @@ +CREATE TABLE point_rule( + ID VARCHAR(64) NOT NULL COMMENT '主键' , + CUSTOMER_ID VARCHAR(64) COMMENT '客户ID' , + EVENT_CODE VARCHAR(32) COMMENT '事件CODE 来自事件表' , + EVENT_NAME VARCHAR(32) COMMENT '事件名称 来自事件表' , + RULE_DESC VARCHAR(32) COMMENT '积分说明 事件说明' , + OPERATE_TYPE VARCHAR(32) COMMENT '操作类型 加积分:add;减积分:subtract' , + UP_LIMIT INT COMMENT '积分上限' , + untitled VARCHAR(32) COMMENT '积分上限描述' , + POINT_NUM INT DEFAULT 0 COMMENT '获得积分值' , + POINT_UNIT VARCHAR(32) COMMENT '获得积分单位 次:time;分钟:minute;小时:hour' , + REMARK VARCHAR(128) COMMENT '备注 备注说明' , + ENABLED_FLAG VARCHAR(1) COMMENT '是否启用 0-否,1-是' , + DEL_FLAG VARCHAR(1) COMMENT '删除标识 0-否,1-是' , + REVISION INT COMMENT '乐观锁' , + CREATED_BY VARCHAR(32) COMMENT '创建人' , + CREATED_TIME DATETIME COMMENT '创建时间' , + UPDATED_BY VARCHAR(32) COMMENT '更新人' , + UPDATED_TIME DATETIME COMMENT '更新时间' , + PRIMARY KEY (ID) +) COMMENT = '积分规则表';; + +CREATE TABLE sys_operate_log( + ID VARCHAR(64) NOT NULL COMMENT '主键' , + CUSTOMER_ID VARCHAR(64) COMMENT '客户ID' , + OBJECT_ID VARCHAR(64) COMMENT '操作对象ID' , + OBJECT_TYPE VARCHAR(64) COMMENT '对象类型 规则:rule' , + OP_TYPE VARCHAR(32) COMMENT '操作类型 新建:add,编辑:edit,删除:del;' , + OP_USER VARCHAR(64) COMMENT '操作用户 操作人' , + BEFORD_DATA VARCHAR(1024) COMMENT '变更前数据 JSON串' , + AFTER_DATA VARCHAR(1024) COMMENT '变更后数据 JSON串' , + DEL_FLAG VARCHAR(1) COMMENT '删除标识 0-否,1-是' , + REVISION INT COMMENT '乐观锁' , + CREATED_BY VARCHAR(32) COMMENT '创建人' , + CREATED_TIME DATETIME COMMENT '创建时间' , + UPDATED_BY VARCHAR(32) COMMENT '更新人' , + UPDATED_TIME DATETIME COMMENT '更新时间' , + PRIMARY KEY (ID) +) COMMENT = '积分系统操作记录表';