fix: 修复notice没有主键及相关问题
This commit is contained in:
parent
f3e8667fbf
commit
22b0a423bd
|
@ -6,14 +6,14 @@ import java.io.Serializable;
|
|||
|
||||
@Data
|
||||
public class Notice implements Serializable {
|
||||
private String id;
|
||||
|
||||
private String event;
|
||||
|
||||
private String testId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String email;
|
||||
|
||||
private String enable;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
@ -104,6 +104,76 @@ public class NoticeExample {
|
|||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(String value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(String value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(String value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(String value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLike(String value) {
|
||||
addCriterion("id like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotLike(String value) {
|
||||
addCriterion("id not like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<String> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<String> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(String value1, String value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(String value1, String value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEventIsNull() {
|
||||
addCriterion("EVENT is null");
|
||||
return (Criteria) this;
|
||||
|
@ -314,76 +384,6 @@ public class NoticeExample {
|
|||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailIsNull() {
|
||||
addCriterion("EMAIL is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailIsNotNull() {
|
||||
addCriterion("EMAIL is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailEqualTo(String value) {
|
||||
addCriterion("EMAIL =", value, "email");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailNotEqualTo(String value) {
|
||||
addCriterion("EMAIL <>", value, "email");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailGreaterThan(String value) {
|
||||
addCriterion("EMAIL >", value, "email");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("EMAIL >=", value, "email");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailLessThan(String value) {
|
||||
addCriterion("EMAIL <", value, "email");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailLessThanOrEqualTo(String value) {
|
||||
addCriterion("EMAIL <=", value, "email");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailLike(String value) {
|
||||
addCriterion("EMAIL like", value, "email");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailNotLike(String value) {
|
||||
addCriterion("EMAIL not like", value, "email");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailIn(List<String> values) {
|
||||
addCriterion("EMAIL in", values, "email");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailNotIn(List<String> values) {
|
||||
addCriterion("EMAIL not in", values, "email");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailBetween(String value1, String value2) {
|
||||
addCriterion("EMAIL between", value1, value2, "email");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEmailNotBetween(String value1, String value2) {
|
||||
addCriterion("EMAIL not between", value1, value2, "email");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableIsNull() {
|
||||
addCriterion("`ENABLE` is null");
|
||||
return (Criteria) this;
|
||||
|
|
|
@ -2,21 +2,30 @@ package io.metersphere.base.mapper;
|
|||
|
||||
import io.metersphere.base.domain.Notice;
|
||||
import io.metersphere.base.domain.NoticeExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NoticeMapper {
|
||||
long countByExample(NoticeExample example);
|
||||
|
||||
int deleteByExample(NoticeExample example);
|
||||
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
int insert(Notice record);
|
||||
|
||||
int insertSelective(Notice record);
|
||||
|
||||
List<Notice> selectByExample(NoticeExample example);
|
||||
|
||||
Notice selectByPrimaryKey(String id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") Notice record, @Param("example") NoticeExample example);
|
||||
|
||||
int updateByExample(@Param("record") Notice record, @Param("example") NoticeExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(Notice record);
|
||||
|
||||
int updateByPrimaryKey(Notice record);
|
||||
}
|
|
@ -2,10 +2,10 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.base.mapper.NoticeMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.Notice">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="EVENT" jdbcType="VARCHAR" property="event" />
|
||||
<result column="TEST_ID" jdbcType="VARCHAR" property="testId" />
|
||||
<result column="NAME" jdbcType="VARCHAR" property="name" />
|
||||
<result column="EMAIL" jdbcType="VARCHAR" property="email" />
|
||||
<result column="ENABLE" jdbcType="VARCHAR" property="enable" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
|
@ -67,7 +67,7 @@
|
|||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
EVENT, TEST_ID, `NAME`, EMAIL, `ENABLE`
|
||||
id, EVENT, TEST_ID, `NAME`, `ENABLE`
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.base.domain.NoticeExample" resultMap="BaseResultMap">
|
||||
select
|
||||
|
@ -83,21 +83,34 @@
|
|||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM notice
|
||||
WHERE id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
DELETE FROM notice
|
||||
WHERE id = #{id,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.NoticeExample">
|
||||
delete from notice
|
||||
DELETE FROM notice
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.base.domain.Notice">
|
||||
insert into notice (EVENT, TEST_ID, `NAME`,
|
||||
EMAIL, `ENABLE`)
|
||||
values (#{event,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
||||
#{email,jdbcType=VARCHAR}, #{enable,jdbcType=VARCHAR})
|
||||
INSERT INTO notice (id, EVENT, TEST_ID,
|
||||
`NAME`, `ENABLE`)
|
||||
VALUES (#{id,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR},
|
||||
#{name,jdbcType=VARCHAR}, #{enable,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.Notice">
|
||||
insert into notice
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="event != null">
|
||||
EVENT,
|
||||
</if>
|
||||
|
@ -107,14 +120,14 @@
|
|||
<if test="name != null">
|
||||
`NAME`,
|
||||
</if>
|
||||
<if test="email != null">
|
||||
EMAIL,
|
||||
</if>
|
||||
<if test="enable != null">
|
||||
`ENABLE`,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="event != null">
|
||||
#{event,jdbcType=VARCHAR},
|
||||
</if>
|
||||
|
@ -124,9 +137,6 @@
|
|||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="email != null">
|
||||
#{email,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="enable != null">
|
||||
#{enable,jdbcType=VARCHAR},
|
||||
</if>
|
||||
|
@ -141,6 +151,9 @@
|
|||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update notice
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.event != null">
|
||||
EVENT = #{record.event,jdbcType=VARCHAR},
|
||||
</if>
|
||||
|
@ -150,9 +163,6 @@
|
|||
<if test="record.name != null">
|
||||
`NAME` = #{record.name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.email != null">
|
||||
EMAIL = #{record.email,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.enable != null">
|
||||
`ENABLE` = #{record.enable,jdbcType=VARCHAR},
|
||||
</if>
|
||||
|
@ -162,14 +172,40 @@
|
|||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update notice
|
||||
set EVENT = #{record.event,jdbcType=VARCHAR},
|
||||
UPDATE notice
|
||||
SET id = #{record.id,jdbcType=VARCHAR},
|
||||
EVENT = #{record.event,jdbcType=VARCHAR},
|
||||
TEST_ID = #{record.testId,jdbcType=VARCHAR},
|
||||
`NAME` = #{record.name,jdbcType=VARCHAR},
|
||||
EMAIL = #{record.email,jdbcType=VARCHAR},
|
||||
`ENABLE` = #{record.enable,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.Notice">
|
||||
UPDATE notice
|
||||
<set>
|
||||
<if test="event != null">
|
||||
EVENT = #{event,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="testId != null">
|
||||
TEST_ID = #{testId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`NAME` = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="enable != null">
|
||||
`ENABLE` = #{enable,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.Notice">
|
||||
UPDATE notice
|
||||
SET EVENT = #{event,jdbcType=VARCHAR},
|
||||
TEST_ID = #{testId,jdbcType=VARCHAR},
|
||||
`NAME` = #{name,jdbcType=VARCHAR},
|
||||
`ENABLE` = #{enable,jdbcType=VARCHAR}
|
||||
WHERE id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -6,16 +6,4 @@ import lombok.Data;
|
|||
@Data
|
||||
public class NoticeDetail extends Notice {
|
||||
private String[] names;
|
||||
|
||||
private String[] emails;
|
||||
|
||||
private String event;
|
||||
|
||||
private String testId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String email;
|
||||
|
||||
private String enable;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class NoticeService {
|
||||
|
@ -24,27 +25,16 @@ public class NoticeService {
|
|||
if (notices.size() > 0) {
|
||||
noticeMapper.deleteByExample(example);
|
||||
}
|
||||
saveNotice(noticeRequest, notice);
|
||||
}
|
||||
|
||||
private void saveNotice(NoticeRequest noticeRequest, Notice notice) {
|
||||
noticeRequest.getNotices().forEach(n -> {
|
||||
if (n.getNames().length > 0) {
|
||||
for (String x : n.getNames()) {
|
||||
notice.setId(UUID.randomUUID().toString());
|
||||
notice.setEvent(n.getEvent());
|
||||
notice.setEmail(n.getEmail());
|
||||
notice.setEnable(n.getEnable());
|
||||
notice.setTestId(noticeRequest.getTestId());
|
||||
notice.setName(x);
|
||||
noticeMapper.insert(notice);
|
||||
}
|
||||
} else {
|
||||
notice.setEvent(n.getEvent());
|
||||
notice.setEmail(n.getEmail());
|
||||
notice.setEnable(n.getEnable());
|
||||
notice.setTestId(noticeRequest.getTestId());
|
||||
notice.setName("");
|
||||
noticeMapper.insert(notice);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -67,18 +57,16 @@ public class NoticeService {
|
|||
notice1.setEnable(n.getEnable());
|
||||
notice1.setTestId(id);
|
||||
notice1.setEvent(n.getEvent());
|
||||
notice1.setEmail(n.getEmail());
|
||||
}
|
||||
if (n.getEvent().equals("执行失败")) {
|
||||
fail.add(n.getName());
|
||||
notice2.setEnable(n.getEnable());
|
||||
notice2.setTestId(id);
|
||||
notice2.setEvent(n.getEvent());
|
||||
notice2.setEmail(n.getEmail());
|
||||
}
|
||||
}
|
||||
successArray = success.toArray(new String[success.size()]);
|
||||
failArray = fail.toArray(new String[fail.size()]);
|
||||
successArray = success.toArray(new String[0]);
|
||||
failArray = fail.toArray(new String[0]);
|
||||
notice1.setNames(successArray);
|
||||
notice2.setNames(failArray);
|
||||
notice.add(notice1);
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
ALTER TABLE notice
|
||||
ADD COLUMN id VARCHAR(50);
|
||||
UPDATE notice
|
||||
SET id = uuid();
|
||||
ALTER TABLE notice
|
||||
MODIFY COLUMN id VARCHAR(50) PRIMARY KEY;
|
||||
ALTER TABLE notice
|
||||
DROP COLUMN EMAIL;
|
|
@ -144,13 +144,11 @@ export default {
|
|||
{
|
||||
event: "执行成功",
|
||||
names: [],
|
||||
email: "邮箱",
|
||||
enable: false
|
||||
},
|
||||
{
|
||||
event: "执行失败",
|
||||
names: [],
|
||||
email: "邮箱",
|
||||
enable: false
|
||||
}
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue