diff --git a/backend/src/main/java/io/dataease/auth/service/ExtAuthService.java b/backend/src/main/java/io/dataease/auth/service/ExtAuthService.java new file mode 100644 index 0000000000..7a69be10b3 --- /dev/null +++ b/backend/src/main/java/io/dataease/auth/service/ExtAuthService.java @@ -0,0 +1,12 @@ +package io.dataease.auth.service; + +import io.dataease.commons.model.AuthURD; + +import java.util.Set; + +public interface ExtAuthService { + + Set userIdsByRD(AuthURD request); + + AuthURD resourceTarget(String resourceId); +} diff --git a/backend/src/main/java/io/dataease/auth/service/impl/ExtAuthServiceImpl.java b/backend/src/main/java/io/dataease/auth/service/impl/ExtAuthServiceImpl.java new file mode 100644 index 0000000000..f38f9272a0 --- /dev/null +++ b/backend/src/main/java/io/dataease/auth/service/impl/ExtAuthServiceImpl.java @@ -0,0 +1,63 @@ +package io.dataease.auth.service.impl; + +import io.dataease.auth.service.ExtAuthService; +import io.dataease.base.domain.SysAuth; +import io.dataease.base.domain.SysAuthExample; +import io.dataease.base.mapper.SysAuthMapper; +import io.dataease.base.mapper.ext.ExtAuthMapper; +import io.dataease.commons.model.AuthURD; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +@Service +public class ExtAuthServiceImpl implements ExtAuthService { + + @Resource + private ExtAuthMapper extAuthMapper; + + @Resource + private SysAuthMapper sysAuthMapper; + + @Override + public Set userIdsByRD(AuthURD request) { + Set result = new HashSet<>(); + List roleIds = request.getRoleIds(); + List deptIds = request.getDeptIds(); + if (!CollectionUtils.isEmpty(roleIds)) { + result.addAll(extAuthMapper.queryUserIdWithRoleIds(roleIds)); + } + if (!CollectionUtils.isEmpty(deptIds)) { + result.addAll(extAuthMapper.queryUserIdWithDeptIds(deptIds)); + } + + return result; + } + + @Override + public AuthURD resourceTarget(String resourceId) { + AuthURD authURD = new AuthURD(); + SysAuthExample example = new SysAuthExample(); + example.createCriteria().andAuthSourceEqualTo(resourceId); + List sysAuths = sysAuthMapper.selectByExample(example); + Map> authMap = sysAuths.stream().collect(Collectors.groupingBy(SysAuth::getAuthTargetType)); + if (!CollectionUtils.isEmpty(authMap.get("user"))) { + authURD.setUserIds(authMap.get("user").stream().map(item -> Long.parseLong(item.getAuthTarget())).collect(Collectors.toList())); + } + + if (!CollectionUtils.isEmpty(authMap.get("role"))) { + authURD.setUserIds(authMap.get("role").stream().map(item -> Long.parseLong(item.getAuthTarget())).collect(Collectors.toList())); + } + + if (!CollectionUtils.isEmpty(authMap.get("dept"))) { + authURD.setUserIds(authMap.get("dept").stream().map(item -> Long.parseLong(item.getAuthTarget())).collect(Collectors.toList())); + } + return authURD; + } +} diff --git a/backend/src/main/java/io/dataease/base/domain/SysMsg.java b/backend/src/main/java/io/dataease/base/domain/SysMsg.java new file mode 100644 index 0000000000..d18c3eada6 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/domain/SysMsg.java @@ -0,0 +1,27 @@ +package io.dataease.base.domain; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class SysMsg implements Serializable { + private Long msgId; + + private Long userId; + + private Integer type; + + private Boolean status; + + private String router; + + private String param; + + private Long createTime; + + private Long readTime; + + private String content; + + private static final long serialVersionUID = 1L; +} \ 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 new file mode 100644 index 0000000000..60c1d39c54 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/domain/SysMsgExample.java @@ -0,0 +1,770 @@ +package io.dataease.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class SysMsgExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public SysMsgExample() { + 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 andMsgIdIsNull() { + addCriterion("msg_id is null"); + return (Criteria) this; + } + + public Criteria andMsgIdIsNotNull() { + addCriterion("msg_id is not null"); + return (Criteria) this; + } + + public Criteria andMsgIdEqualTo(Long value) { + addCriterion("msg_id =", value, "msgId"); + return (Criteria) this; + } + + public Criteria andMsgIdNotEqualTo(Long value) { + addCriterion("msg_id <>", value, "msgId"); + return (Criteria) this; + } + + public Criteria andMsgIdGreaterThan(Long value) { + addCriterion("msg_id >", value, "msgId"); + return (Criteria) this; + } + + public Criteria andMsgIdGreaterThanOrEqualTo(Long value) { + addCriterion("msg_id >=", value, "msgId"); + return (Criteria) this; + } + + public Criteria andMsgIdLessThan(Long value) { + addCriterion("msg_id <", value, "msgId"); + return (Criteria) this; + } + + public Criteria andMsgIdLessThanOrEqualTo(Long value) { + addCriterion("msg_id <=", value, "msgId"); + return (Criteria) this; + } + + public Criteria andMsgIdIn(List values) { + addCriterion("msg_id in", values, "msgId"); + return (Criteria) this; + } + + public Criteria andMsgIdNotIn(List values) { + addCriterion("msg_id not in", values, "msgId"); + return (Criteria) this; + } + + public Criteria andMsgIdBetween(Long value1, Long value2) { + addCriterion("msg_id between", value1, value2, "msgId"); + return (Criteria) this; + } + + public Criteria andMsgIdNotBetween(Long value1, Long value2) { + addCriterion("msg_id not between", value1, value2, "msgId"); + 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 andTypeIsNull() { + addCriterion("`type` is null"); + return (Criteria) this; + } + + public Criteria andTypeIsNotNull() { + addCriterion("`type` is not null"); + return (Criteria) this; + } + + public Criteria andTypeEqualTo(Integer value) { + addCriterion("`type` =", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotEqualTo(Integer value) { + addCriterion("`type` <>", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThan(Integer value) { + addCriterion("`type` >", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("`type` >=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThan(Integer value) { + addCriterion("`type` <", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThanOrEqualTo(Integer value) { + addCriterion("`type` <=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeIn(List values) { + addCriterion("`type` in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List values) { + addCriterion("`type` not in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeBetween(Integer value1, Integer value2) { + addCriterion("`type` between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotBetween(Integer value1, Integer value2) { + addCriterion("`type` not between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andStatusIsNull() { + addCriterion("`status` is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("`status` is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(Boolean value) { + addCriterion("`status` =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(Boolean value) { + addCriterion("`status` <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(Boolean value) { + addCriterion("`status` >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(Boolean value) { + addCriterion("`status` >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(Boolean value) { + addCriterion("`status` <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(Boolean value) { + addCriterion("`status` <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("`status` in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("`status` not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(Boolean value1, Boolean value2) { + addCriterion("`status` between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(Boolean value1, Boolean value2) { + addCriterion("`status` not between", value1, value2, "status"); + 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; + } + + public Criteria andParamIsNotNull() { + addCriterion("param is not null"); + return (Criteria) this; + } + + public Criteria andParamEqualTo(String value) { + addCriterion("param =", value, "param"); + return (Criteria) this; + } + + public Criteria andParamNotEqualTo(String value) { + addCriterion("param <>", value, "param"); + return (Criteria) this; + } + + public Criteria andParamGreaterThan(String value) { + addCriterion("param >", value, "param"); + return (Criteria) this; + } + + public Criteria andParamGreaterThanOrEqualTo(String value) { + addCriterion("param >=", value, "param"); + return (Criteria) this; + } + + public Criteria andParamLessThan(String value) { + addCriterion("param <", value, "param"); + return (Criteria) this; + } + + public Criteria andParamLessThanOrEqualTo(String value) { + addCriterion("param <=", value, "param"); + return (Criteria) this; + } + + public Criteria andParamLike(String value) { + addCriterion("param like", value, "param"); + return (Criteria) this; + } + + public Criteria andParamNotLike(String value) { + addCriterion("param not like", value, "param"); + return (Criteria) this; + } + + public Criteria andParamIn(List values) { + addCriterion("param in", values, "param"); + return (Criteria) this; + } + + public Criteria andParamNotIn(List values) { + addCriterion("param not in", values, "param"); + return (Criteria) this; + } + + public Criteria andParamBetween(String value1, String value2) { + addCriterion("param between", value1, value2, "param"); + return (Criteria) this; + } + + public Criteria andParamNotBetween(String value1, String value2) { + addCriterion("param not between", value1, value2, "param"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Long value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Long value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Long value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Long value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Long value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Long value1, Long value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Long value1, Long value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andReadTimeIsNull() { + addCriterion("read_time is null"); + return (Criteria) this; + } + + public Criteria andReadTimeIsNotNull() { + addCriterion("read_time is not null"); + return (Criteria) this; + } + + public Criteria andReadTimeEqualTo(Long value) { + addCriterion("read_time =", value, "readTime"); + return (Criteria) this; + } + + public Criteria andReadTimeNotEqualTo(Long value) { + addCriterion("read_time <>", value, "readTime"); + return (Criteria) this; + } + + public Criteria andReadTimeGreaterThan(Long value) { + addCriterion("read_time >", value, "readTime"); + return (Criteria) this; + } + + public Criteria andReadTimeGreaterThanOrEqualTo(Long value) { + addCriterion("read_time >=", value, "readTime"); + return (Criteria) this; + } + + public Criteria andReadTimeLessThan(Long value) { + addCriterion("read_time <", value, "readTime"); + return (Criteria) this; + } + + public Criteria andReadTimeLessThanOrEqualTo(Long value) { + addCriterion("read_time <=", value, "readTime"); + return (Criteria) this; + } + + public Criteria andReadTimeIn(List values) { + addCriterion("read_time in", values, "readTime"); + return (Criteria) this; + } + + public Criteria andReadTimeNotIn(List values) { + addCriterion("read_time not in", values, "readTime"); + return (Criteria) this; + } + + public Criteria andReadTimeBetween(Long value1, Long value2) { + addCriterion("read_time between", value1, value2, "readTime"); + return (Criteria) this; + } + + public Criteria andReadTimeNotBetween(Long value1, Long value2) { + addCriterion("read_time not between", value1, value2, "readTime"); + return (Criteria) this; + } + + public Criteria andContentIsNull() { + addCriterion("content is null"); + return (Criteria) this; + } + + public Criteria andContentIsNotNull() { + addCriterion("content is not null"); + return (Criteria) this; + } + + public Criteria andContentEqualTo(String value) { + addCriterion("content =", value, "content"); + return (Criteria) this; + } + + public Criteria andContentNotEqualTo(String value) { + addCriterion("content <>", value, "content"); + return (Criteria) this; + } + + public Criteria andContentGreaterThan(String value) { + addCriterion("content >", value, "content"); + return (Criteria) this; + } + + public Criteria andContentGreaterThanOrEqualTo(String value) { + addCriterion("content >=", value, "content"); + return (Criteria) this; + } + + public Criteria andContentLessThan(String value) { + addCriterion("content <", value, "content"); + return (Criteria) this; + } + + public Criteria andContentLessThanOrEqualTo(String value) { + addCriterion("content <=", value, "content"); + return (Criteria) this; + } + + public Criteria andContentLike(String value) { + addCriterion("content like", value, "content"); + return (Criteria) this; + } + + public Criteria andContentNotLike(String value) { + addCriterion("content not like", value, "content"); + return (Criteria) this; + } + + public Criteria andContentIn(List values) { + addCriterion("content in", values, "content"); + return (Criteria) this; + } + + public Criteria andContentNotIn(List values) { + addCriterion("content not in", values, "content"); + return (Criteria) this; + } + + public Criteria andContentBetween(String value1, String value2) { + addCriterion("content between", value1, value2, "content"); + return (Criteria) this; + } + + public Criteria andContentNotBetween(String value1, String value2) { + addCriterion("content not between", value1, value2, "content"); + 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/SysMsgMapper.java b/backend/src/main/java/io/dataease/base/mapper/SysMsgMapper.java new file mode 100644 index 0000000000..8ba7f526c0 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/SysMsgMapper.java @@ -0,0 +1,30 @@ +package io.dataease.base.mapper; + +import io.dataease.base.domain.SysMsg; +import io.dataease.base.domain.SysMsgExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface SysMsgMapper { + long countByExample(SysMsgExample example); + + int deleteByExample(SysMsgExample example); + + int deleteByPrimaryKey(Long msgId); + + int insert(SysMsg record); + + int insertSelective(SysMsg record); + + List selectByExample(SysMsgExample example); + + SysMsg selectByPrimaryKey(Long msgId); + + int updateByExampleSelective(@Param("record") SysMsg record, @Param("example") SysMsgExample example); + + int updateByExample(@Param("record") SysMsg record, @Param("example") SysMsgExample example); + + int updateByPrimaryKeySelective(SysMsg record); + + int updateByPrimaryKey(SysMsg record); +} \ 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 new file mode 100644 index 0000000000..d13dafb604 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/SysMsgMapper.xml @@ -0,0 +1,275 @@ + + + + + + + + + + + + + + + + + + + + + + + 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_id, user_id, `type`, `status`, router, param, create_time, read_time, content + + + + + delete from sys_msg + where msg_id = #{msgId,jdbcType=BIGINT} + + + delete from sys_msg + + + + + + insert into sys_msg (msg_id, user_id, `type`, + `status`, router, param, + create_time, read_time, content + ) + values (#{msgId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, + #{status,jdbcType=BIT}, #{router,jdbcType=VARCHAR}, #{param,jdbcType=VARCHAR}, + #{createTime,jdbcType=BIGINT}, #{readTime,jdbcType=BIGINT}, #{content,jdbcType=VARCHAR} + ) + + + insert into sys_msg + + + msg_id, + + + user_id, + + + `type`, + + + `status`, + + + router, + + + param, + + + create_time, + + + read_time, + + + content, + + + + + #{msgId,jdbcType=BIGINT}, + + + #{userId,jdbcType=BIGINT}, + + + #{type,jdbcType=INTEGER}, + + + #{status,jdbcType=BIT}, + + + #{router,jdbcType=VARCHAR}, + + + #{param,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=BIGINT}, + + + #{readTime,jdbcType=BIGINT}, + + + #{content,jdbcType=VARCHAR}, + + + + + + update sys_msg + + + msg_id = #{record.msgId,jdbcType=BIGINT}, + + + user_id = #{record.userId,jdbcType=BIGINT}, + + + `type` = #{record.type,jdbcType=INTEGER}, + + + `status` = #{record.status,jdbcType=BIT}, + + + router = #{record.router,jdbcType=VARCHAR}, + + + param = #{record.param,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=BIGINT}, + + + read_time = #{record.readTime,jdbcType=BIGINT}, + + + content = #{record.content,jdbcType=VARCHAR}, + + + + + + + + update sys_msg + set msg_id = #{record.msgId,jdbcType=BIGINT}, + user_id = #{record.userId,jdbcType=BIGINT}, + `type` = #{record.type,jdbcType=INTEGER}, + `status` = #{record.status,jdbcType=BIT}, + router = #{record.router,jdbcType=VARCHAR}, + param = #{record.param,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=BIGINT}, + read_time = #{record.readTime,jdbcType=BIGINT}, + content = #{record.content,jdbcType=VARCHAR} + + + + + + update sys_msg + + + user_id = #{userId,jdbcType=BIGINT}, + + + `type` = #{type,jdbcType=INTEGER}, + + + `status` = #{status,jdbcType=BIT}, + + + router = #{router,jdbcType=VARCHAR}, + + + param = #{param,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=BIGINT}, + + + read_time = #{readTime,jdbcType=BIGINT}, + + + content = #{content,jdbcType=VARCHAR}, + + + where msg_id = #{msgId,jdbcType=BIGINT} + + + update sys_msg + set user_id = #{userId,jdbcType=BIGINT}, + `type` = #{type,jdbcType=INTEGER}, + `status` = #{status,jdbcType=BIT}, + router = #{router,jdbcType=VARCHAR}, + param = #{param,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + read_time = #{readTime,jdbcType=BIGINT}, + content = #{content,jdbcType=VARCHAR} + where msg_id = #{msgId,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtAuthMapper.java b/backend/src/main/java/io/dataease/base/mapper/ext/ExtAuthMapper.java new file mode 100644 index 0000000000..fe7d57a75b --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtAuthMapper.java @@ -0,0 +1,17 @@ +package io.dataease.base.mapper.ext; + + +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +public interface ExtAuthMapper { + + List queryUserIdWithRoleIds(@Param("roleIds") List roleIds); + + List queryUserIdWithDeptIds(@Param("deptIds") List deptIds); + + + // Set queryUserIdWithRD(@Param("roleIds") List roleIds, @Param("deptIds") List deptIds); +} diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtAuthMapper.xml b/backend/src/main/java/io/dataease/base/mapper/ext/ExtAuthMapper.xml new file mode 100644 index 0000000000..991709ff3b --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtAuthMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelShareMapper.java b/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelShareMapper.java index a676b133e6..03f3aab385 100644 --- a/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelShareMapper.java +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelShareMapper.java @@ -15,4 +15,8 @@ public interface ExtPanelShareMapper { List query(Map param); List queryWithResource(GridExample example); + + List queryUserIdWithRoleIds(Map> param); + + List queryUserIdWithDeptIds(Map> param); } diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelShareMapper.xml b/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelShareMapper.xml index e880756b87..f288f31e74 100644 --- a/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelShareMapper.xml +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtPanelShareMapper.xml @@ -46,6 +46,24 @@ + + + + diff --git a/backend/src/main/java/io/dataease/commons/model/AuthURD.java b/backend/src/main/java/io/dataease/commons/model/AuthURD.java new file mode 100644 index 0000000000..cf16b9bda6 --- /dev/null +++ b/backend/src/main/java/io/dataease/commons/model/AuthURD.java @@ -0,0 +1,19 @@ +package io.dataease.commons.model; + + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class AuthURD implements Serializable { + + private List userIds; + + private List deptIds; + + private List roleIds; + + +} diff --git a/backend/src/main/java/io/dataease/commons/utils/AuthUtils.java b/backend/src/main/java/io/dataease/commons/utils/AuthUtils.java index fbfce091f0..1462859425 100644 --- a/backend/src/main/java/io/dataease/commons/utils/AuthUtils.java +++ b/backend/src/main/java/io/dataease/commons/utils/AuthUtils.java @@ -1,23 +1,41 @@ package io.dataease.commons.utils; import io.dataease.auth.api.dto.CurrentUserDto; -import io.dataease.service.sys.SysUserService; +import io.dataease.auth.service.ExtAuthService; +import io.dataease.commons.model.AuthURD; import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.Set; @Component public class AuthUtils { - private static SysUserService sysUserService; + private static ExtAuthService extAuthService; @Autowired - public void setSysUserService(SysUserService sysUserService) { - AuthUtils.sysUserService = sysUserService; + public void setExtAuthService(ExtAuthService extAuthService) { + AuthUtils.extAuthService = extAuthService; } public static CurrentUserDto getUser(){ CurrentUserDto userDto = (CurrentUserDto)SecurityUtils.getSubject().getPrincipal(); return userDto; } + + //根据组织 角色 用户 获取下属用户ID + public static Set userIdsByURD(AuthURD request) { + Set userIds = extAuthService.userIdsByRD(request); + if (!CollectionUtils.isEmpty(request.getUserIds())) { + userIds.addAll(request.getUserIds()); + } + return userIds; + } + + // 获取资源对那些人/角色/组织 有权限 + public static AuthURD authURDR(String resourceId) { + return extAuthService.resourceTarget(resourceId); + } } diff --git a/backend/src/main/java/io/dataease/controller/message/MsgController.java b/backend/src/main/java/io/dataease/controller/message/MsgController.java new file mode 100644 index 0000000000..49d6de81c7 --- /dev/null +++ b/backend/src/main/java/io/dataease/controller/message/MsgController.java @@ -0,0 +1,39 @@ +package io.dataease.controller.message; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import io.dataease.base.domain.SysMsg; +import io.dataease.commons.utils.AuthUtils; +import io.dataease.commons.utils.PageUtils; +import io.dataease.commons.utils.Pager; +import io.dataease.controller.message.dto.MsgRequest; +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; + +@Api(tags = "系统:消息管理") +@RequestMapping("/api/sys_msg") +@RestController +public class MsgController { + + @Resource + private SysMsgService sysMsgService; + + @ApiOperation("查询消息") + @PostMapping("/list/{goPage}/{pageSize}") + 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)); + return listPager; + } + + @PostMapping("/setReaded/{msgId}") + public void setReaded(@PathVariable Long msgId) { + sysMsgService.setReaded(msgId); + } +} 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 new file mode 100644 index 0000000000..c95b20d637 --- /dev/null +++ b/backend/src/main/java/io/dataease/controller/message/dto/MsgRequest.java @@ -0,0 +1,13 @@ +package io.dataease.controller.message.dto; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class MsgRequest implements Serializable { + + private Integer type; + + private Boolean status; +} 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 2a856f21b9..9e262a7022 100644 --- a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java +++ b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java @@ -10,10 +10,8 @@ import io.dataease.commons.constants.JdbcConstants; import io.dataease.commons.constants.JobStatus; import io.dataease.commons.constants.ScheduleType; import io.dataease.commons.constants.UpdateType; -import io.dataease.commons.utils.CommonBeanFactory; -import io.dataease.commons.utils.DorisTableUtils; -import io.dataease.commons.utils.HttpClientUtil; -import io.dataease.commons.utils.LogUtil; +import io.dataease.commons.model.AuthURD; +import io.dataease.commons.utils.*; import io.dataease.datasource.constants.DatasourceTypes; import io.dataease.datasource.dto.*; import io.dataease.datasource.provider.DatasourceProvider; @@ -24,6 +22,7 @@ import io.dataease.dto.dataset.DataTableInfoDTO; import io.dataease.exception.DataEaseException; import io.dataease.listener.util.CacheUtils; import io.dataease.provider.QueryProvider; +import io.dataease.service.message.DeMsgutil; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; @@ -74,8 +73,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.net.InetAddress; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @Service @@ -206,10 +204,15 @@ public class ExtractDataService { extractData(datasetTable, "all_scope"); replaceTable(DorisTableUtils.dorisName(datasetTableId)); saveSucessLog(datasetTableTaskLog); + + sendWebMsg(datasetTable, taskId,true); + // deleteFile("all_scope", datasetTableId); + updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime); }catch (Exception e){ saveErrorLog(datasetTableId, taskId, e); + sendWebMsg(datasetTable, taskId,false); updateTableStatus(datasetTableId, datasetTable, JobStatus.Error, null); dropDorisTable(DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTableId))); // deleteFile("all_scope", datasetTableId); @@ -230,6 +233,7 @@ public class ExtractDataService { Long execTime = System.currentTimeMillis(); extractData(datasetTable, "incremental_add"); saveSucessLog(datasetTableTaskLog); + sendWebMsg(datasetTable, taskId,true); updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime); }else { DatasetTableIncrementalConfig datasetTableIncrementalConfig = dataSetTableService.incrementalConfig(datasetTableId); @@ -267,12 +271,17 @@ public class ExtractDataService { extractData(datasetTable, "incremental_delete"); } saveSucessLog(datasetTableTaskLog); + + sendWebMsg(datasetTable, taskId,true); + // deleteFile("incremental_add", datasetTableId); // deleteFile("incremental_delete", datasetTableId); + updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime); } }catch (Exception e){ saveErrorLog(datasetTableId, taskId, e); + sendWebMsg(datasetTable, taskId,false); updateTableStatus(datasetTableId, datasetTable, JobStatus.Error, null); // deleteFile("incremental_add", datasetTableId); // deleteFile("incremental_delete", datasetTableId); @@ -294,6 +303,20 @@ public class ExtractDataService { } + private void sendWebMsg(DatasetTable datasetTable, String taskId, Boolean status) { + String msg = status ? "成功" : "失败"; + String id = datasetTable.getId(); + AuthURD authURD = AuthUtils.authURDR(id); + Set userIds = AuthUtils.userIdsByURD(authURD); + Gson gson = new Gson(); + userIds.forEach(userId -> { + Map param = new HashMap<>(); + param.put("tableId", id); + param.put("taskId", taskId); + DeMsgutil.sendMsg(userId, 1, "数据集【"+datasetTable.getName()+"】同步"+msg, gson.toJson(param)); + }); + } + private void updateTableStatus(String datasetTableId, DatasetTable datasetTable, JobStatus completed, Long execTime) { datasetTable.setSyncStatus(completed.name()); if(execTime != null){ diff --git a/backend/src/main/java/io/dataease/service/message/DeMsgutil.java b/backend/src/main/java/io/dataease/service/message/DeMsgutil.java new file mode 100644 index 0000000000..fc1b3d354b --- /dev/null +++ b/backend/src/main/java/io/dataease/service/message/DeMsgutil.java @@ -0,0 +1,53 @@ +package io.dataease.service.message; + +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; + + @Autowired + public void setSysMsgService(SysMsgService sysMsgService) { + 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) { + 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()); + sysMsg.setParam(param); + sysMsgService.save(sysMsg); + } + +} diff --git a/backend/src/main/java/io/dataease/service/message/SysMsgService.java b/backend/src/main/java/io/dataease/service/message/SysMsgService.java new file mode 100644 index 0000000000..754dc6d6ab --- /dev/null +++ b/backend/src/main/java/io/dataease/service/message/SysMsgService.java @@ -0,0 +1,61 @@ +package io.dataease.service.message; + + +import io.dataease.base.domain.SysMsg; +import io.dataease.base.domain.SysMsgExample; +import io.dataease.base.mapper.SysMsgMapper; +import io.dataease.controller.message.dto.MsgRequest; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.List; + +@Service +public class SysMsgService { + + @Resource + private SysMsgMapper sysMsgMapper; + + public List query(Long userId, MsgRequest msgRequest) { + String orderClause = ""; + SysMsgExample example = new SysMsgExample(); + SysMsgExample.Criteria criteria = example.createCriteria(); + criteria.andUserIdEqualTo(userId); + + + if (ObjectUtils.isNotEmpty(msgRequest.getType())) { + criteria.andTypeEqualTo(msgRequest.getType()); + } + + if (ObjectUtils.isNotEmpty(msgRequest.getStatus())) { + criteria.andStatusEqualTo(msgRequest.getStatus()); + }else { + orderClause += " status asc ,"; + } + + orderClause += " create_time desc"; + example.setOrderByClause(orderClause); + List sysMsgs = sysMsgMapper.selectByExample(example); + return sysMsgs; + } + + public void setReaded(Long msgId) { + SysMsg sysMsg = new SysMsg(); + sysMsg.setMsgId(msgId); + sysMsg.setStatus(true); + sysMsgMapper.updateByPrimaryKeySelective(sysMsg); + } + + public void save(SysMsg sysMsg) { +// sysMsg.setStatus(false); +// sysMsg.setCreateTime(System.currentTimeMillis()); + sysMsgMapper.insert(sysMsg); + } + + public void update(SysMsg sysMsg) { + + sysMsgMapper.updateByPrimaryKey(sysMsg); + } + + +} 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 6c2d7c1300..c80551437c 100644 --- a/backend/src/main/java/io/dataease/service/panel/ShareService.java +++ b/backend/src/main/java/io/dataease/service/panel/ShareService.java @@ -1,12 +1,16 @@ package io.dataease.service.panel; +import com.google.gson.Gson; import io.dataease.auth.api.dto.CurrentRoleDto; import io.dataease.auth.api.dto.CurrentUserDto; +import io.dataease.base.domain.PanelGroup; import io.dataease.base.domain.PanelShare; import io.dataease.base.domain.PanelShareExample; +import io.dataease.base.mapper.PanelGroupMapper; import io.dataease.base.mapper.PanelShareMapper; import io.dataease.base.mapper.ext.ExtPanelShareMapper; import io.dataease.base.mapper.ext.query.GridExample; +import io.dataease.commons.model.AuthURD; import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.CommonBeanFactory; @@ -14,15 +18,14 @@ import io.dataease.controller.request.panel.PanelShareRequest; import io.dataease.controller.sys.base.BaseGridRequest; import io.dataease.dto.panel.PanelShareDto; import io.dataease.dto.panel.PanelSharePo; +import io.dataease.service.message.DeMsgutil; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; @@ -32,13 +35,15 @@ public class ShareService { @Autowired(required = false) private PanelShareMapper mapper; + @Resource + private PanelGroupMapper panelGroupMapper; @Resource private ExtPanelShareMapper extPanelShareMapper; @Transactional public void save(PanelShareRequest request){ - + List panelGroups = queryGroup(request.getPanelIds()); //1.先根据仪表板删除所有已经分享的 Integer type = request.getType(); List panelIds = request.getPanelIds(); @@ -66,6 +71,33 @@ public class ShareService { if (CollectionUtils.isNotEmpty(shares)){ extPanelShareMapper.batchInsert(shares); } + + // 下面是发送提醒消息逻辑 + Set userIdSet = new HashSet(); + AuthURD authURD = new AuthURD(); + if (type == 0) { + authURD.setUserIds(targetIds); + } + if (type == 1) { + authURD.setRoleIds(targetIds); + } + if(type == 2) { + authURD.setDeptIds(targetIds); + } + userIdSet = AuthUtils.userIdsByURD(authURD); + + CurrentUserDto user = AuthUtils.getUser(); + String msg = StringUtils.joinWith(",", panelGroups.stream().map(PanelGroup::getName).collect(Collectors.toList())); + Gson gson = new Gson(); + userIdSet.forEach(userId -> { + // DeMsgutil.sendMsg(userId, 0, user.getNickName()+" 分享了仪表板【"+msg+"】给您,请查收!"); + DeMsgutil.sendMsg(userId, 0, user.getNickName()+" 分享了仪表板【"+msg+"】给您,请查收!", gson.toJson(panelIds)); + }); + + } + + private List queryGroup(List panelIds) { + return panelIds.stream().map(panelGroupMapper::selectByPrimaryKey).collect(Collectors.toList()); } /** diff --git a/backend/src/main/resources/db/migration/V10__web_msg.sql b/backend/src/main/resources/db/migration/V10__web_msg.sql new file mode 100644 index 0000000000..dfb1d13e33 --- /dev/null +++ b/backend/src/main/resources/db/migration/V10__web_msg.sql @@ -0,0 +1,19 @@ +-- ---------------------------- +-- Table structure for sys_msg +-- ---------------------------- +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 '类型', + `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_status` (`status`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='消息通知表'; \ No newline at end of file diff --git a/frontend/src/api/system/msg.js b/frontend/src/api/system/msg.js new file mode 100644 index 0000000000..6b4638fc7d --- /dev/null +++ b/frontend/src/api/system/msg.js @@ -0,0 +1,19 @@ +import request from '@/utils/request' + +export function query(pageIndex, pageSize, data) { + return request({ + url: '/api/sys_msg/list/' + pageIndex + '/' + pageSize, + method: 'post', + loading: true, + data + }) +} + +export function updateStatus(msgId) { + return request({ + url: '/api/sys_msg/setReaded/' + msgId, + method: 'post', + loading: true + }) +} + diff --git a/frontend/src/components/Notification/index.vue b/frontend/src/components/Notification/index.vue new file mode 100644 index 0000000000..f4ccc0e370 --- /dev/null +++ b/frontend/src/components/Notification/index.vue @@ -0,0 +1,178 @@ + + + + + diff --git a/frontend/src/icons/svg/all-msg.svg b/frontend/src/icons/svg/all-msg.svg new file mode 100644 index 0000000000..e8a1f85bad --- /dev/null +++ b/frontend/src/icons/svg/all-msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/icons/svg/notification.svg b/frontend/src/icons/svg/notification.svg new file mode 100644 index 0000000000..4f7b1167d6 --- /dev/null +++ b/frontend/src/icons/svg/notification.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/icons/svg/readed-msg.svg b/frontend/src/icons/svg/readed-msg.svg new file mode 100644 index 0000000000..55ae26090c --- /dev/null +++ b/frontend/src/icons/svg/readed-msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/icons/svg/unread-msg.svg b/frontend/src/icons/svg/unread-msg.svg new file mode 100644 index 0000000000..86c571f275 --- /dev/null +++ b/frontend/src/icons/svg/unread-msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/icons/svg/web-msg.svg b/frontend/src/icons/svg/web-msg.svg new file mode 100644 index 0000000000..c3c609e73f --- /dev/null +++ b/frontend/src/icons/svg/web-msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index 42db324cf2..ac06118638 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -1137,5 +1137,12 @@ export default { can_not_move_change_sort: 'Cannot move to change sort', can_not_move_parent_to_children: 'Parent organization cannot move to its own child node', move_success: 'Mobile success' + }, + webmsg: { + web_msg: 'On site message notification', + show_more: 'View more', + all_type: 'All type', + panel_type: 'Panel Share', + dataset_type: 'Dataset sync' } } diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 235c84a14f..25ccba0d53 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -1179,5 +1179,12 @@ export default { can_not_move_change_sort: '不能移動以改變排序', can_not_move_parent_to_children: '父組織不能移動到自己的子節點下', move_success: '移動成功' + }, + webmsg: { + web_msg: '站內消息通知', + show_more: '查看更多', + all_type: '全部類型', + panel_type: '儀表板分享', + dataset_type: '數據集同步' } } diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 2f2f0a20ea..c8e612fc2d 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -1142,5 +1142,12 @@ export default { can_not_move_change_sort: '不能移动以改变排序', can_not_move_parent_to_children: '父组织不能移动到自己的子节点下', move_success: '移动成功' + }, + webmsg: { + web_msg: '站内消息通知', + show_more: '查看更多', + all_type: '全部类型', + panel_type: '仪表板分享', + dataset_type: '数据集同步' } } diff --git a/frontend/src/layout/components/Topbar.vue b/frontend/src/layout/components/Topbar.vue index c7ef78be59..6b04a0790f 100644 --- a/frontend/src/layout/components/Topbar.vue +++ b/frontend/src/layout/components/Topbar.vue @@ -35,7 +35,7 @@ - +
@@ -75,7 +75,7 @@ import { mapGetters } from 'vuex' import AppLink from './Sidebar/Link' import variables from '@/styles/variables.scss' import { isExternal } from '@/utils/validate' -// import Doc from '@/components/Doc' +import Notification from '@/components/Notification' // import Screenfull from '@/components/Screenfull' // import SizeSelect from '@/components/SizeSelect' import LangSelect from '@/components/LangSelect' @@ -86,6 +86,7 @@ export default { AppLink, // Screenfull, // SizeSelect, + Notification, LangSelect // Doc }, diff --git a/frontend/src/permission.js b/frontend/src/permission.js index dda02c2b86..4dd236cfc0 100644 --- a/frontend/src/permission.js +++ b/frontend/src/permission.js @@ -76,6 +76,7 @@ export const loadMenus = (next, to) => { buildMenus().then(res => { const filterDatas = filterRouter(res.data) const asyncRouter = filterAsyncRouter(filterDatas) + addMsgMenu(asyncRouter) asyncRouter.push({ path: '*', redirect: '/404', hidden: true }) store.dispatch('permission/GenerateRoutes', asyncRouter).then(() => { // 存储路由 router.addRoutes(asyncRouter) @@ -87,6 +88,44 @@ export const loadMenus = (next, to) => { }) }) } + +export const addMsgMenu = asyncRouter => { + const menu = { + path: 'system-msg-web', + component: () => import('@/views/msg/index'), + name: 'sys-msg-web', + meta: { title: '站内消息', icon: 'all-msg' }, + children: [ + { + path: 'all', + component: () => import('@/views/msg/all'), + name: 'sys-msg-web-all', + meta: { title: '所有消息', icon: 'web-msg' } + }, + { + path: 'unread', + component: () => import('@/views/msg/unread'), + name: 'sys-msg-web-unread', + meta: { title: '未读消息', icon: 'unread-msg' } + + }, + { + path: 'readed', + component: () => import('@/views/msg/readed'), + name: 'sys-msg-web-readed', + meta: { title: '已读消息', icon: 'readed-msg' } + } + ] + } + asyncRouter.forEach(element => { + if (element.name === 'system') { + if (element.children) { + element.children.splice(0, 0, menu) + } + // element.children.push(menu) + } + }) +} /** * 验证path是否有效 * @param {*} path diff --git a/frontend/src/styles/index.scss b/frontend/src/styles/index.scss index d6beaf3f54..93ee1c8c13 100644 --- a/frontend/src/styles/index.scss +++ b/frontend/src/styles/index.scss @@ -189,10 +189,26 @@ div:focus { } } } +.de-msg-data-table { + .el-table__body-wrapper >table>{ + tbody { + .el-table__row { + :hover { + cursor: pointer; + } + } + td { + padding: 3px 0 !important; + } + } + } +} .de-filter-data-table::before { height: 0px !important; } - +.de-msg-data-table::before { + height: 0px !important; +} .custom-component-class { width: 100%; div.el-input-group__append { diff --git a/frontend/src/styles/sidebar.scss b/frontend/src/styles/sidebar.scss index 6f5fdcafab..7f92d75481 100644 --- a/frontend/src/styles/sidebar.scss +++ b/frontend/src/styles/sidebar.scss @@ -85,7 +85,7 @@ } .is-active>.el-submenu__title { - color: $subMenuActiveText !important; + color: $menuActiveText !important; } & .nest-menu .el-submenu>.el-submenu__title, @@ -94,7 +94,7 @@ background-color: $subMenuBg !important; &:hover { - background-color: $subMenuHover !important; + background-color: $menuHover !important; } } } diff --git a/frontend/src/styles/variables.scss b/frontend/src/styles/variables.scss index 4dfe4ad8d9..0f4300f328 100644 --- a/frontend/src/styles/variables.scss +++ b/frontend/src/styles/variables.scss @@ -36,7 +36,7 @@ $menuBg:#ffffff; // $menuHover:#263445; $menuHover: rgba(158, 158, 158, 0.2); -$subMenuBg:#1f2d3d; +$subMenuBg:#ffffff; // $subMenuHover:#001528; $subMenuHover:#0a7be0; $colorBg:rgba(10,123,224,.1); diff --git a/frontend/src/utils/webMsg.js b/frontend/src/utils/webMsg.js new file mode 100644 index 0000000000..0f57d12276 --- /dev/null +++ b/frontend/src/utils/webMsg.js @@ -0,0 +1,17 @@ +export const msgTypes = [ + // { value: -1, label: '全部类型' }, + // { value: 0, label: '仪表板分享' }, + // { value: 1, label: '数据集同步' } + { value: -1, label: 'webmsg.all_type' }, + { value: 0, label: 'webmsg.panel_type' }, + { value: 1, label: 'webmsg.dataset_type' } +] + +export const getTypeName = value => { + for (let index = 0; index < msgTypes.length; index++) { + const element = msgTypes[index] + if (element.value === value) { + return element.label + } + } +} diff --git a/frontend/src/views/dataset/data/ViewTable.vue b/frontend/src/views/dataset/data/ViewTable.vue index ee41a2b5af..0330cb80a4 100644 --- a/frontend/src/views/dataset/data/ViewTable.vue +++ b/frontend/src/views/dataset/data/ViewTable.vue @@ -103,6 +103,9 @@ export default { 'param': function() { this.initTable(this.param) } + }, + created() { + }, mounted() { this.initTable(this.param) @@ -187,6 +190,10 @@ export default { return { 'type': type } + }, + msg2Current(sourceParam) { + this.tabActive = 'updateInfo' + this.table.msgTaskId = sourceParam.taskId } } } diff --git a/frontend/src/views/dataset/index.vue b/frontend/src/views/dataset/index.vue index 364e3e1fd9..6ba8bf7c8a 100644 --- a/frontend/src/views/dataset/index.vue +++ b/frontend/src/views/dataset/index.vue @@ -7,7 +7,7 @@ - + @@ -40,6 +40,27 @@ export default { mounted() { removeClass(document.body, 'showRightPanel') }, + created() { + this.$store.dispatch('app/toggleSideBarHide', true) + let routerParam + if ((routerParam = this.$router.currentRoute.params) !== null && routerParam.msgNotification) { + // 说明是从消息通知跳转过来的 + if (routerParam.msgType === 1) { // 是数据集同步 + 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) + }) + } catch (error) { + console.error(error) + } + } + } + } + }, methods: { switchComponent(c) { this.param = c.param diff --git a/frontend/src/views/msg/all.vue b/frontend/src/views/msg/all.vue new file mode 100644 index 0000000000..576a634137 --- /dev/null +++ b/frontend/src/views/msg/all.vue @@ -0,0 +1,146 @@ + + + + + diff --git a/frontend/src/views/msg/index.vue b/frontend/src/views/msg/index.vue new file mode 100644 index 0000000000..0d8026c857 --- /dev/null +++ b/frontend/src/views/msg/index.vue @@ -0,0 +1,21 @@ + + + + diff --git a/frontend/src/views/msg/readed.vue b/frontend/src/views/msg/readed.vue new file mode 100644 index 0000000000..4683d5f533 --- /dev/null +++ b/frontend/src/views/msg/readed.vue @@ -0,0 +1,140 @@ + + + + + diff --git a/frontend/src/views/msg/unread.vue b/frontend/src/views/msg/unread.vue new file mode 100644 index 0000000000..ee069a5921 --- /dev/null +++ b/frontend/src/views/msg/unread.vue @@ -0,0 +1,146 @@ + + + + + diff --git a/frontend/src/views/panel/GrantAuth/shareTree.vue b/frontend/src/views/panel/GrantAuth/shareTree.vue index acc3747ce4..f9b353538c 100644 --- a/frontend/src/views/panel/GrantAuth/shareTree.vue +++ b/frontend/src/views/panel/GrantAuth/shareTree.vue @@ -1,9 +1,9 @@