Browse Source

添加事件表及接口

dev_shibei_match
jianjun 5 years ago
parent
commit
6b919f334b
  1. 119
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/EventFormDTO.java
  2. 11
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/ProjectConstant.java
  3. 79
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java
  4. 35
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/EventDao.java
  5. 81
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/EventEntity.java
  6. 41
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/enu/SysResponseEnum.java
  7. 35
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/EventService.java
  8. 60
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java
  9. 20
      epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/epmet_common_service.sql
  10. 28
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/EventDao.xml
  11. 39
      epmet-module/epmet-point/epmet-point-server/src/main/resources/db/migration/epmet_point.sql

119
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

11
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 {
/**
* 时间已存在
*/
}

79
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<Boolean> addEvent(@RequestBody EventFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, AddGroup.class);
eventService.addEvent(formDTO);
return new Result<Boolean>().ok(true);
}
/**
* desc:修改事件如果已存在则不作任何改动直接返回成功
*
* @param formDTO
* @return
*/
@GetMapping("updateEvent")
public Result<Boolean> updateEvent(@RequestBody EventFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, UpdateGroup.class);
eventService.updateEvent(formDTO);
return new Result<Boolean>().ok(true);
}
}

35
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<EventEntity> {
int getCountByEventCode(@Param("eventCode") String eventCode);
}

81
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

41
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;
}
}

35
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<EventEntity> {
void addEvent(EventFormDTO formDTO);
void updateEvent(EventFormDTO formDTO);
}

60
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<EventDao, EventEntity> 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);
}
}

20
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 = '事件表';

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

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.EventDao">
<resultMap type="com.epmet.entity.EventEntity" id="eventMap">
<result property="id" column="ID"/>
<result property="classId" column="CLASS_ID"/>
<result property="appId" column="APP_ID"/>
<result property="appName" column="APP_NAME"/>
<result property="eventCode" column="EVENT_CODE"/>
<result property="eventName" column="EVENT_NAME"/>
<result property="eventDesc" column="EVENT_DESC"/>
<result property="eventGroupId" column="EVENT_GROUP_ID"/>
<result property="isCommon" column="IS_COMMON"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="getCountByEventCode" resultType="int">
select count(ID) from event where EVENT_CODE = #{eventCode,jdbcType=VARCHAR}
</select>
</mapper>

39
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 = '积分系统操作记录表';
Loading…
Cancel
Save