11 changed files with 548 additions and 0 deletions
@ -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; |
|||
|
|||
} |
@ -0,0 +1,11 @@ |
|||
package com.epmet.constant; |
|||
|
|||
/** |
|||
* desc:项目常量 |
|||
*/ |
|||
public interface ProjectConstant { |
|||
/** |
|||
* 时间已存在 |
|||
*/ |
|||
|
|||
} |
@ -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); |
|||
} |
|||
|
|||
} |
@ -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); |
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
} |
|||
} |
@ -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); |
|||
} |
@ -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);
|
|||
} |
|||
} |
@ -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> |
@ -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…
Reference in new issue