From f5939b1a843c474052bfecb423fd7226f2674dc2 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Fri, 9 Jul 2021 17:23:53 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=E5=8F=98=E6=9B=B4=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E6=9D=BF=E4=B8=8B=E8=BD=BD=E8=A7=86=E5=9B=BE=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/canvas/components/Editor/Preview.vue | 2 +- frontend/src/components/canvas/components/Editor/index.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/canvas/components/Editor/Preview.vue b/frontend/src/components/canvas/components/Editor/Preview.vue index 922fceb47c..2665b8f95b 100644 --- a/frontend/src/components/canvas/components/Editor/Preview.vue +++ b/frontend/src/components/canvas/components/Editor/Preview.vue @@ -20,7 +20,7 @@ - {{$t('chart.export_details')}} + {{ $t('chart.export_details') }} diff --git a/frontend/src/components/canvas/components/Editor/index.vue b/frontend/src/components/canvas/components/Editor/index.vue index 5f5cefb06d..a3962b3fb5 100644 --- a/frontend/src/components/canvas/components/Editor/index.vue +++ b/frontend/src/components/canvas/components/Editor/index.vue @@ -100,7 +100,7 @@ :destroy-on-close="true" > - + {{ $t('chart.export_details') }} From 3094a04e01cac158d3fbdccd71a7ed94c6a32476 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Fri, 9 Jul 2021 18:07:44 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=E3=80=90=E4=BB=AA=E8=A1=A8=E6=9D=BF?= =?UTF-8?q?=E3=80=91=E5=9B=BE=E8=A1=A8=E6=98=8E=E7=BB=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=95=B0=E5=80=BC=E4=B8=BA0=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/canvas/custom-component/UserViewDialog.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/canvas/custom-component/UserViewDialog.vue b/frontend/src/components/canvas/custom-component/UserViewDialog.vue index 362a66f215..322b6e05e6 100644 --- a/frontend/src/components/canvas/custom-component/UserViewDialog.vue +++ b/frontend/src/components/canvas/custom-component/UserViewDialog.vue @@ -43,7 +43,7 @@ export default { debugger const excelHeader = JSON.parse(JSON.stringify(this.chart.data.fields)).map(item => item.name) const excelHeaderKeys = JSON.parse(JSON.stringify(this.chart.data.fields)).map(item => item.dataeaseName) - const excelData = JSON.parse(JSON.stringify(this.chart.data.tableRow)).map(item => excelHeaderKeys.map(i => item[i] || '')) + const excelData = JSON.parse(JSON.stringify(this.chart.data.tableRow)).map(item => excelHeaderKeys.map(i => item[i])) const excelName = this.chart.name export_json_to_excel(excelHeader, excelData, excelName) } From ff82cffff453d9a44ccd58173115bad2a5e662d2 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 9 Jul 2021 18:37:07 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8E=A5=E6=94=B6=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/base/domain/SysMsg.java | 4 +- .../dataease/base/domain/SysMsgChannel.java | 13 + .../base/domain/SysMsgChannelExample.java | 330 +++++++++++ .../dataease/base/domain/SysMsgExample.java | 118 +--- .../dataease/base/domain/SysMsgSetting.java | 19 + .../base/domain/SysMsgSettingExample.java | 500 +++++++++++++++++ .../io/dataease/base/domain/SysMsgType.java | 19 + .../base/domain/SysMsgTypeExample.java | 530 ++++++++++++++++++ .../base/mapper/SysMsgChannelMapper.java | 30 + .../base/mapper/SysMsgChannelMapper.xml | 164 ++++++ .../io/dataease/base/mapper/SysMsgMapper.xml | 53 +- .../base/mapper/SysMsgSettingMapper.java | 30 + .../base/mapper/SysMsgSettingMapper.xml | 211 +++++++ .../base/mapper/SysMsgTypeMapper.java | 30 + .../dataease/base/mapper/SysMsgTypeMapper.xml | 211 +++++++ .../base/mapper/ext/ExtSysMsgMapper.java | 6 + .../base/mapper/ext/ExtSysMsgMapper.xml | 60 ++ .../commons/constants/SysMsgConstants.java | 7 + .../controller/message/MsgController.java | 43 +- .../controller/message/dto/MsgGridDto.java | 11 + .../controller/message/dto/MsgRequest.java | 2 +- .../message/dto/MsgSettingRequest.java | 14 + .../message/dto/SettingTreeNode.java | 19 + .../service/dataset/ExtractDataService.java | 6 +- .../dataease/service/message/DeMsgutil.java | 27 +- .../io/dataease/service/message/MsgAop.java | 55 ++ .../service/message/SysMsgService.java | 142 ++++- .../dataease/service/panel/ShareService.java | 10 +- .../src/main/resources/ehcache/ehcache.xml | 21 + .../resources/i18n/messages_en_US.properties | 6 + .../resources/i18n/messages_zh_CN.properties | 6 + .../resources/i18n/messages_zh_TW.properties | 6 + frontend/src/api/system/msg.js | 41 ++ .../src/components/Notification/index.vue | 21 +- frontend/src/icons/svg/msg-setting.svg | 1 + frontend/src/lang/en.js | 5 +- frontend/src/lang/tw.js | 5 +- frontend/src/lang/zh.js | 5 +- frontend/src/store/getters.js | 3 +- frontend/src/store/index.js | 4 +- frontend/src/store/modules/msg.js | 25 + frontend/src/utils/webMsg.js | 24 +- frontend/src/views/msg/all.vue | 12 +- frontend/src/views/msg/readed.vue | 10 +- frontend/src/views/msg/setting.vue | 161 ++++++ frontend/src/views/msg/unread.vue | 10 +- 46 files changed, 2826 insertions(+), 204 deletions(-) create mode 100644 backend/src/main/java/io/dataease/base/domain/SysMsgChannel.java create mode 100644 backend/src/main/java/io/dataease/base/domain/SysMsgChannelExample.java create mode 100644 backend/src/main/java/io/dataease/base/domain/SysMsgSetting.java create mode 100644 backend/src/main/java/io/dataease/base/domain/SysMsgSettingExample.java create mode 100644 backend/src/main/java/io/dataease/base/domain/SysMsgType.java create mode 100644 backend/src/main/java/io/dataease/base/domain/SysMsgTypeExample.java create mode 100644 backend/src/main/java/io/dataease/base/mapper/SysMsgChannelMapper.java create mode 100644 backend/src/main/java/io/dataease/base/mapper/SysMsgChannelMapper.xml create mode 100644 backend/src/main/java/io/dataease/base/mapper/SysMsgSettingMapper.java create mode 100644 backend/src/main/java/io/dataease/base/mapper/SysMsgSettingMapper.xml create mode 100644 backend/src/main/java/io/dataease/base/mapper/SysMsgTypeMapper.java create mode 100644 backend/src/main/java/io/dataease/base/mapper/SysMsgTypeMapper.xml create mode 100644 backend/src/main/java/io/dataease/base/mapper/ext/ExtSysMsgMapper.xml create mode 100644 backend/src/main/java/io/dataease/commons/constants/SysMsgConstants.java create mode 100644 backend/src/main/java/io/dataease/controller/message/dto/MsgGridDto.java create mode 100644 backend/src/main/java/io/dataease/controller/message/dto/MsgSettingRequest.java create mode 100644 backend/src/main/java/io/dataease/controller/message/dto/SettingTreeNode.java create mode 100644 backend/src/main/java/io/dataease/service/message/MsgAop.java create mode 100644 frontend/src/icons/svg/msg-setting.svg create mode 100644 frontend/src/store/modules/msg.js create mode 100644 frontend/src/views/msg/setting.vue diff --git a/backend/src/main/java/io/dataease/base/domain/SysMsg.java b/backend/src/main/java/io/dataease/base/domain/SysMsg.java index d18c3eada6..b9759f2f1a 100644 --- a/backend/src/main/java/io/dataease/base/domain/SysMsg.java +++ b/backend/src/main/java/io/dataease/base/domain/SysMsg.java @@ -9,12 +9,10 @@ public class SysMsg implements Serializable { private Long userId; - private Integer type; + private Long typeId; private Boolean status; - private String router; - private String param; private Long createTime; diff --git a/backend/src/main/java/io/dataease/base/domain/SysMsgChannel.java b/backend/src/main/java/io/dataease/base/domain/SysMsgChannel.java new file mode 100644 index 0000000000..0ca1830b37 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/domain/SysMsgChannel.java @@ -0,0 +1,13 @@ +package io.dataease.base.domain; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class SysMsgChannel implements Serializable { + private Long msgChannelId; + + private String channelName; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/domain/SysMsgChannelExample.java b/backend/src/main/java/io/dataease/base/domain/SysMsgChannelExample.java new file mode 100644 index 0000000000..6c860f8837 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/domain/SysMsgChannelExample.java @@ -0,0 +1,330 @@ +package io.dataease.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class SysMsgChannelExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public SysMsgChannelExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andMsgChannelIdIsNull() { + addCriterion("msg_channel_id is null"); + return (Criteria) this; + } + + public Criteria andMsgChannelIdIsNotNull() { + addCriterion("msg_channel_id is not null"); + return (Criteria) this; + } + + public Criteria andMsgChannelIdEqualTo(Long value) { + addCriterion("msg_channel_id =", value, "msgChannelId"); + return (Criteria) this; + } + + public Criteria andMsgChannelIdNotEqualTo(Long value) { + addCriterion("msg_channel_id <>", value, "msgChannelId"); + return (Criteria) this; + } + + public Criteria andMsgChannelIdGreaterThan(Long value) { + addCriterion("msg_channel_id >", value, "msgChannelId"); + return (Criteria) this; + } + + public Criteria andMsgChannelIdGreaterThanOrEqualTo(Long value) { + addCriterion("msg_channel_id >=", value, "msgChannelId"); + return (Criteria) this; + } + + public Criteria andMsgChannelIdLessThan(Long value) { + addCriterion("msg_channel_id <", value, "msgChannelId"); + return (Criteria) this; + } + + public Criteria andMsgChannelIdLessThanOrEqualTo(Long value) { + addCriterion("msg_channel_id <=", value, "msgChannelId"); + return (Criteria) this; + } + + public Criteria andMsgChannelIdIn(List values) { + addCriterion("msg_channel_id in", values, "msgChannelId"); + return (Criteria) this; + } + + public Criteria andMsgChannelIdNotIn(List values) { + addCriterion("msg_channel_id not in", values, "msgChannelId"); + return (Criteria) this; + } + + public Criteria andMsgChannelIdBetween(Long value1, Long value2) { + addCriterion("msg_channel_id between", value1, value2, "msgChannelId"); + return (Criteria) this; + } + + public Criteria andMsgChannelIdNotBetween(Long value1, Long value2) { + addCriterion("msg_channel_id not between", value1, value2, "msgChannelId"); + return (Criteria) this; + } + + public Criteria andChannelNameIsNull() { + addCriterion("channel_name is null"); + return (Criteria) this; + } + + public Criteria andChannelNameIsNotNull() { + addCriterion("channel_name is not null"); + return (Criteria) this; + } + + public Criteria andChannelNameEqualTo(String value) { + addCriterion("channel_name =", value, "channelName"); + return (Criteria) this; + } + + public Criteria andChannelNameNotEqualTo(String value) { + addCriterion("channel_name <>", value, "channelName"); + return (Criteria) this; + } + + public Criteria andChannelNameGreaterThan(String value) { + addCriterion("channel_name >", value, "channelName"); + return (Criteria) this; + } + + public Criteria andChannelNameGreaterThanOrEqualTo(String value) { + addCriterion("channel_name >=", value, "channelName"); + return (Criteria) this; + } + + public Criteria andChannelNameLessThan(String value) { + addCriterion("channel_name <", value, "channelName"); + return (Criteria) this; + } + + public Criteria andChannelNameLessThanOrEqualTo(String value) { + addCriterion("channel_name <=", value, "channelName"); + return (Criteria) this; + } + + public Criteria andChannelNameLike(String value) { + addCriterion("channel_name like", value, "channelName"); + return (Criteria) this; + } + + public Criteria andChannelNameNotLike(String value) { + addCriterion("channel_name not like", value, "channelName"); + return (Criteria) this; + } + + public Criteria andChannelNameIn(List values) { + addCriterion("channel_name in", values, "channelName"); + return (Criteria) this; + } + + public Criteria andChannelNameNotIn(List values) { + addCriterion("channel_name not in", values, "channelName"); + return (Criteria) this; + } + + public Criteria andChannelNameBetween(String value1, String value2) { + addCriterion("channel_name between", value1, value2, "channelName"); + return (Criteria) this; + } + + public Criteria andChannelNameNotBetween(String value1, String value2) { + addCriterion("channel_name not between", value1, value2, "channelName"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/domain/SysMsgExample.java b/backend/src/main/java/io/dataease/base/domain/SysMsgExample.java index 60c1d39c54..e242693c0c 100644 --- a/backend/src/main/java/io/dataease/base/domain/SysMsgExample.java +++ b/backend/src/main/java/io/dataease/base/domain/SysMsgExample.java @@ -224,63 +224,63 @@ public class SysMsgExample { return (Criteria) this; } - public Criteria andTypeIsNull() { - addCriterion("`type` is null"); + public Criteria andTypeIdIsNull() { + addCriterion("type_id is null"); return (Criteria) this; } - public Criteria andTypeIsNotNull() { - addCriterion("`type` is not null"); + public Criteria andTypeIdIsNotNull() { + addCriterion("type_id is not null"); return (Criteria) this; } - public Criteria andTypeEqualTo(Integer value) { - addCriterion("`type` =", value, "type"); + public Criteria andTypeIdEqualTo(Long value) { + addCriterion("type_id =", value, "typeId"); return (Criteria) this; } - public Criteria andTypeNotEqualTo(Integer value) { - addCriterion("`type` <>", value, "type"); + public Criteria andTypeIdNotEqualTo(Long value) { + addCriterion("type_id <>", value, "typeId"); return (Criteria) this; } - public Criteria andTypeGreaterThan(Integer value) { - addCriterion("`type` >", value, "type"); + public Criteria andTypeIdGreaterThan(Long value) { + addCriterion("type_id >", value, "typeId"); return (Criteria) this; } - public Criteria andTypeGreaterThanOrEqualTo(Integer value) { - addCriterion("`type` >=", value, "type"); + public Criteria andTypeIdGreaterThanOrEqualTo(Long value) { + addCriterion("type_id >=", value, "typeId"); return (Criteria) this; } - public Criteria andTypeLessThan(Integer value) { - addCriterion("`type` <", value, "type"); + public Criteria andTypeIdLessThan(Long value) { + addCriterion("type_id <", value, "typeId"); return (Criteria) this; } - public Criteria andTypeLessThanOrEqualTo(Integer value) { - addCriterion("`type` <=", value, "type"); + public Criteria andTypeIdLessThanOrEqualTo(Long value) { + addCriterion("type_id <=", value, "typeId"); return (Criteria) this; } - public Criteria andTypeIn(List values) { - addCriterion("`type` in", values, "type"); + public Criteria andTypeIdIn(List values) { + addCriterion("type_id in", values, "typeId"); return (Criteria) this; } - public Criteria andTypeNotIn(List values) { - addCriterion("`type` not in", values, "type"); + public Criteria andTypeIdNotIn(List values) { + addCriterion("type_id not in", values, "typeId"); return (Criteria) this; } - public Criteria andTypeBetween(Integer value1, Integer value2) { - addCriterion("`type` between", value1, value2, "type"); + public Criteria andTypeIdBetween(Long value1, Long value2) { + addCriterion("type_id between", value1, value2, "typeId"); return (Criteria) this; } - public Criteria andTypeNotBetween(Integer value1, Integer value2) { - addCriterion("`type` not between", value1, value2, "type"); + public Criteria andTypeIdNotBetween(Long value1, Long value2) { + addCriterion("type_id not between", value1, value2, "typeId"); return (Criteria) this; } @@ -344,76 +344,6 @@ public class SysMsgExample { return (Criteria) this; } - public Criteria andRouterIsNull() { - addCriterion("router is null"); - return (Criteria) this; - } - - public Criteria andRouterIsNotNull() { - addCriterion("router is not null"); - return (Criteria) this; - } - - public Criteria andRouterEqualTo(String value) { - addCriterion("router =", value, "router"); - return (Criteria) this; - } - - public Criteria andRouterNotEqualTo(String value) { - addCriterion("router <>", value, "router"); - return (Criteria) this; - } - - public Criteria andRouterGreaterThan(String value) { - addCriterion("router >", value, "router"); - return (Criteria) this; - } - - public Criteria andRouterGreaterThanOrEqualTo(String value) { - addCriterion("router >=", value, "router"); - return (Criteria) this; - } - - public Criteria andRouterLessThan(String value) { - addCriterion("router <", value, "router"); - return (Criteria) this; - } - - public Criteria andRouterLessThanOrEqualTo(String value) { - addCriterion("router <=", value, "router"); - return (Criteria) this; - } - - public Criteria andRouterLike(String value) { - addCriterion("router like", value, "router"); - return (Criteria) this; - } - - public Criteria andRouterNotLike(String value) { - addCriterion("router not like", value, "router"); - return (Criteria) this; - } - - public Criteria andRouterIn(List values) { - addCriterion("router in", values, "router"); - return (Criteria) this; - } - - public Criteria andRouterNotIn(List values) { - addCriterion("router not in", values, "router"); - return (Criteria) this; - } - - public Criteria andRouterBetween(String value1, String value2) { - addCriterion("router between", value1, value2, "router"); - return (Criteria) this; - } - - public Criteria andRouterNotBetween(String value1, String value2) { - addCriterion("router not between", value1, value2, "router"); - return (Criteria) this; - } - public Criteria andParamIsNull() { addCriterion("param is null"); return (Criteria) this; diff --git a/backend/src/main/java/io/dataease/base/domain/SysMsgSetting.java b/backend/src/main/java/io/dataease/base/domain/SysMsgSetting.java new file mode 100644 index 0000000000..4d679effec --- /dev/null +++ b/backend/src/main/java/io/dataease/base/domain/SysMsgSetting.java @@ -0,0 +1,19 @@ +package io.dataease.base.domain; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class SysMsgSetting implements Serializable { + private Long msgSettingId; + + private Long userId; + + private Long typeId; + + private Long channelId; + + private Boolean enable; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/domain/SysMsgSettingExample.java b/backend/src/main/java/io/dataease/base/domain/SysMsgSettingExample.java new file mode 100644 index 0000000000..6e2f095840 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/domain/SysMsgSettingExample.java @@ -0,0 +1,500 @@ +package io.dataease.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class SysMsgSettingExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public SysMsgSettingExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andMsgSettingIdIsNull() { + addCriterion("msg_setting_id is null"); + return (Criteria) this; + } + + public Criteria andMsgSettingIdIsNotNull() { + addCriterion("msg_setting_id is not null"); + return (Criteria) this; + } + + public Criteria andMsgSettingIdEqualTo(Long value) { + addCriterion("msg_setting_id =", value, "msgSettingId"); + return (Criteria) this; + } + + public Criteria andMsgSettingIdNotEqualTo(Long value) { + addCriterion("msg_setting_id <>", value, "msgSettingId"); + return (Criteria) this; + } + + public Criteria andMsgSettingIdGreaterThan(Long value) { + addCriterion("msg_setting_id >", value, "msgSettingId"); + return (Criteria) this; + } + + public Criteria andMsgSettingIdGreaterThanOrEqualTo(Long value) { + addCriterion("msg_setting_id >=", value, "msgSettingId"); + return (Criteria) this; + } + + public Criteria andMsgSettingIdLessThan(Long value) { + addCriterion("msg_setting_id <", value, "msgSettingId"); + return (Criteria) this; + } + + public Criteria andMsgSettingIdLessThanOrEqualTo(Long value) { + addCriterion("msg_setting_id <=", value, "msgSettingId"); + return (Criteria) this; + } + + public Criteria andMsgSettingIdIn(List values) { + addCriterion("msg_setting_id in", values, "msgSettingId"); + return (Criteria) this; + } + + public Criteria andMsgSettingIdNotIn(List values) { + addCriterion("msg_setting_id not in", values, "msgSettingId"); + return (Criteria) this; + } + + public Criteria andMsgSettingIdBetween(Long value1, Long value2) { + addCriterion("msg_setting_id between", value1, value2, "msgSettingId"); + return (Criteria) this; + } + + public Criteria andMsgSettingIdNotBetween(Long value1, Long value2) { + addCriterion("msg_setting_id not between", value1, value2, "msgSettingId"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andTypeIdIsNull() { + addCriterion("type_id is null"); + return (Criteria) this; + } + + public Criteria andTypeIdIsNotNull() { + addCriterion("type_id is not null"); + return (Criteria) this; + } + + public Criteria andTypeIdEqualTo(Long value) { + addCriterion("type_id =", value, "typeId"); + return (Criteria) this; + } + + public Criteria andTypeIdNotEqualTo(Long value) { + addCriterion("type_id <>", value, "typeId"); + return (Criteria) this; + } + + public Criteria andTypeIdGreaterThan(Long value) { + addCriterion("type_id >", value, "typeId"); + return (Criteria) this; + } + + public Criteria andTypeIdGreaterThanOrEqualTo(Long value) { + addCriterion("type_id >=", value, "typeId"); + return (Criteria) this; + } + + public Criteria andTypeIdLessThan(Long value) { + addCriterion("type_id <", value, "typeId"); + return (Criteria) this; + } + + public Criteria andTypeIdLessThanOrEqualTo(Long value) { + addCriterion("type_id <=", value, "typeId"); + return (Criteria) this; + } + + public Criteria andTypeIdIn(List values) { + addCriterion("type_id in", values, "typeId"); + return (Criteria) this; + } + + public Criteria andTypeIdNotIn(List values) { + addCriterion("type_id not in", values, "typeId"); + return (Criteria) this; + } + + public Criteria andTypeIdBetween(Long value1, Long value2) { + addCriterion("type_id between", value1, value2, "typeId"); + return (Criteria) this; + } + + public Criteria andTypeIdNotBetween(Long value1, Long value2) { + addCriterion("type_id not between", value1, value2, "typeId"); + return (Criteria) this; + } + + public Criteria andChannelIdIsNull() { + addCriterion("channel_id is null"); + return (Criteria) this; + } + + public Criteria andChannelIdIsNotNull() { + addCriterion("channel_id is not null"); + return (Criteria) this; + } + + public Criteria andChannelIdEqualTo(Long value) { + addCriterion("channel_id =", value, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdNotEqualTo(Long value) { + addCriterion("channel_id <>", value, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdGreaterThan(Long value) { + addCriterion("channel_id >", value, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdGreaterThanOrEqualTo(Long value) { + addCriterion("channel_id >=", value, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdLessThan(Long value) { + addCriterion("channel_id <", value, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdLessThanOrEqualTo(Long value) { + addCriterion("channel_id <=", value, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdIn(List values) { + addCriterion("channel_id in", values, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdNotIn(List values) { + addCriterion("channel_id not in", values, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdBetween(Long value1, Long value2) { + addCriterion("channel_id between", value1, value2, "channelId"); + return (Criteria) this; + } + + public Criteria andChannelIdNotBetween(Long value1, Long value2) { + addCriterion("channel_id not between", value1, value2, "channelId"); + return (Criteria) this; + } + + public Criteria andEnableIsNull() { + addCriterion("`enable` is null"); + return (Criteria) this; + } + + public Criteria andEnableIsNotNull() { + addCriterion("`enable` is not null"); + return (Criteria) this; + } + + public Criteria andEnableEqualTo(Boolean value) { + addCriterion("`enable` =", value, "enable"); + return (Criteria) this; + } + + public Criteria andEnableNotEqualTo(Boolean value) { + addCriterion("`enable` <>", value, "enable"); + return (Criteria) this; + } + + public Criteria andEnableGreaterThan(Boolean value) { + addCriterion("`enable` >", value, "enable"); + return (Criteria) this; + } + + public Criteria andEnableGreaterThanOrEqualTo(Boolean value) { + addCriterion("`enable` >=", value, "enable"); + return (Criteria) this; + } + + public Criteria andEnableLessThan(Boolean value) { + addCriterion("`enable` <", value, "enable"); + return (Criteria) this; + } + + public Criteria andEnableLessThanOrEqualTo(Boolean value) { + addCriterion("`enable` <=", value, "enable"); + return (Criteria) this; + } + + public Criteria andEnableIn(List values) { + addCriterion("`enable` in", values, "enable"); + return (Criteria) this; + } + + public Criteria andEnableNotIn(List values) { + addCriterion("`enable` not in", values, "enable"); + return (Criteria) this; + } + + public Criteria andEnableBetween(Boolean value1, Boolean value2) { + addCriterion("`enable` between", value1, value2, "enable"); + return (Criteria) this; + } + + public Criteria andEnableNotBetween(Boolean value1, Boolean value2) { + addCriterion("`enable` not between", value1, value2, "enable"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/domain/SysMsgType.java b/backend/src/main/java/io/dataease/base/domain/SysMsgType.java new file mode 100644 index 0000000000..fd27679478 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/domain/SysMsgType.java @@ -0,0 +1,19 @@ +package io.dataease.base.domain; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class SysMsgType implements Serializable { + private Long msgTypeId; + + private Long pid; + + private String typeName; + + private String router; + + private String callback; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/domain/SysMsgTypeExample.java b/backend/src/main/java/io/dataease/base/domain/SysMsgTypeExample.java new file mode 100644 index 0000000000..143c4a936e --- /dev/null +++ b/backend/src/main/java/io/dataease/base/domain/SysMsgTypeExample.java @@ -0,0 +1,530 @@ +package io.dataease.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class SysMsgTypeExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public SysMsgTypeExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andMsgTypeIdIsNull() { + addCriterion("msg_type_id is null"); + return (Criteria) this; + } + + public Criteria andMsgTypeIdIsNotNull() { + addCriterion("msg_type_id is not null"); + return (Criteria) this; + } + + public Criteria andMsgTypeIdEqualTo(Long value) { + addCriterion("msg_type_id =", value, "msgTypeId"); + return (Criteria) this; + } + + public Criteria andMsgTypeIdNotEqualTo(Long value) { + addCriterion("msg_type_id <>", value, "msgTypeId"); + return (Criteria) this; + } + + public Criteria andMsgTypeIdGreaterThan(Long value) { + addCriterion("msg_type_id >", value, "msgTypeId"); + return (Criteria) this; + } + + public Criteria andMsgTypeIdGreaterThanOrEqualTo(Long value) { + addCriterion("msg_type_id >=", value, "msgTypeId"); + return (Criteria) this; + } + + public Criteria andMsgTypeIdLessThan(Long value) { + addCriterion("msg_type_id <", value, "msgTypeId"); + return (Criteria) this; + } + + public Criteria andMsgTypeIdLessThanOrEqualTo(Long value) { + addCriterion("msg_type_id <=", value, "msgTypeId"); + return (Criteria) this; + } + + public Criteria andMsgTypeIdIn(List values) { + addCriterion("msg_type_id in", values, "msgTypeId"); + return (Criteria) this; + } + + public Criteria andMsgTypeIdNotIn(List values) { + addCriterion("msg_type_id not in", values, "msgTypeId"); + return (Criteria) this; + } + + public Criteria andMsgTypeIdBetween(Long value1, Long value2) { + addCriterion("msg_type_id between", value1, value2, "msgTypeId"); + return (Criteria) this; + } + + public Criteria andMsgTypeIdNotBetween(Long value1, Long value2) { + addCriterion("msg_type_id not between", value1, value2, "msgTypeId"); + return (Criteria) this; + } + + public Criteria andPidIsNull() { + addCriterion("pid is null"); + return (Criteria) this; + } + + public Criteria andPidIsNotNull() { + addCriterion("pid is not null"); + return (Criteria) this; + } + + public Criteria andPidEqualTo(Long value) { + addCriterion("pid =", value, "pid"); + return (Criteria) this; + } + + public Criteria andPidNotEqualTo(Long value) { + addCriterion("pid <>", value, "pid"); + return (Criteria) this; + } + + public Criteria andPidGreaterThan(Long value) { + addCriterion("pid >", value, "pid"); + return (Criteria) this; + } + + public Criteria andPidGreaterThanOrEqualTo(Long value) { + addCriterion("pid >=", value, "pid"); + return (Criteria) this; + } + + public Criteria andPidLessThan(Long value) { + addCriterion("pid <", value, "pid"); + return (Criteria) this; + } + + public Criteria andPidLessThanOrEqualTo(Long value) { + addCriterion("pid <=", value, "pid"); + return (Criteria) this; + } + + public Criteria andPidIn(List values) { + addCriterion("pid in", values, "pid"); + return (Criteria) this; + } + + public Criteria andPidNotIn(List values) { + addCriterion("pid not in", values, "pid"); + return (Criteria) this; + } + + public Criteria andPidBetween(Long value1, Long value2) { + addCriterion("pid between", value1, value2, "pid"); + return (Criteria) this; + } + + public Criteria andPidNotBetween(Long value1, Long value2) { + addCriterion("pid not between", value1, value2, "pid"); + return (Criteria) this; + } + + public Criteria andTypeNameIsNull() { + addCriterion("type_name is null"); + return (Criteria) this; + } + + public Criteria andTypeNameIsNotNull() { + addCriterion("type_name is not null"); + return (Criteria) this; + } + + public Criteria andTypeNameEqualTo(String value) { + addCriterion("type_name =", value, "typeName"); + return (Criteria) this; + } + + public Criteria andTypeNameNotEqualTo(String value) { + addCriterion("type_name <>", value, "typeName"); + return (Criteria) this; + } + + public Criteria andTypeNameGreaterThan(String value) { + addCriterion("type_name >", value, "typeName"); + return (Criteria) this; + } + + public Criteria andTypeNameGreaterThanOrEqualTo(String value) { + addCriterion("type_name >=", value, "typeName"); + return (Criteria) this; + } + + public Criteria andTypeNameLessThan(String value) { + addCriterion("type_name <", value, "typeName"); + return (Criteria) this; + } + + public Criteria andTypeNameLessThanOrEqualTo(String value) { + addCriterion("type_name <=", value, "typeName"); + return (Criteria) this; + } + + public Criteria andTypeNameLike(String value) { + addCriterion("type_name like", value, "typeName"); + return (Criteria) this; + } + + public Criteria andTypeNameNotLike(String value) { + addCriterion("type_name not like", value, "typeName"); + return (Criteria) this; + } + + public Criteria andTypeNameIn(List values) { + addCriterion("type_name in", values, "typeName"); + return (Criteria) this; + } + + public Criteria andTypeNameNotIn(List values) { + addCriterion("type_name not in", values, "typeName"); + return (Criteria) this; + } + + public Criteria andTypeNameBetween(String value1, String value2) { + addCriterion("type_name between", value1, value2, "typeName"); + return (Criteria) this; + } + + public Criteria andTypeNameNotBetween(String value1, String value2) { + addCriterion("type_name not between", value1, value2, "typeName"); + return (Criteria) this; + } + + public Criteria andRouterIsNull() { + addCriterion("router is null"); + return (Criteria) this; + } + + public Criteria andRouterIsNotNull() { + addCriterion("router is not null"); + return (Criteria) this; + } + + public Criteria andRouterEqualTo(String value) { + addCriterion("router =", value, "router"); + return (Criteria) this; + } + + public Criteria andRouterNotEqualTo(String value) { + addCriterion("router <>", value, "router"); + return (Criteria) this; + } + + public Criteria andRouterGreaterThan(String value) { + addCriterion("router >", value, "router"); + return (Criteria) this; + } + + public Criteria andRouterGreaterThanOrEqualTo(String value) { + addCriterion("router >=", value, "router"); + return (Criteria) this; + } + + public Criteria andRouterLessThan(String value) { + addCriterion("router <", value, "router"); + return (Criteria) this; + } + + public Criteria andRouterLessThanOrEqualTo(String value) { + addCriterion("router <=", value, "router"); + return (Criteria) this; + } + + public Criteria andRouterLike(String value) { + addCriterion("router like", value, "router"); + return (Criteria) this; + } + + public Criteria andRouterNotLike(String value) { + addCriterion("router not like", value, "router"); + return (Criteria) this; + } + + public Criteria andRouterIn(List values) { + addCriterion("router in", values, "router"); + return (Criteria) this; + } + + public Criteria andRouterNotIn(List values) { + addCriterion("router not in", values, "router"); + return (Criteria) this; + } + + public Criteria andRouterBetween(String value1, String value2) { + addCriterion("router between", value1, value2, "router"); + return (Criteria) this; + } + + public Criteria andRouterNotBetween(String value1, String value2) { + addCriterion("router not between", value1, value2, "router"); + return (Criteria) this; + } + + public Criteria andCallbackIsNull() { + addCriterion("callback is null"); + return (Criteria) this; + } + + public Criteria andCallbackIsNotNull() { + addCriterion("callback is not null"); + return (Criteria) this; + } + + public Criteria andCallbackEqualTo(String value) { + addCriterion("callback =", value, "callback"); + return (Criteria) this; + } + + public Criteria andCallbackNotEqualTo(String value) { + addCriterion("callback <>", value, "callback"); + return (Criteria) this; + } + + public Criteria andCallbackGreaterThan(String value) { + addCriterion("callback >", value, "callback"); + return (Criteria) this; + } + + public Criteria andCallbackGreaterThanOrEqualTo(String value) { + addCriterion("callback >=", value, "callback"); + return (Criteria) this; + } + + public Criteria andCallbackLessThan(String value) { + addCriterion("callback <", value, "callback"); + return (Criteria) this; + } + + public Criteria andCallbackLessThanOrEqualTo(String value) { + addCriterion("callback <=", value, "callback"); + return (Criteria) this; + } + + public Criteria andCallbackLike(String value) { + addCriterion("callback like", value, "callback"); + return (Criteria) this; + } + + public Criteria andCallbackNotLike(String value) { + addCriterion("callback not like", value, "callback"); + return (Criteria) this; + } + + public Criteria andCallbackIn(List values) { + addCriterion("callback in", values, "callback"); + return (Criteria) this; + } + + public Criteria andCallbackNotIn(List values) { + addCriterion("callback not in", values, "callback"); + return (Criteria) this; + } + + public Criteria andCallbackBetween(String value1, String value2) { + addCriterion("callback between", value1, value2, "callback"); + return (Criteria) this; + } + + public Criteria andCallbackNotBetween(String value1, String value2) { + addCriterion("callback not between", value1, value2, "callback"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/SysMsgChannelMapper.java b/backend/src/main/java/io/dataease/base/mapper/SysMsgChannelMapper.java new file mode 100644 index 0000000000..06948bd2f7 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/SysMsgChannelMapper.java @@ -0,0 +1,30 @@ +package io.dataease.base.mapper; + +import io.dataease.base.domain.SysMsgChannel; +import io.dataease.base.domain.SysMsgChannelExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface SysMsgChannelMapper { + long countByExample(SysMsgChannelExample example); + + int deleteByExample(SysMsgChannelExample example); + + int deleteByPrimaryKey(Long msgChannelId); + + int insert(SysMsgChannel record); + + int insertSelective(SysMsgChannel record); + + List selectByExample(SysMsgChannelExample example); + + SysMsgChannel selectByPrimaryKey(Long msgChannelId); + + int updateByExampleSelective(@Param("record") SysMsgChannel record, @Param("example") SysMsgChannelExample example); + + int updateByExample(@Param("record") SysMsgChannel record, @Param("example") SysMsgChannelExample example); + + int updateByPrimaryKeySelective(SysMsgChannel record); + + int updateByPrimaryKey(SysMsgChannel record); +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/SysMsgChannelMapper.xml b/backend/src/main/java/io/dataease/base/mapper/SysMsgChannelMapper.xml new file mode 100644 index 0000000000..9e8a89dcdf --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/SysMsgChannelMapper.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + msg_channel_id, channel_name + + + + + delete from sys_msg_channel + where msg_channel_id = #{msgChannelId,jdbcType=BIGINT} + + + delete from sys_msg_channel + + + + + + insert into sys_msg_channel (msg_channel_id, channel_name) + values (#{msgChannelId,jdbcType=BIGINT}, #{channelName,jdbcType=VARCHAR}) + + + insert into sys_msg_channel + + + msg_channel_id, + + + channel_name, + + + + + #{msgChannelId,jdbcType=BIGINT}, + + + #{channelName,jdbcType=VARCHAR}, + + + + + + update sys_msg_channel + + + msg_channel_id = #{record.msgChannelId,jdbcType=BIGINT}, + + + channel_name = #{record.channelName,jdbcType=VARCHAR}, + + + + + + + + update sys_msg_channel + set msg_channel_id = #{record.msgChannelId,jdbcType=BIGINT}, + channel_name = #{record.channelName,jdbcType=VARCHAR} + + + + + + update sys_msg_channel + + + channel_name = #{channelName,jdbcType=VARCHAR}, + + + where msg_channel_id = #{msgChannelId,jdbcType=BIGINT} + + + update sys_msg_channel + set channel_name = #{channelName,jdbcType=VARCHAR} + where msg_channel_id = #{msgChannelId,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/SysMsgMapper.xml b/backend/src/main/java/io/dataease/base/mapper/SysMsgMapper.xml index d13dafb604..ac47b7b666 100644 --- a/backend/src/main/java/io/dataease/base/mapper/SysMsgMapper.xml +++ b/backend/src/main/java/io/dataease/base/mapper/SysMsgMapper.xml @@ -4,9 +4,8 @@ - + - @@ -71,7 +70,7 @@ - msg_id, user_id, `type`, `status`, router, param, create_time, read_time, content + msg_id, user_id, type_id, `status`, param, create_time, read_time, content + select + + distinct + + + from sys_msg_setting + + + + + order by ${orderByClause} + + + + + delete from sys_msg_setting + where msg_setting_id = #{msgSettingId,jdbcType=BIGINT} + + + delete from sys_msg_setting + + + + + + insert into sys_msg_setting (msg_setting_id, user_id, type_id, + channel_id, `enable`) + values (#{msgSettingId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{typeId,jdbcType=BIGINT}, + #{channelId,jdbcType=BIGINT}, #{enable,jdbcType=BIT}) + + + insert into sys_msg_setting + + + msg_setting_id, + + + user_id, + + + type_id, + + + channel_id, + + + `enable`, + + + + + #{msgSettingId,jdbcType=BIGINT}, + + + #{userId,jdbcType=BIGINT}, + + + #{typeId,jdbcType=BIGINT}, + + + #{channelId,jdbcType=BIGINT}, + + + #{enable,jdbcType=BIT}, + + + + + + update sys_msg_setting + + + msg_setting_id = #{record.msgSettingId,jdbcType=BIGINT}, + + + user_id = #{record.userId,jdbcType=BIGINT}, + + + type_id = #{record.typeId,jdbcType=BIGINT}, + + + channel_id = #{record.channelId,jdbcType=BIGINT}, + + + `enable` = #{record.enable,jdbcType=BIT}, + + + + + + + + update sys_msg_setting + set msg_setting_id = #{record.msgSettingId,jdbcType=BIGINT}, + user_id = #{record.userId,jdbcType=BIGINT}, + type_id = #{record.typeId,jdbcType=BIGINT}, + channel_id = #{record.channelId,jdbcType=BIGINT}, + `enable` = #{record.enable,jdbcType=BIT} + + + + + + update sys_msg_setting + + + user_id = #{userId,jdbcType=BIGINT}, + + + type_id = #{typeId,jdbcType=BIGINT}, + + + channel_id = #{channelId,jdbcType=BIGINT}, + + + `enable` = #{enable,jdbcType=BIT}, + + + where msg_setting_id = #{msgSettingId,jdbcType=BIGINT} + + + update sys_msg_setting + set user_id = #{userId,jdbcType=BIGINT}, + type_id = #{typeId,jdbcType=BIGINT}, + channel_id = #{channelId,jdbcType=BIGINT}, + `enable` = #{enable,jdbcType=BIT} + where msg_setting_id = #{msgSettingId,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/SysMsgTypeMapper.java b/backend/src/main/java/io/dataease/base/mapper/SysMsgTypeMapper.java new file mode 100644 index 0000000000..8d156a832d --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/SysMsgTypeMapper.java @@ -0,0 +1,30 @@ +package io.dataease.base.mapper; + +import io.dataease.base.domain.SysMsgType; +import io.dataease.base.domain.SysMsgTypeExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface SysMsgTypeMapper { + long countByExample(SysMsgTypeExample example); + + int deleteByExample(SysMsgTypeExample example); + + int deleteByPrimaryKey(Long msgTypeId); + + int insert(SysMsgType record); + + int insertSelective(SysMsgType record); + + List selectByExample(SysMsgTypeExample example); + + SysMsgType selectByPrimaryKey(Long msgTypeId); + + int updateByExampleSelective(@Param("record") SysMsgType record, @Param("example") SysMsgTypeExample example); + + int updateByExample(@Param("record") SysMsgType record, @Param("example") SysMsgTypeExample example); + + int updateByPrimaryKeySelective(SysMsgType record); + + int updateByPrimaryKey(SysMsgType record); +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/SysMsgTypeMapper.xml b/backend/src/main/java/io/dataease/base/mapper/SysMsgTypeMapper.xml new file mode 100644 index 0000000000..c3cc487413 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/SysMsgTypeMapper.xml @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + msg_type_id, pid, type_name, router, callback + + + + + delete from sys_msg_type + where msg_type_id = #{msgTypeId,jdbcType=BIGINT} + + + delete from sys_msg_type + + + + + + insert into sys_msg_type (msg_type_id, pid, type_name, + router, callback) + values (#{msgTypeId,jdbcType=BIGINT}, #{pid,jdbcType=BIGINT}, #{typeName,jdbcType=VARCHAR}, + #{router,jdbcType=VARCHAR}, #{callback,jdbcType=VARCHAR}) + + + insert into sys_msg_type + + + msg_type_id, + + + pid, + + + type_name, + + + router, + + + callback, + + + + + #{msgTypeId,jdbcType=BIGINT}, + + + #{pid,jdbcType=BIGINT}, + + + #{typeName,jdbcType=VARCHAR}, + + + #{router,jdbcType=VARCHAR}, + + + #{callback,jdbcType=VARCHAR}, + + + + + + update sys_msg_type + + + msg_type_id = #{record.msgTypeId,jdbcType=BIGINT}, + + + pid = #{record.pid,jdbcType=BIGINT}, + + + type_name = #{record.typeName,jdbcType=VARCHAR}, + + + router = #{record.router,jdbcType=VARCHAR}, + + + callback = #{record.callback,jdbcType=VARCHAR}, + + + + + + + + update sys_msg_type + set msg_type_id = #{record.msgTypeId,jdbcType=BIGINT}, + pid = #{record.pid,jdbcType=BIGINT}, + type_name = #{record.typeName,jdbcType=VARCHAR}, + router = #{record.router,jdbcType=VARCHAR}, + callback = #{record.callback,jdbcType=VARCHAR} + + + + + + update sys_msg_type + + + pid = #{pid,jdbcType=BIGINT}, + + + type_name = #{typeName,jdbcType=VARCHAR}, + + + router = #{router,jdbcType=VARCHAR}, + + + callback = #{callback,jdbcType=VARCHAR}, + + + where msg_type_id = #{msgTypeId,jdbcType=BIGINT} + + + update sys_msg_type + set pid = #{pid,jdbcType=BIGINT}, + type_name = #{typeName,jdbcType=VARCHAR}, + router = #{router,jdbcType=VARCHAR}, + callback = #{callback,jdbcType=VARCHAR} + where msg_type_id = #{msgTypeId,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysMsgMapper.java b/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysMsgMapper.java index 9d5c2ad132..676b746ab2 100644 --- a/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysMsgMapper.java +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysMsgMapper.java @@ -1,5 +1,8 @@ package io.dataease.base.mapper.ext; +import io.dataease.base.domain.SysMsgExample; +import io.dataease.base.mapper.ext.query.GridExample; +import io.dataease.controller.message.dto.MsgGridDto; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -33,4 +36,7 @@ public interface ExtSysMsgMapper { int batchDelete(@Param("msgIds") List msgIds); + List queryGrid(SysMsgExample example); + + } diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysMsgMapper.xml b/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysMsgMapper.xml new file mode 100644 index 0000000000..53892fc215 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtSysMsgMapper.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + diff --git a/backend/src/main/java/io/dataease/commons/constants/SysMsgConstants.java b/backend/src/main/java/io/dataease/commons/constants/SysMsgConstants.java new file mode 100644 index 0000000000..206bfbc264 --- /dev/null +++ b/backend/src/main/java/io/dataease/commons/constants/SysMsgConstants.java @@ -0,0 +1,7 @@ +package io.dataease.commons.constants; + +public class SysMsgConstants { + + public final static String SYS_MSG_CHANNEL = "sys_msg_channel"; + public final static String SYS_MSG_TYPE = "sys_msg_type"; +} diff --git a/backend/src/main/java/io/dataease/controller/message/MsgController.java b/backend/src/main/java/io/dataease/controller/message/MsgController.java index a3125df1de..51415ea0ff 100644 --- a/backend/src/main/java/io/dataease/controller/message/MsgController.java +++ b/backend/src/main/java/io/dataease/controller/message/MsgController.java @@ -2,16 +2,21 @@ package io.dataease.controller.message; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; -import io.dataease.base.domain.SysMsg; +import io.dataease.base.domain.SysMsgChannel; +import io.dataease.base.domain.SysMsgSetting; +import io.dataease.base.domain.SysMsgType; import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.PageUtils; import io.dataease.commons.utils.Pager; +import io.dataease.controller.handler.annotation.I18n; +import io.dataease.controller.message.dto.MsgGridDto; import io.dataease.controller.message.dto.MsgRequest; +import io.dataease.controller.message.dto.MsgSettingRequest; +import io.dataease.controller.message.dto.SettingTreeNode; import io.dataease.service.message.SysMsgService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; - import javax.annotation.Resource; import java.util.List; @@ -25,10 +30,10 @@ public class MsgController { @ApiOperation("查询消息") @PostMapping("/list/{goPage}/{pageSize}") - public Pager> messages(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody MsgRequest msgRequest) { + public Pager> messages(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody MsgRequest msgRequest) { Long userId = AuthUtils.getUser().getUserId(); Page page = PageHelper.startPage(goPage, pageSize, true); - Pager> listPager = PageUtils.setPageInfo(page, sysMsgService.query(userId, msgRequest)); + Pager> listPager = PageUtils.setPageInfo(page, sysMsgService.queryGrid(userId, msgRequest)); return listPager; } @@ -47,4 +52,34 @@ public class MsgController { public void batchDelete(@RequestBody List msgIds) { sysMsgService.batchDelete(msgIds); } + + @I18n + @PostMapping("/treeNodes") + public List treeNodes() { + + return sysMsgService.treeNodes(); + } + + @I18n + @PostMapping("/channelList") + public List channelList() { + return sysMsgService.channelList(); + } + + @PostMapping("/settingList") + public List settingList() { + return sysMsgService.settingList(); + } + + @PostMapping("/updateSetting") + public void updateSetting(@RequestBody MsgSettingRequest request) { + sysMsgService.updateSetting(request); + } + + @I18n + @PostMapping("/types") + public List allTypes() { + List sysMsgTypes = sysMsgService.queryMsgTypes(); + return sysMsgTypes; + } } diff --git a/backend/src/main/java/io/dataease/controller/message/dto/MsgGridDto.java b/backend/src/main/java/io/dataease/controller/message/dto/MsgGridDto.java new file mode 100644 index 0000000000..f88d6a57f3 --- /dev/null +++ b/backend/src/main/java/io/dataease/controller/message/dto/MsgGridDto.java @@ -0,0 +1,11 @@ +package io.dataease.controller.message.dto; + +import io.dataease.base.domain.SysMsg; +import lombok.Data; + +@Data +public class MsgGridDto extends SysMsg { + + private String router; + private String callback; +} diff --git a/backend/src/main/java/io/dataease/controller/message/dto/MsgRequest.java b/backend/src/main/java/io/dataease/controller/message/dto/MsgRequest.java index c081703309..6f9c3daba2 100644 --- a/backend/src/main/java/io/dataease/controller/message/dto/MsgRequest.java +++ b/backend/src/main/java/io/dataease/controller/message/dto/MsgRequest.java @@ -10,7 +10,7 @@ public class MsgRequest implements Serializable { private static final long serialVersionUID = 1920091635946508658L; - private Integer type; + private Long type; private Boolean status; diff --git a/backend/src/main/java/io/dataease/controller/message/dto/MsgSettingRequest.java b/backend/src/main/java/io/dataease/controller/message/dto/MsgSettingRequest.java new file mode 100644 index 0000000000..3f1ec00b85 --- /dev/null +++ b/backend/src/main/java/io/dataease/controller/message/dto/MsgSettingRequest.java @@ -0,0 +1,14 @@ +package io.dataease.controller.message.dto; + + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class MsgSettingRequest implements Serializable { + + private Long typeId; + + private Long channelId; +} diff --git a/backend/src/main/java/io/dataease/controller/message/dto/SettingTreeNode.java b/backend/src/main/java/io/dataease/controller/message/dto/SettingTreeNode.java new file mode 100644 index 0000000000..154147a223 --- /dev/null +++ b/backend/src/main/java/io/dataease/controller/message/dto/SettingTreeNode.java @@ -0,0 +1,19 @@ +package io.dataease.controller.message.dto; + + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class SettingTreeNode implements Serializable { + + private static final long serialVersionUID = -2416283978185545199L; + + private Long id; + + private String name; + + private List children; +} diff --git a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java index 008f2309bd..fedb4262c2 100644 --- a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java +++ b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java @@ -25,7 +25,6 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.poi.hssf.usermodel.HSSFSheet; @@ -60,11 +59,9 @@ import org.pentaho.di.trans.steps.userdefinedjavaclass.UserDefinedJavaClassDef; import org.pentaho.di.trans.steps.userdefinedjavaclass.UserDefinedJavaClassMeta; import org.pentaho.di.www.SlaveServerJobStatus; import org.quartz.JobExecutionContext; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; - import javax.annotation.Resource; import java.io.File; import java.io.FileInputStream; @@ -337,6 +334,7 @@ public class ExtractDataService { private void sendWebMsg(DatasetTable datasetTable, String taskId, Boolean status) { String msg = status ? "成功" : "失败"; + Long typeId = status ? 5L : 6L; String id = datasetTable.getId(); AuthURD authURD = AuthUtils.authURDR(id); Set userIds = AuthUtils.userIdsByURD(authURD); @@ -345,7 +343,7 @@ public class ExtractDataService { Map param = new HashMap<>(); param.put("tableId", id); param.put("taskId", taskId); - DeMsgutil.sendMsg(userId, 1, "数据集【"+datasetTable.getName()+"】同步"+msg, gson.toJson(param)); + DeMsgutil.sendMsg(userId, typeId, 1L, "数据集【"+datasetTable.getName()+"】同步"+msg, gson.toJson(param)); }); } diff --git a/backend/src/main/java/io/dataease/service/message/DeMsgutil.java b/backend/src/main/java/io/dataease/service/message/DeMsgutil.java index fc1b3d354b..765d9e27e8 100644 --- a/backend/src/main/java/io/dataease/service/message/DeMsgutil.java +++ b/backend/src/main/java/io/dataease/service/message/DeMsgutil.java @@ -4,21 +4,11 @@ import io.dataease.base.domain.SysMsg; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; -import java.util.HashMap; -import java.util.Map; @Component public class DeMsgutil { - private static Map routerMap ; - @PostConstruct - public void init() { - routerMap = new HashMap<>(); - routerMap.put(0, "panel"); - routerMap.put(1, "dataset"); - } private static SysMsgService sysMsgService; @@ -27,27 +17,18 @@ public class DeMsgutil { DeMsgutil.sysMsgService = sysMsgService; } - public static void sendMsg(Long userId, int type, String content) { - SysMsg sysMsg = new SysMsg(); - sysMsg.setUserId(userId); - sysMsg.setType(type); - sysMsg.setContent(content); - sysMsg.setRouter(routerMap.get(type)); - sysMsg.setStatus(false); - sysMsg.setCreateTime(System.currentTimeMillis()); - sysMsgService.save(sysMsg); - } - public static void sendMsg(Long userId, int type, String content, String param) { + + public static void sendMsg(Long userId, Long typeId, Long channelId, String content, String param) { SysMsg sysMsg = new SysMsg(); sysMsg.setUserId(userId); - sysMsg.setType(type); + sysMsg.setTypeId(typeId); sysMsg.setContent(content); - sysMsg.setRouter(routerMap.get(type)); sysMsg.setStatus(false); sysMsg.setCreateTime(System.currentTimeMillis()); sysMsg.setParam(param); sysMsgService.save(sysMsg); } + } diff --git a/backend/src/main/java/io/dataease/service/message/MsgAop.java b/backend/src/main/java/io/dataease/service/message/MsgAop.java new file mode 100644 index 0000000000..1dc102206a --- /dev/null +++ b/backend/src/main/java/io/dataease/service/message/MsgAop.java @@ -0,0 +1,55 @@ +package io.dataease.service.message; + +import io.dataease.base.domain.SysMsgSettingExample; +import io.dataease.base.mapper.SysMsgSettingMapper; +import org.apache.commons.lang3.ObjectUtils; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; +import javax.annotation.Resource; + +@Aspect +@Component +public class MsgAop { + + @Resource + private SysMsgSettingMapper sysMsgSettingMapper; + + + + + + /** + * 对sendMsg 切面拦截 + * @param point + */ + @Around("(execution(* io.dataease.service.message.DeMsgutil.sendMsg(..)))") + public Object cutPoint(ProceedingJoinPoint point) { + + Object[] args = point.getArgs(); + Object arg0 = args[0]; + Object arg1 = args[1]; + Object arg2 = args[2]; + + if (ObjectUtils.isEmpty(arg0) || ObjectUtils.isEmpty(arg1) || ObjectUtils.isEmpty(arg2)) { + return null; + } + Long userId = (Long) arg0; + Long typeId = (Long) arg1; + Long channelId = (Long) arg2; + + SysMsgSettingExample example = new SysMsgSettingExample(); + example.createCriteria().andChannelIdEqualTo(channelId).andUserIdEqualTo(userId).andTypeIdEqualTo(typeId).andEnableEqualTo(true); + + try { + if (sysMsgSettingMapper.countByExample(example) > 0) + return point.proceed(args); + return null; + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + return null; + + } +} diff --git a/backend/src/main/java/io/dataease/service/message/SysMsgService.java b/backend/src/main/java/io/dataease/service/message/SysMsgService.java index 6c9a4273c0..9f8255bc4d 100644 --- a/backend/src/main/java/io/dataease/service/message/SysMsgService.java +++ b/backend/src/main/java/io/dataease/service/message/SysMsgService.java @@ -1,16 +1,29 @@ package io.dataease.service.message; -import io.dataease.base.domain.SysMsg; -import io.dataease.base.domain.SysMsgExample; +import io.dataease.base.domain.*; +import io.dataease.base.mapper.SysMsgChannelMapper; import io.dataease.base.mapper.SysMsgMapper; +import io.dataease.base.mapper.SysMsgSettingMapper; +import io.dataease.base.mapper.SysMsgTypeMapper; import io.dataease.base.mapper.ext.ExtSysMsgMapper; +import io.dataease.commons.constants.AuthConstants; +import io.dataease.commons.constants.SysMsgConstants; +import io.dataease.commons.utils.AuthUtils; +import io.dataease.commons.utils.CommonBeanFactory; +import io.dataease.controller.message.dto.MsgGridDto; import io.dataease.controller.message.dto.MsgRequest; +import io.dataease.controller.message.dto.MsgSettingRequest; +import io.dataease.controller.message.dto.SettingTreeNode; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Service public class SysMsgService { @@ -21,6 +34,17 @@ public class SysMsgService { @Resource private ExtSysMsgMapper extSysMsgMapper; + + @Resource + private SysMsgTypeMapper sysMsgTypeMapper; + + + @Resource + private SysMsgChannelMapper sysMsgChannelMapper; + + @Resource + private SysMsgSettingMapper sysMsgSettingMapper; + public List query(Long userId, MsgRequest msgRequest) { String orderClause = " create_time desc"; SysMsgExample example = new SysMsgExample(); @@ -34,7 +58,7 @@ public class SysMsgService { } if (ObjectUtils.isNotEmpty(msgRequest.getType())) { - criteria.andTypeEqualTo(msgRequest.getType()); + criteria.andTypeIdEqualTo(msgRequest.getType()); } if (ObjectUtils.isNotEmpty(msgRequest.getStatus())) { @@ -46,6 +70,36 @@ public class SysMsgService { return sysMsgs; } + public List queryGrid(Long userId, MsgRequest msgRequest) { + String orderClause = " create_time desc"; + SysMsgExample example = new SysMsgExample(); + SysMsgExample.Criteria criteria = example.createCriteria(); + criteria.andUserIdEqualTo(userId); + + List orders = msgRequest.getOrders(); + + if (CollectionUtils.isNotEmpty(orders)) { + orderClause = String.join(", ", orders); + } + + if (ObjectUtils.isNotEmpty(msgRequest.getType())) { + SysMsgTypeExample sysMsgTypeExample = new SysMsgTypeExample(); + sysMsgTypeExample.createCriteria().andPidEqualTo(msgRequest.getType()); + + List sysMsgTypes = sysMsgTypeMapper.selectByExample(sysMsgTypeExample); + List typeIds = sysMsgTypes.stream().map(SysMsgType::getMsgTypeId).collect(Collectors.toList()); + criteria.andTypeIdIn(typeIds); + } + + if (ObjectUtils.isNotEmpty(msgRequest.getStatus())) { + criteria.andStatusEqualTo(msgRequest.getStatus()); + } + + example.setOrderByClause(orderClause); + List msgGridDtos = extSysMsgMapper.queryGrid(example); + return msgGridDtos; + } + public void setReaded(Long msgId) { SysMsg sysMsg = new SysMsg(); sysMsg.setMsgId(msgId); @@ -67,4 +121,86 @@ public class SysMsgService { } + public List treeNodes() { + SysMsgService proxy = CommonBeanFactory.getBean(SysMsgService.class); + List sysMsgTypes = proxy.queryMsgTypes(); + return buildTree(sysMsgTypes); + } + + @Cacheable(SysMsgConstants.SYS_MSG_TYPE) + public List queryMsgTypes() { + SysMsgTypeExample example = new SysMsgTypeExample(); + List sysMsgTypes = sysMsgTypeMapper.selectByExample(example); + return sysMsgTypes; + } + + private List buildTree(List lists){ + List rootNodes = new ArrayList<>(); + lists.forEach(node -> { + SettingTreeNode settingTreeNode = convert(node); + if (isParent(node)) { + rootNodes.add(settingTreeNode); + } + lists.forEach(tNode -> { + if (tNode.getPid() == settingTreeNode.getId()) { + if (settingTreeNode.getChildren() == null) { + settingTreeNode.setChildren(new ArrayList()); + } + settingTreeNode.getChildren().add(convert(tNode)); + } + }); + }); + return rootNodes; + } + + private Boolean isParent(SysMsgType typeNode) { + return typeNode.getPid() == 0L; + } + + public SettingTreeNode convert(SysMsgType typeNode) { + SettingTreeNode settingTreeNode = new SettingTreeNode(); + settingTreeNode.setId(typeNode.getMsgTypeId()); + settingTreeNode.setName(typeNode.getTypeName()); + return settingTreeNode; + } + + + @Cacheable(SysMsgConstants.SYS_MSG_CHANNEL) + public List channelList() { + SysMsgChannelExample example = new SysMsgChannelExample(); + return sysMsgChannelMapper.selectByExample(example); + } + + public List settingList() { + Long userId = AuthUtils.getUser().getUserId(); + SysMsgSettingExample example = new SysMsgSettingExample(); + example.createCriteria().andUserIdEqualTo(userId); + List sysMsgSettings = sysMsgSettingMapper.selectByExample(example); + return sysMsgSettings; + } + + @Transactional + public void updateSetting(MsgSettingRequest request) { + Long typeId = request.getTypeId(); + Long channelId = request.getChannelId(); + Long userId = AuthUtils.getUser().getUserId(); + SysMsgSettingExample example = new SysMsgSettingExample(); + example.createCriteria().andUserIdEqualTo(userId).andTypeIdEqualTo(typeId).andChannelIdEqualTo(channelId); + List sysMsgSettings = sysMsgSettingMapper.selectByExample(example); + if (CollectionUtils.isNotEmpty(sysMsgSettings)) { + sysMsgSettings.forEach(setting -> { + setting.setEnable(!setting.getEnable()); + sysMsgSettingMapper.updateByPrimaryKeySelective(setting); + }); + return; + } + SysMsgSetting sysMsgSetting = new SysMsgSetting(); + sysMsgSetting.setEnable(true); + sysMsgSetting.setChannelId(channelId); + sysMsgSetting.setTypeId(typeId); + sysMsgSetting.setUserId(userId); + sysMsgSettingMapper.insert(sysMsgSetting); + } + + } diff --git a/backend/src/main/java/io/dataease/service/panel/ShareService.java b/backend/src/main/java/io/dataease/service/panel/ShareService.java index 8165df9932..7656b61bcf 100644 --- a/backend/src/main/java/io/dataease/service/panel/ShareService.java +++ b/backend/src/main/java/io/dataease/service/panel/ShareService.java @@ -133,14 +133,14 @@ public class ShareService { List msgParam = new ArrayList(); msgParam.add(panelGroupId); addUserIdSet.forEach(userId -> { - if (!redUserIdSet.contains(userId)){ - DeMsgutil.sendMsg(userId, 0, user.getNickName()+" 分享了仪表板【"+msg+"】,请查收!", gson.toJson(msgParam)); + if (!redUserIdSet.contains(userId) && user.getUserId() != userId){ + DeMsgutil.sendMsg(userId, 2L, 1L,user.getNickName()+" 分享了仪表板【"+msg+"】,请查收!", gson.toJson(msgParam)); } }); redUserIdSet.forEach(userId -> { - if (!addUserIdSet.contains(userId)){ - DeMsgutil.sendMsg(userId, 0, user.getNickName()+" 取消分享了仪表板【"+msg+"】,请查收!", gson.toJson(msgParam)); + if (!addUserIdSet.contains(userId) && user.getUserId() != userId){ + DeMsgutil.sendMsg(userId, 3L, 1L,user.getNickName()+" 取消分享了仪表板【"+msg+"】,请查收!", gson.toJson(msgParam)); } }); @@ -263,7 +263,7 @@ public class ShareService { Gson gson = new Gson(); userIdSet.forEach(userId -> { // DeMsgutil.sendMsg(userId, 0, user.getNickName()+" 分享了仪表板【"+msg+"】给您,请查收!"); - DeMsgutil.sendMsg(userId, 0, user.getNickName()+" 分享了仪表板【"+msg+"】给您,请查收!", gson.toJson(panelIds)); + DeMsgutil.sendMsg(userId, 2L,1L, user.getNickName()+" 分享了仪表板【"+msg+"】给您,请查收!", gson.toJson(panelIds)); }); } diff --git a/backend/src/main/resources/ehcache/ehcache.xml b/backend/src/main/resources/ehcache/ehcache.xml index 8f3bf770f0..3407f77ff9 100644 --- a/backend/src/main/resources/ehcache/ehcache.xml +++ b/backend/src/main/resources/ehcache/ehcache.xml @@ -95,4 +95,25 @@ /> + + + + + + + \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index daa0be9874..9265246666 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -266,4 +266,10 @@ i18n_schema_is_empty=Database schema is empty 所有消息=All Messages 未读消息=Unread Messages 已读消息=Read Messages +接收管理=Receive Manage +i18n_msg_type_panel_share=Dashboard sharing +i18n_msg_type_panel_share_cacnel=Dashboard unshared +i18n_msg_type_dataset_sync=Data set synchronization +i18n_msg_type_dataset_sync_success=Dataset synchronization successful +i18n_msg_type_dataset_sync_faild=Dataset synchronization failed i18n_data_not_sync=Please sync data first \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 0871efe0cd..afd2b013fe 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -265,4 +265,10 @@ i18n_schema_is_empty=数据库 Schema 为空 所有消息=所有消息 未读消息=未读消息 已读消息=已读消息 +接收管理=接收管理 +i18n_msg_type_panel_share=仪表板分享 +i18n_msg_type_panel_share_cacnel=仪表板取消分享 +i18n_msg_type_dataset_sync=数据集同步 +i18n_msg_type_dataset_sync_success=数据集同步成功 +i18n_msg_type_dataset_sync_faild=数据集同步失败 i18n_data_not_sync=请先完成数据同步 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 1dccd068c1..8edc897158 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -268,4 +268,10 @@ i18n_schema_is_empty=數據庫 Schema 為空 所有消息=所有消息 未读消息=未讀消息 已读消息=已讀消息 +接收管理=接收管理 +i18n_msg_type_panel_share=儀表板分享 +i18n_msg_type_panel_share_cacnel=儀表板取消分享 +i18n_msg_type_dataset_sync=數據集同步 +i18n_msg_type_dataset_sync_success=數據集同步成功 +i18n_msg_type_dataset_sync_faild=數據集同步失敗 i18n_data_not_sync=請先完成數據同步 \ No newline at end of file diff --git a/frontend/src/api/system/msg.js b/frontend/src/api/system/msg.js index 0f4cc70dfe..bf13395a41 100644 --- a/frontend/src/api/system/msg.js +++ b/frontend/src/api/system/msg.js @@ -26,3 +26,44 @@ export function batchRead(data) { }) } +export function treeList() { + return request({ + url: '/api/sys_msg/treeNodes', + method: 'post', + loading: true + }) +} + +export function channelList() { + return request({ + url: '/api/sys_msg/channelList', + method: 'post', + loading: true + }) +} + +export function settingList() { + return request({ + url: '/api/sys_msg/settingList', + method: 'post', + loading: true + }) +} + +export function updateSetting(data) { + return request({ + url: '/api/sys_msg/updateSetting', + method: 'post', + loading: true, + data + }) +} + +export function allTypes(data) { + return request({ + url: '/api/sys_msg/types', + method: 'post', + loading: true + }) +} + diff --git a/frontend/src/components/Notification/index.vue b/frontend/src/components/Notification/index.vue index 1d2a307a31..4ec8f8102d 100644 --- a/frontend/src/components/Notification/index.vue +++ b/frontend/src/components/Notification/index.vue @@ -31,7 +31,7 @@
-
【{{ $t(getTypeName(scope.row.type)) }}】  {{ scope.row.content }}
+
【{{ getTypeName(scope.row.typeId) }}】  {{ scope.row.content }}
{{ scope.row.createTime | timestampFormatDate }}
+
+ + + + + +
+ + + + + + + + + + diff --git a/frontend/src/views/msg/unread.vue b/frontend/src/views/msg/unread.vue index c5bfd90319..6482e67ddc 100644 --- a/frontend/src/views/msg/unread.vue +++ b/frontend/src/views/msg/unread.vue @@ -2,7 +2,7 @@ - {{ $t(item.label) }} + {{ $t(item.typeName) }} @@ -61,7 +61,7 @@ import LayoutContent from '@/components/business/LayoutContent' import ComplexTable from '@/components/business/complex-table' import { query, updateStatus, batchRead } from '@/api/system/msg' -import { msgTypes, getTypeName } from '@/utils/webMsg' +import { msgTypes, getTypeName, loadMsgTypes } from '@/utils/webMsg' import bus from '@/utils/bus' import { addOrder, formatOrders } from '@/utils/index' @@ -100,6 +100,10 @@ export default { mounted() { this.search() }, + created() { + // 先加载消息类型 + loadMsgTypes() + }, methods: { select(selection) { }, From d58b06928edc74c46be55ee0a9dcc2fe96a325c5 Mon Sep 17 00:00:00 2001 From: junjie Date: Sat, 10 Jul 2021 10:47:47 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E5=BA=95=E5=B1=82sql=E6=8B=BC=E6=8E=A5?= =?UTF-8?q?=E4=BD=BF=E7=94=A8stg=E9=87=8D=E6=9E=84(mysql=E9=83=A8=E5=88=86?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/pom.xml | 5 + .../datasource/constants/DatasourceTypes.java | 52 +- .../java/io/dataease/dto/sqlObj/SQLObj.java | 29 + .../io/dataease/provider/SQLConstants.java | 25 + .../provider/mysql/MySQLConstants.java | 41 ++ .../provider/mysql/MysqlQueryProvider.java | 616 ++++++++++-------- .../src/main/resources/sql/sqlTemplate.stg | 28 + 7 files changed, 529 insertions(+), 267 deletions(-) create mode 100644 backend/src/main/java/io/dataease/dto/sqlObj/SQLObj.java create mode 100644 backend/src/main/java/io/dataease/provider/mysql/MySQLConstants.java create mode 100644 backend/src/main/resources/sql/sqlTemplate.stg diff --git a/backend/pom.xml b/backend/pom.xml index 500999f194..b7bb00609b 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -365,6 +365,11 @@ 12.2.0.1 + + org.antlr + ST4 + 4.0.8 + diff --git a/backend/src/main/java/io/dataease/datasource/constants/DatasourceTypes.java b/backend/src/main/java/io/dataease/datasource/constants/DatasourceTypes.java index 2d77ec9549..fcaf060a42 100644 --- a/backend/src/main/java/io/dataease/datasource/constants/DatasourceTypes.java +++ b/backend/src/main/java/io/dataease/datasource/constants/DatasourceTypes.java @@ -1,5 +1,55 @@ package io.dataease.datasource.constants; public enum DatasourceTypes { - mysql, sqlServer, excel, doris, oracle + excel("excel", "excel", "", "", "", "", ""), + mysql("mysql", "mysql", "com.mysql.jdbc.Driver", "`", "`", "'", "'"), + sqlServer("sqlServer", "sqlServer", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "\"", "\"", "\"", "\""), + doris("doris", "doris", "com.mysql.jdbc.Driver", "`", "`", "", ""), + oracle("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\""); + + private String feature; + private String desc; + private String driver; + private String keywordPrefix; + private String keywordSuffix; + private String aliasPrefix; + private String aliasSuffix; + + DatasourceTypes(String feature, String desc, String driver, String keywordPrefix, String keywordSuffix, String aliasPrefix, String aliasSuffix) { + this.feature = feature; + this.desc = desc; + this.driver = driver; + this.keywordPrefix = keywordPrefix; + this.keywordSuffix = keywordSuffix; + this.aliasPrefix = aliasPrefix; + this.aliasSuffix = aliasSuffix; + } + + public String getFeature() { + return feature; + } + + public String getDesc() { + return desc; + } + + public String getDriver() { + return driver; + } + + public String getKeywordPrefix() { + return keywordPrefix; + } + + public String getKeywordSuffix() { + return keywordSuffix; + } + + public String getAliasPrefix() { + return aliasPrefix; + } + + public String getAliasSuffix() { + return aliasSuffix; + } } diff --git a/backend/src/main/java/io/dataease/dto/sqlObj/SQLObj.java b/backend/src/main/java/io/dataease/dto/sqlObj/SQLObj.java new file mode 100644 index 0000000000..4505f205a7 --- /dev/null +++ b/backend/src/main/java/io/dataease/dto/sqlObj/SQLObj.java @@ -0,0 +1,29 @@ +package io.dataease.dto.sqlObj; + +import lombok.Builder; +import lombok.Data; + +/** + * @Author gin + * @Date 2021/7/9 12:12 下午 + */ +@Data +@Builder +public class SQLObj { + private String tableName; + private String tableAlias; + + private String fieldName; + private String fieldAlias; + + private String groupField; + private String groupAlias; + + private String orderField; + private String orderAlias; + private String orderDirection; + + private String whereField; + private String whereAlias; + private String whereTermAndValue; +} diff --git a/backend/src/main/java/io/dataease/provider/SQLConstants.java b/backend/src/main/java/io/dataease/provider/SQLConstants.java index a0dacbd57a..76335f84bb 100644 --- a/backend/src/main/java/io/dataease/provider/SQLConstants.java +++ b/backend/src/main/java/io/dataease/provider/SQLConstants.java @@ -8,9 +8,34 @@ import java.util.List; * @Date 2021/7/8 3:12 下午 */ public class SQLConstants { + /** + * 维度类型list + */ public static final List DIMENSION_TYPE = new ArrayList() {{ add(0);// 文本 add(1);// 时间 add(5);// 地理位置 }}; + + /** + * 指标类型list + */ + public static final List QUOTA_TYPE = new ArrayList() {{ + add(2);// 整型 + add(3);// 浮点 + add(4);// 布尔 + }}; + + /** + * sql ST模板 + */ + public static final String SQL_TEMPLATE = "sql/sqlTemplate.stg"; + + public static final String TABLE_ALIAS_PREFIX = "T_A_%s"; + public static final String FIELD_ALIAS_X_PREFIX = "F_AX_%s"; + public static final String FIELD_ALIAS_Y_PREFIX = "F_AY_%s"; + public static final String GROUP_ALIAS_PREFIX = "G_A_%s"; + public static final String ORDER_ALIAS_X_PREFIX = "O_AX_%s"; + public static final String ORDER_ALIAS_Y_PREFIX = "O_AY_%s"; + public static final String WHERE_ALIAS_PREFIX = "W_A_%s"; } diff --git a/backend/src/main/java/io/dataease/provider/mysql/MySQLConstants.java b/backend/src/main/java/io/dataease/provider/mysql/MySQLConstants.java new file mode 100644 index 0000000000..841febf127 --- /dev/null +++ b/backend/src/main/java/io/dataease/provider/mysql/MySQLConstants.java @@ -0,0 +1,41 @@ +package io.dataease.provider.mysql; + +import io.dataease.provider.SQLConstants; + +import static io.dataease.datasource.constants.DatasourceTypes.mysql; + +/** + * @Author gin + * @Date 2021/7/8 7:22 下午 + */ +public class MySQLConstants extends SQLConstants { + public static final String KEYWORD_TABLE = mysql.getKeywordPrefix() + "%s" + mysql.getKeywordSuffix(); + + public static final String KEYWORD_FIX = "%s." + mysql.getKeywordPrefix() + "%s" + mysql.getKeywordSuffix(); + + public static final String UNIX_TIMESTAMP = "UNIX_TIMESTAMP(%s)"; + + public static final String DATE_FORMAT = "DATE_FORMAT(%s,'%s')"; + + public static final String FROM_UNIXTIME = "FROM_UNIXTIME(%s,'%s')"; + + public static final String CAST = "CAST(%s AS %s)"; + + public static final String DEFAULT_DATE_FORMAT = "%Y-%m-%d %H:%i:%S"; + + public static final String DEFAULT_INT_FORMAT = "DECIMAL(20,0)"; + + public static final String DEFAULT_FLOAT_FORMAT = "DECIMAL(20,2)"; + + public static final String WHERE_VALUE_NULL = "(null,'')"; + + public static final String WHERE_VALUE_VALUE = "'%s'"; + + public static final String AGG_COUNT = "COUNT(*)"; + + public static final String AGG_FIELD = "%s(%s)"; + + public static final String WHERE_BETWEEN = "'%s' AND '%s'"; + + public static final String BRACKETS = "(%s)"; +} diff --git a/backend/src/main/java/io/dataease/provider/mysql/MysqlQueryProvider.java b/backend/src/main/java/io/dataease/provider/mysql/MysqlQueryProvider.java index d7a6155664..fb6fe589ac 100644 --- a/backend/src/main/java/io/dataease/provider/mysql/MysqlQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/mysql/MysqlQueryProvider.java @@ -4,19 +4,25 @@ import io.dataease.base.domain.DatasetTableField; import io.dataease.controller.request.chart.ChartExtFilterRequest; import io.dataease.dto.chart.ChartCustomFilterDTO; import io.dataease.dto.chart.ChartViewFieldDTO; +import io.dataease.dto.sqlObj.SQLObj; import io.dataease.provider.QueryProvider; import io.dataease.provider.SQLConstants; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.stringtemplate.v4.ST; +import org.stringtemplate.v4.STGroup; +import org.stringtemplate.v4.STGroupFile; import java.text.MessageFormat; import java.text.SimpleDateFormat; -import java.util.Arrays; +import java.util.ArrayList; import java.util.Date; import java.util.List; +import static io.dataease.provider.SQLConstants.TABLE_ALIAS_PREFIX; + /** * @Author gin * @Date 2021/5/17 2:43 下午 @@ -75,40 +81,59 @@ public class MysqlQueryProvider extends QueryProvider { @Override public String createQuerySQL(String table, List fields) { - String[] array = fields.stream().map(f -> { - StringBuilder stringBuilder = new StringBuilder(); - // 如果原始类型为时间 - if (f.getDeExtractType() == 1) { - if (f.getDeType() == 2 || f.getDeType() == 3) { - stringBuilder.append("UNIX_TIMESTAMP(`").append(f.getOriginName()).append("`)*1000 AS ").append(f.getDataeaseName()); + SQLObj tableObj = SQLObj.builder() + .tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table)) + .tableAlias(String.format(TABLE_ALIAS_PREFIX, 0)) + .build(); + List xFields = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(fields)) { + for (int i = 0; i < fields.size(); i++) { + DatasetTableField f = fields.get(i); + String originField = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName()); + String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i); + String fieldName = ""; + // 处理横轴字段 + if (f.getDeExtractType() == 1) { + if (f.getDeType() == 2 || f.getDeType() == 3) { + fieldName = String.format(MySQLConstants.UNIX_TIMESTAMP, originField) + "*1000"; + } else { + fieldName = originField; + } + } else if (f.getDeExtractType() == 0) { + if (f.getDeType() == 2) { + fieldName = String.format(MySQLConstants.CAST, originField, MySQLConstants.DEFAULT_INT_FORMAT); + } else if (f.getDeType() == 3) { + fieldName = String.format(MySQLConstants.CAST, originField, MySQLConstants.DEFAULT_FLOAT_FORMAT); + } else if (f.getDeType() == 1) { + fieldName = String.format(MySQLConstants.DATE_FORMAT, originField, MySQLConstants.DEFAULT_DATE_FORMAT); + } else { + fieldName = originField; + } } else { - stringBuilder.append("`").append(f.getOriginName()).append("` AS ").append(f.getDataeaseName()); - } - } else if (f.getDeExtractType() == 0) { - if (f.getDeType() == 2) { - stringBuilder.append("CAST(`").append(f.getOriginName()).append("` AS DECIMAL(20,0)) AS ").append(f.getDataeaseName()); - } else if (f.getDeType() == 3) { - stringBuilder.append("CAST(`").append(f.getOriginName()).append("` AS DECIMAL(20,2)) AS ").append(f.getDataeaseName()); - } else if (f.getDeType() == 1) { - stringBuilder.append("DATE_FORMAT(`").append(f.getOriginName()).append("`,'%Y-%m-%d %H:%i:%S') AS _").append(f.getDataeaseName()); - } else { - stringBuilder.append("`").append(f.getOriginName()).append("` AS ").append(f.getDataeaseName()); - } - } else { - if (f.getDeType() == 1) { - stringBuilder.append("FROM_UNIXTIME(CAST(`").append(f.getOriginName()).append("` AS DECIMAL(20,0))/1000,'%Y-%m-%d %H:%i:%S') AS ").append(f.getDataeaseName()); - } else { - stringBuilder.append("`").append(f.getOriginName()).append("` AS ").append(f.getDataeaseName()); + if (f.getDeType() == 1) { + String cast = String.format(MySQLConstants.CAST, originField, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000"; + fieldName = String.format(MySQLConstants.FROM_UNIXTIME, cast, MySQLConstants.DEFAULT_DATE_FORMAT); + } else { + fieldName = originField; + } } + xFields.add(SQLObj.builder() + .fieldName(fieldName) + .fieldAlias(fieldAlias) + .build()); } - return stringBuilder.toString(); - }).toArray(String[]::new); - return MessageFormat.format("SELECT {0} FROM {1} ORDER BY null", StringUtils.join(array, ","), table); + } + + STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE); + ST st_sql = stg.getInstanceOf("querySql"); + if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields); + if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); + return st_sql.render(); } @Override public String createQuerySQLAsTmp(String sql, List fields) { - return createQuerySQL(" (" + sqlFix(sql) + ") AS tmp ", fields); + return createQuerySQL("(" + sqlFix(sql) + ")", fields); } @Override @@ -133,145 +158,98 @@ public class MysqlQueryProvider extends QueryProvider { @Override public String getSQL(String table, List xAxis, List yAxis, List customFilter, List extFilterRequestList) { - // 字段汇总 排序等 - String[] field = yAxis.stream().map(y -> { - StringBuilder f = new StringBuilder(); - if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) { - f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")"); - } else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) { - f.append(y.getSummary()).append("(`").append(y.getOriginName()).append("`)"); - } else { - if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) { - f.append("CAST(") - .append(y.getSummary()).append("(") - .append("CAST(`").append(y.getOriginName()).append("` AS ").append(y.getDeType() == 2 ? "DECIMAL(20,0)" : "DECIMAL(20,2)").append(")") - .append(") AS DECIMAL(20,2)").append(")"); - } else { - f.append(y.getSummary()).append("(") - .append("CAST(`").append(y.getOriginName()).append("` AS ").append(y.getDeType() == 2 ? "DECIMAL(20,0)" : "DECIMAL(20,2)").append(")") - .append(")"); + SQLObj tableObj = SQLObj.builder() + .tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table)) + .tableAlias(String.format(TABLE_ALIAS_PREFIX, 0)) + .build(); + List xFields = new ArrayList<>(); + List xWheres = new ArrayList<>(); + List xOrders = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(xAxis)) { + for (int i = 0; i < xAxis.size(); i++) { + ChartViewFieldDTO x = xAxis.get(i); + String originField = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); + String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i); + // 处理横轴字段 + xFields.add(getXFields(x, originField, fieldAlias)); + // 处理横轴过滤 + xWheres.addAll(getXWheres(x, originField, fieldAlias)); + // 处理横轴排序 + if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) { + xOrders.add(SQLObj.builder() + .orderField(originField) + .orderAlias(fieldAlias) + .orderDirection(x.getSort()) + .build()); } } - f.append(" AS `_").append(y.getSummary()).append("_").append(StringUtils.equalsIgnoreCase(y.getOriginName(), "*") ? "" : y.getOriginName()).append("`"); - return f.toString(); - }).toArray(String[]::new); - String[] groupField = xAxis.stream().map(x -> { - StringBuilder stringBuilder = new StringBuilder(); - // 如果原始类型为时间 - if (x.getDeExtractType() == 1) { - if (x.getDeType() == 2 || x.getDeType() == 3) { - stringBuilder.append("UNIX_TIMESTAMP(`").append(x.getOriginName()).append("`)*1000 AS `_").append(x.getOriginName()).append("`"); - } else if (x.getDeType() == 1) { - String format = transDateFormat(x.getDateStyle(), x.getDatePattern()); - stringBuilder.append("DATE_FORMAT(`").append(x.getOriginName()).append("`,'").append(format).append("') AS `_").append(x.getOriginName()).append("`"); - } else { - stringBuilder.append("`").append(x.getOriginName()).append("` AS `_").append(x.getOriginName()).append("`"); - } - } else { - if (x.getDeType() == 1) { - String format = transDateFormat(x.getDateStyle(), x.getDatePattern()); - if (x.getDeExtractType() == 0) { - stringBuilder.append("DATE_FORMAT(`").append(x.getOriginName()).append("`,'").append(format).append("') AS `_").append(x.getOriginName()).append("`"); - } else { - stringBuilder.append("DATE_FORMAT(").append("FROM_UNIXTIME(CAST(`").append(x.getOriginName()).append("` AS DECIMAL(20,0))/1000,'%Y-%m-%d %H:%i:%S')").append(",'").append(format).append("') AS `_").append(x.getOriginName()).append("`"); - } - } else { - stringBuilder.append("`").append(x.getOriginName()).append("` AS `_").append(x.getOriginName()).append("`"); + } + List yFields = new ArrayList<>(); + List yWheres = new ArrayList<>(); + List yOrders = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(yAxis)) { + for (int i = 0; i < yAxis.size(); i++) { + ChartViewFieldDTO y = yAxis.get(i); + String originField = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); + String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i); + // 处理纵轴字段 + yFields.add(getYFields(y, originField, fieldAlias)); + // 处理纵轴过滤 + yWheres.addAll(getYWheres(y, originField, fieldAlias)); + // 处理纵轴排序 + if (StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none")) { + yOrders.add(SQLObj.builder() + .orderField(originField) + .orderAlias(fieldAlias) + .orderDirection(y.getSort()) + .build()); } } - return stringBuilder.toString(); - }).toArray(String[]::new); - String[] group = xAxis.stream().map(x -> "`_" + x.getOriginName() + "`").toArray(String[]::new); - String[] xOrder = xAxis.stream().filter(f -> StringUtils.isNotEmpty(f.getSort()) && !StringUtils.equalsIgnoreCase(f.getSort(), "none")) - .map(f -> "`_" + f.getOriginName() + "` " + f.getSort()).toArray(String[]::new); - String[] yOrder = yAxis.stream().filter(f -> StringUtils.isNotEmpty(f.getSort()) && !StringUtils.equalsIgnoreCase(f.getSort(), "none")) - .map(f -> "`_" + f.getSummary() + "_" + (StringUtils.equalsIgnoreCase(f.getOriginName(), "*") ? "" : f.getOriginName()) + "` " + f.getSort()).toArray(String[]::new); - String[] order = Arrays.copyOf(xOrder, xOrder.length + yOrder.length); - System.arraycopy(yOrder, 0, order, xOrder.length, yOrder.length); - - String[] xFilter = xAxis.stream().filter(x -> CollectionUtils.isNotEmpty(x.getFilter()) && x.getFilter().size() > 0) - .map(x -> { - String[] s = x.getFilter().stream().map(f -> { - StringBuilder filter = new StringBuilder(); - if (x.getDeType() == 1 && x.getDeExtractType() != 1) { - filter.append(" AND FROM_UNIXTIME(cast(`") - .append(x.getOriginName()) - .append("` AS DECIMAL(20,0))/1000,'%Y-%m-%d %H:%i:%S') "); - } else { - filter.append(" AND `").append(x.getOriginName()).append("`"); - } - filter.append(transMysqlFilterTerm(f.getTerm())); - if (StringUtils.equalsIgnoreCase(f.getTerm(), "null")) { - filter.append("(null,'')"); - } else if (StringUtils.equalsIgnoreCase(f.getTerm(), "not_null")) { - filter.append(" AND `").append(x.getOriginName()).append("`").append(" <> ''"); - } else if (StringUtils.containsIgnoreCase(f.getTerm(), "in")) { - filter.append("('").append(StringUtils.join(f.getValue(), "','")).append("')"); - } else if (StringUtils.containsIgnoreCase(f.getTerm(), "like")) { - filter.append("'%").append(f.getValue()).append("%'"); - } else { - filter.append("'").append(f.getValue()).append("'"); - } - return filter.toString(); - }).toArray(String[]::new); - return StringUtils.join(s, " "); - }).toArray(String[]::new); - - String sql = MessageFormat.format("SELECT {0},{1} FROM {2} WHERE 1=1 {3} GROUP BY {4} ORDER BY null,{5}", - StringUtils.join(groupField, ","), - StringUtils.join(field, ","), - table, - (xFilter.length > 0 ? StringUtils.join(xFilter, " ") : "") + transCustomFilter(customFilter) + transExtFilter(extFilterRequestList),// origin field filter and panel field filter - StringUtils.join(group, ","), - StringUtils.join(order, ",")); - if (sql.endsWith(",")) { - sql = sql.substring(0, sql.length() - 1); - } - // 如果是对结果字段过滤,则再包裹一层sql - String[] resultFilter = yAxis.stream().filter(y -> CollectionUtils.isNotEmpty(y.getFilter()) && y.getFilter().size() > 0) - .map(y -> { - String[] s = y.getFilter().stream().map(f -> { - StringBuilder filter = new StringBuilder(); - // 原始类型不是时间,在de中被转成时间的字段做处理 - if (y.getDeType() == 1 && y.getDeExtractType() != 1) { - filter.append(" AND FROM_UNIXTIME(CAST(`_") - .append(y.getSummary()).append("_").append(StringUtils.equalsIgnoreCase(y.getOriginName(), "*") ? "" : y.getOriginName()).append("`") - .append(" AS DECIMAL(20,0))/1000,'%Y-%m-%d %H:%i:%S') "); - } else { - filter.append(" AND `_").append(y.getSummary()).append("_").append(StringUtils.equalsIgnoreCase(y.getOriginName(), "*") ? "" : y.getOriginName()).append("`"); - } - filter.append(transMysqlFilterTerm(f.getTerm())); - if (StringUtils.equalsIgnoreCase(f.getTerm(), "null")) { - filter.append("(null,'')"); - } else if (StringUtils.equalsIgnoreCase(f.getTerm(), "not_null")) { - filter.append(" AND `_") - .append(y.getSummary()).append("_").append(StringUtils.equalsIgnoreCase(y.getOriginName(), "*") ? "" : y.getOriginName()) - .append("`").append(" <> ''"); - } else if (StringUtils.containsIgnoreCase(f.getTerm(), "in")) { - filter.append("('").append(StringUtils.join(f.getValue(), "','")).append("')"); - } else if (StringUtils.containsIgnoreCase(f.getTerm(), "like")) { - filter.append("'%").append(f.getValue()).append("%'"); - } else { - filter.append("'").append(f.getValue()).append("'"); - } - return filter.toString(); - }).toArray(String[]::new); - return StringUtils.join(s, " "); - }).toArray(String[]::new); - if (resultFilter.length == 0) { - return sql; - } else { - String filterSql = MessageFormat.format("SELECT * FROM {0} WHERE 1=1 {1} ORDER BY {2}", - "(" + sql + ") AS tmp", - StringUtils.join(resultFilter, " "), - ObjectUtils.isNotEmpty(yOrder) ? StringUtils.join(yOrder, ",") : "null"); - return filterSql; } + // 处理视图中字段过滤 + List customWheres = transCustomFilterList(tableObj, customFilter); + // 处理仪表板字段过滤 + List extWheres = transExtFilterList(tableObj, extFilterRequestList); + // 构建sql所有参数 + List fields = new ArrayList<>(); + fields.addAll(xFields); + fields.addAll(yFields); + List wheres = new ArrayList<>(); + wheres.addAll(xWheres); + if (customWheres != null) wheres.addAll(customWheres); + if (extWheres != null) wheres.addAll(extWheres); + List groups = new ArrayList<>(); + groups.addAll(xFields); + // 外层再次套sql + List orders = new ArrayList<>(); + orders.addAll(xOrders); + orders.addAll(yOrders); + List aggWheres = new ArrayList<>(); + aggWheres.addAll(yWheres); + + STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE); + ST st_sql = stg.getInstanceOf("querySql"); + if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields); + if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields); + if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); + if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); + String sql = st_sql.render(); + + ST st = stg.getInstanceOf("querySql"); + SQLObj tableSQL = SQLObj.builder() + .tableName(String.format(MySQLConstants.BRACKETS, sql)) + .tableAlias(String.format(TABLE_ALIAS_PREFIX, 1)) + .build(); + if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres); + if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders); + if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL); + return st.render(); } + @Override public String getSQLAsTmp(String sql, List xAxis, List yAxis, List customFilter, List extFilterRequestList) { - return getSQL(" (" + sqlFix(sql) + ") AS tmp ", xAxis, yAxis, customFilter, extFilterRequestList); + return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, customFilter, extFilterRequestList); } @Override @@ -282,84 +260,70 @@ public class MysqlQueryProvider extends QueryProvider { @Override public String getSQLSummary(String table, List yAxis, List customFilter, List extFilterRequestList) { // 字段汇总 排序等 - String[] field = yAxis.stream().map(y -> { - StringBuilder f = new StringBuilder(); - if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) { - f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")"); - } else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) { - f.append(y.getSummary()).append("(`").append(y.getOriginName()).append("`)"); - } else { - if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) { - f.append("CAST(") - .append(y.getSummary()).append("(") - .append("CAST(`").append(y.getOriginName()).append("` AS ").append(y.getDeType() == 2 ? "DECIMAL(20,0)" : "DECIMAL(20,2)").append(")") - .append(") AS DECIMAL(20,2)").append(")"); - } else { - f.append(y.getSummary()).append("(") - .append("CAST(`").append(y.getOriginName()).append("` AS ").append(y.getDeType() == 2 ? "DECIMAL(20,0)" : "DECIMAL(20,2)").append(")") - .append(")"); + SQLObj tableObj = SQLObj.builder() + .tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table)) + .tableAlias(String.format(TABLE_ALIAS_PREFIX, 0)) + .build(); + List yFields = new ArrayList<>(); + List yWheres = new ArrayList<>(); + List yOrders = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(yAxis)) { + for (int i = 0; i < yAxis.size(); i++) { + ChartViewFieldDTO y = yAxis.get(i); + String originField = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); + String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i); + // 处理纵轴字段 + yFields.add(getYFields(y, originField, fieldAlias)); + // 处理纵轴过滤 + yWheres.addAll(getYWheres(y, originField, fieldAlias)); + // 处理纵轴排序 + if (StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none")) { + yOrders.add(SQLObj.builder() + .orderField(originField) + .orderAlias(fieldAlias) + .orderDirection(y.getSort()) + .build()); } } - f.append(" AS `_").append(y.getSummary()).append("_").append(StringUtils.equalsIgnoreCase(y.getOriginName(), "*") ? "" : y.getOriginName()).append("`"); - return f.toString(); - }).toArray(String[]::new); - - String[] order = yAxis.stream().filter(f -> StringUtils.isNotEmpty(f.getSort()) && !StringUtils.equalsIgnoreCase(f.getSort(), "none")) - .map(f -> "`_" + f.getSummary() + "_" + (StringUtils.equalsIgnoreCase(f.getOriginName(), "*") ? "" : f.getOriginName()) + "` " + f.getSort()).toArray(String[]::new); - - String sql = MessageFormat.format("SELECT {0} FROM {1} WHERE 1=1 {2} ORDER BY null,{3}", - StringUtils.join(field, ","), - table, - transCustomFilter(customFilter) + transExtFilter(extFilterRequestList),// origin field filter and panel field filter - StringUtils.join(order, ",")); - if (sql.endsWith(",")) { - sql = sql.substring(0, sql.length() - 1); - } - // 如果是对结果字段过滤,则再包裹一层sql - String[] resultFilter = yAxis.stream().filter(y -> CollectionUtils.isNotEmpty(y.getFilter()) && y.getFilter().size() > 0) - .map(y -> { - String[] s = y.getFilter().stream().map(f -> { - StringBuilder filter = new StringBuilder(); - // 原始类型不是时间,在de中被转成时间的字段做处理 - if (y.getDeType() == 1 && y.getDeExtractType() != 1) { - filter.append(" AND FROM_UNIXTIME(CAST(`_") - .append(y.getSummary()).append("_").append(StringUtils.equalsIgnoreCase(y.getOriginName(), "*") ? "" : y.getOriginName()).append("`") - .append(" AS DECIMAL(20,0))/1000,'%Y-%m-%d %H:%i:%S') "); - } else { - filter.append(" AND `_").append(y.getSummary()).append("_").append(StringUtils.equalsIgnoreCase(y.getOriginName(), "*") ? "" : y.getOriginName()).append("`"); - } - filter.append(transMysqlFilterTerm(f.getTerm())); - if (StringUtils.equalsIgnoreCase(f.getTerm(), "null")) { - filter.append("(null,'')"); - } else if (StringUtils.equalsIgnoreCase(f.getTerm(), "not_null")) { - filter.append(" AND `_") - .append(y.getSummary()).append("_").append(StringUtils.equalsIgnoreCase(y.getOriginName(), "*") ? "" : y.getOriginName()) - .append("`").append(" <> ''"); - } else if (StringUtils.containsIgnoreCase(f.getTerm(), "in")) { - filter.append("('").append(StringUtils.join(f.getValue(), "','")).append("')"); - } else if (StringUtils.containsIgnoreCase(f.getTerm(), "like")) { - filter.append("'%").append(f.getValue()).append("%'"); - } else { - filter.append("'").append(f.getValue()).append("'"); - } - return filter.toString(); - }).toArray(String[]::new); - return StringUtils.join(s, " "); - }).toArray(String[]::new); - if (resultFilter.length == 0) { - return sql; - } else { - String filterSql = MessageFormat.format("SELECT * FROM {0} WHERE 1=1 {1} ORDER BY {2}", - "(" + sql + ") AS tmp", - StringUtils.join(resultFilter, " "), - ObjectUtils.isNotEmpty(order) ? StringUtils.join(order, ",") : "null"); - return filterSql; } + // 处理视图中字段过滤 + List customWheres = transCustomFilterList(tableObj, customFilter); + // 处理仪表板字段过滤 + List extWheres = transExtFilterList(tableObj, extFilterRequestList); + // 构建sql所有参数 + List fields = new ArrayList<>(); + fields.addAll(yFields); + List wheres = new ArrayList<>(); + if (customWheres != null) wheres.addAll(customWheres); + if (extWheres != null) wheres.addAll(extWheres); + List groups = new ArrayList<>(); + // 外层再次套sql + List orders = new ArrayList<>(); + orders.addAll(yOrders); + List aggWheres = new ArrayList<>(); + aggWheres.addAll(yWheres); + + STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE); + ST st_sql = stg.getInstanceOf("querySql"); + if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields); + if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); + if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); + String sql = st_sql.render(); + + ST st = stg.getInstanceOf("querySql"); + SQLObj tableSQL = SQLObj.builder() + .tableName(String.format(MySQLConstants.BRACKETS, sql)) + .tableAlias(String.format(TABLE_ALIAS_PREFIX, 1)) + .build(); + if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres); + if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders); + if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL); + return st.render(); } @Override public String getSQLSummaryAsTmp(String sql, List yAxis, List customFilter, List extFilterRequestList) { - return getSQLSummary(" (" + sqlFix(sql) + ") AS tmp ", yAxis, customFilter, extFilterRequestList); + return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, customFilter, extFilterRequestList); } @Override @@ -412,7 +376,7 @@ public class MysqlQueryProvider extends QueryProvider { case "null": return " IN "; case "not_null": - return " IS NOT NULL "; + return " NOT IN "; case "between": return " BETWEEN "; default: @@ -420,77 +384,86 @@ public class MysqlQueryProvider extends QueryProvider { } } - public String transCustomFilter(List requestList) { + public List transCustomFilterList(SQLObj tableObj, List requestList) { if (CollectionUtils.isEmpty(requestList)) { - return ""; + return null; } - StringBuilder filter = new StringBuilder(); + List list = new ArrayList<>(); for (ChartCustomFilterDTO request : requestList) { - String value = request.getValue(); DatasetTableField field = request.getField(); if (ObjectUtils.isEmpty(field)) { continue; } + String value = request.getValue(); + String whereName = ""; + String whereTerm = transMysqlFilterTerm(request.getTerm()); + String whereValue = ""; + String originName = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName()); if (field.getDeType() == 1 && field.getDeExtractType() != 1) { - filter.append(" AND FROM_UNIXTIME(CAST(`") - .append(field.getOriginName()) - .append("` AS DECIMAL(20,0))/1000,'%Y-%m-%d %H:%i:%S') "); + String cast = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000"; + whereName = String.format(MySQLConstants.FROM_UNIXTIME, cast, MySQLConstants.DEFAULT_DATE_FORMAT); } else { - filter.append(" AND `").append(field.getOriginName()).append("`"); + whereName = originName; } - filter.append(" ") - .append(transMysqlFilterTerm(request.getTerm())) - .append(" "); - if (StringUtils.equalsIgnoreCase(request.getTerm(), "null")) { - filter.append("(null,'')"); - } else if (StringUtils.equalsIgnoreCase(request.getTerm(), "not_null")) { - filter.append(" AND `").append(field.getOriginName()).append("`").append(" <> ''"); + if (StringUtils.containsIgnoreCase(request.getTerm(), "null")) { + whereValue = MySQLConstants.WHERE_VALUE_NULL; } else if (StringUtils.containsIgnoreCase(request.getTerm(), "in")) { - filter.append("('").append(StringUtils.join(value, "','")).append("')"); + whereValue = "('" + StringUtils.join(value, "','") + "')"; } else if (StringUtils.containsIgnoreCase(request.getTerm(), "like")) { - filter.append("'%").append(value).append("%'"); + whereValue = "'%" + value + "%'"; } else { - filter.append("'").append(value).append("'"); + whereValue = String.format(MySQLConstants.WHERE_VALUE_VALUE, value); } + list.add(SQLObj.builder() + .whereField(whereName) + .whereTermAndValue(whereTerm + whereValue) + .build()); } - return filter.toString(); + return list; } - public String transExtFilter(List requestList) { + public List transExtFilterList(SQLObj tableObj, List requestList) { if (CollectionUtils.isEmpty(requestList)) { - return ""; + return null; } - StringBuilder filter = new StringBuilder(); + List list = new ArrayList<>(); for (ChartExtFilterRequest request : requestList) { List value = request.getValue(); - if (CollectionUtils.isEmpty(value)) { + DatasetTableField field = request.getDatasetTableField(); + if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) { continue; } - DatasetTableField field = request.getDatasetTableField(); + String whereName = ""; + String whereTerm = transMysqlFilterTerm(request.getOperator()); + String whereValue = ""; + String originName = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName()); + if (field.getDeType() == 1 && field.getDeExtractType() != 1) { - filter.append(" AND FROM_UNIXTIME(CAST(`") - .append(field.getOriginName()) - .append("` AS DECIMAL(20,0))/1000,'%Y-%m-%d %H:%i:%S') "); + String cast = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000"; + whereName = String.format(MySQLConstants.FROM_UNIXTIME, cast, MySQLConstants.DEFAULT_DATE_FORMAT); } else { - filter.append(" AND `").append(field.getOriginName()).append("`"); + whereName = originName; } - filter.append(" ") - .append(transMysqlFilterTerm(request.getOperator())) - .append(" "); + + if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) { - filter.append("('").append(StringUtils.join(value, "','")).append("')"); + whereValue = "('" + StringUtils.join(value, "','") + "')"; } else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) { - filter.append("'%").append(value.get(0)).append("%'"); + whereValue = "'%" + value.get(0) + "%'"; } else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String startTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(0)))); String endTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(1)))); - filter.append("'").append(startTime).append("' AND '").append(endTime).append("'"); + whereValue = String.format(MySQLConstants.WHERE_BETWEEN, startTime, endTime); } else { - filter.append("'").append(value.get(0)).append("'"); + whereValue = String.format(MySQLConstants.WHERE_VALUE_VALUE, value.get(0)); } + list.add(SQLObj.builder() + .whereField(whereName) + .whereTermAndValue(whereTerm + whereValue) + .build()); } - return filter.toString(); + return list; } private String sqlFix(String sql) { @@ -525,4 +498,115 @@ public class MysqlQueryProvider extends QueryProvider { return "%Y-%m-%d %H:%i:%S"; } } + + private SQLObj getXFields(ChartViewFieldDTO x, String originField, String fieldAlias) { + String fieldName = ""; + if (x.getDeExtractType() == 1) { + if (x.getDeType() == 2 || x.getDeType() == 3) { + fieldName = String.format(MySQLConstants.UNIX_TIMESTAMP, originField) + "*1000"; + } else if (x.getDeType() == 1) { + String format = transDateFormat(x.getDateStyle(), x.getDatePattern()); + fieldName = String.format(MySQLConstants.DATE_FORMAT, originField, format); + } else { + fieldName = originField; + } + } else { + if (x.getDeType() == 1) { + String format = transDateFormat(x.getDateStyle(), x.getDatePattern()); + if (x.getDeExtractType() == 0) { + fieldName = String.format(MySQLConstants.DATE_FORMAT, originField, format); + } else { + String cast = String.format(MySQLConstants.CAST, originField, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000"; + String from_unixtime = String.format(MySQLConstants.FROM_UNIXTIME, cast, MySQLConstants.DEFAULT_DATE_FORMAT); + fieldName = String.format(MySQLConstants.DATE_FORMAT, from_unixtime, format); + } + } else { + fieldName = originField; + } + } + return SQLObj.builder() + .fieldName(fieldName) + .fieldAlias(fieldAlias) + .build(); + } + + private List getXWheres(ChartViewFieldDTO x, String originField, String fieldAlias) { + List list = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(x.getFilter()) && x.getFilter().size() > 0) { + x.getFilter().forEach(f -> { + String whereName = ""; + String whereTerm = transMysqlFilterTerm(f.getTerm()); + String whereValue = ""; + if (x.getDeType() == 1 && x.getDeExtractType() != 1) { + String cast = String.format(MySQLConstants.CAST, originField, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000"; + whereName = String.format(MySQLConstants.FROM_UNIXTIME, cast, MySQLConstants.DEFAULT_DATE_FORMAT); + } else { + whereName = originField; + } + if (StringUtils.containsIgnoreCase(f.getTerm(), "null")) { + whereValue = MySQLConstants.WHERE_VALUE_NULL; + } else if (StringUtils.containsIgnoreCase(f.getTerm(), "in")) { + whereValue = "('" + StringUtils.join(f.getValue(), "','") + "')"; + } else if (StringUtils.containsIgnoreCase(f.getTerm(), "like")) { + whereValue = "'%" + f.getValue() + "%'"; + } else { + whereValue = String.format(MySQLConstants.WHERE_VALUE_VALUE, f.getValue()); + } + list.add(SQLObj.builder() + .whereField(whereName) + .whereAlias(fieldAlias) + .whereTermAndValue(whereTerm + whereValue) + .build()); + }); + } + return list; + } + + private SQLObj getYFields(ChartViewFieldDTO y, String originField, String fieldAlias) { + String fieldName = ""; + if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) { + fieldName = MySQLConstants.AGG_COUNT; + } else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) { + fieldName = String.format(MySQLConstants.AGG_FIELD, y.getSummary(), originField); + } else { + if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) { + String cast = String.format(MySQLConstants.CAST, originField, y.getDeType() == 2 ? MySQLConstants.DEFAULT_INT_FORMAT : MySQLConstants.DEFAULT_FLOAT_FORMAT); + String agg = String.format(MySQLConstants.AGG_FIELD, y.getSummary(), cast); + fieldName = String.format(MySQLConstants.CAST, agg, MySQLConstants.DEFAULT_FLOAT_FORMAT); + } else { + String cast = String.format(MySQLConstants.CAST, originField, y.getDeType() == 2 ? MySQLConstants.DEFAULT_INT_FORMAT : MySQLConstants.DEFAULT_FLOAT_FORMAT); + fieldName = String.format(MySQLConstants.AGG_FIELD, y.getSummary(), cast); + } + } + return SQLObj.builder() + .fieldName(fieldName) + .fieldAlias(fieldAlias) + .build(); + } + + private List getYWheres(ChartViewFieldDTO y, String originField, String fieldAlias) { + List list = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(y.getFilter()) && y.getFilter().size() > 0) { + y.getFilter().forEach(f -> { + String whereTerm = transMysqlFilterTerm(f.getTerm()); + String whereValue = ""; + // 原始类型不是时间,在de中被转成时间的字段做处理 + if (StringUtils.containsIgnoreCase(f.getTerm(), "null")) { + whereValue = MySQLConstants.WHERE_VALUE_NULL; + } else if (StringUtils.containsIgnoreCase(f.getTerm(), "in")) { + whereValue = "('" + StringUtils.join(f.getValue(), "','") + "')"; + } else if (StringUtils.containsIgnoreCase(f.getTerm(), "like")) { + whereValue = "'%" + f.getValue() + "%'"; + } else { + whereValue = String.format(MySQLConstants.WHERE_VALUE_VALUE, f.getValue()); + } + list.add(SQLObj.builder() + .whereField(fieldAlias) + .whereAlias(fieldAlias) + .whereTermAndValue(whereTerm + whereValue) + .build()); + }); + } + return list; + } } diff --git a/backend/src/main/resources/sql/sqlTemplate.stg b/backend/src/main/resources/sql/sqlTemplate.stg new file mode 100644 index 0000000000..71eb2c3b70 --- /dev/null +++ b/backend/src/main/resources/sql/sqlTemplate.stg @@ -0,0 +1,28 @@ +querySql(groups, aggregators, filters, orders, table) +::=<< +SELECT + + * + + + AS }; separator=",\n"> + + , + + AS }; separator=",\n"> + +FROM + AS + +WHERE + }; separator="\nAND "> + + +GROUP BY + }; separator=",\n"> + + +ORDER BY + }; separator=",\n"> + +>> \ No newline at end of file From b329f894d15a7e3236d9ec5f8565910b0eb8e92d Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 12 Jul 2021 11:30:57 +0800 Subject: [PATCH 5/6] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8E=A5=E6=94=B6=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/constants/SysMsgConstants.java | 1 + .../controller/message/MsgController.java | 7 +- .../controller/message/dto/SubscribeNode.java | 20 ++++++ .../dataease/service/message/DeMsgutil.java | 17 +++-- .../io/dataease/service/message/MsgAop.java | 19 ++++-- .../service/message/SysMsgService.java | 46 +++++++++++-- .../resources/db/migration/V10__web_msg.sql | 65 +++++++++++++++++-- .../src/main/resources/ehcache/ehcache.xml | 17 ++++- .../src/components/Notification/index.vue | 4 +- frontend/src/lang/en.js | 9 ++- frontend/src/lang/tw.js | 9 ++- frontend/src/lang/zh.js | 9 ++- frontend/src/utils/webMsg.js | 2 +- frontend/src/views/dataset/index.vue | 7 +- frontend/src/views/msg/all.vue | 6 +- frontend/src/views/msg/readed.vue | 8 +-- frontend/src/views/msg/setting.vue | 4 +- frontend/src/views/msg/unread.vue | 8 +-- frontend/src/views/panel/index.vue | 7 +- 19 files changed, 206 insertions(+), 59 deletions(-) create mode 100644 backend/src/main/java/io/dataease/controller/message/dto/SubscribeNode.java diff --git a/backend/src/main/java/io/dataease/commons/constants/SysMsgConstants.java b/backend/src/main/java/io/dataease/commons/constants/SysMsgConstants.java index 206bfbc264..6c2689404a 100644 --- a/backend/src/main/java/io/dataease/commons/constants/SysMsgConstants.java +++ b/backend/src/main/java/io/dataease/commons/constants/SysMsgConstants.java @@ -4,4 +4,5 @@ public class SysMsgConstants { public final static String SYS_MSG_CHANNEL = "sys_msg_channel"; public final static String SYS_MSG_TYPE = "sys_msg_type"; + public final static String SYS_MSG_USER_SUBSCRIBE = "sys_msg_user_subscribe"; } diff --git a/backend/src/main/java/io/dataease/controller/message/MsgController.java b/backend/src/main/java/io/dataease/controller/message/MsgController.java index 51415ea0ff..6f84a2e4df 100644 --- a/backend/src/main/java/io/dataease/controller/message/MsgController.java +++ b/backend/src/main/java/io/dataease/controller/message/MsgController.java @@ -8,7 +8,6 @@ import io.dataease.base.domain.SysMsgType; import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.PageUtils; import io.dataease.commons.utils.Pager; -import io.dataease.controller.handler.annotation.I18n; import io.dataease.controller.message.dto.MsgGridDto; import io.dataease.controller.message.dto.MsgRequest; import io.dataease.controller.message.dto.MsgSettingRequest; @@ -53,14 +52,12 @@ public class MsgController { sysMsgService.batchDelete(msgIds); } - @I18n @PostMapping("/treeNodes") public List treeNodes() { return sysMsgService.treeNodes(); } - @I18n @PostMapping("/channelList") public List channelList() { return sysMsgService.channelList(); @@ -73,10 +70,10 @@ public class MsgController { @PostMapping("/updateSetting") public void updateSetting(@RequestBody MsgSettingRequest request) { - sysMsgService.updateSetting(request); + Long userId = AuthUtils.getUser().getUserId(); + sysMsgService.updateSetting(request, userId); } - @I18n @PostMapping("/types") public List allTypes() { List sysMsgTypes = sysMsgService.queryMsgTypes(); diff --git a/backend/src/main/java/io/dataease/controller/message/dto/SubscribeNode.java b/backend/src/main/java/io/dataease/controller/message/dto/SubscribeNode.java new file mode 100644 index 0000000000..40773bd735 --- /dev/null +++ b/backend/src/main/java/io/dataease/controller/message/dto/SubscribeNode.java @@ -0,0 +1,20 @@ +package io.dataease.controller.message.dto; + + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class SubscribeNode implements Serializable { + + private static final long serialVersionUID = -1680823237289721438L; + + private Long typeId; + + private Long channelId; + + public Boolean match(Long type, Long channel) { + return type == typeId && channel == channelId; + } +} diff --git a/backend/src/main/java/io/dataease/service/message/DeMsgutil.java b/backend/src/main/java/io/dataease/service/message/DeMsgutil.java index 765d9e27e8..8d3e62c527 100644 --- a/backend/src/main/java/io/dataease/service/message/DeMsgutil.java +++ b/backend/src/main/java/io/dataease/service/message/DeMsgutil.java @@ -1,6 +1,5 @@ package io.dataease.service.message; -import io.dataease.base.domain.SysMsg; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -20,14 +19,14 @@ public class DeMsgutil { public static void sendMsg(Long userId, Long typeId, Long channelId, String content, String param) { - SysMsg sysMsg = new SysMsg(); - sysMsg.setUserId(userId); - sysMsg.setTypeId(typeId); - sysMsg.setContent(content); - sysMsg.setStatus(false); - sysMsg.setCreateTime(System.currentTimeMillis()); - sysMsg.setParam(param); - sysMsgService.save(sysMsg); +// SysMsg sysMsg = new SysMsg(); +// sysMsg.setUserId(userId); +// sysMsg.setTypeId(typeId); +// sysMsg.setContent(content); +// sysMsg.setStatus(false); +// sysMsg.setCreateTime(System.currentTimeMillis()); +// sysMsg.setParam(param); + sysMsgService.sendMsg(userId, typeId, channelId, content, param); } diff --git a/backend/src/main/java/io/dataease/service/message/MsgAop.java b/backend/src/main/java/io/dataease/service/message/MsgAop.java index 1dc102206a..cf4cb8790e 100644 --- a/backend/src/main/java/io/dataease/service/message/MsgAop.java +++ b/backend/src/main/java/io/dataease/service/message/MsgAop.java @@ -1,20 +1,25 @@ package io.dataease.service.message; -import io.dataease.base.domain.SysMsgSettingExample; -import io.dataease.base.mapper.SysMsgSettingMapper; + +import io.dataease.controller.message.dto.SubscribeNode; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.util.List; @Aspect @Component public class MsgAop { + + + @Resource - private SysMsgSettingMapper sysMsgSettingMapper; + private SysMsgService sysMsgService; @@ -24,7 +29,7 @@ public class MsgAop { * 对sendMsg 切面拦截 * @param point */ - @Around("(execution(* io.dataease.service.message.DeMsgutil.sendMsg(..)))") + @Around("(execution(* io.dataease.service.message.SysMsgService.sendMsg(..)))") public Object cutPoint(ProceedingJoinPoint point) { Object[] args = point.getArgs(); @@ -39,11 +44,11 @@ public class MsgAop { Long typeId = (Long) arg1; Long channelId = (Long) arg2; - SysMsgSettingExample example = new SysMsgSettingExample(); - example.createCriteria().andChannelIdEqualTo(channelId).andUserIdEqualTo(userId).andTypeIdEqualTo(typeId).andEnableEqualTo(true); + List subscribes = sysMsgService.subscribes(userId); try { - if (sysMsgSettingMapper.countByExample(example) > 0) + // 如果已经订阅了这种类型的消息 直接发送 否则直接返回 + if (CollectionUtils.isNotEmpty(subscribes) && subscribes.stream().anyMatch(item -> item.match(typeId, channelId))) return point.proceed(args); return null; } catch (Throwable throwable) { diff --git a/backend/src/main/java/io/dataease/service/message/SysMsgService.java b/backend/src/main/java/io/dataease/service/message/SysMsgService.java index 9f8255bc4d..0bc5cdb8c8 100644 --- a/backend/src/main/java/io/dataease/service/message/SysMsgService.java +++ b/backend/src/main/java/io/dataease/service/message/SysMsgService.java @@ -7,16 +7,13 @@ import io.dataease.base.mapper.SysMsgMapper; import io.dataease.base.mapper.SysMsgSettingMapper; import io.dataease.base.mapper.SysMsgTypeMapper; import io.dataease.base.mapper.ext.ExtSysMsgMapper; -import io.dataease.commons.constants.AuthConstants; import io.dataease.commons.constants.SysMsgConstants; import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.CommonBeanFactory; -import io.dataease.controller.message.dto.MsgGridDto; -import io.dataease.controller.message.dto.MsgRequest; -import io.dataease.controller.message.dto.MsgSettingRequest; -import io.dataease.controller.message.dto.SettingTreeNode; +import io.dataease.controller.message.dto.*; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -179,11 +176,17 @@ public class SysMsgService { return sysMsgSettings; } + /** + * 修改了订阅信息 需要清除缓存 + * @param request + * @param userId + */ @Transactional - public void updateSetting(MsgSettingRequest request) { + @CacheEvict(value = SysMsgConstants.SYS_MSG_USER_SUBSCRIBE, key = "#userId") + public void updateSetting(MsgSettingRequest request, Long userId) { Long typeId = request.getTypeId(); Long channelId = request.getChannelId(); - Long userId = AuthUtils.getUser().getUserId(); + // Long userId = AuthUtils.getUser().getUserId(); SysMsgSettingExample example = new SysMsgSettingExample(); example.createCriteria().andUserIdEqualTo(userId).andTypeIdEqualTo(typeId).andChannelIdEqualTo(channelId); List sysMsgSettings = sysMsgSettingMapper.selectByExample(example); @@ -202,5 +205,34 @@ public class SysMsgService { sysMsgSettingMapper.insert(sysMsgSetting); } + public void sendMsg(Long userId, Long typeId, Long channelId, String content, String param) { + SysMsg sysMsg = new SysMsg(); + sysMsg.setUserId(userId); + sysMsg.setTypeId(typeId); + sysMsg.setContent(content); + sysMsg.setStatus(false); + sysMsg.setCreateTime(System.currentTimeMillis()); + sysMsg.setParam(param); + save(sysMsg); + } + + /** + * 查询用户订阅的消息 并缓存 + * @param userId + * @return + */ + @Cacheable(value = SysMsgConstants.SYS_MSG_USER_SUBSCRIBE, key = "#userId") + public List subscribes(Long userId) { + SysMsgSettingExample example = new SysMsgSettingExample(); + example.createCriteria().andUserIdEqualTo(userId).andEnableEqualTo(true); + List sysMsgSettings = sysMsgSettingMapper.selectByExample(example); + List resultLists = sysMsgSettings.stream().map(item -> { + SubscribeNode subscribeNode = new SubscribeNode(); + subscribeNode.setTypeId(item.getTypeId()); + subscribeNode.setChannelId(item.getChannelId()); + return subscribeNode; + }).collect(Collectors.toList()); + return resultLists; + } } diff --git a/backend/src/main/resources/db/migration/V10__web_msg.sql b/backend/src/main/resources/db/migration/V10__web_msg.sql index 5702ecc48d..139c31b8e8 100644 --- a/backend/src/main/resources/db/migration/V10__web_msg.sql +++ b/backend/src/main/resources/db/migration/V10__web_msg.sql @@ -5,24 +5,81 @@ DROP TABLE IF EXISTS `sys_msg`; CREATE TABLE `sys_msg` ( `msg_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '消息主键', `user_id` bigint(20) NOT NULL COMMENT '用户ID', - `type` int(4) NOT NULL COMMENT '类型', + `type_id` bigint(20) NOT NULL COMMENT '类型', `status` tinyint(1) NOT NULL COMMENT '状态', - `router` varchar(255) DEFAULT NULL COMMENT '跳转路由', `param` varchar(255) DEFAULT NULL COMMENT '路由参数', `create_time` bigint(13) NOT NULL COMMENT '发送时间', `read_time` bigint(13) DEFAULT NULL COMMENT '读取时间', `content` varchar(255) DEFAULT NULL COMMENT '消息内容', PRIMARY KEY (`msg_id`) USING BTREE, KEY `inx_msg_userid` (`user_id`) USING BTREE, - KEY `inx_msg_type` (`type`) USING BTREE, + KEY `inx_msg_type` (`type_id`) USING BTREE, KEY `inx_msg_status` (`status`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='消息通知表'; +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='消息通知表'; + +-- ---------------------------- +-- Table structure for sys_msg_channel +-- ---------------------------- +DROP TABLE IF EXISTS `sys_msg_channel`; +CREATE TABLE `sys_msg_channel` ( + `msg_channel_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `channel_name` varchar(255) DEFAULT NULL COMMENT '渠道名称', + PRIMARY KEY (`msg_channel_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='消息渠道表'; + +-- ---------------------------- +-- Records of sys_msg_channel +-- ---------------------------- +BEGIN; +INSERT INTO `sys_msg_channel` VALUES (1, 'webmsg.channel_inner_msg'); +COMMIT; + + +-- ---------------------------- +-- Table structure for sys_msg_type +-- ---------------------------- +DROP TABLE IF EXISTS `sys_msg_type`; +CREATE TABLE `sys_msg_type` ( + `msg_type_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `pid` bigint(20) NOT NULL COMMENT '父类ID', + `type_name` varchar(255) DEFAULT NULL COMMENT '类型名称', + `router` varchar(255) DEFAULT NULL COMMENT '跳转路由', + `callback` varchar(255) DEFAULT NULL COMMENT '回调方法', + PRIMARY KEY (`msg_type_id`) USING BTREE, + KEY `inx_msgtype_pid` (`pid`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='消息类型表'; + +-- ---------------------------- +-- Records of sys_msg_type +-- ---------------------------- +BEGIN; +INSERT INTO `sys_msg_type` VALUES (1, 0, 'i18n_msg_type_panel_share', 'panel', 'to-msg-share'); +INSERT INTO `sys_msg_type` VALUES (2, 1, 'i18n_msg_type_panel_share', 'panel', 'to-msg-share'); +INSERT INTO `sys_msg_type` VALUES (3, 1, 'i18n_msg_type_panel_share_cacnel', 'panel', 'to-msg-share'); +INSERT INTO `sys_msg_type` VALUES (4, 0, 'i18n_msg_type_dataset_sync', 'dataset', 'to-msg-dataset'); +INSERT INTO `sys_msg_type` VALUES (5, 4, 'i18n_msg_type_dataset_sync_success', 'dataset', 'to-msg-dataset'); +INSERT INTO `sys_msg_type` VALUES (6, 4, 'i18n_msg_type_dataset_sync_faild', 'dataset', 'to-msg-dataset'); +COMMIT; + +-- ---------------------------- +-- Table structure for sys_msg_setting +-- ---------------------------- +DROP TABLE IF EXISTS `sys_msg_setting`; +CREATE TABLE `sys_msg_setting` ( + `msg_setting_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `user_id` bigint(20) NOT NULL COMMENT '用户ID', + `type_id` bigint(20) NOT NULL COMMENT '类型ID', + `channel_id` bigint(20) NOT NULL COMMENT '渠道ID', + `enable` tinyint(1) DEFAULT NULL COMMENT '是否启用', + PRIMARY KEY (`msg_setting_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='消息设置表'; BEGIN; INSERT INTO `sys_menu` VALUES (53, 1, 3, 1, '站内消息', 'sys-msg-web', 'msg/index', 1000, 'all-msg', 'system-msg-web', b'0', b'0', b'0', NULL, NULL, NULL, NULL, NULL); INSERT INTO `sys_menu` VALUES (54, 53, 0, 1, '所有消息', 'sys-msg-web-all', 'msg/all', 1, 'web-msg', 'all', b'0', b'0', b'0', NULL, NULL, NULL, NULL, NULL); INSERT INTO `sys_menu` VALUES (55, 53, 0, 1, '未读消息', 'sys-msg-web-unread', 'msg/unread', 2, 'unread-msg', 'unread', b'0', b'0', b'0', NULL, NULL, NULL, NULL, NULL); INSERT INTO `sys_menu` VALUES (56, 53, 0, 1, '已读消息', 'sys-msg-web-readed', 'msg/readed', 3, 'readed-msg', 'readed', b'0', b'0', b'0', NULL, NULL, NULL, NULL, NULL); +INSERT INTO `sys_menu` VALUES (59, 53, 0, 1, '接收管理', 'sys-msg-setting', 'msg/setting', 4, 'msg-setting', 'setting', b'0', b'0', b'0', NULL, NULL, NULL, NULL, NULL); COMMIT; BEGIN; diff --git a/backend/src/main/resources/ehcache/ehcache.xml b/backend/src/main/resources/ehcache/ehcache.xml index 3407f77ff9..7043e2aa90 100644 --- a/backend/src/main/resources/ehcache/ehcache.xml +++ b/backend/src/main/resources/ehcache/ehcache.xml @@ -102,7 +102,7 @@ maxElementsInMemory="100" maxElementsOnDisk="1000" overflowToDisk="true" - diskPersistent="true" + diskPersistent="false" /> @@ -112,7 +112,20 @@ maxElementsInMemory="100" maxElementsOnDisk="1000" overflowToDisk="true" - diskPersistent="true" + diskPersistent="false" + /> + + + diff --git a/frontend/src/components/Notification/index.vue b/frontend/src/components/Notification/index.vue index 4ec8f8102d..c173641dfe 100644 --- a/frontend/src/components/Notification/index.vue +++ b/frontend/src/components/Notification/index.vue @@ -108,7 +108,7 @@ export default { // console.log(lang) // }, showDetail(row) { - const param = { ...{ msgNotification: true, msgType: row.type, sourceParam: row.param }} + const param = { ...{ msgNotification: true, msgType: row.typeId, sourceParam: row.param }} this.visible = false // if (this.$route && this.$route.name && this.$route.name.includes('panel') && row.type === 0) { // bus.$emit('to-msg-share', param) @@ -162,7 +162,7 @@ export default { }) }, getTypeName(value) { - return getTypeName(value) + return this.$t('webmsg.' + getTypeName(value)) }, open() { this.visible = true diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index 207e2187f3..1f54e9be60 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -1240,6 +1240,13 @@ export default { mark_readed: 'Mark As Read', please_select: 'Please select at least one message', mark_success: 'Mark read successfully', - receive_manage: 'Receive Manage' + receive_manage: 'Receive Manage', + i18n_msg_type_panel_share: 'Dashboard sharing', + i18n_msg_type_panel_share_cacnel: 'Dashboard unshared', + i18n_msg_type_dataset_sync: 'Data set synchronization', + i18n_msg_type_dataset_sync_success: 'Dataset synchronization successful', + i18n_msg_type_dataset_sync_faild: 'Dataset synchronization failed', + i18n_msg_type_all: 'All type', + channel_inner_msg: 'On site news' } } diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 319a8a3c62..8b229008d4 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -1240,6 +1240,13 @@ export default { mark_readed: '標記已讀', please_select: '請至少選擇一條消息', mark_success: '標記已讀成功', - receive_manage: '接收管理' + receive_manage: '接收管理', + i18n_msg_type_panel_share: '儀表板分享', + i18n_msg_type_panel_share_cacnel: '儀表板取消分享', + i18n_msg_type_dataset_sync: '數據集同步', + i18n_msg_type_dataset_sync_success: '數據集同步成功', + i18n_msg_type_dataset_sync_faild: '數據集同步失敗', + i18n_msg_type_all: '全部類型', + channel_inner_msg: '站內消息' } } diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 69f9751ada..91c05e0578 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -1242,6 +1242,13 @@ export default { mark_readed: '标记已读', please_select: '请至少选择一条消息', mark_success: '标记已读成功', - receive_manage: '接收管理' + receive_manage: '接收管理', + i18n_msg_type_panel_share: '仪表板分享', + i18n_msg_type_panel_share_cacnel: '仪表板取消分享', + i18n_msg_type_dataset_sync: '数据集同步', + i18n_msg_type_dataset_sync_success: '数据集同步成功', + i18n_msg_type_dataset_sync_faild: '数据集同步失败', + i18n_msg_type_all: '全部类型', + channel_inner_msg: '站内消息' } } diff --git a/frontend/src/utils/webMsg.js b/frontend/src/utils/webMsg.js index 46ba904728..7e697a59cc 100644 --- a/frontend/src/utils/webMsg.js +++ b/frontend/src/utils/webMsg.js @@ -6,7 +6,7 @@ export const loadMsgTypes = value => { if (!msgTypes || Object.keys(msgTypes).length === 0) { allTypes().then(res => { msgTypes = res.data - const defaultType = { msgTypeId: -1, pid: 0, typeName: '全部类型' } + const defaultType = { msgTypeId: -1, pid: 0, typeName: 'i18n_msg_type_all' } msgTypes.splice(0, 0, defaultType) store.dispatch('msg/setMsgTypes', msgTypes) }) diff --git a/frontend/src/views/dataset/index.vue b/frontend/src/views/dataset/index.vue index 860139cf0e..49415c7a7e 100644 --- a/frontend/src/views/dataset/index.vue +++ b/frontend/src/views/dataset/index.vue @@ -99,15 +99,16 @@ export default { toMsgShare(routerParam) { if (routerParam !== null && routerParam.msgNotification) { - // 说明是从消息通知跳转过来的 - if (routerParam.msgType === 1) { // 是数据集同步 + const panelShareTypeIds = [4, 5, 6] + // 说明是从消息通知跳转过来的 + if (panelShareTypeIds.includes(routerParam.msgType)) { // 是数据集同步 if (routerParam.sourceParam) { try { const msgParam = JSON.parse(routerParam.sourceParam) this.param = msgParam.tableId this.component = ViewTable this.$nextTick(() => { - this.$refs.dynamic_component.msg2Current(routerParam.sourceParam) + this.$refs.dynamic_component && this.$refs.dynamic_component.msg2Current && this.$refs.dynamic_component.msg2Current(routerParam.sourceParam) }) } catch (error) { console.error(error) diff --git a/frontend/src/views/msg/all.vue b/frontend/src/views/msg/all.vue index 6325a48b4c..803a24ba12 100644 --- a/frontend/src/views/msg/all.vue +++ b/frontend/src/views/msg/all.vue @@ -2,7 +2,7 @@ - {{ $t(item.typeName) }} + {{ $t('webmsg.' + item.typeName) }} - {{ $t(item.typeName) }} + {{ $t('webmsg.' + item.typeName) }} - + @@ -118,13 +118,13 @@ export default { }) }, getTypeName(value) { - return getTypeName(value) + return this.$t('webmsg.' + getTypeName(value)) }, typeChange(value) { this.search() }, toDetail(row) { - const param = { ...{ msgNotification: true, msgType: row.type, sourceParam: row.param }} + const param = { ...{ msgNotification: true, msgType: row.typeId, sourceParam: row.param }} this.$router.push({ name: row.router, params: param }) }, sortChange({ column, prop, order }) { diff --git a/frontend/src/views/msg/setting.vue b/frontend/src/views/msg/setting.vue index 124ee469fc..730cd3d858 100644 --- a/frontend/src/views/msg/setting.vue +++ b/frontend/src/views/msg/setting.vue @@ -4,7 +4,7 @@ {{ $t('webmsg.type') }} - {{ channel.channelName }} + {{ $t(channel.channelName) }} @@ -18,7 +18,7 @@ > - + {{ $t('webmsg.' + data.name) }}