From 22b0a423bdd12aa8001035b4db1e3a66cc647e42 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Sun, 27 Sep 2020 14:14:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dnotice=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E4=B8=BB=E9=94=AE=E5=8F=8A=E7=9B=B8=E5=85=B3=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/base/domain/Notice.java | 4 +- .../base/domain/NoticeExample.java | 140 +++++++++--------- .../metersphere/base/mapper/NoticeMapper.java | 11 +- .../metersphere/base/mapper/NoticeMapper.xml | 74 ++++++--- .../notice/domain/NoticeDetail.java | 12 -- .../notice/service/NoticeService.java | 20 +-- .../db/migration/V26__modify_notice.sql | 8 + .../common/components/MsScheduleEdit.vue | 2 - 8 files changed, 149 insertions(+), 122 deletions(-) create mode 100644 backend/src/main/resources/db/migration/V26__modify_notice.sql diff --git a/backend/src/main/java/io/metersphere/base/domain/Notice.java b/backend/src/main/java/io/metersphere/base/domain/Notice.java index 572407b455..5ea2856cc1 100644 --- a/backend/src/main/java/io/metersphere/base/domain/Notice.java +++ b/backend/src/main/java/io/metersphere/base/domain/Notice.java @@ -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; diff --git a/backend/src/main/java/io/metersphere/base/domain/NoticeExample.java b/backend/src/main/java/io/metersphere/base/domain/NoticeExample.java index faee41158a..a6270bd8bb 100644 --- a/backend/src/main/java/io/metersphere/base/domain/NoticeExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/NoticeExample.java @@ -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 values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List 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 values) { - addCriterion("EMAIL in", values, "email"); - return (Criteria) this; - } - - public Criteria andEmailNotIn(List 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; diff --git a/backend/src/main/java/io/metersphere/base/mapper/NoticeMapper.java b/backend/src/main/java/io/metersphere/base/mapper/NoticeMapper.java index 4ca41aabdf..c1cba6f589 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/NoticeMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/NoticeMapper.java @@ -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 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); } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/NoticeMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/NoticeMapper.xml index 9e59138b2c..fa2aae33b6 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/NoticeMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/NoticeMapper.xml @@ -2,10 +2,10 @@ + - @@ -67,7 +67,7 @@ - EVENT, TEST_ID, `NAME`, EMAIL, `ENABLE` + id, EVENT, TEST_ID, `NAME`, `ENABLE` + + + DELETE FROM notice + WHERE id = #{id,jdbcType=VARCHAR} + - delete from notice + DELETE FROM 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 into notice + + id, + EVENT, @@ -107,14 +120,14 @@ `NAME`, - - EMAIL, - `ENABLE`, + + #{id,jdbcType=VARCHAR}, + #{event,jdbcType=VARCHAR}, @@ -124,9 +137,6 @@ #{name,jdbcType=VARCHAR}, - - #{email,jdbcType=VARCHAR}, - #{enable,jdbcType=VARCHAR}, @@ -141,6 +151,9 @@ update notice + + id = #{record.id,jdbcType=VARCHAR}, + EVENT = #{record.event,jdbcType=VARCHAR}, @@ -150,9 +163,6 @@ `NAME` = #{record.name,jdbcType=VARCHAR}, - - EMAIL = #{record.email,jdbcType=VARCHAR}, - `ENABLE` = #{record.enable,jdbcType=VARCHAR}, @@ -162,14 +172,40 @@ - 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} + + UPDATE notice + + + EVENT = #{event,jdbcType=VARCHAR}, + + + TEST_ID = #{testId,jdbcType=VARCHAR}, + + + `NAME` = #{name,jdbcType=VARCHAR}, + + + `ENABLE` = #{enable,jdbcType=VARCHAR}, + + + WHERE id = #{id,jdbcType=VARCHAR} + + + 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} + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/notice/domain/NoticeDetail.java b/backend/src/main/java/io/metersphere/notice/domain/NoticeDetail.java index 662187272f..e3a10050d9 100644 --- a/backend/src/main/java/io/metersphere/notice/domain/NoticeDetail.java +++ b/backend/src/main/java/io/metersphere/notice/domain/NoticeDetail.java @@ -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; } diff --git a/backend/src/main/java/io/metersphere/notice/service/NoticeService.java b/backend/src/main/java/io/metersphere/notice/service/NoticeService.java index 80e73f6f6f..1a2e0b7836 100644 --- a/backend/src/main/java/io/metersphere/notice/service/NoticeService.java +++ b/backend/src/main/java/io/metersphere/notice/service/NoticeService.java @@ -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); diff --git a/backend/src/main/resources/db/migration/V26__modify_notice.sql b/backend/src/main/resources/db/migration/V26__modify_notice.sql new file mode 100644 index 0000000000..1fc59022ea --- /dev/null +++ b/backend/src/main/resources/db/migration/V26__modify_notice.sql @@ -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; diff --git a/frontend/src/business/components/common/components/MsScheduleEdit.vue b/frontend/src/business/components/common/components/MsScheduleEdit.vue index 0fcddf2e4e..edf2874f31 100644 --- a/frontend/src/business/components/common/components/MsScheduleEdit.vue +++ b/frontend/src/business/components/common/components/MsScheduleEdit.vue @@ -144,13 +144,11 @@ export default { { event: "执行成功", names: [], - email: "邮箱", enable: false }, { event: "执行失败", names: [], - email: "邮箱", enable: false } ],