feat: 恢复误删

This commit is contained in:
fit2cloud-chenyw 2021-02-26 11:40:15 +08:00
parent b07ea4ab71
commit ccaa6a2774
38 changed files with 3066 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class ChartGroup implements Serializable {
private String id;
private String name;
private String pid;
private Integer level;
private String type;
private String createBy;
private Long createTime;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,670 @@
package io.dataease.base.domain;
import java.util.ArrayList;
import java.util.List;
public class ChartGroupExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public ChartGroupExample() {
oredCriteria = new ArrayList<Criteria>();
}
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<Criteria> 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<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> 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 andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("`name` is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("`name` is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("`name` =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("`name` <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("`name` >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("`name` >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("`name` <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("`name` <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("`name` like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("`name` not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("`name` not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("`name` between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("`name` not between", value1, value2, "name");
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(String value) {
addCriterion("pid =", value, "pid");
return (Criteria) this;
}
public Criteria andPidNotEqualTo(String value) {
addCriterion("pid <>", value, "pid");
return (Criteria) this;
}
public Criteria andPidGreaterThan(String value) {
addCriterion("pid >", value, "pid");
return (Criteria) this;
}
public Criteria andPidGreaterThanOrEqualTo(String value) {
addCriterion("pid >=", value, "pid");
return (Criteria) this;
}
public Criteria andPidLessThan(String value) {
addCriterion("pid <", value, "pid");
return (Criteria) this;
}
public Criteria andPidLessThanOrEqualTo(String value) {
addCriterion("pid <=", value, "pid");
return (Criteria) this;
}
public Criteria andPidLike(String value) {
addCriterion("pid like", value, "pid");
return (Criteria) this;
}
public Criteria andPidNotLike(String value) {
addCriterion("pid not like", value, "pid");
return (Criteria) this;
}
public Criteria andPidIn(List<String> values) {
addCriterion("pid in", values, "pid");
return (Criteria) this;
}
public Criteria andPidNotIn(List<String> values) {
addCriterion("pid not in", values, "pid");
return (Criteria) this;
}
public Criteria andPidBetween(String value1, String value2) {
addCriterion("pid between", value1, value2, "pid");
return (Criteria) this;
}
public Criteria andPidNotBetween(String value1, String value2) {
addCriterion("pid not between", value1, value2, "pid");
return (Criteria) this;
}
public Criteria andLevelIsNull() {
addCriterion("`level` is null");
return (Criteria) this;
}
public Criteria andLevelIsNotNull() {
addCriterion("`level` is not null");
return (Criteria) this;
}
public Criteria andLevelEqualTo(Integer value) {
addCriterion("`level` =", value, "level");
return (Criteria) this;
}
public Criteria andLevelNotEqualTo(Integer value) {
addCriterion("`level` <>", value, "level");
return (Criteria) this;
}
public Criteria andLevelGreaterThan(Integer value) {
addCriterion("`level` >", value, "level");
return (Criteria) this;
}
public Criteria andLevelGreaterThanOrEqualTo(Integer value) {
addCriterion("`level` >=", value, "level");
return (Criteria) this;
}
public Criteria andLevelLessThan(Integer value) {
addCriterion("`level` <", value, "level");
return (Criteria) this;
}
public Criteria andLevelLessThanOrEqualTo(Integer value) {
addCriterion("`level` <=", value, "level");
return (Criteria) this;
}
public Criteria andLevelIn(List<Integer> values) {
addCriterion("`level` in", values, "level");
return (Criteria) this;
}
public Criteria andLevelNotIn(List<Integer> values) {
addCriterion("`level` not in", values, "level");
return (Criteria) this;
}
public Criteria andLevelBetween(Integer value1, Integer value2) {
addCriterion("`level` between", value1, value2, "level");
return (Criteria) this;
}
public Criteria andLevelNotBetween(Integer value1, Integer value2) {
addCriterion("`level` not between", value1, value2, "level");
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(String value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("`type` like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("`type` not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andCreateByIsNull() {
addCriterion("create_by is null");
return (Criteria) this;
}
public Criteria andCreateByIsNotNull() {
addCriterion("create_by is not null");
return (Criteria) this;
}
public Criteria andCreateByEqualTo(String value) {
addCriterion("create_by =", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotEqualTo(String value) {
addCriterion("create_by <>", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByGreaterThan(String value) {
addCriterion("create_by >", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByGreaterThanOrEqualTo(String value) {
addCriterion("create_by >=", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByLessThan(String value) {
addCriterion("create_by <", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByLessThanOrEqualTo(String value) {
addCriterion("create_by <=", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByLike(String value) {
addCriterion("create_by like", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotLike(String value) {
addCriterion("create_by not like", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByIn(List<String> values) {
addCriterion("create_by in", values, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotIn(List<String> values) {
addCriterion("create_by not in", values, "createBy");
return (Criteria) this;
}
public Criteria andCreateByBetween(String value1, String value2) {
addCriterion("create_by between", value1, value2, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotBetween(String value1, String value2) {
addCriterion("create_by not between", value1, value2, "createBy");
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<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> 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 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);
}
}
}

View File

@ -0,0 +1,30 @@
package io.dataease.base.mapper;
import io.dataease.base.domain.ChartGroup;
import io.dataease.base.domain.ChartGroupExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ChartGroupMapper {
long countByExample(ChartGroupExample example);
int deleteByExample(ChartGroupExample example);
int deleteByPrimaryKey(String id);
int insert(ChartGroup record);
int insertSelective(ChartGroup record);
List<ChartGroup> selectByExample(ChartGroupExample example);
ChartGroup selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") ChartGroup record, @Param("example") ChartGroupExample example);
int updateByExample(@Param("record") ChartGroup record, @Param("example") ChartGroupExample example);
int updateByPrimaryKeySelective(ChartGroup record);
int updateByPrimaryKey(ChartGroup record);
}

View File

@ -0,0 +1,243 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.dataease.base.mapper.ChartGroupMapper">
<resultMap id="BaseResultMap" type="io.dataease.base.domain.ChartGroup">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="pid" jdbcType="VARCHAR" property="pid" />
<result column="level" jdbcType="INTEGER" property="level" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, pid, `level`, `type`, create_by, create_time
</sql>
<select id="selectByExample" parameterType="io.dataease.base.domain.ChartGroupExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from chart_group
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from chart_group
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from chart_group
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.dataease.base.domain.ChartGroupExample">
delete from chart_group
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.dataease.base.domain.ChartGroup">
insert into chart_group (id, `name`, pid,
`level`, `type`, create_by,
create_time)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{pid,jdbcType=VARCHAR},
#{level,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.ChartGroup">
insert into chart_group
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
`name`,
</if>
<if test="pid != null">
pid,
</if>
<if test="level != null">
`level`,
</if>
<if test="type != null">
`type`,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="pid != null">
#{pid,jdbcType=VARCHAR},
</if>
<if test="level != null">
#{level,jdbcType=INTEGER},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.dataease.base.domain.ChartGroupExample" resultType="java.lang.Long">
select count(*) from chart_group
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update chart_group
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.pid != null">
pid = #{record.pid,jdbcType=VARCHAR},
</if>
<if test="record.level != null">
`level` = #{record.level,jdbcType=INTEGER},
</if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update chart_group
set id = #{record.id,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
pid = #{record.pid,jdbcType=VARCHAR},
`level` = #{record.level,jdbcType=INTEGER},
`type` = #{record.type,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.ChartGroup">
update chart_group
<set>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="pid != null">
pid = #{pid,jdbcType=VARCHAR},
</if>
<if test="level != null">
`level` = #{level,jdbcType=INTEGER},
</if>
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.ChartGroup">
update chart_group
set `name` = #{name,jdbcType=VARCHAR},
pid = #{pid,jdbcType=VARCHAR},
`level` = #{level,jdbcType=INTEGER},
`type` = #{type,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -0,0 +1,26 @@
package io.dataease.controller.chart;
import com.alibaba.fastjson.JSON;
import io.dataease.base.domain.DatasetTable;
import io.dataease.controller.request.dataset.DataSetTableRequest;
import io.dataease.datasource.dto.TableFiled;
import io.dataease.service.dataset.DataSetTableService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("chart/table")
public class ChartController {
@PostMapping("list")
public List<JSON> list(@RequestBody DataSetTableRequest dataSetTableRequest) {
return new ArrayList<>();
}
}

View File

@ -0,0 +1,32 @@
package io.dataease.controller.chart;
import io.dataease.base.domain.ChartGroup;
import io.dataease.controller.request.chart.ChartGroupRequest;
import io.dataease.dto.chart.ChartGroupDTO;
import io.dataease.service.chart.ChartGroupService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("chart/group")
public class ChartGroupController {
@Resource
private ChartGroupService chartGroupService;
@PostMapping("/save")
public ChartGroupDTO save(@RequestBody ChartGroup ChartGroup) {
return chartGroupService.save(ChartGroup);
}
@PostMapping("/tree")
public List<ChartGroupDTO> tree(@RequestBody ChartGroupRequest ChartGroup) {
return chartGroupService.tree(ChartGroup);
}
@PostMapping("/delete/{id}")
public void tree(@PathVariable String id) {
chartGroupService.delete(id);
}
}

View File

@ -0,0 +1,11 @@
package io.dataease.controller.request.chart;
import io.dataease.base.domain.ChartGroup;
import io.dataease.base.domain.DatasetGroup;
import lombok.Data;
@Data
public class ChartGroupRequest extends ChartGroup {
private String sort;
}

View File

@ -0,0 +1,13 @@
package io.dataease.dto.chart;
import io.dataease.base.domain.DatasetGroup;
import lombok.Data;
import java.util.List;
@Data
public class ChartGroupDTO extends DatasetGroup {
private String label;
private List<ChartGroupDTO> children;
}

View File

@ -0,0 +1,36 @@
package io.dataease.notice.controller;
import io.dataease.notice.domain.MessageDetail;
import io.dataease.notice.service.NoticeService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("notice")
public class NoticeController {
@Resource
private NoticeService noticeService;
@PostMapping("save/message/task")
public void saveMessage(@RequestBody MessageDetail messageDetail) {
noticeService.saveMessageTask(messageDetail);
}
@GetMapping("/search/message/type/{type}")
public List<MessageDetail> searchMessage(@PathVariable String type) {
return noticeService.searchMessageByType(type);
}
@GetMapping("/search/message/{testId}")
public List<MessageDetail> searchMessageSchedule(@PathVariable String testId) {
return noticeService.searchMessageByTestId(testId);
}
@GetMapping("/delete/message/{identification}")
public int deleteMessage(@PathVariable String identification) {
return noticeService.delMessage(identification);
}
}

View File

@ -0,0 +1,11 @@
package io.dataease.notice.controller.request;
import io.dataease.notice.domain.MessageDetail;
import lombok.Data;
import java.util.List;
@Data
public class MessageRequest {
private List<MessageDetail> messageDetail;
}

View File

@ -0,0 +1,18 @@
package io.dataease.notice.domain;
import lombok.Data;
@Data
public class Mail {
// 发送给谁
private String to;
// 发送主题
private String subject;
// 发送内容
private String content;
// 附件地址
private String filePath;
}

View File

@ -0,0 +1,15 @@
package io.dataease.notice.domain;
import lombok.Data;
@Data
public class MailInfo {
private String host;
private String port;
private String account;
private String password;
private String ssl;
private String tls;
private String recipient;
}

View File

@ -0,0 +1,21 @@
package io.dataease.notice.domain;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class MessageDetail {
private List<String> userIds = new ArrayList<>();
private String event;
private String taskType;
private String webhook;
private String type;
private String identification;
private String organizationId;
private Boolean isSet;
private String testId;
private Long createTime;
private String template;
}

View File

@ -0,0 +1,13 @@
package io.dataease.notice.domain;
import lombok.Data;
import java.util.List;
@Data
public class MessageSettingDetail {
private List<MessageDetail> jenkinsTask;
private List<MessageDetail> testCasePlanTask;
private List<MessageDetail> reviewTask;
private List<MessageDetail> defectTask;
}

View File

@ -0,0 +1,9 @@
package io.dataease.notice.domain;
import lombok.Data;
@Data
public class UserDetail {
private String email;
private String phone;
}

View File

@ -0,0 +1,45 @@
package io.dataease.notice.message;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;
public class LinkMessage implements Message {
private String title;
private String text;
private String picUrl;
private String messageUrl;
public String toJsonString() {
Map<String, Object> items = new HashMap<String, Object>();
items.put("msgtype", "link");
Map<String, String> linkContent = new HashMap<String, String>();
if (StringUtils.isBlank(title)) {
throw new IllegalArgumentException("title should not be blank");
}
linkContent.put("title", title);
if (StringUtils.isBlank(messageUrl)) {
throw new IllegalArgumentException("messageUrl should not be blank");
}
linkContent.put("messageUrl", messageUrl);
if (StringUtils.isBlank(text)) {
throw new IllegalArgumentException("text should not be blank");
}
linkContent.put("text", text);
if (StringUtils.isNotBlank(picUrl)) {
linkContent.put("picUrl", picUrl);
}
items.put("link", linkContent);
return JSON.toJSONString(items);
}
}

View File

@ -0,0 +1,5 @@
package io.dataease.notice.message;
public interface Message {
String toJsonString();
}

View File

@ -0,0 +1,64 @@
package io.dataease.notice.message;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TextMessage implements Message {
private String text;
private List<String> mentionedMobileList;
private boolean isAtAll;
public TextMessage(String text) {
this.text = text;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public boolean isAtAll() {
return isAtAll;
}
public void setIsAtAll(boolean isAtAll) {
this.isAtAll = isAtAll;
}
public List<String> getMentionedMobileList() {
return mentionedMobileList;
}
public void setMentionedMobileList(List<String> mentionedMobileList) {
this.mentionedMobileList = mentionedMobileList;
}
public String toJsonString() {
Map<String, Object> items = new HashMap<String, Object>();
items.put("msgtype", "text");
Map<String, Object> textContent = new HashMap<String, Object>();
if (StringUtils.isBlank(text)) {
throw new IllegalArgumentException("text should not be blank");
}
textContent.put("content", text);
if (isAtAll) {
if (mentionedMobileList == null) mentionedMobileList = new ArrayList<String>();
mentionedMobileList.add("@all");
}
if (mentionedMobileList != null && !mentionedMobileList.isEmpty()) {
textContent.put("mentioned_mobile_list", mentionedMobileList);
}
items.put("text", textContent);
return JSON.toJSONString(items);
}
}

View File

@ -0,0 +1,150 @@
package io.dataease.notice.sender;
import io.dataease.commons.constants.NoticeConstants;
import io.dataease.commons.utils.LogUtil;
import io.dataease.notice.domain.MessageDetail;
import io.dataease.notice.domain.UserDetail;
import io.dataease.service.UserService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.StringUtils;
import javax.annotation.Resource;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public abstract class AbstractNoticeSender implements NoticeSender {
@Resource
private UserService userService;
protected String getContext(MessageDetail messageDetail, NoticeModel noticeModel) {
// 如果配置了模版就直接使用模版
if (StringUtils.isNotBlank(messageDetail.getTemplate())) {
return getContent(messageDetail.getTemplate(), noticeModel.getParamMap());
}
// 处理 userIds 中包含的特殊值
List<String> realUserIds = getRealUserIds(messageDetail.getUserIds(), noticeModel.getRelatedUsers(), messageDetail.getEvent());
messageDetail.setUserIds(realUserIds);
// 处理 WeCom Ding context
String context = "";
switch (messageDetail.getEvent()) {
case NoticeConstants.Event.CREATE:
case NoticeConstants.Event.UPDATE:
case NoticeConstants.Event.DELETE:
case NoticeConstants.Event.COMMENT:
context = noticeModel.getContext();
break;
case NoticeConstants.Event.EXECUTE_FAILED:
context = noticeModel.getFailedContext();
break;
case NoticeConstants.Event.EXECUTE_SUCCESSFUL:
context = noticeModel.getSuccessContext();
break;
default:
break;
}
return context;
}
protected String getHtmlContext(MessageDetail messageDetail, NoticeModel noticeModel) {
// 如果配置了模版就直接使用模版
if (StringUtils.isNotBlank(messageDetail.getTemplate())) {
return getContent(messageDetail.getTemplate(), noticeModel.getParamMap());
}
// 处理 userIds 中包含的特殊值
List<String> realUserIds = getRealUserIds(messageDetail.getUserIds(), noticeModel.getRelatedUsers(), messageDetail.getEvent());
messageDetail.setUserIds(realUserIds);
// 处理 mail context
String context = "";
try {
switch (messageDetail.getEvent()) {
case NoticeConstants.Event.CREATE:
case NoticeConstants.Event.UPDATE:
case NoticeConstants.Event.DELETE:
case NoticeConstants.Event.COMMENT:
URL resource = this.getClass().getResource("/mail/" + noticeModel.getMailTemplate() + ".html");
context = IOUtils.toString(resource, StandardCharsets.UTF_8);
break;
case NoticeConstants.Event.EXECUTE_FAILED:
URL resource1 = this.getClass().getResource("/mail/" + noticeModel.getFailedMailTemplate() + ".html");
context = IOUtils.toString(resource1, StandardCharsets.UTF_8);
break;
case NoticeConstants.Event.EXECUTE_SUCCESSFUL:
URL resource2 = this.getClass().getResource("/mail/" + noticeModel.getSuccessMailTemplate() + ".html");
context = IOUtils.toString(resource2, StandardCharsets.UTF_8);
break;
default:
break;
}
} catch (IOException e) {
LogUtil.error(e);
}
return getContent(context, noticeModel.getParamMap());
}
protected String getContent(String template, Map<String, Object> context) {
if (MapUtils.isNotEmpty(context)) {
for (String k : context.keySet()) {
if (context.get(k) != null) {
template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", context.get(k).toString());
} else {
template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", "未设置");
}
}
}
return template;
}
protected List<String> getUserPhones(List<String> userIds) {
List<UserDetail> list = userService.queryTypeByIds(userIds);
List<String> phoneList = new ArrayList<>();
list.forEach(u -> phoneList.add(u.getPhone()));
LogUtil.info("收件人地址: " + phoneList);
return phoneList.stream().distinct().collect(Collectors.toList());
}
protected List<String> getUserEmails(List<String> userIds) {
List<UserDetail> list = userService.queryTypeByIds(userIds);
List<String> phoneList = new ArrayList<>();
list.forEach(u -> phoneList.add(u.getEmail()));
LogUtil.info("收件人地址: " + phoneList);
return phoneList.stream().distinct().collect(Collectors.toList());
}
private List<String> getRealUserIds(List<String> userIds, List<String> relatedUsers, String event) {
List<String> toUserIds = new ArrayList<>();
for (String userId : userIds) {
switch (userId) {
case NoticeConstants.RelatedUser.EXECUTOR:
if (StringUtils.equals(NoticeConstants.Event.CREATE, event)) {
toUserIds.addAll(relatedUsers);
}
break;
case NoticeConstants.RelatedUser.FOUNDER:
if (StringUtils.equals(NoticeConstants.Event.UPDATE, event)
|| StringUtils.equals(NoticeConstants.Event.DELETE, event)) {
toUserIds.addAll(relatedUsers);
}
break;
case NoticeConstants.RelatedUser.MAINTAINER:
if (StringUtils.equals(NoticeConstants.Event.COMMENT, event)) {
toUserIds.addAll(relatedUsers);
}
break;
default:
toUserIds.add(userId);
break;
}
}
return toUserIds;
}
}

View File

@ -0,0 +1,51 @@
package io.dataease.notice.sender;
import lombok.Builder;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
@Builder
public class NoticeModel {
/**
* 保存 测试id
*/
private String testId;
/**
* 保存状态
*/
private String status;
/**
* Event
*/
private String event;
/**
* 消息主题
*/
private String subject;
/**
* 消息内容
*/
private String context;
private String successContext;
private String failedContext;
/**
* html 消息模版
*/
private String mailTemplate;
private String failedMailTemplate;
private String successMailTemplate;
/**
* 保存特殊的用户
*/
private List<String> relatedUsers;
/**
* 模版里的参数信息
*/
private Map<String, Object> paramMap;
}

View File

@ -0,0 +1,9 @@
package io.dataease.notice.sender;
import io.dataease.notice.domain.MessageDetail;
import org.springframework.scheduling.annotation.Async;
public interface NoticeSender {
@Async
void send(MessageDetail messageDetail, NoticeModel noticeModel);
}

View File

@ -0,0 +1,50 @@
package io.dataease.notice.sender.impl;
import io.dataease.commons.utils.LogUtil;
import io.dataease.notice.domain.MessageDetail;
import io.dataease.notice.sender.AbstractNoticeSender;
import io.dataease.notice.sender.NoticeModel;
import io.dataease.notice.service.MailService;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.util.List;
@Component
public class MailNoticeSender extends AbstractNoticeSender {
@Resource
private MailService mailService;
private void sendMail(MessageDetail messageDetail, String context, NoticeModel noticeModel) throws MessagingException {
LogUtil.info("发送邮件开始 ");
JavaMailSenderImpl javaMailSender = mailService.getMailSender();
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setFrom(javaMailSender.getUsername());
LogUtil.info("发件人地址"+javaMailSender.getUsername());
LogUtil.info("helper"+helper);
helper.setSubject("MeterSphere " + noticeModel.getSubject());
List<String> emails = super.getUserEmails(messageDetail.getUserIds());
String[] users = emails.toArray(new String[0]);
LogUtil.info("收件人地址: " + emails);
helper.setText(context, true);
helper.setTo(users);
javaMailSender.send(mimeMessage);
}
@Override
public void send(MessageDetail messageDetail, NoticeModel noticeModel) {
String context = super.getHtmlContext(messageDetail, noticeModel);
try {
sendMail(messageDetail, context, noticeModel);
LogUtil.info("发送邮件结束");
} catch (Exception e) {
LogUtil.error(e);
}
}
}

View File

@ -0,0 +1,39 @@
package io.dataease.notice.sender.impl;
import io.dataease.notice.sender.AbstractNoticeSender;
import io.dataease.commons.utils.LogUtil;
import io.dataease.notice.domain.MessageDetail;
import io.dataease.notice.message.TextMessage;
import io.dataease.notice.sender.NoticeModel;
import io.dataease.notice.util.WxChatbotClient;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.List;
@Component
public class WeComNoticeSender extends AbstractNoticeSender {
public void sendWechatRobot(MessageDetail messageDetail, String context) {
List<String> userIds = messageDetail.getUserIds();
if (CollectionUtils.isEmpty(userIds)) {
return;
}
TextMessage message = new TextMessage(context);
List<String> phoneLists = super.getUserPhones(userIds);
message.setMentionedMobileList(phoneLists);
try {
WxChatbotClient.send(messageDetail.getWebhook(), message);
} catch (IOException e) {
LogUtil.error(e.getMessage(), e);
}
}
@Override
public void send(MessageDetail messageDetail, NoticeModel noticeModel) {
String context = super.getContext(messageDetail, noticeModel);
sendWechatRobot(messageDetail, context);
}
}

View File

@ -0,0 +1,79 @@
package io.dataease.notice.service;
import io.dataease.base.domain.SystemParameter;
import io.dataease.commons.constants.ParamConstants;
import io.dataease.commons.utils.EncryptUtils;
import io.dataease.service.system.SystemParameterService;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.Properties;
@Service
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public class MailService {
@Resource
private SystemParameterService systemParameterService;
public JavaMailSenderImpl getMailSender() {
Properties props = new Properties();
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
List<SystemParameter> paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue());
javaMailSender.setDefaultEncoding("UTF-8");
javaMailSender.setProtocol("smtp");
props.put("mail.smtp.auth", "true");
for (SystemParameter p : paramList) {
switch (p.getParamKey()) {
case "smtp.host":
javaMailSender.setHost(p.getParamValue());
break;
case "smtp.port":
javaMailSender.setPort(Integer.parseInt(p.getParamValue()));
break;
case "smtp.account":
javaMailSender.setUsername(p.getParamValue());
break;
case "smtp.password":
javaMailSender.setPassword(EncryptUtils.aesDecrypt(p.getParamValue()).toString());
break;
case "smtp.ssl":
if (BooleanUtils.toBoolean(p.getParamValue())) {
javaMailSender.setProtocol("smtps");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
}
break;
case "smtp.tls":
String result = BooleanUtils.toString(BooleanUtils.toBoolean(p.getParamValue()), "true", "false");
props.put("mail.smtp.starttls.enable", result);
props.put("mail.smtp.starttls.required", result);
break;
/* case "smtp.anon":
boolean isAnon = BooleanUtils.toBoolean(p.getParamValue());
if (isAnon) {
props.put("mail.smtp.auth", "false");
javaMailSender.setUsername(null);
javaMailSender.setPassword(null);
}
break;*/
default:
break;
}
}
props.put("mail.smtp.timeout", "30000");
props.put("mail.smtp.connectiontimeout", "5000");
javaMailSender.setJavaMailProperties(props);
return javaMailSender;
}
}

View File

@ -0,0 +1,63 @@
package io.dataease.notice.service;
import io.dataease.commons.constants.NoticeConstants;
import io.dataease.notice.domain.MessageDetail;
import io.dataease.notice.sender.NoticeModel;
import io.dataease.notice.sender.NoticeSender;
import io.dataease.notice.sender.impl.MailNoticeSender;
import io.dataease.notice.sender.impl.WeComNoticeSender;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
@Component
public class NoticeSendService {
@Resource
private MailNoticeSender mailNoticeSender;
@Resource
private WeComNoticeSender weComNoticeSender;
@Resource
private NoticeService noticeService;
private NoticeSender getNoticeSender(MessageDetail messageDetail) {
NoticeSender noticeSender = null;
switch (messageDetail.getType()) {
case NoticeConstants.Type.EMAIL:
noticeSender = mailNoticeSender;
break;
case NoticeConstants.Type.WECHAT_ROBOT:
noticeSender = weComNoticeSender;
break;
// case NoticeConstants.Type.NAIL_ROBOT:
// noticeSender = dingNoticeSender;
// break;
default:
break;
}
return noticeSender;
}
public void send(String taskType, NoticeModel noticeModel) {
List<MessageDetail> messageDetails;
switch (taskType) {
case NoticeConstants.Mode.API:
messageDetails = noticeService.searchMessageByType(NoticeConstants.TaskType.JENKINS_TASK);
break;
case NoticeConstants.Mode.SCHEDULE:
messageDetails = noticeService.searchMessageByTestId(noticeModel.getTestId());
break;
default:
messageDetails = noticeService.searchMessageByType(taskType);
break;
}
messageDetails.forEach(messageDetail -> {
if (StringUtils.equals(messageDetail.getEvent(), noticeModel.getEvent())) {
this.getNoticeSender(messageDetail).send(messageDetail, noticeModel);
}
});
}
}

View File

@ -0,0 +1,160 @@
package io.dataease.notice.service;
import io.dataease.base.domain.MessageTask;
import io.dataease.base.domain.MessageTaskExample;
import io.dataease.base.mapper.MessageTaskMapper;
import io.dataease.commons.exception.DEException;
import io.dataease.commons.user.SessionUser;
import io.dataease.commons.utils.SessionUtils;
import io.dataease.i18n.Translator;
import io.dataease.notice.domain.MessageDetail;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
public class NoticeService {
@Resource
private MessageTaskMapper messageTaskMapper;
public void saveMessageTask(MessageDetail messageDetail) {
MessageTaskExample example = new MessageTaskExample();
example.createCriteria().andIdentificationEqualTo(messageDetail.getIdentification());
List<MessageTask> messageTaskLists = messageTaskMapper.selectByExample(example);
if (messageTaskLists.size() > 0) {
delMessage(messageDetail.getIdentification());
}
SessionUser user = SessionUtils.getUser();
String orgId = user.getLastOrganizationId();
long time = System.currentTimeMillis();
String identification = messageDetail.getIdentification();
if (StringUtils.isBlank(identification)) {
identification = UUID.randomUUID().toString();
}
for (String userId : messageDetail.getUserIds()) {
checkUserIdExist(userId, messageDetail, orgId);
MessageTask messageTask = new MessageTask();
messageTask.setId(UUID.randomUUID().toString());
messageTask.setEvent(messageDetail.getEvent());
messageTask.setTaskType(messageDetail.getTaskType());
messageTask.setUserId(userId);
messageTask.setType(messageDetail.getType());
messageTask.setWebhook(messageDetail.getWebhook());
messageTask.setIdentification(identification);
messageTask.setIsSet(false);
messageTask.setOrganizationId(orgId);
messageTask.setTestId(messageDetail.getTestId());
messageTask.setCreateTime(time);
setTemplate(messageDetail, messageTask);
messageTaskMapper.insert(messageTask);
}
}
private void setTemplate(MessageDetail messageDetail, MessageTask messageTask) {
if (StringUtils.isNotBlank(messageDetail.getTemplate())) {
messageTask.setTemplate(messageDetail.getTemplate());
}
}
private void checkUserIdExist(String userId, MessageDetail list, String orgId) {
MessageTaskExample example = new MessageTaskExample();
if (StringUtils.isBlank(list.getTestId())) {
example.createCriteria()
.andUserIdEqualTo(userId)
.andEventEqualTo(list.getEvent())
.andTypeEqualTo(list.getType())
.andTaskTypeEqualTo(list.getTaskType())
.andWebhookEqualTo(list.getWebhook())
.andOrganizationIdEqualTo(orgId);
} else {
example.createCriteria()
.andUserIdEqualTo(userId)
.andEventEqualTo(list.getEvent())
.andTypeEqualTo(list.getType())
.andTaskTypeEqualTo(list.getTaskType())
.andWebhookEqualTo(list.getWebhook())
.andTestIdEqualTo(list.getTestId())
.andOrganizationIdEqualTo(orgId);
}
if (messageTaskMapper.countByExample(example) > 0) {
DEException.throwException(Translator.get("message_task_already_exists"));
}
}
public List<MessageDetail> searchMessageByTestId(String testId) {
MessageTaskExample example = new MessageTaskExample();
example.createCriteria().andTestIdEqualTo(testId);
List<MessageTask> messageTaskLists = messageTaskMapper.selectByExampleWithBLOBs(example);
List<MessageDetail> scheduleMessageTask = new ArrayList<>();
Map<String, List<MessageTask>> MessageTaskMap = messageTaskLists.stream().collect(Collectors.groupingBy(MessageTask::getIdentification));
MessageTaskMap.forEach((k, v) -> {
MessageDetail messageDetail = getMessageDetail(v);
scheduleMessageTask.add(messageDetail);
});
scheduleMessageTask.sort(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed());
return scheduleMessageTask;
}
public List<MessageDetail> searchMessageByType(String type) {
SessionUser user = SessionUtils.getUser();
String orgId = user.getLastOrganizationId();
List<MessageDetail> messageDetails = new ArrayList<>();
MessageTaskExample example = new MessageTaskExample();
example.createCriteria()
.andTaskTypeEqualTo(type)
.andOrganizationIdEqualTo(orgId);
List<MessageTask> messageTaskLists = messageTaskMapper.selectByExampleWithBLOBs(example);
Map<String, List<MessageTask>> messageTaskMap = messageTaskLists.stream()
.collect(Collectors.groupingBy(NoticeService::fetchGroupKey));
messageTaskMap.forEach((k, v) -> {
MessageDetail messageDetail = getMessageDetail(v);
messageDetails.add(messageDetail);
});
return messageDetails.stream()
.sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed())
.collect(Collectors.toList())
.stream()
.distinct()
.collect(Collectors.toList());
}
private MessageDetail getMessageDetail(List<MessageTask> messageTasks) {
Set<String> userIds = new HashSet<>();
MessageDetail messageDetail = new MessageDetail();
for (MessageTask m : messageTasks) {
userIds.add(m.getUserId());
messageDetail.setEvent(m.getEvent());
messageDetail.setTaskType(m.getTaskType());
messageDetail.setWebhook(m.getWebhook());
messageDetail.setIdentification(m.getIdentification());
messageDetail.setType(m.getType());
messageDetail.setIsSet(m.getIsSet());
messageDetail.setCreateTime(m.getCreateTime());
messageDetail.setTemplate(m.getTemplate());
}
if (CollectionUtils.isNotEmpty(userIds)) {
messageDetail.setUserIds(new ArrayList<>(userIds));
}
return messageDetail;
}
private static String fetchGroupKey(MessageTask messageTask) {
return messageTask.getTaskType() + "#" + messageTask.getIdentification();
}
public int delMessage(String identification) {
MessageTaskExample example = new MessageTaskExample();
example.createCriteria().andIdentificationEqualTo(identification);
return messageTaskMapper.deleteByExample(example);
}
}

View File

@ -0,0 +1,47 @@
package io.dataease.notice.util;
import com.alibaba.fastjson.JSON;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
public class SendResult {
private boolean isSuccess;
private Integer errorCode;
private String errorMsg;
public boolean isSuccess() {
return isSuccess;
}
public void setIsSuccess(boolean isSuccess) {
this.isSuccess = isSuccess;
}
public Integer getErrorCode() {
return errorCode;
}
public void setErrorCode(Integer errorCode) {
this.errorCode = errorCode;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public String toString() {
Map<String, Object> items = new HashMap<String, Object>();
items.put("errorCode", errorCode);
items.put("errorMsg", errorMsg);
items.put("isSuccess", isSuccess);
return JSON.toJSONString(items);
}
}

View File

@ -0,0 +1,50 @@
package io.dataease.notice.util;
import com.alibaba.fastjson.JSONObject;
import io.dataease.notice.message.Message;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
/**
*
*/
public class WxChatbotClient {
static HttpClient httpclient = HttpClients.createDefault();
public static SendResult send(String webhook, Message message) throws IOException {
if (StringUtils.isBlank(webhook)) {
return new SendResult();
}
HttpPost httppost = new HttpPost(webhook);
httppost.addHeader("Content-Type", "application/json; charset=utf-8");
StringEntity se = new StringEntity(message.toJsonString(), "utf-8");
httppost.setEntity(se);
SendResult sendResult = new SendResult();
HttpResponse response = httpclient.execute(httppost);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String result = EntityUtils.toString(response.getEntity());
JSONObject obj = JSONObject.parseObject(result);
Integer errcode = obj.getInteger("errcode");
sendResult.setErrorCode(errcode);
sendResult.setErrorMsg(obj.getString("errmsg"));
sendResult.setIsSuccess(errcode.equals(0));
}
return sendResult;
}
}

View File

@ -0,0 +1,111 @@
package io.dataease.service.chart;
import io.dataease.base.domain.ChartGroup;
import io.dataease.base.domain.ChartGroupExample;
import io.dataease.base.mapper.ChartGroupMapper;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.controller.request.chart.ChartGroupRequest;
import io.dataease.dto.chart.ChartGroupDTO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Service
public class ChartGroupService {
@Resource
private ChartGroupMapper chartGroupMapper;
public ChartGroupDTO save(ChartGroup chartGroup) {
if (StringUtils.isEmpty(chartGroup.getId())) {
chartGroup.setId(UUID.randomUUID().toString());
chartGroup.setCreateTime(System.currentTimeMillis());
chartGroupMapper.insert(chartGroup);
} else {
chartGroupMapper.updateByPrimaryKey(chartGroup);
}
ChartGroupDTO ChartGroupDTO = new ChartGroupDTO();
BeanUtils.copyBean(ChartGroupDTO, chartGroup);
ChartGroupDTO.setLabel(ChartGroupDTO.getName());
return ChartGroupDTO;
}
public void delete(String id) {
ChartGroupRequest ChartGroup = new ChartGroupRequest();
ChartGroup.setId(id);
List<ChartGroupDTO> tree = tree(ChartGroup);
List<String> ids = new ArrayList<>();
getAllId(tree, ids);
ChartGroupExample ChartGroupExample = new ChartGroupExample();
ChartGroupExample.createCriteria().andIdIn(ids);
chartGroupMapper.deleteByExample(ChartGroupExample);
}
public List<ChartGroupDTO> tree(ChartGroupRequest ChartGroup) {
ChartGroupExample ChartGroupExample = new ChartGroupExample();
ChartGroupExample.Criteria criteria = ChartGroupExample.createCriteria();
if (StringUtils.isNotEmpty(ChartGroup.getName())) {
criteria.andNameLike("%" + ChartGroup.getName() + "%");
}
if (StringUtils.isNotEmpty(ChartGroup.getType())) {
criteria.andTypeEqualTo(ChartGroup.getType());
}
if (StringUtils.isNotEmpty(ChartGroup.getId())) {
criteria.andIdEqualTo(ChartGroup.getId());
} else {
criteria.andLevelEqualTo(0);
}
ChartGroupExample.setOrderByClause(ChartGroup.getSort());
List<ChartGroup> ChartGroups = chartGroupMapper.selectByExample(ChartGroupExample);
List<ChartGroupDTO> DTOs = ChartGroups.stream().map(ele -> {
ChartGroupDTO dto = new ChartGroupDTO();
BeanUtils.copyBean(dto, ele);
dto.setLabel(ele.getName());
return dto;
}).collect(Collectors.toList());
getAll(DTOs, ChartGroup);
return DTOs;
}
public void getAll(List<ChartGroupDTO> list, ChartGroupRequest ChartGroup) {
for (ChartGroupDTO obj : list) {
ChartGroupExample ChartGroupExample = new ChartGroupExample();
ChartGroupExample.Criteria criteria = ChartGroupExample.createCriteria();
if (StringUtils.isNotEmpty(ChartGroup.getName())) {
criteria.andNameLike("%" + ChartGroup.getName() + "%");
}
if (StringUtils.isNotEmpty(ChartGroup.getType())) {
criteria.andTypeEqualTo(ChartGroup.getType());
}
criteria.andPidEqualTo(obj.getId());
ChartGroupExample.setOrderByClause(ChartGroup.getSort());
List<ChartGroup> ChartGroups = chartGroupMapper.selectByExample(ChartGroupExample);
List<ChartGroupDTO> DTOs = ChartGroups.stream().map(ele -> {
ChartGroupDTO dto = new ChartGroupDTO();
BeanUtils.copyBean(dto, ele);
dto.setLabel(ele.getName());
return dto;
}).collect(Collectors.toList());
obj.setChildren(DTOs);
if (CollectionUtils.isNotEmpty(DTOs)) {
getAll(DTOs, ChartGroup);
}
}
}
public List<String> getAllId(List<ChartGroupDTO> list, List<String> ids) {
for (ChartGroupDTO dto : list) {
ids.add(dto.getId());
if (CollectionUtils.isNotEmpty(dto.getChildren())) {
getAllId(dto.getChildren(), ids);
}
}
return ids;
}
}

View File

@ -0,0 +1,12 @@
-- chart start
CREATE TABLE IF NOT EXISTS `chart_group` (
`id` varchar(50) NOT NULL COMMENT 'ID',
`name` varchar(64) NOT NULL COMMENT '名称',
`pid` varchar(50) COMMENT '父级ID',
`level` int(10) COMMENT '当前分组处于第几级',
`type` varchar(50) COMMENT 'group or scene',
`create_by` varchar(50) COMMENT '创建人ID',
`create_time` bigint(13) COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- chart end

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

View File

@ -0,0 +1,45 @@
<template>
<ms-container>
<ms-aside-container>
<group/>
</ms-aside-container>
<ms-main-container>
<keep-alive>
<router-view/>
</keep-alive>
</ms-main-container>
</ms-container>
</template>
<script>
import MsMainContainer from "../common/components/MsMainContainer";
import MsContainer from "../common/components/MsContainer";
import MsAsideContainer from "../common/components/MsAsideContainer";
import MsSettingMenu from "../settings/SettingMenu";
import MsCurrentUser from "../settings/CurrentUser";
import Group from "./group/Group";
export default {
name: "Chart",
components: {MsMainContainer, MsContainer, MsAsideContainer, MsSettingMenu, MsCurrentUser, Group},
data() {
return {}
}
}
</script>
<style scoped>
.ms-aside-container {
height: calc(100vh - 40px);
padding: 15px;
min-width: 300px;
max-width: 500px;
}
.ms-main-container {
height: calc(100vh - 40px);
}
</style>

View File

@ -0,0 +1,148 @@
<template>
<el-col>
<el-row>
<el-row style="height: 26px;">
<span style="line-height: 26px;">
{{$t('dataset.add_db_table')}}
</span>
<el-row style="float: right">
<el-button size="mini" @click="cancel">
{{$t('dataset.cancel')}}
</el-button>
<el-button size="mini" type="primary" @click="save" :disabled="checkTableList.length < 1">
{{$t('dataset.confirm')}}
</el-button>
</el-row>
</el-row>
<el-divider/>
<el-row>
<el-form :inline="true">
<el-form-item class="form-item">
<el-select v-model="dataSource" filterable :placeholder="$t('dataset.pls_slc_data_source')" size="mini">
<el-option
v-for="item in options"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item class="form-item" style="float: right;">
<el-input
size="mini"
:placeholder="$t('dataset.search')"
prefix-icon="el-icon-search"
v-model="searchTable"
clearable>
</el-input>
</el-form-item>
</el-form>
</el-row>
<el-row style="overflow: auto;height: 600px;">
<el-checkbox-group v-model="checkTableList" size="small">
<el-checkbox
border
v-for="t in tables"
:label="t"
:key="t">
</el-checkbox>
</el-checkbox-group>
</el-row>
</el-row>
</el-col>
</template>
<script>
export default {
name: "AddDB",
data() {
return {
searchTable: '',
options: [],
dataSource: '',
tables: [],
checkTableList: [],
scene: null
}
},
mounted() {
this.initDataSource();
this.scene = this.$route.params.scene;
},
activated() {
this.initDataSource();
this.scene = this.$route.params.scene;
},
methods: {
initDataSource() {
this.$get("/datasource/list", response => {
this.options = response.data;
})
},
save() {
// console.log(this.checkTableList);
// console.log(this.scene);
let sceneId = this.scene.id;
let dataSourceId = this.dataSource;
let tables = [];
this.checkTableList.forEach(function (name) {
tables.push({
name: name,
sceneId: sceneId,
dataSourceId: dataSourceId,
type: 'db'
})
});
this.$post('/dataset/table/batchAdd', tables, response => {
this.$store.commit('setSceneData', new Date().getTime());
this.cancel();
});
},
cancel() {
this.dataReset();
this.$router.push("/dataset/home");
},
dataReset() {
this.searchTable = '';
this.options = [];
this.dataSource = '';
this.tables = [];
this.checkTableList = [];
}
},
watch: {
dataSource(val) {
if (val) {
this.$post("/datasource/getTables", {id: val}, response => {
this.tables = response.data;
}
)
}
}
},
}
</script>
<style scoped>
.el-divider--horizontal {
margin: 12px 0;
}
.form-item {
margin-bottom: 6px;
}
.el-checkbox {
margin-bottom: 14px;
margin-left: 0;
margin-right: 14px;
}
.el-checkbox.is-bordered + .el-checkbox.is-bordered {
margin-left: 0;
}
</style>

View File

@ -0,0 +1,25 @@
<template>
<el-col style="height: 100%;">
<el-row style="height: 100%;" class="custom-position">
{{$t('chart.pls_slc_tbl_left')}}
</el-row>
</el-col>
</template>
<script>
export default {
name: "ChartHome"
}
</script>
<style scoped>
.custom-position {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
flex-flow: row nowrap;
color: #9ea6b2;
}
</style>

View File

@ -0,0 +1,62 @@
<template>
<el-col>
<el-table
size="mini"
:data="data"
border
style="width: 100%;">
<el-table-column
width="180px"
v-for="field in fields"
:key="field.fieldName"
:prop="field.fieldName"
:label="field.fieldName">
</el-table-column>
</el-table>
</el-col>
</template>
<script>
export default {
props: {
table: Object,
fields: Array,
data: Array
},
name: "TabDataPreview",
data() {
return {
tableData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1517 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1516 弄'
}]
}
},
computed: {},
created() {
},
mounted() {
},
activated() {
},
methods: {},
watch: {}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,122 @@
<template>
<el-col>
<el-row>
<el-row style="height: 26px;">
<span v-show="false">{{tableId}}</span>
<span style="line-height: 26px;">
{{table.name}}
</span>
<el-row style="float: right">
<el-button size="mini">
{{$t('dataset.edit')}}
</el-button>
<el-button size="mini">
{{$t('dataset.create_view')}}
</el-button>
</el-row>
</el-row>
<el-divider/>
<el-tabs v-model="tabActive">
<el-tab-pane :label="$t('dataset.data_preview')" name="dataPreview">
<tab-data-preview :table="table" :fields="fields" :data="data"/>
</el-tab-pane>
<el-tab-pane label="tab2" name="tab2">
tab2
</el-tab-pane>
<el-tab-pane label="tab3" name="tab3">
tab3
</el-tab-pane>
<el-tab-pane label="tab4" name="tab4">
tab4
</el-tab-pane>
</el-tabs>
</el-row>
</el-col>
</template>
<script>
import TabDataPreview from "./TabDataPreview";
export default {
name: "ViewTable",
components: {TabDataPreview},
data() {
return {
table: {
name: ''
},
fields: [],
data: [],
tabActive: 'dataPreview',
}
},
computed: {
tableId() {
console.log(this.$store.state.dataset.table);
this.initTable(this.$store.state.dataset.table);
return this.$store.state.dataset.table;
}
},
created() {
this.resetTable();
},
mounted() {
this.resetTable();
},
activated() {
this.resetTable();
},
methods: {
initTable(id) {
if (id !== null) {
this.fields = [];
this.data = [];
this.$post('/dataset/table/get/' + id, null, response => {
this.table = response.data;
this.initPreviewData();
})
}
},
initPreviewData() {
if (this.table.id) {
this.$post('/dataset/table/getPreviewData', this.table, response => {
this.fields = response.data.fields;
this.data = response.data.data;
});
}
},
initTableFields() {
if (this.table.id) {
this.$post('/dataset/table/getFields', this.table, response => {
});
}
},
initTableData() {
if (this.table.id) {
this.$post('/dataset/table/getData', this.table, response => {
});
}
},
resetTable() {
this.table = {
name: ''
}
}
},
watch: {}
}
</script>
<style scoped>
.el-divider--horizontal {
margin: 12px 0;
}
.form-item {
margin-bottom: 6px;
}
</style>

View File

@ -0,0 +1,540 @@
<template xmlns:el-col="http://www.w3.org/1999/html">
<el-col>
<!-- group -->
<el-col v-if="!sceneMode">
<el-row class="title-css">
<span class="title-text">
{{ $t('chart.datalist') }}
</span>
</el-row>
<el-divider/>
<el-row>
<el-button icon="el-icon-circle-plus" type="primary" size="mini" @click="add('group')">
{{$t('chart.add_group')}}
</el-button>
<el-button icon="el-icon-folder-add" type="primary" size="mini" @click="add('scene')">
{{$t('chart.add_scene')}}
</el-button>
</el-row>
<el-row>
<el-form>
<el-form-item class="form-item">
<el-input
size="mini"
:placeholder="$t('chart.search')"
prefix-icon="el-icon-search"
v-model="search"
clearable>
</el-input>
</el-form-item>
</el-form>
</el-row>
<el-col class="custom-tree-container">
<div class="block">
<el-tree
:default-expanded-keys="expandedArray"
:data="data"
node-key="id"
:expand-on-click-node="true"
@node-click="nodeClick">
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>
<span v-if="data.type === 'scene'">
<el-button
icon="el-icon-folder"
type="text"
size="mini">
</el-button>
</span>
<span style="margin-left: 6px">{{ data.name }}</span>
</span>
<span>
<span @click.stop v-if="data.type ==='group'">
<el-dropdown trigger="click" @command="clickAdd" size="small">
<span class="el-dropdown-link">
<el-button
icon="el-icon-plus"
type="text"
size="small">
</el-button>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-circle-plus" :command="beforeClickAdd('group',data,node)">
{{$t('chart.group')}}
</el-dropdown-item>
<el-dropdown-item icon="el-icon-folder-add" :command="beforeClickAdd('scene',data,node)">
{{$t('chart.scene')}}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</span>
<span @click.stop style="margin-left: 12px;">
<el-dropdown trigger="click" @command="clickMore" size="small">
<span class="el-dropdown-link">
<el-button
icon="el-icon-more"
type="text"
size="small">
</el-button>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-edit-outline" :command="beforeClickMore('rename',data,node)">
{{$t('chart.rename')}}
</el-dropdown-item>
<el-dropdown-item icon="el-icon-delete" :command="beforeClickMore('delete',data,node)">
{{$t('chart.delete')}}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</span>
</span>
</span>
</el-tree>
</div>
</el-col>
<!--group add/edit-->
<el-dialog :title="dialogTitle" :visible="editGroup" :show-close="false" width="30%">
<el-form :model="groupForm" :rules="groupFormRules" ref="groupForm">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="groupForm.name"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close()" size="mini">{{$t('chart.cancel')}}</el-button>
<el-button type="primary" @click="saveGroup(groupForm)" size="mini">{{$t('chart.confirm')}}</el-button>
</div>
</el-dialog>
</el-col>
<!--scene-->
<el-col v-if="sceneMode">
<el-row class="title-css">
<span class="title-text">
{{currGroup.name}}
</span>
<el-button icon="el-icon-back" size="mini" @click="back" style="float: right">
{{$t('chart.back')}}
</el-button>
</el-row>
<el-divider/>
<el-row>
<el-button type="primary" size="mini" plain @click="selectTable">
{{$t('chart.add_chart')}}
</el-button>
</el-row>
<el-row>
<el-form>
<el-form-item class="form-item">
<el-input
size="mini"
:placeholder="$t('chart.search')"
prefix-icon="el-icon-search"
v-model="search"
clearable>
</el-input>
</el-form-item>
</el-form>
</el-row>
<span>{{sceneData}}</span>
<el-tree
:data="chartData"
node-key="id"
:expand-on-click-node="true"
@node-click="sceneClick">
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>
<span>({{data.type}})</span>
<span style="margin-left: 6px">{{ data.name }}</span>
</span>
<span>
<span @click.stop style="margin-left: 12px;">
<el-dropdown trigger="click" @command="clickMore">
<span class="el-dropdown-link">
<el-button
icon="el-icon-more"
type="text"
size="small">
</el-button>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-edit-outline" :command="beforeClickMore('renameChart',data,node)">
{{$t('chart.rename')}}
</el-dropdown-item>
<el-dropdown-item icon="el-icon-delete" :command="beforeClickMore('deleteChart',data,node)">
{{$t('chart.delete')}}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</span>
</span>
</span>
</el-tree>
<!--rename chart-->
<el-dialog :title="$t('chart.table')" :visible="editTable" :show-close="false" width="30%">
<el-form :model="tableForm" :rules="tableFormRules" ref="tableForm">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="tableForm.name"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="closeTable()" size="mini">{{$t('chart.cancel')}}</el-button>
<el-button type="primary" @click="saveTable(tableForm)" size="mini">{{$t('chart.confirm')}}</el-button>
</div>
</el-dialog>
<!--dataset table select-->
<el-dialog title="select table" :visible="selectTableFlag" :show-close="false" width="70%" class="dialog-css">
<table-selector/>
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="selectTableFlag = false">{{$t('chart.cancel')}}</el-button>
<el-button type="primary" size="mini" @click="selectTableFlag = false">{{$t('chart.confirm')}}</el-button>
</div>
</el-dialog>
</el-col>
</el-col>
</template>
<script>
import TableSelector from "../view/TableSelector";
export default {
name: "Group",
components: {TableSelector},
data() {
return {
sceneMode: false,
dialogTitle: '',
search: '',
editGroup: false,
editTable: false,
data: [],
chartData: [],
currGroup: null,
expandedArray: [],
groupForm: {
name: '',
pid: null,
level: 0,
type: '',
children: [],
sort: 'type desc,name asc'
},
tableForm: {
name: '',
sort: 'type asc,create_time desc,name asc'
},
groupFormRules: {
name: [
{required: true, message: this.$t('commons.input_content'), trigger: 'blur'},
],
},
tableFormRules: {
name: [
{required: true, message: this.$t('commons.input_content'), trigger: 'blur'},
],
},
selectTableFlag: false
}
},
computed: {
sceneData: function () {
this.chartTree();
return this.$store.state.chart.sceneData;
}
},
mounted() {
this.groupTree(this.groupForm);
this.chartTree();
this.$router.push('/chart');
},
activated() {
this.groupTree(this.groupForm);
this.chartTree();
this.$router.push('/chart');
},
watch: {},
methods: {
clickAdd(param) {
this.add(param.type);
this.groupForm.pid = param.data.id;
this.groupForm.level = param.data.level + 1;
},
beforeClickAdd(type, data, node) {
return {
'type': type,
'data': data,
'node': node
}
},
clickMore(param) {
switch (param.type) {
case 'rename':
this.add(param.data.type);
this.groupForm = JSON.parse(JSON.stringify(param.data));
break;
case 'move':
break;
case 'delete':
this.delete(param.data);
break;
case 'renameChart':
this.editTable = true;
this.tableForm = JSON.parse(JSON.stringify(param.data));
break;
case 'deleteChart':
this.deleteChart(param.data);
break;
}
},
beforeClickMore(type, data, node) {
return {
'type': type,
'data': data,
'node': node
}
},
add(type) {
switch (type) {
case 'group':
this.dialogTitle = this.$t('chart.group');
break;
case 'scene':
this.dialogTitle = this.$t('chart.scene');
break;
}
this.groupForm.type = type;
this.editGroup = true;
},
saveGroup(group) {
this.$refs['groupForm'].validate((valid) => {
if (valid) {
this.$post("/chart/group/save", group, response => {
this.close();
this.$message({
message: this.$t('commons.save_success'),
type: 'success',
showClose: true,
});
this.groupTree(this.groupForm);
})
} else {
this.$message({
message: this.$t('commons.input_content'),
type: 'error',
showClose: true,
});
return false;
}
});
},
saveTable(table) {
this.$refs['tableForm'].validate((valid) => {
if (valid) {
this.$post("/chart/table/update", table, response => {
this.closeTable();
this.$message({
message: this.$t('commons.save_success'),
type: 'success',
showClose: true,
});
this.chartTree();
this.$router.push('/chart/home');
this.$store.commit('setTable', null);
})
} else {
this.$message({
message: this.$t('commons.input_content'),
type: 'error',
showClose: true,
});
return false;
}
});
},
delete(data) {
this.$confirm(this.$t('chart.confirm_delete'), this.$t('chart.tips'), {
confirmButtonText: this.$t('chart.confirm'),
cancelButtonText: this.$t('chart.cancel'),
type: 'warning'
}).then(() => {
this.$post("/chart/group/delete/" + data.id, null, response => {
this.$message({
type: 'success',
message: this.$t('chart.delete_success'),
showClose: true,
});
this.groupTree(this.groupForm);
});
}).catch(() => {
});
},
deleteChart(data) {
this.$confirm(this.$t('chart.confirm_delete'), this.$t('chart.tips'), {
confirmButtonText: this.$t('chart.confirm'),
cancelButtonText: this.$t('chart.cancel'),
type: 'warning'
}).then(() => {
this.$post("/chart/table/delete/" + data.id, null, response => {
this.$message({
type: 'success',
message: this.$t('chart.delete_success'),
showClose: true,
});
this.chartTree();
this.$router.push('/chart/home');
this.$store.commit('setTable', null);
});
}).catch(() => {
});
},
close() {
this.editGroup = false;
this.groupForm = {
name: '',
pid: null,
level: 0,
type: '',
children: [],
sort: 'type desc,name asc'
}
},
closeTable() {
this.editTable = false;
this.tableForm = {
name: '',
}
},
groupTree(group) {
this.$post("/chart/group/tree", group, response => {
this.data = response.data;
})
},
chartTree() {
this.chartData = [];
if (this.currGroup) {
this.$post('/chart/table/list', {
sort: 'type asc,create_time desc,name asc',
sceneId: this.currGroup.id
}, response => {
this.chartData = response.data;
});
}
},
nodeClick(data, node) {
if (data.type === 'scene') {
this.sceneMode = true;
this.currGroup = data;
}
if (node.expanded) {
this.expandedArray.push(data.id);
} else {
let index = this.expandedArray.indexOf(data.id);
if (index > -1) {
this.expandedArray.splice(index, 1);
}
}
},
back() {
this.sceneMode = false;
this.$router.push('/chart/home');
},
beforeClickAddData(type) {
return {
'type': type
}
},
addDB() {
this.$router.push({
name: 'add_db',
params: {
scene: this.currGroup
}
})
},
sceneClick(data, node) {
// this.$store.commit('setChart', data.id);
// this.$router.push({
// name: 'ChartGroup',
// params: {
// table: data
// }
// });
},
selectTable() {
this.selectTableFlag = true;
}
},
}
</script>
<style scoped>
.el-divider--horizontal {
margin: 12px 0
}
.search-input {
padding: 12px 0;
}
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
.custom-position {
flex: 1;
display: flex;
align-items: center;
font-size: 14px;
flex-flow: row nowrap;
}
.form-item {
margin-bottom: 0;
}
.title-css {
height: 26px;
}
.title-text {
line-height: 26px;
}
.dialog-css >>> .el-dialog__header {
padding: 20px 20px 0;
}
.dialog-css >>> .el-dialog__body {
padding: 10px 20px 20px;
}
</style>

View File

@ -0,0 +1,18 @@
const Chart = () => import('@/business/components/chart/Chart');
const ChartHome = () => import('@/business/components/chart/data/ChartHome');
export default {
path: "/chart",
name: "ChartGroup",
redirect: "/chart/home",
components: {
content: Chart,
},
children: [
{
path: 'home',
name: 'home',
component: ChartHome,
}
]
}