forked from github/dataease
Merge remote-tracking branch 'origin/main' into main
# Conflicts: # frontend/src/components/canvas/components/Editor/ContextMenu.vue
This commit is contained in:
commit
cd5f1af773
@ -17,7 +17,6 @@
|
||||
<java.version>1.8</java.version>
|
||||
<graalvm.version>20.1.0</graalvm.version>
|
||||
<jwt.version>3.12.1</jwt.version>
|
||||
<spark.version>3.1.1</spark.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -315,70 +314,12 @@
|
||||
<artifactId>ehcache</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
<!-- hbase -->
|
||||
<dependency>
|
||||
<groupId>org.apache.hbase</groupId>
|
||||
<artifactId>hbase-client</artifactId>
|
||||
<version>2.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.hbase</groupId>
|
||||
<artifactId>hbase-common</artifactId>
|
||||
<version>2.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.hbase</groupId>
|
||||
<artifactId>hbase-mapreduce</artifactId>
|
||||
<version>2.4.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>6.8</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.spark</groupId>
|
||||
<artifactId>spark-core_2.12</artifactId>
|
||||
<version>${spark.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.objenesis</groupId>
|
||||
<artifactId>objenesis</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.spark</groupId>
|
||||
<artifactId>spark-streaming_2.12</artifactId>
|
||||
<version>${spark.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.spark</groupId>
|
||||
<artifactId>spark-sql_2.12</artifactId>
|
||||
<version>${spark.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>janino</artifactId>
|
||||
<groupId>org.codehaus.janino</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.janino</groupId>
|
||||
<artifactId>janino</artifactId>
|
||||
@ -400,27 +341,16 @@
|
||||
<artifactId>metastore</artifactId>
|
||||
<version>8.3.0.18-1084</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pentaho</groupId>
|
||||
<artifactId>pentaho-big-data-kettle-plugins-hbase-meta</artifactId>
|
||||
<version>8.3.0.18-1084</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pentaho</groupId>
|
||||
<artifactId>pentaho-big-data-kettle-plugins-hbase</artifactId>
|
||||
<version>8.3.0.18-1084</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pentaho</groupId>
|
||||
<artifactId>pentaho-big-data-impl-cluster</artifactId>
|
||||
<version>8.3.0.18-1084</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.pentaho.di.plugins</groupId>
|
||||
<artifactId>pdi-engine-configuration-impl</artifactId>
|
||||
<version>8.3.0.7-683</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>c3p0</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
<version>0.9.1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -9,7 +9,7 @@ public class CurrentRoleDto implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String code;
|
||||
// private String code;
|
||||
|
||||
private String name;
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ public class DynamicMenuDto implements Serializable {
|
||||
|
||||
private String permission;
|
||||
|
||||
private Boolean hidden;
|
||||
|
||||
private List<DynamicMenuDto> children;
|
||||
|
||||
}
|
||||
|
@ -68,6 +68,9 @@ public class F2CRealm extends AuthorizingRealm {
|
||||
if (user == null) {
|
||||
throw new AuthenticationException("User didn't existed!");
|
||||
}
|
||||
if (user.getEnabled()==0) {
|
||||
throw new AuthenticationException("User is valid!");
|
||||
}
|
||||
String pass = null;
|
||||
try {
|
||||
pass = user.getPassword();
|
||||
|
@ -35,10 +35,14 @@ public class AuthServer implements AuthApi {
|
||||
String username = loginDto.getUsername();
|
||||
String password = loginDto.getPassword();
|
||||
SysUserEntity user = authUserService.getUserByName(username);
|
||||
String realPwd = user.getPassword();
|
||||
|
||||
if (ObjectUtils.isEmpty(user)){
|
||||
throw new RuntimeException("没有该用户!");
|
||||
}
|
||||
if (user.getEnabled()==0){
|
||||
throw new RuntimeException("用户已经失效!");
|
||||
}
|
||||
String realPwd = user.getPassword();
|
||||
//私钥解密
|
||||
String pwd = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, password);
|
||||
//md5加密
|
||||
|
@ -42,6 +42,7 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
|
||||
menuMeta.setIcon(sysMenu.getIcon());
|
||||
dynamicMenuDto.setMeta(menuMeta);
|
||||
dynamicMenuDto.setPermission(sysMenu.getPermission());
|
||||
dynamicMenuDto.setHidden(sysMenu.getHidden());
|
||||
return dynamicMenuDto;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@ -22,7 +24,9 @@ public class JWTUtils {
|
||||
// token过期时间1min (过期会自动刷新续命 目的是避免一直都是同一个token )
|
||||
private static final long EXPIRE_TIME = 1*60*1000;
|
||||
// 登录间隔时间10min 超过这个时间强制重新登录
|
||||
private static final long Login_Interval = 10*60*1000;
|
||||
private static long Login_Interval;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -79,6 +83,11 @@ public class JWTUtils {
|
||||
* @return
|
||||
*/
|
||||
public static boolean loginExpire(String token){
|
||||
if (Login_Interval==0) {
|
||||
String property = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout");
|
||||
int seconds = StringUtils.isNotEmpty(property) ? Integer.parseInt(property): (10*60);
|
||||
Login_Interval = seconds * 1000;
|
||||
}
|
||||
Long now = System.currentTimeMillis();
|
||||
Long lastOperateTime = tokenLastOperateTime(token);
|
||||
boolean isExpire = false;
|
||||
@ -169,4 +178,5 @@ public class JWTUtils {
|
||||
long now = System.currentTimeMillis();
|
||||
tokens_expire.put(token, now);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,13 +18,15 @@ public class DatasetTableField implements Serializable {
|
||||
|
||||
private String type;
|
||||
|
||||
private Integer size;
|
||||
|
||||
private Integer deType;
|
||||
|
||||
private Boolean checked;
|
||||
|
||||
private Integer columnIndex;
|
||||
|
||||
private Long lastSyncTime;
|
||||
|
||||
private Integer deType;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
}
|
@ -454,6 +454,126 @@ public class DatasetTableFieldExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSizeIsNull() {
|
||||
addCriterion("`size` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSizeIsNotNull() {
|
||||
addCriterion("`size` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSizeEqualTo(Integer value) {
|
||||
addCriterion("`size` =", value, "size");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSizeNotEqualTo(Integer value) {
|
||||
addCriterion("`size` <>", value, "size");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSizeGreaterThan(Integer value) {
|
||||
addCriterion("`size` >", value, "size");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSizeGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("`size` >=", value, "size");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSizeLessThan(Integer value) {
|
||||
addCriterion("`size` <", value, "size");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSizeLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("`size` <=", value, "size");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSizeIn(List<Integer> values) {
|
||||
addCriterion("`size` in", values, "size");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSizeNotIn(List<Integer> values) {
|
||||
addCriterion("`size` not in", values, "size");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSizeBetween(Integer value1, Integer value2) {
|
||||
addCriterion("`size` between", value1, value2, "size");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSizeNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("`size` not between", value1, value2, "size");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeIsNull() {
|
||||
addCriterion("de_type is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeIsNotNull() {
|
||||
addCriterion("de_type is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeEqualTo(Integer value) {
|
||||
addCriterion("de_type =", value, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeNotEqualTo(Integer value) {
|
||||
addCriterion("de_type <>", value, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeGreaterThan(Integer value) {
|
||||
addCriterion("de_type >", value, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("de_type >=", value, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeLessThan(Integer value) {
|
||||
addCriterion("de_type <", value, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("de_type <=", value, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeIn(List<Integer> values) {
|
||||
addCriterion("de_type in", values, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeNotIn(List<Integer> values) {
|
||||
addCriterion("de_type not in", values, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeBetween(Integer value1, Integer value2) {
|
||||
addCriterion("de_type between", value1, value2, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("de_type not between", value1, value2, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCheckedIsNull() {
|
||||
addCriterion("`checked` is null");
|
||||
return (Criteria) this;
|
||||
@ -633,66 +753,6 @@ public class DatasetTableFieldExample {
|
||||
addCriterion("last_sync_time not between", value1, value2, "lastSyncTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeIsNull() {
|
||||
addCriterion("de_type is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeIsNotNull() {
|
||||
addCriterion("de_type is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeEqualTo(Integer value) {
|
||||
addCriterion("de_type =", value, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeNotEqualTo(Integer value) {
|
||||
addCriterion("de_type <>", value, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeGreaterThan(Integer value) {
|
||||
addCriterion("de_type >", value, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("de_type >=", value, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeLessThan(Integer value) {
|
||||
addCriterion("de_type <", value, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("de_type <=", value, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeIn(List<Integer> values) {
|
||||
addCriterion("de_type in", values, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeNotIn(List<Integer> values) {
|
||||
addCriterion("de_type not in", values, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeBetween(Integer value1, Integer value2) {
|
||||
addCriterion("de_type between", value1, value2, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeTypeNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("de_type not between", value1, value2, "deType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
@ -7,8 +7,6 @@ import lombok.Data;
|
||||
public class SysRole implements Serializable {
|
||||
private Long roleId;
|
||||
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
@ -164,76 +164,6 @@ public class SysRoleExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeIsNull() {
|
||||
addCriterion("code is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeIsNotNull() {
|
||||
addCriterion("code is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeEqualTo(String value) {
|
||||
addCriterion("code =", value, "code");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeNotEqualTo(String value) {
|
||||
addCriterion("code <>", value, "code");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeGreaterThan(String value) {
|
||||
addCriterion("code >", value, "code");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("code >=", value, "code");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeLessThan(String value) {
|
||||
addCriterion("code <", value, "code");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeLessThanOrEqualTo(String value) {
|
||||
addCriterion("code <=", value, "code");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeLike(String value) {
|
||||
addCriterion("code like", value, "code");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeNotLike(String value) {
|
||||
addCriterion("code not like", value, "code");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeIn(List<String> values) {
|
||||
addCriterion("code in", values, "code");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeNotIn(List<String> values) {
|
||||
addCriterion("code not in", values, "code");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeBetween(String value1, String value2) {
|
||||
addCriterion("code between", value1, value2, "code");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCodeNotBetween(String value1, String value2) {
|
||||
addCriterion("code not between", value1, value2, "code");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNull() {
|
||||
addCriterion("`name` is null");
|
||||
return (Criteria) this;
|
||||
|
@ -7,10 +7,11 @@
|
||||
<result column="origin_name" jdbcType="VARCHAR" property="originName" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||
<result column="size" jdbcType="INTEGER" property="size" />
|
||||
<result column="de_type" jdbcType="INTEGER" property="deType" />
|
||||
<result column="checked" jdbcType="BIT" property="checked" />
|
||||
<result column="column_index" jdbcType="INTEGER" property="columnIndex" />
|
||||
<result column="last_sync_time" jdbcType="BIGINT" property="lastSyncTime" />
|
||||
<result column="de_type" jdbcType="INTEGER" property="deType" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
@ -71,8 +72,8 @@
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, table_id, origin_name, `name`, `type`, `checked`, column_index, last_sync_time,
|
||||
de_type
|
||||
id, table_id, origin_name, `name`, `type`, `size`, de_type, `checked`, column_index,
|
||||
last_sync_time
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.dataease.base.domain.DatasetTableFieldExample" resultMap="BaseResultMap">
|
||||
select
|
||||
@ -106,11 +107,13 @@
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.dataease.base.domain.DatasetTableField">
|
||||
insert into dataset_table_field (id, table_id, origin_name,
|
||||
`name`, `type`, `checked`, column_index,
|
||||
last_sync_time, de_type)
|
||||
`name`, `type`, `size`, de_type,
|
||||
`checked`, column_index, last_sync_time
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{tableId,jdbcType=VARCHAR}, #{originName,jdbcType=VARCHAR},
|
||||
#{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{checked,jdbcType=BIT}, #{columnIndex,jdbcType=INTEGER},
|
||||
#{lastSyncTime,jdbcType=BIGINT}, #{deType,jdbcType=INTEGER})
|
||||
#{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{size,jdbcType=INTEGER}, #{deType,jdbcType=INTEGER},
|
||||
#{checked,jdbcType=BIT}, #{columnIndex,jdbcType=INTEGER}, #{lastSyncTime,jdbcType=BIGINT}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.dataease.base.domain.DatasetTableField">
|
||||
insert into dataset_table_field
|
||||
@ -130,6 +133,12 @@
|
||||
<if test="type != null">
|
||||
`type`,
|
||||
</if>
|
||||
<if test="size != null">
|
||||
`size`,
|
||||
</if>
|
||||
<if test="deType != null">
|
||||
de_type,
|
||||
</if>
|
||||
<if test="checked != null">
|
||||
`checked`,
|
||||
</if>
|
||||
@ -139,9 +148,6 @@
|
||||
<if test="lastSyncTime != null">
|
||||
last_sync_time,
|
||||
</if>
|
||||
<if test="deType != null">
|
||||
de_type,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
@ -159,6 +165,12 @@
|
||||
<if test="type != null">
|
||||
#{type,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="size != null">
|
||||
#{size,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="deType != null">
|
||||
#{deType,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="checked != null">
|
||||
#{checked,jdbcType=BIT},
|
||||
</if>
|
||||
@ -168,9 +180,6 @@
|
||||
<if test="lastSyncTime != null">
|
||||
#{lastSyncTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="deType != null">
|
||||
#{deType,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.dataease.base.domain.DatasetTableFieldExample" resultType="java.lang.Long">
|
||||
@ -197,6 +206,12 @@
|
||||
<if test="record.type != null">
|
||||
`type` = #{record.type,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.size != null">
|
||||
`size` = #{record.size,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.deType != null">
|
||||
de_type = #{record.deType,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.checked != null">
|
||||
`checked` = #{record.checked,jdbcType=BIT},
|
||||
</if>
|
||||
@ -206,9 +221,6 @@
|
||||
<if test="record.lastSyncTime != null">
|
||||
last_sync_time = #{record.lastSyncTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.deType != null">
|
||||
de_type = #{record.deType,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
@ -221,10 +233,11 @@
|
||||
origin_name = #{record.originName,jdbcType=VARCHAR},
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
`type` = #{record.type,jdbcType=VARCHAR},
|
||||
`size` = #{record.size,jdbcType=INTEGER},
|
||||
de_type = #{record.deType,jdbcType=INTEGER},
|
||||
`checked` = #{record.checked,jdbcType=BIT},
|
||||
column_index = #{record.columnIndex,jdbcType=INTEGER},
|
||||
last_sync_time = #{record.lastSyncTime,jdbcType=BIGINT},
|
||||
de_type = #{record.deType,jdbcType=INTEGER}
|
||||
last_sync_time = #{record.lastSyncTime,jdbcType=BIGINT}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
@ -244,6 +257,12 @@
|
||||
<if test="type != null">
|
||||
`type` = #{type,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="size != null">
|
||||
`size` = #{size,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="deType != null">
|
||||
de_type = #{deType,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="checked != null">
|
||||
`checked` = #{checked,jdbcType=BIT},
|
||||
</if>
|
||||
@ -253,9 +272,6 @@
|
||||
<if test="lastSyncTime != null">
|
||||
last_sync_time = #{lastSyncTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="deType != null">
|
||||
de_type = #{deType,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
@ -265,10 +281,11 @@
|
||||
origin_name = #{originName,jdbcType=VARCHAR},
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
`type` = #{type,jdbcType=VARCHAR},
|
||||
`size` = #{size,jdbcType=INTEGER},
|
||||
de_type = #{deType,jdbcType=INTEGER},
|
||||
`checked` = #{checked,jdbcType=BIT},
|
||||
column_index = #{columnIndex,jdbcType=INTEGER},
|
||||
last_sync_time = #{lastSyncTime,jdbcType=BIGINT},
|
||||
de_type = #{deType,jdbcType=INTEGER}
|
||||
last_sync_time = #{lastSyncTime,jdbcType=BIGINT}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
@ -3,7 +3,6 @@
|
||||
<mapper namespace="io.dataease.base.mapper.SysRoleMapper">
|
||||
<resultMap id="BaseResultMap" type="io.dataease.base.domain.SysRole">
|
||||
<id column="role_id" jdbcType="BIGINT" property="roleId" />
|
||||
<result column="code" jdbcType="VARCHAR" property="code" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="description" jdbcType="VARCHAR" property="description" />
|
||||
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
||||
@ -70,7 +69,7 @@
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
role_id, code, `name`, description, create_by, update_by, create_time, update_time
|
||||
role_id, `name`, description, create_by, update_by, create_time, update_time
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.dataease.base.domain.SysRoleExample" resultMap="BaseResultMap">
|
||||
select
|
||||
@ -103,12 +102,12 @@
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.dataease.base.domain.SysRole">
|
||||
insert into sys_role (role_id, code, `name`,
|
||||
description, create_by, update_by,
|
||||
create_time, update_time)
|
||||
values (#{roleId,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
||||
#{description,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR},
|
||||
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT})
|
||||
insert into sys_role (role_id, `name`, description,
|
||||
create_by, update_by, create_time,
|
||||
update_time)
|
||||
values (#{roleId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
|
||||
#{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
|
||||
#{updateTime,jdbcType=BIGINT})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.dataease.base.domain.SysRole">
|
||||
insert into sys_role
|
||||
@ -116,9 +115,6 @@
|
||||
<if test="roleId != null">
|
||||
role_id,
|
||||
</if>
|
||||
<if test="code != null">
|
||||
code,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`name`,
|
||||
</if>
|
||||
@ -142,9 +138,6 @@
|
||||
<if test="roleId != null">
|
||||
#{roleId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="code != null">
|
||||
#{code,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -177,9 +170,6 @@
|
||||
<if test="record.roleId != null">
|
||||
role_id = #{record.roleId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.code != null">
|
||||
code = #{record.code,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -206,7 +196,6 @@
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update sys_role
|
||||
set role_id = #{record.roleId,jdbcType=BIGINT},
|
||||
code = #{record.code,jdbcType=VARCHAR},
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
description = #{record.description,jdbcType=VARCHAR},
|
||||
create_by = #{record.createBy,jdbcType=VARCHAR},
|
||||
@ -220,9 +209,6 @@
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.SysRole">
|
||||
update sys_role
|
||||
<set>
|
||||
<if test="code != null">
|
||||
code = #{code,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -246,8 +232,7 @@
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.SysRole">
|
||||
update sys_role
|
||||
set code = #{code,jdbcType=VARCHAR},
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
set `name` = #{name,jdbcType=VARCHAR},
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
create_by = #{createBy,jdbcType=VARCHAR},
|
||||
update_by = #{updateBy,jdbcType=VARCHAR},
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
<resultMap id="roleMap" type="io.dataease.auth.api.dto.CurrentRoleDto" >
|
||||
<id column="role_id" property="id"/>
|
||||
<result column="code" jdbcType="VARCHAR" property="code"/>
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
</resultMap>
|
||||
|
||||
@ -29,7 +28,7 @@
|
||||
</select>
|
||||
|
||||
<select id="roleCodes" resultType="String">
|
||||
select r.code from sys_role r
|
||||
select r.id from sys_role r
|
||||
left join sys_users_roles sur on sur.role_id = r.role_id
|
||||
where sur.user_id = #{userId}
|
||||
</select>
|
||||
@ -43,7 +42,7 @@
|
||||
</select>
|
||||
|
||||
<select id="roles" resultMap="roleMap">
|
||||
select r.role_id, r.code, r.name
|
||||
select r.role_id, r.name
|
||||
from sys_role r
|
||||
left join sys_users_roles sur on sur.role_id = r.role_id
|
||||
where sur.user_id = #{userId}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package io.dataease.commons.utils;
|
||||
|
||||
public class DorisTableUtils {
|
||||
|
||||
public static String dorisName(String datasetId){
|
||||
return "ds_" + datasetId.replace("-", "_");
|
||||
}
|
||||
|
||||
public static String dorisTmpName(String dorisName){
|
||||
return "tmp_" + dorisName;
|
||||
}
|
||||
|
||||
public static String dorisDeleteName(String dorisName){
|
||||
return "delete_" + dorisName;
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package io.dataease.config;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fit2cloud.autoconfigure.QuartzAutoConfiguration;
|
||||
import io.dataease.base.domain.Datasource;
|
||||
import io.dataease.commons.utils.CommonThreadPool;
|
||||
import org.pentaho.di.core.KettleEnvironment;
|
||||
import org.pentaho.di.repository.filerep.KettleFileRepository;
|
||||
@ -21,41 +23,27 @@ public class CommonConfig {
|
||||
private Environment env; // 保存了配置文件的信息
|
||||
private static String root_path = "/opt/dataease/data/kettle/";
|
||||
|
||||
// @Bean
|
||||
// @ConditionalOnMissingBean
|
||||
// public org.apache.hadoop.conf.Configuration configuration() {
|
||||
// org.apache.hadoop.conf.Configuration configuration = new org.apache.hadoop.conf.Configuration();
|
||||
// configuration.set("hbase.zookeeper.quorum", env.getProperty("hbase.zookeeper.quorum"));
|
||||
// configuration.set("hbase.zookeeper.property.clientPort", env.getProperty("hbase.zookeeper.property.clientPort"));
|
||||
// configuration.set("hbase.client.retries.number", env.getProperty("hbase.client.retries.number", "1"));
|
||||
// return configuration;
|
||||
// }
|
||||
@Bean(name = "DorisDatasource")
|
||||
@ConditionalOnMissingBean
|
||||
public Datasource configuration() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("dataSourceType", "jdbc");
|
||||
jsonObject.put("dataBase", env.getProperty("doris.db", "doris"));
|
||||
jsonObject.put("username", env.getProperty("doris.user", "root"));
|
||||
jsonObject.put("password", env.getProperty("doris.password", "dataease"));
|
||||
jsonObject.put("host", env.getProperty("doris.host", "doris"));
|
||||
jsonObject.put("port", env.getProperty("doris.port", "9030"));
|
||||
jsonObject.put("httpPort", env.getProperty("doris.httpPort", "8030"));
|
||||
|
||||
Datasource datasource = new Datasource();
|
||||
datasource.setId("doris");
|
||||
datasource.setName("doris");
|
||||
datasource.setDesc("doris");
|
||||
datasource.setType("mysql");
|
||||
datasource.setConfiguration(jsonObject.toJSONString());
|
||||
return datasource;
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// @ConditionalOnMissingBean
|
||||
// public SparkSession javaSparkSession() {
|
||||
// SparkSession spark = SparkSession.builder()
|
||||
// .appName(env.getProperty("spark.appName", "DataeaseJob"))
|
||||
// .master(env.getProperty("spark.master", "local[*]"))
|
||||
// .config("spark.scheduler.mode", env.getProperty("spark.scheduler.mode", "FAIR"))
|
||||
//// .config("spark.serializer", env.getProperty("spark.serializer", "org.apache.spark.serializer.KryoSerializer"))
|
||||
//// .config("spark.executor.cores", env.getProperty("spark.executor.cores", "8"))
|
||||
//// .config("spark.executor.memory", env.getProperty("spark.executor.memory", "6442450944b"))
|
||||
//// .config("spark.locality.wait", env.getProperty("spark.locality.wait", "600000"))
|
||||
//// .config("spark.maxRemoteBlockSizeFetchToMem", env.getProperty("spark.maxRemoteBlockSizeFetchToMem", "2000m"))
|
||||
//// .config("spark.shuffle.detectCorrupt", env.getProperty("spark.shuffle.detectCorrupt", "false"))
|
||||
//// .config("spark.shuffle.service.enabled", env.getProperty("spark.shuffle.service.enabled", "true"))
|
||||
//// .config("spark.sql.adaptive.enabled", env.getProperty("spark.sql.adaptive.enabled", "true"))
|
||||
//// .config("spark.sql.adaptive.shuffle.targetPostShuffleInputSize", env.getProperty("spark.sql.adaptive.shuffle.targetPostShuffleInputSize", "200M"))
|
||||
//// .config("spark.sql.broadcastTimeout", env.getProperty("spark.sql.broadcastTimeout", "12000"))
|
||||
//// .config("spark.sql.retainGroupColumns", env.getProperty("spark.sql.retainGroupColumns", "false"))
|
||||
//// .config("spark.sql.sortMergeJoinExec.buffer.in.memory.threshold", env.getProperty("spark.sql.sortMergeJoinExec.buffer.in.memory.threshold", "100000"))
|
||||
//// .config("spark.sql.sortMergeJoinExec.buffer.spill.threshold", env.getProperty("spark.sql.sortMergeJoinExec.buffer.spill.threshold", "100000"))
|
||||
//// .config("spark.sql.variable.substitute", env.getProperty("spark.sql.variable.substitute", "false"))
|
||||
//// .config("spark.temp.expired.time", env.getProperty("spark.temp.expired.time", "3600"))
|
||||
// .getOrCreate();
|
||||
// return spark;
|
||||
// }
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
|
@ -63,9 +63,9 @@ public class DataSetTableController {
|
||||
return dataSetTableService.getData(dataSetTableRequest);
|
||||
}
|
||||
|
||||
@PostMapping("getPreviewData")
|
||||
public Map<String, Object> getPreviewData(@RequestBody DataSetTableRequest dataSetTableRequest) throws Exception {
|
||||
return dataSetTableService.getPreviewData(dataSetTableRequest);
|
||||
@PostMapping("getPreviewData/{page}/{pageSize}")
|
||||
public Map<String, Object> getPreviewData(@RequestBody DataSetTableRequest dataSetTableRequest, @PathVariable Integer page, @PathVariable Integer pageSize) throws Exception {
|
||||
return dataSetTableService.getPreviewData(dataSetTableRequest, page, pageSize);
|
||||
}
|
||||
|
||||
@PostMapping("sqlPreview")
|
||||
|
@ -7,6 +7,7 @@ import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.controller.sys.request.MenuCreateRequest;
|
||||
import io.dataease.controller.sys.request.MenuDeleteRequest;
|
||||
import io.dataease.controller.sys.response.MenuNodeResponse;
|
||||
import io.dataease.controller.sys.response.MenuTreeNode;
|
||||
import io.dataease.service.sys.MenuService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -62,6 +63,12 @@ public class SysMenuController {
|
||||
sets.add(pid);
|
||||
return sets;
|
||||
}
|
||||
@PostMapping("/nodesByMenuId/{menuId}")
|
||||
public List<MenuTreeNode> nodesByMenuId(@PathVariable("menuId") Long menuId) {
|
||||
return menuService.searchTree(menuId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package io.dataease.controller.sys.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class MenuTreeNode implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String label;
|
||||
|
||||
private Boolean hasChildren;
|
||||
|
||||
private List<MenuTreeNode> children;
|
||||
|
||||
public List<MenuTreeNode> toList(){
|
||||
List<MenuTreeNode> lists = new ArrayList<>();
|
||||
lists.add(this);
|
||||
return lists;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import io.dataease.base.domain.Datasource;
|
||||
import io.dataease.commons.utils.PageUtils;
|
||||
import io.dataease.commons.utils.Pager;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.datasource.dto.DBTableDTO;
|
||||
import io.dataease.datasource.service.DatasourceService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -41,7 +42,7 @@ public class DatasourceController {
|
||||
return PageUtils.setPageInfo(page, datasourceService.gridQuery(request));
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{datasourceID}")
|
||||
@PostMapping("/delete/{datasourceID}")
|
||||
public void deleteDatasource(@PathVariable(value = "datasourceID") String datasourceID) {
|
||||
datasourceService.deleteDatasource(datasourceID);
|
||||
}
|
||||
@ -52,7 +53,7 @@ public class DatasourceController {
|
||||
}
|
||||
|
||||
@PostMapping("/getTables")
|
||||
public List<String> getTables(@RequestBody Datasource datasource) throws Exception {
|
||||
public List<DBTableDTO> getTables(@RequestBody Datasource datasource) throws Exception {
|
||||
return datasourceService.getTables(datasource);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package io.dataease.datasource.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @Author gin
|
||||
* @Date 2021/4/30 10:57 上午
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class DBTableDTO {
|
||||
private String datasourceId;
|
||||
private String name;
|
||||
private boolean enableCheck;
|
||||
private String datasetPath;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package io.dataease.datasource.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DorisConfigration extends MysqlConfigration {
|
||||
|
||||
private Integer httpPort;
|
||||
}
|
@ -6,7 +6,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class MysqlConfigrationDTO extends JdbcDTO {
|
||||
public class MysqlConfigration extends JdbcDTO {
|
||||
|
||||
private String driver = "com.mysql.cj.jdbc.Driver";
|
||||
|
@ -8,6 +8,7 @@ import io.dataease.datasource.request.DatasourceRequest;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class DatasourceProvider {
|
||||
|
||||
@ -15,8 +16,6 @@ public abstract class DatasourceProvider {
|
||||
|
||||
abstract public List<String[]> getData(DatasourceRequest datasourceRequest) throws Exception;
|
||||
|
||||
abstract public ResultSet getDataResultSet(DatasourceRequest datasourceRequest) throws Exception;
|
||||
|
||||
abstract public List<String> getTables(DatasourceRequest datasourceRequest) throws Exception;
|
||||
|
||||
public List<TableFiled> getTableFileds(DatasourceRequest datasourceRequest) throws Exception {
|
||||
@ -27,13 +26,11 @@ public abstract class DatasourceProvider {
|
||||
getData(datasourceRequest);
|
||||
}
|
||||
|
||||
abstract public Long count(DatasourceRequest datasourceRequest) throws Exception;
|
||||
abstract public List<String[]> fetchResult(DatasourceRequest datasourceRequest) throws Exception;
|
||||
|
||||
abstract public List<String[]> getPageData(DatasourceRequest datasourceRequest) throws Exception;
|
||||
abstract public List<TableFiled> fetchResultField(DatasourceRequest datasourceRequest) throws Exception;
|
||||
|
||||
abstract public List<String[]> fetchResult(ResultSet rs) throws Exception;
|
||||
abstract public Map<String, List> fetchResultAndField(DatasourceRequest datasourceRequest) throws Exception;
|
||||
|
||||
abstract public List<TableFiled> fetchResultField(ResultSet rs) throws Exception;
|
||||
|
||||
abstract public void initConnectionPool(DatasourceRequest datasourceRequest) throws Exception;
|
||||
abstract public void initDataSource(DatasourceRequest datasourceRequest) throws Exception;
|
||||
}
|
||||
|
@ -1,26 +1,25 @@
|
||||
package io.dataease.datasource.provider;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.base.domain.DatasetTableField;
|
||||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||
import io.dataease.datasource.constants.DatasourceTypes;
|
||||
import io.dataease.datasource.dto.MysqlConfigrationDTO;
|
||||
import io.dataease.datasource.dto.MysqlConfigration;
|
||||
import io.dataease.datasource.dto.SqlServerConfigration;
|
||||
import io.dataease.datasource.dto.TableFiled;
|
||||
import io.dataease.datasource.request.DatasourceRequest;
|
||||
import org.apache.arrow.util.VisibleForTesting;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.sql.*;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
|
||||
@Service("jdbc")
|
||||
public class JdbcProvider extends DatasourceProvider {
|
||||
|
||||
private static Map<String, ArrayBlockingQueue<Connection>> jdbcConnection = new HashMap<>();
|
||||
private static int poolSize = 20;
|
||||
private static Map<String, ComboPooledDataSource> jdbcConnection = new HashMap<>();
|
||||
private static int initPoolSize = 5;
|
||||
private static int maxConnections = 200;
|
||||
@Override
|
||||
public List<String[]> getData(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<String[]> list = new LinkedList<>();
|
||||
@ -35,67 +34,46 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
} catch (Exception e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
}finally {
|
||||
returnSource(connection, datasourceRequest.getDatasource().getId());
|
||||
connection.close();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void exec(DatasourceRequest datasourceRequest) throws Exception {
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = getConnectionFromPool(datasourceRequest);
|
||||
Statement stat = connection.createStatement();
|
||||
stat.execute(datasourceRequest.getQuery());
|
||||
Boolean result = stat.execute(datasourceRequest.getQuery());
|
||||
stat.close();
|
||||
} catch (SQLException e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
} catch (Exception e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
}finally {
|
||||
returnSource(connection, datasourceRequest.getDatasource().getId());
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResultSet getDataResultSet(DatasourceRequest datasourceRequest) throws Exception {
|
||||
public List<String[]> fetchResult(DatasourceRequest datasourceRequest) throws Exception {
|
||||
ResultSet rs;
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = getConnectionFromPool(datasourceRequest);
|
||||
Statement stat = connection.createStatement();
|
||||
rs = stat.executeQuery(datasourceRequest.getQuery());
|
||||
return fetchResult(rs);
|
||||
} catch (SQLException e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
} catch (Exception e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
}finally {
|
||||
returnSource(connection, datasourceRequest.getDatasource().getId());
|
||||
connection.close();
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String[]> getPageData(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<String[]> list = new LinkedList<>();
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = getConnectionFromPool(datasourceRequest);
|
||||
Statement stat = connection.createStatement();
|
||||
ResultSet rs = stat.executeQuery(datasourceRequest.getQuery() + MessageFormat.format(" LIMIT {0}, {1}", (datasourceRequest.getStartPage() - 1) * datasourceRequest.getPageSize(), datasourceRequest.getPageSize()));
|
||||
list = fetchResult(rs);
|
||||
} catch (SQLException e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
} catch (Exception e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
}finally {
|
||||
returnSource(connection, datasourceRequest.getDatasource().getId());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String[]> fetchResult(ResultSet rs) throws Exception {
|
||||
private List<String[]> fetchResult(ResultSet rs) throws Exception {
|
||||
List<String[]> list = new LinkedList<>();
|
||||
ResultSetMetaData metaData = rs.getMetaData();
|
||||
int columnCount = metaData.getColumnCount();
|
||||
@ -104,7 +82,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
for (int j = 0; j < columnCount; j++) {
|
||||
int columType = metaData.getColumnType(j + 1);
|
||||
switch (columType) {
|
||||
case java.sql.Types.DATE:
|
||||
case Types.DATE:
|
||||
row[j] = rs.getDate(j + 1).toString();
|
||||
break;
|
||||
default:
|
||||
@ -118,7 +96,49 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableFiled> fetchResultField(ResultSet rs) throws Exception {
|
||||
public List<TableFiled> fetchResultField(DatasourceRequest datasourceRequest) throws Exception {
|
||||
ResultSet rs;
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = getConnectionFromPool(datasourceRequest);
|
||||
Statement stat = connection.createStatement();
|
||||
rs = stat.executeQuery(datasourceRequest.getQuery());
|
||||
return fetchResultField(rs);
|
||||
} catch (SQLException e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
} catch (Exception e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
}finally {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List> fetchResultAndField(DatasourceRequest datasourceRequest) throws Exception {
|
||||
ResultSet rs;
|
||||
Map<String, List> result = new HashMap<>();
|
||||
Connection connection = null;
|
||||
List<String[]> dataList = new LinkedList<>();
|
||||
List<TableFiled> fieldList = new ArrayList<>();
|
||||
try {
|
||||
connection = getConnectionFromPool(datasourceRequest);
|
||||
Statement stat = connection.createStatement();
|
||||
rs = stat.executeQuery(datasourceRequest.getQuery());
|
||||
dataList = fetchResult(rs);
|
||||
fieldList = fetchResultField(rs);
|
||||
result.put("dataList", dataList);
|
||||
result.put("fieldList", fieldList);
|
||||
return result;
|
||||
} catch (SQLException e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
} catch (Exception e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
}finally {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
|
||||
private List<TableFiled> fetchResultField(ResultSet rs) throws Exception {
|
||||
List<TableFiled> fieldList = new ArrayList<>();
|
||||
ResultSetMetaData metaData = rs.getMetaData();
|
||||
int columnCount = metaData.getColumnCount();
|
||||
@ -130,6 +150,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
field.setFieldName(l);
|
||||
field.setRemarks(l);
|
||||
field.setFieldType(t);
|
||||
field.setFieldSize(metaData.getColumnDisplaySize(j + 1));
|
||||
fieldList.add(field);
|
||||
}
|
||||
return fieldList;
|
||||
@ -142,16 +163,18 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
Connection con = null;
|
||||
try {
|
||||
con = getConnectionFromPool(datasourceRequest);
|
||||
Statement ps = con.createStatement();
|
||||
ResultSet resultSet = ps.executeQuery(queryStr);
|
||||
Statement statement = con.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery(queryStr);
|
||||
while (resultSet.next()) {
|
||||
tables.add(resultSet.getString(1));
|
||||
}
|
||||
resultSet.close();
|
||||
statement.close();
|
||||
return tables;
|
||||
} catch (Exception e) {
|
||||
throw new Exception("ERROR: " + e.getMessage(), e);
|
||||
}finally {
|
||||
returnSource(con, datasourceRequest.getDatasource().getId());
|
||||
con.close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,17 +198,19 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
remarks = colName;
|
||||
}
|
||||
tableFiled.setRemarks(remarks);
|
||||
tableFiled.setFieldSize(Integer.valueOf(resultSet.getString("COLUMN_SIZE")));
|
||||
String dbType = resultSet.getString("TYPE_NAME");
|
||||
tableFiled.setFieldType(dbType);
|
||||
list.add(tableFiled);
|
||||
}
|
||||
}
|
||||
resultSet.close();
|
||||
} catch (SQLException e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
} catch (Exception e) {
|
||||
throw new Exception("ERROR:" + e.getMessage(), e);
|
||||
}finally {
|
||||
returnSource(connection, datasourceRequest.getDatasource().getId());
|
||||
connection.close();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -198,6 +223,8 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
con = getConnection(datasourceRequest);
|
||||
Statement ps = con.createStatement();
|
||||
ResultSet resultSet = ps.executeQuery(queryStr);
|
||||
resultSet.close();
|
||||
ps.close();
|
||||
} catch (Exception e) {
|
||||
throw new Exception("ERROR: " + e.getMessage(), e);
|
||||
}finally {
|
||||
@ -217,45 +244,43 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
} catch (Exception e) {
|
||||
throw new Exception("ERROR: " + e.getMessage(), e);
|
||||
}finally {
|
||||
returnSource(con, datasourceRequest.getDatasource().getId());
|
||||
con.close();
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
private void returnSource(Connection connection, String dataSourceId) throws Exception{
|
||||
if(connection != null && !connection.isClosed()){
|
||||
ArrayBlockingQueue<Connection> connections = jdbcConnection.get(dataSourceId);
|
||||
connections.put(connection);
|
||||
}
|
||||
}
|
||||
|
||||
private Connection getConnectionFromPool(DatasourceRequest datasourceRequest)throws Exception {
|
||||
ArrayBlockingQueue<Connection> connections = jdbcConnection.get(datasourceRequest.getDatasource().getId());
|
||||
if (connections == null) {
|
||||
initConnectionPool(datasourceRequest);
|
||||
ComboPooledDataSource dataSource = jdbcConnection.get(datasourceRequest.getDatasource().getId());
|
||||
if (dataSource == null) {
|
||||
initDataSource(datasourceRequest);
|
||||
}
|
||||
connections = jdbcConnection.get(datasourceRequest.getDatasource().getId());
|
||||
Connection co = connections.take();
|
||||
dataSource = jdbcConnection.get(datasourceRequest.getDatasource().getId());
|
||||
Connection co = dataSource.getConnection();
|
||||
return co;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initConnectionPool(DatasourceRequest datasourceRequest)throws Exception{
|
||||
ArrayBlockingQueue<Connection> connections = jdbcConnection.get(datasourceRequest.getDatasource().getId());
|
||||
if (connections == null) {
|
||||
connections = new ArrayBlockingQueue<>(poolSize);
|
||||
for (int i = 0; i < poolSize ; i++) {
|
||||
Connection connection = getConnection(datasourceRequest);
|
||||
connections.add(connection);
|
||||
}
|
||||
jdbcConnection.put(datasourceRequest.getDatasource().getId(), connections);
|
||||
}else {
|
||||
for (int i = 0; i < poolSize ; i++) {
|
||||
Connection connection = connections.take();
|
||||
connection.close();
|
||||
connection = getConnection(datasourceRequest);
|
||||
connections.add(connection);
|
||||
}
|
||||
public void initDataSource(DatasourceRequest datasourceRequest)throws Exception{
|
||||
ComboPooledDataSource dataSource = jdbcConnection.get(datasourceRequest.getDatasource().getId());
|
||||
if (dataSource == null) {
|
||||
dataSource = new ComboPooledDataSource();
|
||||
setCredential(datasourceRequest, dataSource);
|
||||
dataSource.setMaxIdleTime(30); // 最大空闲时间
|
||||
dataSource.setAcquireIncrement(5);// 增长数
|
||||
dataSource.setInitialPoolSize(initPoolSize);// 初始连接数
|
||||
dataSource.setMinPoolSize(initPoolSize); // 最小连接数
|
||||
dataSource.setMaxPoolSize(maxConnections); // 最大连接数
|
||||
dataSource.setAcquireRetryAttempts(30);// 获取连接重试次数
|
||||
dataSource.setIdleConnectionTestPeriod(60); // 每60s检查数据库空闲连接
|
||||
dataSource.setMaxStatements(0); // c3p0全局的PreparedStatements缓存的大小
|
||||
dataSource.setBreakAfterAcquireFailure(false); // 获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常。但是数据源仍有效保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试获取连接失败后该数据源将申明已断开并永久关闭。Default: false
|
||||
dataSource.setTestConnectionOnCheckout(false); // 在每个connection 提交是校验有效性
|
||||
dataSource.setTestConnectionOnCheckin(true); // 取得连接的同时将校验连接的有效性
|
||||
dataSource.setCheckoutTimeout(60000); // 从连接池获取连接的超时时间,如设为0则无限期等待。单位毫秒,默认为0
|
||||
dataSource.setPreferredTestQuery("SELECT 1");
|
||||
dataSource.setDebugUnreturnedConnectionStackTraces(true);
|
||||
dataSource.setUnreturnedConnectionTimeout(3600);
|
||||
jdbcConnection.put(datasourceRequest.getDatasource().getId(), dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,11 +292,11 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(datasourceRequest.getDatasource().getType());
|
||||
switch (datasourceType) {
|
||||
case mysql:
|
||||
MysqlConfigrationDTO mysqlConfigrationDTO = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), MysqlConfigrationDTO.class);
|
||||
username = mysqlConfigrationDTO.getUsername();
|
||||
password = mysqlConfigrationDTO.getPassword();
|
||||
driver = mysqlConfigrationDTO.getDriver();
|
||||
jdbcurl = mysqlConfigrationDTO.getJdbc();
|
||||
MysqlConfigration mysqlConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), MysqlConfigration.class);
|
||||
username = mysqlConfigration.getUsername();
|
||||
password = mysqlConfigration.getPassword();
|
||||
driver = mysqlConfigration.getDriver();
|
||||
jdbcurl = mysqlConfigration.getJdbc();
|
||||
break;
|
||||
case sqlServer:
|
||||
SqlServerConfigration sqlServerConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), SqlServerConfigration.class);
|
||||
@ -293,12 +318,35 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
return DriverManager.getConnection(jdbcurl, props);
|
||||
}
|
||||
|
||||
|
||||
private void setCredential(DatasourceRequest datasourceRequest, ComboPooledDataSource dataSource) throws PropertyVetoException {
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(datasourceRequest.getDatasource().getType());
|
||||
switch (datasourceType) {
|
||||
case mysql:
|
||||
MysqlConfigration mysqlConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), MysqlConfigration.class);
|
||||
dataSource.setUser(mysqlConfigration.getUsername());
|
||||
dataSource.setDriverClass(mysqlConfigration.getDriver());
|
||||
dataSource.setPassword(mysqlConfigration.getPassword());
|
||||
dataSource.setJdbcUrl(mysqlConfigration.getJdbc());
|
||||
break;
|
||||
case sqlServer:
|
||||
SqlServerConfigration sqlServerConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), SqlServerConfigration.class);
|
||||
dataSource.setUser(sqlServerConfigration.getUsername());
|
||||
dataSource.setDriverClass(sqlServerConfigration.getDriver());
|
||||
dataSource.setPassword(sqlServerConfigration.getPassword());
|
||||
dataSource.setJdbcUrl(sqlServerConfigration.getJdbc());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private String getDatabase(DatasourceRequest datasourceRequest) {
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(datasourceRequest.getDatasource().getType());
|
||||
switch (datasourceType) {
|
||||
case mysql:
|
||||
MysqlConfigrationDTO mysqlConfigrationDTO = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), MysqlConfigrationDTO.class);
|
||||
return mysqlConfigrationDTO.getDataBase();
|
||||
MysqlConfigration mysqlConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), MysqlConfigration.class);
|
||||
return mysqlConfigration.getDataBase();
|
||||
case sqlServer:
|
||||
SqlServerConfigration sqlServerConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), SqlServerConfigration.class);
|
||||
return sqlServerConfigration.getDataBase();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.dataease.datasource.service;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.base.domain.*;
|
||||
import io.dataease.base.mapper.*;
|
||||
import io.dataease.base.mapper.ext.ExtDataSourceMapper;
|
||||
@ -7,15 +8,19 @@ import io.dataease.base.mapper.ext.query.GridExample;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.CommonThreadPool;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.datasource.dto.DBTableDTO;
|
||||
import io.dataease.datasource.provider.DatasourceProvider;
|
||||
import io.dataease.datasource.provider.ProviderFactory;
|
||||
import io.dataease.datasource.request.DatasourceRequest;
|
||||
import io.dataease.dto.dataset.DataTableInfoDTO;
|
||||
import io.dataease.service.dataset.DataSetGroupService;
|
||||
import org.apache.commons.collections4.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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -29,6 +34,10 @@ public class DatasourceService {
|
||||
private CommonThreadPool commonThreadPool;
|
||||
@Resource
|
||||
private ExtDataSourceMapper extDataSourceMapper;
|
||||
@Resource
|
||||
private DatasetTableMapper datasetTableMapper;
|
||||
@Resource
|
||||
private DataSetGroupService dataSetGroupService;
|
||||
|
||||
public Datasource addDatasource(Datasource datasource) {
|
||||
DatasourceExample example = new DatasourceExample();
|
||||
@ -41,7 +50,6 @@ public class DatasourceService {
|
||||
datasource.setUpdateTime(currentTimeMillis);
|
||||
datasource.setCreateTime(currentTimeMillis);
|
||||
datasourceMapper.insertSelective(datasource);
|
||||
initConnectionPool(datasource);
|
||||
return datasource;
|
||||
}
|
||||
|
||||
@ -58,7 +66,7 @@ public class DatasourceService {
|
||||
return datasourceMapper.selectByExampleWithBLOBs(example);
|
||||
}
|
||||
|
||||
public List<Datasource> gridQuery(BaseGridRequest request){
|
||||
public List<Datasource> gridQuery(BaseGridRequest request) {
|
||||
GridExample gridExample = request.convertExample();
|
||||
return extDataSourceMapper.query(gridExample);
|
||||
}
|
||||
@ -71,7 +79,6 @@ public class DatasourceService {
|
||||
datasource.setCreateTime(null);
|
||||
datasource.setUpdateTime(System.currentTimeMillis());
|
||||
datasourceMapper.updateByPrimaryKeySelective(datasource);
|
||||
initConnectionPool(datasource);
|
||||
}
|
||||
|
||||
public void validate(Datasource datasource) throws Exception {
|
||||
@ -81,42 +88,43 @@ public class DatasourceService {
|
||||
datasourceProvider.test(datasourceRequest);
|
||||
}
|
||||
|
||||
public List<String> getTables(Datasource datasource) throws Exception {
|
||||
public List<DBTableDTO> getTables(Datasource datasource) throws Exception {
|
||||
Datasource ds = datasourceMapper.selectByPrimaryKey(datasource.getId());
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
return datasourceProvider.getTables(datasourceRequest);
|
||||
List<String> tables = datasourceProvider.getTables(datasourceRequest);
|
||||
|
||||
// 获取当前数据源下的db类型数据集
|
||||
DatasetTableExample datasetTableExample = new DatasetTableExample();
|
||||
datasetTableExample.createCriteria().andTypeEqualTo("db").andDataSourceIdEqualTo(datasource.getId());
|
||||
List<DatasetTable> datasetTables = datasetTableMapper.selectByExampleWithBLOBs(datasetTableExample);
|
||||
List<DBTableDTO> list = new ArrayList<>();
|
||||
for (String name : tables) {
|
||||
DBTableDTO dbTableDTO = new DBTableDTO();
|
||||
dbTableDTO.setDatasourceId(datasource.getId());
|
||||
dbTableDTO.setName(name);
|
||||
dbTableDTO.setEnableCheck(true);
|
||||
dbTableDTO.setDatasetPath(null);
|
||||
for (DatasetTable datasetTable : datasetTables) {
|
||||
DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class);
|
||||
if (StringUtils.equals(name, dataTableInfoDTO.getTable())) {
|
||||
dbTableDTO.setEnableCheck(false);
|
||||
|
||||
List<DatasetGroup> parents = dataSetGroupService.getParents(datasetTable.getSceneId());
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
parents.forEach(ele -> stringBuilder.append(ele.getName()).append("/"));
|
||||
stringBuilder.append(datasetTable.getName());
|
||||
dbTableDTO.setDatasetPath(stringBuilder.toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
list.add(dbTableDTO);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Datasource get(String id) {
|
||||
return datasourceMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
private void initConnectionPool(Datasource datasource){
|
||||
commonThreadPool.addTask(() ->{
|
||||
try {
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(datasource);
|
||||
datasourceProvider.initConnectionPool(datasourceRequest);
|
||||
}catch (Exception e){}
|
||||
});
|
||||
}
|
||||
|
||||
public void initAllDataSourceConnectionPool(){
|
||||
List<Datasource> datasources = datasourceMapper.selectByExampleWithBLOBs(new DatasourceExample());
|
||||
datasources.forEach(datasource -> {
|
||||
commonThreadPool.addTask(() ->{
|
||||
try {
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(datasource);
|
||||
datasourceProvider.initConnectionPool(datasourceRequest);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package io.dataease.dto.dataset;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @Author gin
|
||||
* @Date 2021/4/28 11:13 上午
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class DataSetPreviewPage {
|
||||
private Integer total = 0;
|
||||
private Integer show = 0;
|
||||
private Integer page = 1;
|
||||
private Integer pageSize = 100;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package io.dataease.listener;
|
||||
|
||||
import io.dataease.datasource.service.DatasourceService;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Component
|
||||
@Order(value = 2)
|
||||
public class AppStartInitDataSourceListener implements ApplicationListener<ApplicationReadyEvent> {
|
||||
@Resource
|
||||
private DatasourceService datasourceService;
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
|
||||
System.out.println("================= Init datasource connection pool =================");
|
||||
// 项目启动,从数据集中找到定时抽取的表,从HBase中读取放入缓存
|
||||
datasourceService.initAllDataSourceConnectionPool();
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import io.dataease.base.domain.*;
|
||||
import io.dataease.base.mapper.ChartViewMapper;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.controller.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.controller.request.chart.ChartExtRequest;
|
||||
import io.dataease.controller.request.chart.ChartViewRequest;
|
||||
@ -149,7 +150,7 @@ public class ChartViewService {
|
||||
// data = sparkCalc.getData(table.getId(), fields, xAxis, yAxis, "tmp_" + view.getId().split("-")[0], extFilterList);
|
||||
|
||||
// 连接doris,构建doris数据源查询
|
||||
Datasource ds = dorisDatasource();
|
||||
Datasource ds = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
@ -245,24 +246,6 @@ public class ChartViewService {
|
||||
return filter.toString();
|
||||
}
|
||||
|
||||
public Datasource dorisDatasource() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("dataSourceType", "jdbc");
|
||||
jsonObject.put("dataBase", "example_db");
|
||||
jsonObject.put("username", "root");
|
||||
jsonObject.put("password", "dataease");
|
||||
jsonObject.put("host", "59.110.64.159");
|
||||
jsonObject.put("port", "9030");
|
||||
|
||||
Datasource datasource = new Datasource();
|
||||
datasource.setId("doris");
|
||||
datasource.setName("doris");
|
||||
datasource.setDesc("doris");
|
||||
datasource.setType("mysql");
|
||||
datasource.setConfiguration(jsonObject.toJSONString());
|
||||
return datasource;
|
||||
}
|
||||
|
||||
public String getSQL(String type, String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(type);
|
||||
switch (datasourceType) {
|
||||
|
@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
@ -158,4 +159,21 @@ public class DataSetGroupService {
|
||||
throw new RuntimeException("Name can't repeat in same group.");
|
||||
}
|
||||
}
|
||||
|
||||
public List<DatasetGroup> getParents(String id) {
|
||||
List<DatasetGroup> list = new ArrayList<>();
|
||||
DatasetGroup datasetGroup = datasetGroupMapper.selectByPrimaryKey(id);
|
||||
list.add(datasetGroup);
|
||||
getParent(list, datasetGroup);
|
||||
Collections.reverse(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
public void getParent(List<DatasetGroup> list, DatasetGroup datasetGroup) {
|
||||
if (StringUtils.isNotEmpty(datasetGroup.getPid())) {
|
||||
DatasetGroup d = datasetGroupMapper.selectByPrimaryKey(datasetGroup.getPid());
|
||||
list.add(d);
|
||||
getParent(list, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import io.dataease.datasource.dto.TableFiled;
|
||||
import io.dataease.datasource.provider.DatasourceProvider;
|
||||
import io.dataease.datasource.provider.ProviderFactory;
|
||||
import io.dataease.datasource.request.DatasourceRequest;
|
||||
import io.dataease.dto.dataset.DataSetPreviewPage;
|
||||
import io.dataease.dto.dataset.DataTableInfoDTO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
@ -34,7 +35,6 @@ import javax.annotation.Resource;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -81,7 +81,15 @@ public class DataSetTableService {
|
||||
saveTableField(datasetTable);
|
||||
}
|
||||
} else {
|
||||
datasetTableMapper.updateByPrimaryKeySelective(datasetTable);
|
||||
int update = datasetTableMapper.updateByPrimaryKeySelective(datasetTable);
|
||||
// sql 更新
|
||||
if (update == 1) {
|
||||
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) {
|
||||
// 删除所有字段,重新抽象
|
||||
dataSetTableFieldsService.deleteByTableId(datasetTable.getId());
|
||||
saveTableField(datasetTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
return datasetTable;
|
||||
}
|
||||
@ -172,7 +180,7 @@ public class DataSetTableService {
|
||||
return datasourceProvider.getData(datasourceRequest);
|
||||
}
|
||||
|
||||
public Map<String, Object> getPreviewData(DataSetTableRequest dataSetTableRequest) throws Exception {
|
||||
public Map<String, Object> getPreviewData(DataSetTableRequest dataSetTableRequest, Integer page, Integer pageSize) throws Exception {
|
||||
DatasetTableField datasetTableField = DatasetTableField.builder().build();
|
||||
datasetTableField.setTableId(dataSetTableRequest.getId());
|
||||
datasetTableField.setChecked(Boolean.TRUE);
|
||||
@ -183,6 +191,14 @@ public class DataSetTableService {
|
||||
DatasetTable datasetTable = datasetTableMapper.selectByPrimaryKey(dataSetTableRequest.getId());
|
||||
|
||||
List<String[]> data = new ArrayList<>();
|
||||
DataSetPreviewPage dataSetPreviewPage = new DataSetPreviewPage();
|
||||
dataSetPreviewPage.setShow(Integer.valueOf(dataSetTableRequest.getRow()));
|
||||
dataSetPreviewPage.setPage(page);
|
||||
dataSetPreviewPage.setPageSize(pageSize);
|
||||
int realSize = Integer.parseInt(dataSetTableRequest.getRow()) < pageSize ? Integer.parseInt(dataSetTableRequest.getRow()) : pageSize;
|
||||
if (page == Integer.parseInt(dataSetTableRequest.getRow()) / pageSize + 1) {
|
||||
realSize = Integer.parseInt(dataSetTableRequest.getRow()) % pageSize;
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "db")) {
|
||||
Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId());
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
@ -190,11 +206,18 @@ public class DataSetTableService {
|
||||
datasourceRequest.setDatasource(ds);
|
||||
|
||||
String table = dataTableInfoDTO.getTable();
|
||||
datasourceRequest.setQuery(createQuerySQL(ds.getType(), table, fieldArray) + " LIMIT 0," + dataSetTableRequest.getRow());
|
||||
datasourceRequest.setQuery(createQuerySQL(ds.getType(), table, fieldArray) + " LIMIT " + (page - 1) * pageSize + "," + realSize);
|
||||
|
||||
try {
|
||||
data.addAll(datasourceProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setQuery(createQueryCountSQL(ds.getType(), table));
|
||||
dataSetPreviewPage.setTotal(Integer.valueOf(datasourceProvider.getData(datasourceRequest).get(0)[0]));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) {
|
||||
Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId());
|
||||
@ -203,11 +226,18 @@ public class DataSetTableService {
|
||||
datasourceRequest.setDatasource(ds);
|
||||
|
||||
String sql = dataTableInfoDTO.getSql();
|
||||
datasourceRequest.setQuery(createQuerySQL(ds.getType(), " (" + sql + ") AS tmp ", fieldArray) + " LIMIT 0," + dataSetTableRequest.getRow());
|
||||
datasourceRequest.setQuery(createQuerySQL(ds.getType(), " (" + sql + ") AS tmp ", fieldArray) + " LIMIT " + (page - 1) * pageSize + "," + realSize);
|
||||
|
||||
try {
|
||||
data.addAll(datasourceProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setQuery(createQueryCountSQL(ds.getType(), " (" + sql + ") AS tmp "));
|
||||
dataSetPreviewPage.setTotal(Integer.valueOf(datasourceProvider.getData(datasourceRequest).get(0)[0]));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) {
|
||||
|
||||
@ -229,6 +259,7 @@ public class DataSetTableService {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("fields", fields);
|
||||
map.put("data", jsonArray);
|
||||
map.put("page", dataSetPreviewPage);
|
||||
|
||||
return map;
|
||||
}
|
||||
@ -239,10 +270,10 @@ public class DataSetTableService {
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
String sql = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class).getSql();
|
||||
datasourceRequest.setQuery(sql);
|
||||
ResultSet dataResultSet = datasourceProvider.getDataResultSet(datasourceRequest);
|
||||
List<String[]> data = datasourceProvider.fetchResult(dataResultSet);
|
||||
List<TableFiled> fields = datasourceProvider.fetchResultField(dataResultSet);
|
||||
datasourceRequest.setQuery("SELECT * FROM (" + sql + ") AS tmp LIMIT 0,1000");
|
||||
Map<String, List> result = datasourceProvider.fetchResultAndField(datasourceRequest);
|
||||
List<String[]> data = result.get("dataList");
|
||||
List<TableFiled> fields = result.get("fieldList");
|
||||
String[] fieldArray = fields.stream().map(TableFiled::getFieldName).toArray(String[]::new);
|
||||
|
||||
List<Map<String, Object>> jsonArray = new ArrayList<>();
|
||||
@ -263,67 +294,6 @@ public class DataSetTableService {
|
||||
return map;
|
||||
}
|
||||
|
||||
public List<String[]> getDataSetData(String datasourceId, String table, List<DatasetTableField> fields) {
|
||||
List<String[]> data = new ArrayList<>();
|
||||
Datasource ds = datasourceMapper.selectByPrimaryKey(datasourceId);
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
String[] fieldArray = fields.stream().map(DatasetTableField::getOriginName).toArray(String[]::new);
|
||||
datasourceRequest.setQuery(createQuerySQL(ds.getType(), table, fieldArray) + " LIMIT 0, 10");
|
||||
try {
|
||||
data.addAll(datasourceProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public Long getDataSetTotalData(String datasourceId, String table) {
|
||||
List<String[]> data = new ArrayList<>();
|
||||
Datasource ds = datasourceMapper.selectByPrimaryKey(datasourceId);
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
datasourceRequest.setQuery("select count(*) from " + table);
|
||||
try {
|
||||
return datasourceProvider.count(datasourceRequest);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return 0l;
|
||||
}
|
||||
|
||||
public List<String[]> getDataSetPageData(String datasourceId, String table, List<DatasetTableField> fields, Long startPage, Long pageSize) {
|
||||
List<String[]> data = new ArrayList<>();
|
||||
Datasource ds = datasourceMapper.selectByPrimaryKey(datasourceId);
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
String[] fieldArray = fields.stream().map(DatasetTableField::getOriginName).toArray(String[]::new);
|
||||
datasourceRequest.setPageSize(pageSize);
|
||||
datasourceRequest.setStartPage(startPage);
|
||||
datasourceRequest.setQuery(createQuerySQL(ds.getType(), table, fieldArray));
|
||||
try {
|
||||
return datasourceProvider.getData(datasourceRequest);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<String[]> getDataSetDataBySql(String datasourceId, String table, String sql) {
|
||||
List<String[]> data = new ArrayList<>();
|
||||
Datasource ds = datasourceMapper.selectByPrimaryKey(datasourceId);
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
datasourceRequest.setQuery(sql);
|
||||
try {
|
||||
return datasourceProvider.getData(datasourceRequest);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public void saveTableField(DatasetTable datasetTable) throws Exception {
|
||||
Datasource ds = datasourceMapper.selectByPrimaryKey(datasetTable.getDataSourceId());
|
||||
DataSetTableRequest dataSetTableRequest = new DataSetTableRequest();
|
||||
@ -338,8 +308,7 @@ public class DataSetTableService {
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
datasourceRequest.setQuery(new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class).getSql());
|
||||
ResultSet dataResultSet = datasourceProvider.getDataResultSet(datasourceRequest);
|
||||
fields = datasourceProvider.fetchResultField(dataResultSet);
|
||||
fields = datasourceProvider.fetchResultField(datasourceRequest);
|
||||
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) {
|
||||
DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class);
|
||||
String path = dataTableInfoDTO.getData();
|
||||
@ -367,6 +336,7 @@ public class DataSetTableService {
|
||||
} else {
|
||||
datasetTableField.setDeType(transFieldType(ds.getType(), filed.getFieldType()));
|
||||
}
|
||||
datasetTableField.setSize(filed.getFieldSize());
|
||||
datasetTableField.setChecked(true);
|
||||
datasetTableField.setColumnIndex(i);
|
||||
datasetTableField.setLastSyncTime(syncTime);
|
||||
@ -375,6 +345,18 @@ public class DataSetTableService {
|
||||
}
|
||||
}
|
||||
|
||||
public String createQueryCountSQL(String type, String table) {
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(type);
|
||||
switch (datasourceType) {
|
||||
case mysql:
|
||||
return MessageFormat.format("SELECT count(*) FROM {0}", table);
|
||||
case sqlServer:
|
||||
return MessageFormat.format("SELECT count(*) FROM {0}", table);
|
||||
default:
|
||||
return MessageFormat.format("SELECT count(*) FROM {0}", table);
|
||||
}
|
||||
}
|
||||
|
||||
public String createQuerySQL(String type, String table, String[] fields) {
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(type);
|
||||
switch (datasourceType) {
|
||||
|
@ -7,24 +7,29 @@ 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.LogUtil;
|
||||
import io.dataease.datasource.constants.DatasourceTypes;
|
||||
import io.dataease.datasource.dto.MysqlConfigrationDTO;
|
||||
import io.dataease.datasource.dto.DorisConfigration;
|
||||
import io.dataease.datasource.dto.MysqlConfigration;
|
||||
import io.dataease.datasource.dto.TableFiled;
|
||||
import io.dataease.datasource.provider.DatasourceProvider;
|
||||
import io.dataease.datasource.provider.JdbcProvider;
|
||||
import io.dataease.datasource.provider.ProviderFactory;
|
||||
import io.dataease.datasource.request.DatasourceRequest;
|
||||
import io.dataease.dto.dataset.DataSetTaskLogDTO;
|
||||
import io.dataease.dto.dataset.DataTableInfoDTO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.pentaho.di.cluster.SlaveServer;
|
||||
import org.pentaho.di.core.database.DatabaseMeta;
|
||||
import org.pentaho.di.core.plugins.PluginRegistry;
|
||||
import org.pentaho.di.core.plugins.StepPluginType;
|
||||
import org.pentaho.di.core.row.ValueMetaInterface;
|
||||
import org.pentaho.di.job.Job;
|
||||
import org.pentaho.di.job.JobExecutionConfiguration;
|
||||
import org.pentaho.di.job.JobHopMeta;
|
||||
import org.pentaho.di.job.JobMeta;
|
||||
import org.pentaho.di.job.entries.shell.JobEntryShell;
|
||||
import org.pentaho.di.job.entries.special.JobEntrySpecial;
|
||||
import org.pentaho.di.job.entries.success.JobEntrySuccess;
|
||||
import org.pentaho.di.job.entries.trans.JobEntryTrans;
|
||||
@ -34,18 +39,23 @@ import org.pentaho.di.repository.filerep.KettleFileRepository;
|
||||
import org.pentaho.di.trans.TransHopMeta;
|
||||
import org.pentaho.di.trans.TransMeta;
|
||||
import org.pentaho.di.trans.step.StepMeta;
|
||||
import org.pentaho.di.trans.steps.sql.ExecSQLMeta;
|
||||
import org.pentaho.di.trans.steps.tableinput.TableInputMeta;
|
||||
import org.pentaho.di.trans.steps.textfileoutput.TextFileField;
|
||||
import org.pentaho.di.trans.steps.textfileoutput.TextFileOutputMeta;
|
||||
import org.pentaho.di.trans.steps.userdefinedjavaclass.UserDefinedJavaClassDef;
|
||||
import org.pentaho.di.trans.steps.userdefinedjavaclass.UserDefinedJavaClassMeta;
|
||||
import org.pentaho.di.www.SlaveServerJobStatus;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class ExtractDataService {
|
||||
@ -61,15 +71,12 @@ public class ExtractDataService {
|
||||
@Resource
|
||||
private DatasourceMapper datasourceMapper;
|
||||
private static ExecutorService pool = Executors.newScheduledThreadPool(50); //设置连接池
|
||||
private Connection connection;
|
||||
|
||||
private static String lastUpdateTime = "${__last_update_time__}";
|
||||
private static String currentUpdateTime = "${__current_update_time__}";
|
||||
private static String dataease_column_family = "dataease";
|
||||
private static String separator = "|";
|
||||
private static String extention = "txt";
|
||||
private static String root_path = "/opt/dataease/data/kettle/";
|
||||
private static String data_path = "/opt/dataease/data/db/";
|
||||
private static String hbase_conf_file = "/opt/dataease/conf/hbase-site.xml";
|
||||
private static String pentaho_mappings = "pentaho_mappings";
|
||||
|
||||
@Value("${carte.host:127.0.0.1}")
|
||||
private String carte;
|
||||
@ -79,61 +86,99 @@ public class ExtractDataService {
|
||||
private String user;
|
||||
@Value("${carte.passwd:cluster}")
|
||||
private String passwd;
|
||||
@Value("${hbase.zookeeper.quorum:zookeeper}")
|
||||
private String zkHost;
|
||||
@Value("${hbase.zookeeper.property.clientPort:2181}")
|
||||
private String zkPort;
|
||||
|
||||
// @Resource
|
||||
// private SparkCalc sparkCalc;
|
||||
private static String creatTableSql = "CREATE TABLE IF NOT EXISTS TABLE_NAME" +
|
||||
"Column_Fields" +
|
||||
"UNIQUE KEY(dataease_uuid)\n" +
|
||||
"DISTRIBUTED BY HASH(dataease_uuid) BUCKETS 10\n" +
|
||||
"PROPERTIES(\"replication_num\" = \"1\");";
|
||||
|
||||
private static String shellScript = "curl --location-trusted -u %s:%s -H \"label:%s\" -H \"column_separator:%s\" -H \"columns:%s\" -H \"merge_type: %s\" -T %s -XPUT http://%s:%s/api/%s/%s/_stream_load\n" +
|
||||
"rm -rf %s\n";
|
||||
|
||||
private String createDorisTablColumnSql( List<DatasetTableField> datasetTableFields){
|
||||
String Column_Fields = "dataease_uuid varchar(50),";
|
||||
for (DatasetTableField datasetTableField : datasetTableFields) {
|
||||
Column_Fields = Column_Fields + datasetTableField.getOriginName() + " ";
|
||||
switch (datasetTableField.getDeType()){
|
||||
case 0:
|
||||
Column_Fields = Column_Fields + "varchar(lenth)".replace("lenth", String.valueOf(datasetTableField.getSize())) + ",";
|
||||
break;
|
||||
case 1:
|
||||
Column_Fields = Column_Fields + "varchar(lenth)".replace("lenth", String.valueOf(datasetTableField.getSize())) + ",";
|
||||
break;
|
||||
case 2:
|
||||
Column_Fields = Column_Fields + "bigint(lenth)".replace("lenth", String.valueOf(datasetTableField.getSize())) + ",";
|
||||
break;
|
||||
case 3:
|
||||
Column_Fields = Column_Fields + "DOUBLE" + ",";
|
||||
break;
|
||||
default:
|
||||
Column_Fields = Column_Fields + "varchar(lenth)".replace("lenth", String.valueOf(datasetTableField.getSize())) + ",";
|
||||
break;
|
||||
}
|
||||
}
|
||||
Column_Fields = Column_Fields.substring(0, Column_Fields.length() -1 );
|
||||
Column_Fields = "(" + Column_Fields + ")\n";
|
||||
return Column_Fields;
|
||||
}
|
||||
|
||||
private void createDorisTable(String dorisTableName, String dorisTablColumnSql) throws Exception{
|
||||
Datasource dorisDatasource = (Datasource)CommonBeanFactory.getBean("DorisDatasource");
|
||||
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);;
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(dorisDatasource);
|
||||
datasourceRequest.setQuery(creatTableSql.replace("TABLE_NAME", dorisTableName).replace("Column_Fields", dorisTablColumnSql));
|
||||
System.out.println(datasourceRequest.getQuery());
|
||||
jdbcProvider.exec(datasourceRequest);
|
||||
}
|
||||
|
||||
private void replaceTable (String dorisTableName) throws Exception{
|
||||
Datasource dorisDatasource = (Datasource)CommonBeanFactory.getBean("DorisDatasource");
|
||||
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);;
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(dorisDatasource);
|
||||
datasourceRequest.setQuery("ALTER TABLE DORIS_TABLE REPLACE WITH TABLE DORIS_TMP_TABLE PROPERTIES('swap' = 'false');".replace("DORIS_TABLE", dorisTableName).replace("DORIS_TMP_TABLE", DorisTableUtils.dorisTmpName(dorisTableName)));
|
||||
jdbcProvider.exec(datasourceRequest);
|
||||
}
|
||||
|
||||
public void extractData(String datasetTableId, String taskId, String type) {
|
||||
DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog();
|
||||
UpdateType updateType = UpdateType.valueOf(type);
|
||||
try {
|
||||
// Admin admin = getConnection().getAdmin();
|
||||
DatasetTable datasetTable = dataSetTableService.get(datasetTableId);
|
||||
Datasource datasource = datasourceMapper.selectByPrimaryKey(datasetTable.getDataSourceId());
|
||||
List<DatasetTableField> datasetTableFields = dataSetTableFieldsService.list(DatasetTableField.builder().tableId(datasetTable.getId()).build());
|
||||
String table = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable();
|
||||
TableName hbaseTable = TableName.valueOf(datasetTableId);
|
||||
datasetTableFields.sort((o1, o2) -> {
|
||||
if (o1.getOriginName() == null) {
|
||||
return -1;
|
||||
}
|
||||
if (o2.getOriginName() == null) {
|
||||
return 1;
|
||||
}
|
||||
return o1.getOriginName().compareTo(o2.getOriginName());
|
||||
});
|
||||
|
||||
String tableName = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable();
|
||||
String dorisTablColumnSql = createDorisTablColumnSql(datasetTableFields);
|
||||
switch (updateType) {
|
||||
// 全量更新
|
||||
case all_scope:
|
||||
writeDatasetTableTaskLog(datasetTableTaskLog, datasetTableId, taskId);
|
||||
|
||||
//check pentaho_mappings table
|
||||
// TableName pentaho_mappings = TableName.valueOf(this.pentaho_mappings);
|
||||
// if (!admin.tableExists(pentaho_mappings)) {
|
||||
// creatHaseTable(pentaho_mappings, admin, Arrays.asList("columns", "key"));
|
||||
// }
|
||||
|
||||
//check pentaho files
|
||||
if (!isExitFile("job_" + datasetTableId + ".kjb") || !isExitFile("trans_" + datasetTableId + ".ktr")) {
|
||||
generateTransFile("all_scope", datasetTable, datasource, table, datasetTableFields, null);
|
||||
generateJobFile("all_scope", datasetTable);
|
||||
}
|
||||
|
||||
// if (!admin.tableExists(hbaseTable)) {
|
||||
// creatHaseTable(hbaseTable, admin, Arrays.asList(dataease_column_family));
|
||||
// }
|
||||
// admin.disableTable(hbaseTable);
|
||||
// admin.truncateTable(hbaseTable, true);
|
||||
|
||||
// TODO before: check doris table column type
|
||||
createDorisTable(DorisTableUtils.dorisName(datasetTableId), dorisTablColumnSql);
|
||||
createDorisTable(DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTableId)), dorisTablColumnSql);
|
||||
generateTransFile("all_scope", datasetTable, datasource, tableName, datasetTableFields, null);
|
||||
generateJobFile("all_scope", datasetTable, String.join(",", datasetTableFields.stream().map(DatasetTableField::getOriginName).collect(Collectors.toList())));
|
||||
extractData(datasetTable, "all_scope");
|
||||
// after sync complete,read data to cache from HBase
|
||||
// sparkCalc.getHBaseDataAndCache(datasetTableId, dataSetTableFieldsService.getFieldsByTableId(datasetTableId));
|
||||
replaceTable(DorisTableUtils.dorisName(datasetTableId));
|
||||
datasetTableTaskLog.setStatus(JobStatus.Completed.name());
|
||||
datasetTableTaskLog.setEndTime(System.currentTimeMillis());
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog);
|
||||
break;
|
||||
|
||||
// 增量更新
|
||||
case add_scope:
|
||||
// 增量更新
|
||||
// if (!admin.tableExists(hbaseTable)) {
|
||||
// LogUtil.error("TableName error, dataaset: " + datasetTableId);
|
||||
// return;
|
||||
// }
|
||||
DatasetTableIncrementalConfig datasetTableIncrementalConfig = dataSetTableService.incrementalConfig(datasetTableId);
|
||||
if (datasetTableIncrementalConfig == null || StringUtils.isEmpty(datasetTableIncrementalConfig.getTableId())) {
|
||||
return;
|
||||
@ -149,15 +194,12 @@ public class ExtractDataService {
|
||||
|
||||
// 增量添加
|
||||
if (StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalAdd().replace(" ", ""))) {
|
||||
System.out.println("datasetTableIncrementalConfig.getIncrementalAdd(): " + datasetTableIncrementalConfig.getIncrementalAdd());
|
||||
String sql = datasetTableIncrementalConfig.getIncrementalAdd().replace(lastUpdateTime, dataSetTaskLogDTOS.get(0).getStartTime().toString()
|
||||
.replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString()));
|
||||
//TODO sql column
|
||||
|
||||
if (!isExitFile("job_add_" + datasetTableId + ".kjb") || !isExitFile("trans_add_" + datasetTableId + ".ktr")) {
|
||||
generateTransFile("incremental_add", datasetTable, datasource, table, datasetTableFields, sql);
|
||||
generateJobFile("incremental_add", datasetTable);
|
||||
}
|
||||
|
||||
generateTransFile("incremental_add", datasetTable, datasource, tableName, datasetTableFields, sql);
|
||||
generateJobFile("incremental_add", datasetTable, fetchSqlField(sql, datasource));
|
||||
extractData(datasetTable, "incremental_add");
|
||||
}
|
||||
|
||||
@ -165,14 +207,12 @@ public class ExtractDataService {
|
||||
if (StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalDelete())) {
|
||||
String sql = datasetTableIncrementalConfig.getIncrementalDelete().replace(lastUpdateTime, dataSetTaskLogDTOS.get(0).getStartTime().toString()
|
||||
.replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString()));
|
||||
if (!isExitFile("job_delete_" + datasetTableId + ".kjb") || !isExitFile("trans_delete_" + datasetTableId + ".ktr")) {
|
||||
generateTransFile("incremental_delete", datasetTable, datasource, table, datasetTableFields, sql);
|
||||
generateJobFile("incremental_delete", datasetTable);
|
||||
}
|
||||
//TODO sql column
|
||||
;
|
||||
generateTransFile("incremental_delete", datasetTable, datasource, tableName, datasetTableFields, sql);
|
||||
generateJobFile("incremental_delete", datasetTable, fetchSqlField(sql, datasource));
|
||||
extractData(datasetTable, "incremental_delete");
|
||||
}
|
||||
// after sync complete,read data to cache from HBase
|
||||
// sparkCalc.getHBaseDataAndCache(datasetTableId, dataSetTableFieldsService.getFieldsByTableId(datasetTableId));
|
||||
datasetTableTaskLog.setStatus(JobStatus.Completed.name());
|
||||
datasetTableTaskLog.setEndTime(System.currentTimeMillis());
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog);
|
||||
@ -202,18 +242,6 @@ public class ExtractDataService {
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog);
|
||||
}
|
||||
|
||||
// private void creatHaseTable(TableName tableName, Admin admin, List<String> columnFamily) throws Exception {
|
||||
// TableDescriptorBuilder descBuilder = TableDescriptorBuilder.newBuilder(tableName);
|
||||
// Collection<ColumnFamilyDescriptor> families = new ArrayList<>();
|
||||
// for (String s : columnFamily) {
|
||||
// ColumnFamilyDescriptor hcd = ColumnFamilyDescriptorBuilder.of(s);
|
||||
// families.add(hcd);
|
||||
// }
|
||||
// descBuilder.setColumnFamilies(families);
|
||||
// TableDescriptor desc = descBuilder.build();
|
||||
// admin.createTable(desc);
|
||||
// }
|
||||
|
||||
private void extractData(DatasetTable datasetTable, String extractType) throws Exception {
|
||||
KettleFileRepository repository = CommonBeanFactory.getBean(KettleFileRepository.class);
|
||||
RepositoryDirectoryInterface repositoryDirectoryInterface = repository.loadRepositoryDirectoryTree();
|
||||
@ -238,9 +266,14 @@ public class ExtractDataService {
|
||||
jobExecutionConfiguration.setRepository(repository);
|
||||
String lastCarteObjectId = Job.sendToSlaveServer(jobMeta, jobExecutionConfiguration, repository, null);
|
||||
SlaveServerJobStatus jobStatus = null;
|
||||
do {
|
||||
boolean running = true;
|
||||
while(running) {
|
||||
jobStatus = remoteSlaveServer.getJobStatus(jobMeta.getName(), lastCarteObjectId, 0);
|
||||
} while (jobStatus != null && jobStatus.isRunning());
|
||||
running = jobStatus.isRunning();
|
||||
if(!running)
|
||||
break;
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
if (jobStatus.getStatusDescription().equals("Finished")) {
|
||||
return;
|
||||
} else {
|
||||
@ -248,14 +281,6 @@ public class ExtractDataService {
|
||||
}
|
||||
}
|
||||
|
||||
// private synchronized Connection getConnection() throws Exception {
|
||||
// if (connection == null || connection.isClosed()) {
|
||||
// Configuration cfg = CommonBeanFactory.getBean(Configuration.class);
|
||||
// connection = ConnectionFactory.createConnection(cfg, pool);
|
||||
// }
|
||||
// return connection;
|
||||
// }
|
||||
|
||||
private boolean isExitFile(String fileName) {
|
||||
File file = new File(root_path + fileName);
|
||||
return file.exists();
|
||||
@ -270,32 +295,32 @@ public class ExtractDataService {
|
||||
return remoteSlaveServer;
|
||||
}
|
||||
|
||||
private void generateJobFile(String extractType, DatasetTable datasetTable) throws Exception {
|
||||
private void generateJobFile(String extractType, DatasetTable datasetTable, String columnFeilds) throws Exception {
|
||||
String dorisOutputTable = null;
|
||||
String jobName = null;
|
||||
switch (extractType) {
|
||||
case "all_scope":
|
||||
jobName = "job_" + datasetTable.getId();
|
||||
break;
|
||||
case "incremental_add":
|
||||
jobName = "job_add_" + datasetTable.getId();
|
||||
break;
|
||||
case "incremental_delete":
|
||||
jobName = "job_delete_" + datasetTable.getId();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
String script = null;
|
||||
Datasource dorisDatasource = (Datasource)CommonBeanFactory.getBean("DorisDatasource");
|
||||
DorisConfigration dorisConfigration = new Gson().fromJson(dorisDatasource.getConfiguration(), DorisConfigration.class);
|
||||
String columns = columnFeilds + ",dataease_uuid";
|
||||
String transName = null;
|
||||
switch (extractType) {
|
||||
case "all_scope":
|
||||
transName = "trans_" + datasetTable.getId();
|
||||
dorisOutputTable = DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTable.getId()));
|
||||
jobName = "job_" + datasetTable.getId();
|
||||
script = String.format(shellScript, dorisConfigration.getUsername(), dorisConfigration.getPassword(), String.valueOf(System.currentTimeMillis()), separator, columns, "APPEND",root_path + dorisOutputTable + "." + extention, dorisConfigration.getHost(),dorisConfigration.getHttpPort(), dorisConfigration.getDataBase(), dorisOutputTable, root_path + dorisOutputTable + "." + extention);
|
||||
break;
|
||||
case "incremental_add":
|
||||
transName = "trans_add_" + datasetTable.getId();
|
||||
dorisOutputTable = DorisTableUtils.dorisName(datasetTable.getId());
|
||||
jobName = "job_add_" + datasetTable.getId();
|
||||
script = String.format(shellScript, dorisConfigration.getUsername(), dorisConfigration.getPassword(), String.valueOf(System.currentTimeMillis()), separator, columns, "APPEND", root_path + dorisOutputTable + "." + extention, dorisConfigration.getHost(),dorisConfigration.getHttpPort(), dorisConfigration.getDataBase(), dorisOutputTable, root_path + dorisOutputTable + "." + extention);
|
||||
break;
|
||||
case "incremental_delete":
|
||||
transName = "trans_delete_" + datasetTable.getId();
|
||||
dorisOutputTable = DorisTableUtils.dorisDeleteName(DorisTableUtils.dorisName(datasetTable.getId()));
|
||||
script = String.format(shellScript, dorisConfigration.getUsername(), dorisConfigration.getPassword(), String.valueOf(System.currentTimeMillis()), separator, columns, "DELETE", root_path + dorisOutputTable + "." + extention, dorisConfigration.getHost(),dorisConfigration.getHttpPort(), dorisConfigration.getDataBase(), DorisTableUtils.dorisName(datasetTable.getId()), root_path + dorisOutputTable + "." + extention);
|
||||
jobName = "job_delete_" + datasetTable.getId();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -303,6 +328,8 @@ public class ExtractDataService {
|
||||
|
||||
JobMeta jobMeta = new JobMeta();
|
||||
jobMeta.setName(jobName);
|
||||
|
||||
//start
|
||||
JobEntrySpecial start = new JobEntrySpecial();
|
||||
start.setName("START");
|
||||
start.setStart(true);
|
||||
@ -311,6 +338,7 @@ public class ExtractDataService {
|
||||
startEntry.setLocation(100, 100);
|
||||
jobMeta.addJobEntry(startEntry);
|
||||
|
||||
//trans
|
||||
JobEntryTrans transrans = new JobEntryTrans();
|
||||
transrans.setTransname(transName);
|
||||
transrans.setName("Transformation");
|
||||
@ -321,14 +349,30 @@ public class ExtractDataService {
|
||||
|
||||
jobMeta.addJobHop(new JobHopMeta(startEntry, transEntry));
|
||||
|
||||
//exec shell
|
||||
JobEntryShell shell = new JobEntryShell();
|
||||
shell.setScript(script);
|
||||
shell.insertScript = true;
|
||||
shell.setName("shell");
|
||||
JobEntryCopy shellEntry = new JobEntryCopy(shell);
|
||||
shellEntry.setDrawn(true);
|
||||
shellEntry.setLocation(500, 100);
|
||||
jobMeta.addJobEntry(shellEntry);
|
||||
|
||||
JobHopMeta transHop = new JobHopMeta(transEntry, shellEntry);
|
||||
transHop.setEvaluation(true);
|
||||
jobMeta.addJobHop(transHop);
|
||||
|
||||
//success
|
||||
JobEntrySuccess success = new JobEntrySuccess();
|
||||
success.setName("Success");
|
||||
JobEntryCopy successEntry = new JobEntryCopy(success);
|
||||
successEntry.setDrawn(true);
|
||||
successEntry.setLocation(500, 100);
|
||||
successEntry.setLocation(700, 100);
|
||||
jobMeta.addJobEntry(successEntry);
|
||||
|
||||
JobHopMeta greenHop = new JobHopMeta(transEntry, successEntry);
|
||||
|
||||
JobHopMeta greenHop = new JobHopMeta(shellEntry, successEntry);
|
||||
greenHop.setEvaluation(true);
|
||||
jobMeta.addJobHop(greenHop);
|
||||
|
||||
@ -337,164 +381,139 @@ public class ExtractDataService {
|
||||
FileUtils.writeStringToFile(file, jobXml, "UTF-8");
|
||||
}
|
||||
|
||||
private String fetchSqlField(String sql, Datasource ds)throws Exception{
|
||||
String tmpSql = sql;
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
if(tmpSql.trim().endsWith(";")){
|
||||
tmpSql = tmpSql.substring(0, tmpSql.length() -1 ) + " limit 0";
|
||||
}else {
|
||||
tmpSql = tmpSql + " limit 0";
|
||||
}
|
||||
datasourceRequest.setQuery(tmpSql);
|
||||
return String.join(",", datasourceProvider.fetchResultField(datasourceRequest).stream().map(TableFiled::getFieldName).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private void generateTransFile(String extractType, DatasetTable datasetTable, Datasource datasource, String table, List<DatasetTableField> datasetTableFields, String selectSQL) throws Exception {
|
||||
TransMeta transMeta = new TransMeta();
|
||||
String transName = null;
|
||||
switch (extractType) {
|
||||
case "all_scope":
|
||||
transName = "trans_" + datasetTable.getId();
|
||||
datasetTableFields.sort((o1, o2) -> {
|
||||
if (o1.getOriginName() == null) {
|
||||
return -1;
|
||||
}
|
||||
if (o2.getOriginName() == null) {
|
||||
return 1;
|
||||
}
|
||||
return o1.getOriginName().compareTo(o2.getOriginName());
|
||||
});
|
||||
selectSQL = dataSetTableService.createQuerySQL(datasource.getType(), table, datasetTableFields.stream().map(DatasetTableField::getOriginName).toArray(String[]::new));
|
||||
break;
|
||||
case "incremental_add":
|
||||
transName = "trans_add_" + datasetTable.getId();
|
||||
break;
|
||||
case "incremental_delete":
|
||||
transName = "trans_delete_" + datasetTable.getId();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
transMeta.setName(transName);
|
||||
String dorisOutputTable = null;
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(datasource.getType());
|
||||
DatabaseMeta dataMeta = null;
|
||||
switch (datasourceType) {
|
||||
case mysql:
|
||||
MysqlConfigrationDTO mysqlConfigrationDTO = new Gson().fromJson(datasource.getConfiguration(), MysqlConfigrationDTO.class);
|
||||
dataMeta = new DatabaseMeta("db", "MYSQL", "Native", mysqlConfigrationDTO.getHost(), mysqlConfigrationDTO.getDataBase(), mysqlConfigrationDTO.getPort().toString(), mysqlConfigrationDTO.getUsername(), mysqlConfigrationDTO.getPassword());
|
||||
MysqlConfigration mysqlConfigration = new Gson().fromJson(datasource.getConfiguration(), MysqlConfigration.class);
|
||||
dataMeta = new DatabaseMeta("db", "MYSQL", "Native", mysqlConfigration.getHost(), mysqlConfigration.getDataBase(), mysqlConfigration.getPort().toString(), mysqlConfigration.getUsername(), mysqlConfigration.getPassword());
|
||||
transMeta.addDatabase(dataMeta);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
//registry是给每个步骤生成一个标识id
|
||||
PluginRegistry registry = PluginRegistry.getInstance();
|
||||
//第一个表输入步骤(TableInputMeta)
|
||||
TableInputMeta tableInput = new TableInputMeta();
|
||||
Datasource dorisDatasource = (Datasource)CommonBeanFactory.getBean("DorisDatasource");
|
||||
MysqlConfigration dorisConfigration = new Gson().fromJson(dorisDatasource.getConfiguration(), MysqlConfigration.class);
|
||||
DatabaseMeta dorisDataMeta = new DatabaseMeta("doris", "MYSQL", "Native", dorisConfigration.getHost(), dorisConfigration.getDataBase(), dorisConfigration.getPort().toString(), dorisConfigration.getUsername(), dorisConfigration.getPassword());
|
||||
transMeta.addDatabase(dorisDataMeta);
|
||||
StepMeta inputStep = null;
|
||||
StepMeta outputStep = null;
|
||||
StepMeta udjcStep = null;
|
||||
TransHopMeta hi1 = null;
|
||||
TransHopMeta hi2 = null;
|
||||
String transName = null;
|
||||
|
||||
//给表输入添加一个DatabaseMeta连接数据库
|
||||
DatabaseMeta database_bjdt = transMeta.findDatabase("db");
|
||||
tableInput.setDatabaseMeta(database_bjdt);
|
||||
tableInput.setSQL(selectSQL);
|
||||
//添加TableInputMeta到转换中
|
||||
String tableInputPluginId = registry.getPluginId(StepPluginType.class, tableInput);
|
||||
StepMeta fromStep = new StepMeta(tableInputPluginId, "Data Input", tableInput);
|
||||
//给步骤添加在spoon工具中的显示位置
|
||||
fromStep.setDraw(true);
|
||||
fromStep.setLocation(100, 100);
|
||||
transMeta.addStep(fromStep);
|
||||
switch (extractType) {
|
||||
case "all_scope":
|
||||
transName = "trans_" + datasetTable.getId();
|
||||
dorisOutputTable = DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTable.getId()));
|
||||
selectSQL = dataSetTableService.createQuerySQL(datasource.getType(), table, datasetTableFields.stream().map(DatasetTableField::getOriginName).toArray(String[]::new));
|
||||
transMeta.setName(transName);
|
||||
break;
|
||||
case "incremental_add":
|
||||
transName = "trans_add_" + datasetTable.getId();
|
||||
dorisOutputTable = DorisTableUtils.dorisName(datasetTable.getId());
|
||||
transMeta.setName(transName);
|
||||
break;
|
||||
case "incremental_delete":
|
||||
dorisOutputTable = DorisTableUtils.dorisDeleteName(DorisTableUtils.dorisName(datasetTable.getId()));
|
||||
transName = "trans_delete_" + datasetTable.getId();
|
||||
transMeta.setName(transName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//第二个 (TextFileOutput)
|
||||
TextFileOutputMeta textFileOutputMeta = new TextFileOutputMeta();
|
||||
textFileOutputMeta.setFilename(data_path + datasetTable.getId());
|
||||
textFileOutputMeta.setExtension("txt");
|
||||
textFileOutputMeta.setSeparator(";");
|
||||
textFileOutputMeta.setFileCompression("None");
|
||||
textFileOutputMeta.setEnclosure("\"");
|
||||
textFileOutputMeta.setEncoding("UTF-8");
|
||||
TextFileField[] outputFields = new TextFileField[1];
|
||||
outputFields[0] = new TextFileField();
|
||||
textFileOutputMeta.setOutputFields(outputFields);
|
||||
|
||||
StepMeta tostep = new StepMeta("TextFileOutput", "TextFileOutput", textFileOutputMeta);
|
||||
tostep.setLocation(600, 100);
|
||||
tostep.setDraw(true);
|
||||
transMeta.addStep(tostep);
|
||||
TransHopMeta hi1 = new TransHopMeta(fromStep, tostep);
|
||||
inputStep = inputStep(transMeta, selectSQL);
|
||||
udjcStep = udjc(datasetTableFields);
|
||||
outputStep = outputStep(dorisOutputTable);
|
||||
hi1 = new TransHopMeta(inputStep, udjcStep);
|
||||
hi2 = new TransHopMeta(udjcStep, outputStep);
|
||||
transMeta.addTransHop(hi1);
|
||||
|
||||
|
||||
// //第二个 (User defined Java class)
|
||||
// UserDefinedJavaClassMeta userDefinedJavaClassMeta = new UserDefinedJavaClassMeta();
|
||||
// List<UserDefinedJavaClassMeta.FieldInfo> fields = new ArrayList<>();
|
||||
// UserDefinedJavaClassMeta.FieldInfo fieldInfo = new UserDefinedJavaClassMeta.FieldInfo("uuid", ValueMetaInterface.TYPE_STRING, -1, -1);
|
||||
// fields.add(fieldInfo);
|
||||
// userDefinedJavaClassMeta.setFieldInfo(fields);
|
||||
// List<UserDefinedJavaClassDef> definitions = new ArrayList<UserDefinedJavaClassDef>();
|
||||
// UserDefinedJavaClassDef userDefinedJavaClassDef = new UserDefinedJavaClassDef(UserDefinedJavaClassDef.ClassType.TRANSFORM_CLASS, "Processor", code);
|
||||
// userDefinedJavaClassDef.setActive(true);
|
||||
// definitions.add(userDefinedJavaClassDef);
|
||||
// userDefinedJavaClassMeta.replaceDefinitions(definitions);
|
||||
//
|
||||
// StepMeta userDefinedJavaClassStep = new StepMeta("UserDefinedJavaClass", "UserDefinedJavaClass", userDefinedJavaClassMeta);
|
||||
// userDefinedJavaClassStep.setLocation(300, 100);
|
||||
// userDefinedJavaClassStep.setDraw(true);
|
||||
// transMeta.addStep(userDefinedJavaClassStep);
|
||||
//
|
||||
// //第三个 (HBaseOutputMeta)
|
||||
// NamedClusterService namedClusterService = new NamedClusterManager();
|
||||
// NamedCluster clusterTemplate = new NamedClusterImpl();
|
||||
// clusterTemplate.setName("hadoop");
|
||||
// clusterTemplate.setZooKeeperHost(zkHost);
|
||||
// clusterTemplate.setZooKeeperPort(zkPort);
|
||||
// clusterTemplate.setStorageScheme("HDFS");
|
||||
// namedClusterService.setClusterTemplate(clusterTemplate);
|
||||
//
|
||||
// List<ClusterInitializerProvider> providers = new ArrayList<>();
|
||||
// ClusterInitializer clusterInitializer = new ClusterInitializerImpl(providers);
|
||||
// NamedClusterServiceLocator namedClusterServiceLocator = new NamedClusterServiceLocatorImpl(clusterInitializer);
|
||||
//
|
||||
// List<RuntimeTestActionHandler> runtimeTestActionHandlers = new ArrayList<>();
|
||||
// RuntimeTestActionHandler defaultHandler = null;
|
||||
//
|
||||
// RuntimeTestActionService runtimeTestActionService = new RuntimeTestActionServiceImpl(runtimeTestActionHandlers, defaultHandler);
|
||||
// RuntimeTester runtimeTester = new RuntimeTesterImpl(new ArrayList<>(Arrays.asList(mock(RuntimeTest.class))), mock(ExecutorService.class), "modules");
|
||||
//
|
||||
// Put put = new Put((datasetTable.getId() + "," + "target_mapping").getBytes());
|
||||
// for (DatasetTableField datasetTableField : datasetTableFields) {
|
||||
// put.addColumn("columns".getBytes(), (dataease_column_family + "," + datasetTableField.getOriginName() + "," + datasetTableField.getOriginName()).getBytes(), transToColumnType(datasetTableField.getDeType()).getBytes());
|
||||
// }
|
||||
// put.addColumn("key".getBytes(), "uuid".getBytes(), "String".getBytes());
|
||||
// TableName pentaho_mappings = TableName.valueOf(this.pentaho_mappings);
|
||||
// Table tab = getConnection().getTable(pentaho_mappings);
|
||||
// tab.put(put);
|
||||
//
|
||||
// HBaseOutputMeta hBaseOutputMeta = new HBaseOutputMeta(namedClusterService, namedClusterServiceLocator, runtimeTestActionService, runtimeTester);
|
||||
// hBaseOutputMeta.setTargetTableName(datasetTable.getId());
|
||||
// hBaseOutputMeta.setTargetMappingName("target_mapping");
|
||||
// hBaseOutputMeta.setNamedCluster(clusterTemplate);
|
||||
// hBaseOutputMeta.setCoreConfigURL(hbase_conf_file);
|
||||
// hBaseOutputMeta.setDisableWriteToWAL(true);
|
||||
// hBaseOutputMeta.setWriteBufferSize("31457280"); //30M
|
||||
// if (extractType.equalsIgnoreCase("incremental_delete")) {
|
||||
// hBaseOutputMeta.setDeleteRowKey(true);
|
||||
// }
|
||||
// StepMeta tostep = new StepMeta("HBaseOutput", "HBaseOutput", hBaseOutputMeta);
|
||||
// tostep.setLocation(600, 100);
|
||||
//
|
||||
// tostep.setDraw(true);
|
||||
// transMeta.addStep(tostep);
|
||||
// TransHopMeta hi1 = new TransHopMeta(fromStep, userDefinedJavaClassStep);
|
||||
// TransHopMeta hi2 = new TransHopMeta(userDefinedJavaClassStep, tostep);
|
||||
// transMeta.addTransHop(hi1);
|
||||
// transMeta.addTransHop(hi2);
|
||||
transMeta.addTransHop(hi2);
|
||||
transMeta.addStep(inputStep);
|
||||
transMeta.addStep(udjcStep);
|
||||
transMeta.addStep(outputStep);
|
||||
|
||||
String transXml = transMeta.getXML();
|
||||
File file = new File(root_path + transName + ".ktr");
|
||||
FileUtils.writeStringToFile(file, transXml, "UTF-8");
|
||||
}
|
||||
|
||||
public String transToColumnType(Integer field) {
|
||||
switch (field) {
|
||||
case 0:
|
||||
return "String";
|
||||
case 1:
|
||||
return "Date";
|
||||
case 2:
|
||||
return "BigNumber";
|
||||
default:
|
||||
return "String";
|
||||
}
|
||||
private StepMeta inputStep(TransMeta transMeta, String selectSQL){
|
||||
TableInputMeta tableInput = new TableInputMeta();
|
||||
DatabaseMeta database = transMeta.findDatabase("db");
|
||||
tableInput.setDatabaseMeta(database);
|
||||
tableInput.setSQL(selectSQL);
|
||||
StepMeta fromStep = new StepMeta("TableInput", "Data Input", tableInput);
|
||||
fromStep.setDraw(true);
|
||||
fromStep.setLocation(100, 100);
|
||||
return fromStep;
|
||||
}
|
||||
|
||||
private StepMeta outputStep(String dorisOutputTable){
|
||||
TextFileOutputMeta textFileOutputMeta = new TextFileOutputMeta();
|
||||
textFileOutputMeta.setEncoding("UTF-8");
|
||||
textFileOutputMeta.setHeaderEnabled(false);
|
||||
textFileOutputMeta.setFilename(root_path + dorisOutputTable);
|
||||
textFileOutputMeta.setSeparator(separator);
|
||||
textFileOutputMeta.setExtension(extention);
|
||||
textFileOutputMeta.setOutputFields(new TextFileField[0]);
|
||||
StepMeta outputStep = new StepMeta("TextFileOutput", "TextFileOutput", textFileOutputMeta);
|
||||
outputStep.setLocation(600, 100);
|
||||
outputStep.setDraw(true);
|
||||
return outputStep;
|
||||
}
|
||||
|
||||
private StepMeta udjc(List<DatasetTableField> datasetTableFields){
|
||||
UserDefinedJavaClassMeta userDefinedJavaClassMeta = new UserDefinedJavaClassMeta();
|
||||
List<UserDefinedJavaClassMeta.FieldInfo> fields = new ArrayList<>();
|
||||
UserDefinedJavaClassMeta.FieldInfo fieldInfo = new UserDefinedJavaClassMeta.FieldInfo("dataease_uuid", ValueMetaInterface.TYPE_STRING, -1, -1);
|
||||
fields.add(fieldInfo);
|
||||
userDefinedJavaClassMeta.setFieldInfo(fields);
|
||||
List<UserDefinedJavaClassDef> definitions = new ArrayList<UserDefinedJavaClassDef>();
|
||||
UserDefinedJavaClassDef userDefinedJavaClassDef = new UserDefinedJavaClassDef(UserDefinedJavaClassDef.ClassType.TRANSFORM_CLASS, "Processor",
|
||||
code.replace("Column_Fields", String.join(",", datasetTableFields.stream().map(DatasetTableField::getOriginName).collect(Collectors.toList()))));
|
||||
userDefinedJavaClassDef.setActive(true);
|
||||
definitions.add(userDefinedJavaClassDef);
|
||||
userDefinedJavaClassMeta.replaceDefinitions(definitions);
|
||||
|
||||
StepMeta userDefinedJavaClassStep = new StepMeta("UserDefinedJavaClass", "UserDefinedJavaClass", userDefinedJavaClassMeta);
|
||||
userDefinedJavaClassStep.setLocation(300, 100);
|
||||
userDefinedJavaClassStep.setDraw(true);
|
||||
return userDefinedJavaClassStep;
|
||||
}
|
||||
|
||||
private StepMeta execSqlStep(TransMeta transMeta, String dorisOutputTable, List<DatasetTableField>datasetTableFields){
|
||||
ExecSQLMeta execSQLMeta = new ExecSQLMeta();
|
||||
DatabaseMeta dorisDatabaseMeta = transMeta.findDatabase("doris");
|
||||
execSQLMeta.setDatabaseMeta(dorisDatabaseMeta);
|
||||
String deleteSql = "delete from DORIS_TABLE where dataease_uuid='?';".replace("DORIS_TABLE", dorisOutputTable);
|
||||
execSQLMeta.setSql(deleteSql);
|
||||
execSQLMeta.setExecutedEachInputRow(true);
|
||||
execSQLMeta.setArguments(new String[]{"dataease_uuid"});
|
||||
StepMeta execSQLStep = new StepMeta("ExecSQL", "ExecSQL", execSQLMeta);
|
||||
execSQLStep.setLocation(600, 100);
|
||||
execSQLStep.setDraw(true);
|
||||
return execSQLStep;
|
||||
}
|
||||
|
||||
private static String code = "import org.pentaho.di.core.row.ValueMetaInterface;\n" +
|
||||
@ -506,29 +525,11 @@ public class ExtractDataService {
|
||||
"import java.util.List;\n" +
|
||||
"import java.util.concurrent.ExecutorService;\n" +
|
||||
"import java.util.concurrent.Executors;\n" +
|
||||
"import org.pentaho.di.core.util.StringUtil;\n" +
|
||||
"\n" +
|
||||
"public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {\n" +
|
||||
" if (first) {\n" +
|
||||
" first = false;\n" +
|
||||
"\n" +
|
||||
" /* TODO: Your code here. (Using info fields)\n" +
|
||||
"\n" +
|
||||
" FieldHelper infoField = get(Fields.Info, \"info_field_name\");\n" +
|
||||
"\n" +
|
||||
" RowSet infoStream = findInfoRowSet(\"info_stream_tag\");\n" +
|
||||
"\n" +
|
||||
" Object[] infoRow = null;\n" +
|
||||
"\n" +
|
||||
" int infoRowCount = 0;\n" +
|
||||
"\n" +
|
||||
" // Read all rows from info step before calling getRow() method, which returns first row from any\n" +
|
||||
" // input rowset. As rowMeta for info and input steps varies getRow() can lead to errors.\n" +
|
||||
" while((infoRow = getRowFrom(infoStream)) != null){\n" +
|
||||
"\n" +
|
||||
" // do something with info data\n" +
|
||||
" infoRowCount++;\n" +
|
||||
" }\n" +
|
||||
" */\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" Object[] r = getRow();\n" +
|
||||
@ -538,19 +539,17 @@ public class ExtractDataService {
|
||||
" return false;\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" // It is always safest to call createOutputRow() to ensure that your output row's Object[] is large\n" +
|
||||
" // enough to handle any new fields you are creating in this step.\n" +
|
||||
" r = createOutputRow(r, data.outputRowMeta.size());\n" +
|
||||
" String str = \"\";\n" +
|
||||
" List<ValueMetaInterface> valueMetaList = data.outputRowMeta.getValueMetaList();\n" +
|
||||
" for (ValueMetaInterface valueMetaInterface : valueMetaList) {\n" +
|
||||
"\t if(!valueMetaInterface.getName().equalsIgnoreCase(\"uuid\")){\n" +
|
||||
" str = str + get(Fields.In, valueMetaInterface.getName()).getString(r);\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" List<String> fileds = Arrays.asList(\"Column_Fields\".split(\",\"));\n" +
|
||||
" for (String filed : fileds) {\n" +
|
||||
" String tmp = get(Fields.In, filed).getString(r);\n" +
|
||||
" str = str + tmp;\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" String md5 = md5(str);\n" +
|
||||
" get(Fields.Out, \"uuid\").setValue(r, md5);\n" +
|
||||
" get(Fields.Out, \"dataease_uuid\").setValue(r, md5);\n" +
|
||||
"\n" +
|
||||
" putRow(data.outputRowMeta, r);\n" +
|
||||
"\n" +
|
||||
@ -590,6 +589,6 @@ public class ExtractDataService {
|
||||
" str = str + d[i];\n" +
|
||||
" }\n" +
|
||||
" return str;\n" +
|
||||
" }\n";
|
||||
" }";
|
||||
}
|
||||
|
||||
|
@ -1,53 +0,0 @@
|
||||
package io.dataease.service.spark;
|
||||
|
||||
import org.apache.spark.sql.Dataset;
|
||||
import org.apache.spark.sql.Row;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author gin
|
||||
* @Date 2021/4/13 12:32 下午
|
||||
*/
|
||||
public class CacheUtil {
|
||||
private static CacheUtil cacheUtil;
|
||||
private static Map<String, Dataset<Row>> cacheMap;
|
||||
|
||||
private CacheUtil(){
|
||||
cacheMap = new HashMap<String, Dataset<Row>>();
|
||||
}
|
||||
|
||||
public static CacheUtil getInstance(){
|
||||
if (cacheUtil == null){
|
||||
cacheUtil = new CacheUtil();
|
||||
}
|
||||
return cacheUtil;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加缓存
|
||||
* @param key
|
||||
* @param obj
|
||||
*/
|
||||
public void addCacheData(String key,Dataset<Row> obj){
|
||||
cacheMap.put(key,obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取出缓存
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Dataset<Row> getCacheData(String key){
|
||||
return cacheMap.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清楚缓存
|
||||
* @param key
|
||||
*/
|
||||
public void removeCacheData(String key){
|
||||
cacheMap.remove(key);
|
||||
}
|
||||
}
|
@ -1,407 +0,0 @@
|
||||
//package io.dataease.service.spark;
|
||||
//
|
||||
//import io.dataease.base.domain.DatasetTableField;
|
||||
//import io.dataease.commons.utils.CommonBeanFactory;
|
||||
//import io.dataease.controller.request.chart.ChartExtFilterRequest;
|
||||
//import io.dataease.dto.chart.ChartViewFieldDTO;
|
||||
//import org.antlr.analysis.MachineProbe;
|
||||
//import org.apache.commons.collections4.CollectionUtils;
|
||||
//import org.apache.commons.lang3.ObjectUtils;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.apache.hadoop.hbase.client.Result;
|
||||
//import org.apache.hadoop.hbase.client.Scan;
|
||||
//import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
|
||||
//import org.apache.hadoop.hbase.mapreduce.TableInputFormat;
|
||||
//import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||
//import org.apache.hadoop.hbase.protobuf.generated.ClientProtos;
|
||||
//import org.apache.hadoop.hbase.util.Bytes;
|
||||
//import org.apache.spark.api.java.JavaPairRDD;
|
||||
//import org.apache.spark.api.java.JavaRDD;
|
||||
//import org.apache.spark.api.java.JavaSparkContext;
|
||||
//import org.apache.spark.api.java.function.FlatMapFunction;
|
||||
//import org.apache.spark.api.java.function.Function;
|
||||
//import org.apache.spark.sql.*;
|
||||
//import org.apache.spark.sql.types.DataTypes;
|
||||
//import org.apache.spark.sql.types.StructField;
|
||||
//import org.apache.spark.sql.types.StructType;
|
||||
//import org.apache.spark.storage.StorageLevel;
|
||||
//import org.springframework.core.env.Environment;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//import scala.Tuple2;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.math.BigDecimal;
|
||||
//import java.text.MessageFormat;
|
||||
//import java.util.*;
|
||||
//
|
||||
///**
|
||||
// * @Author gin
|
||||
// * @Date 2021/3/26 3:49 下午
|
||||
// */
|
||||
//@Service
|
||||
//public class SparkCalc {
|
||||
// private static String column_family = "dataease";
|
||||
// private static String data_path = "/opt/dataease/data/db/";
|
||||
// @Resource
|
||||
// private Environment env; // 保存了配置文件的信息
|
||||
//
|
||||
// public List<String[]> getData(String hTable, List<DatasetTableField> fields, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, String tmpTable, List<ChartExtFilterRequest> requestList) throws Exception {
|
||||
// // Spark Context
|
||||
// SparkSession spark = CommonBeanFactory.getBean(SparkSession.class);
|
||||
// JavaSparkContext sparkContext = new JavaSparkContext(spark.sparkContext());
|
||||
//
|
||||
// // Spark SQL Context
|
||||
// SQLContext sqlContext = new SQLContext(sparkContext);
|
||||
// sqlContext.setConf("spark.sql.shuffle.partitions", env.getProperty("spark.sql.shuffle.partitions", "1"));
|
||||
// sqlContext.setConf("spark.default.parallelism", env.getProperty("spark.default.parallelism", "1"));
|
||||
//
|
||||
// /*Map<String, BigDecimal> dataFrame = getData(sparkContext, sqlContext, hTable, fields);
|
||||
// List<String[]> data = new ArrayList<>();
|
||||
// Iterator<Map.Entry<String, BigDecimal>> iterator = dataFrame.entrySet().iterator();
|
||||
// while (iterator.hasNext()) {
|
||||
// String[] r = new String[2];
|
||||
// Map.Entry<String, BigDecimal> next = iterator.next();
|
||||
// String key = next.getKey();
|
||||
// BigDecimal value = next.getValue();
|
||||
// r[0] = key;
|
||||
// r[1] = value.toString();
|
||||
// data.add(r);
|
||||
// }*/
|
||||
//
|
||||
//// Dataset<Row> dataFrame = getData(sparkContext, sqlContext, hTable, fields);
|
||||
// Dataset<Row> dataFrame = CacheUtil.getInstance().getCacheData(hTable);
|
||||
// if (ObjectUtils.isEmpty(dataFrame)) {
|
||||
// dataFrame = getHBaseDataAndCache(sparkContext, sqlContext, hTable, fields);
|
||||
// }
|
||||
//
|
||||
// dataFrame.createOrReplaceTempView(tmpTable);
|
||||
// Dataset<Row> sql = sqlContext.sql(getSQL(xAxis, yAxis, tmpTable, requestList));
|
||||
// // transform
|
||||
// List<String[]> data = new ArrayList<>();
|
||||
// List<Row> list = sql.collectAsList();
|
||||
// for (Row row : list) {
|
||||
// String[] r = new String[row.length()];
|
||||
// for (int i = 0; i < row.length(); i++) {
|
||||
// r[i] = row.get(i) == null ? "null" : row.get(i).toString();
|
||||
// }
|
||||
// data.add(r);
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
//
|
||||
// public Dataset<Row> getHBaseDataAndCache(String hTable, List<DatasetTableField> fields) throws Exception {
|
||||
// // Spark Context
|
||||
// SparkSession spark = CommonBeanFactory.getBean(SparkSession.class);
|
||||
// JavaSparkContext sparkContext = new JavaSparkContext(spark.sparkContext());
|
||||
//
|
||||
// // Spark SQL Context
|
||||
// SQLContext sqlContext = new SQLContext(sparkContext);
|
||||
// sqlContext.setConf("spark.sql.shuffle.partitions", env.getProperty("spark.sql.shuffle.partitions", "1"));
|
||||
// sqlContext.setConf("spark.default.parallelism", env.getProperty("spark.default.parallelism", "1"));
|
||||
// return getHBaseDataAndCache(sparkContext, sqlContext, hTable, fields);
|
||||
// }
|
||||
//
|
||||
// public Map<String, BigDecimal> getData(JavaSparkContext sparkContext, SQLContext sqlContext, String tableId, List<DatasetTableField> fields) throws Exception {
|
||||
// fields.sort((o1, o2) -> {
|
||||
// if (o1.getOriginName() == null) {
|
||||
// return -1;
|
||||
// }
|
||||
// if (o2.getOriginName() == null) {
|
||||
// return 1;
|
||||
// }
|
||||
// return o1.getOriginName().compareTo(o2.getOriginName());
|
||||
// });
|
||||
//
|
||||
// JavaRDD<String> pairRDD = sparkContext.textFile(data_path + tableId + ".txt");
|
||||
//// System.out.println(pairRDD.count());
|
||||
//
|
||||
//// JavaRDD<Map.Entry<String, BigDecimal>> rdd = pairRDD.map((Function<String, Map.Entry<String, BigDecimal>>) v1 -> {
|
||||
//// Map<String, BigDecimal> map = new HashMap<>();
|
||||
//// String[] items = v1.split(";");
|
||||
//// String day = null;
|
||||
//// BigDecimal res = new BigDecimal(0);
|
||||
//// for (int i = 0; i < items.length; i++) {
|
||||
//// String l = items[i];
|
||||
//// DatasetTableField x = fields.get(i);
|
||||
//// if (x.getOriginName().equalsIgnoreCase("sync_day")) {
|
||||
//// day = l;
|
||||
//// }
|
||||
//// if (x.getOriginName().equalsIgnoreCase("usage_cost")) {
|
||||
//// res = new BigDecimal(l);
|
||||
//// }
|
||||
//// }
|
||||
//// BigDecimal bigDecimal = map.get(day);
|
||||
//// if (bigDecimal == null) {
|
||||
//// map.put(day, res);
|
||||
//// } else {
|
||||
//// map.put(day, bigDecimal.add(res));
|
||||
//// }
|
||||
//// return map.entrySet().iterator().next();
|
||||
//// });
|
||||
//
|
||||
// JavaRDD<Map.Entry<String, BigDecimal>> rdd = pairRDD.mapPartitions((FlatMapFunction<java.util.Iterator<String>, Map.Entry<String, BigDecimal>>) tuple2Iterator -> {
|
||||
// Map<String, BigDecimal> map = new HashMap<>();
|
||||
// while (tuple2Iterator.hasNext()) {
|
||||
// String[] items = tuple2Iterator.next().split(";");
|
||||
// String day = null;
|
||||
// BigDecimal res = new BigDecimal(0);
|
||||
// for (int i = 0; i < items.length; i++) {
|
||||
// String l = items[i];
|
||||
// DatasetTableField x = fields.get(i);
|
||||
// if (x.getOriginName().equalsIgnoreCase("sync_day")) {
|
||||
// day = l;
|
||||
// }
|
||||
// if (x.getOriginName().equalsIgnoreCase("usage_cost")) {
|
||||
// res = new BigDecimal(l);
|
||||
// }
|
||||
// }
|
||||
// BigDecimal bigDecimal = map.get(day);
|
||||
// if (bigDecimal == null) {
|
||||
// map.put(day, res);
|
||||
// } else {
|
||||
// map.put(day, bigDecimal.add(res));
|
||||
// }
|
||||
// }
|
||||
// return map.entrySet().iterator();
|
||||
// });
|
||||
//
|
||||
//
|
||||
//// System.out.println(rdd.count());
|
||||
//
|
||||
// Map<String, BigDecimal> map = new HashMap<>();
|
||||
// List<Map.Entry<String, BigDecimal>> collect = rdd.collect();
|
||||
//// System.out.println(collect.size());
|
||||
//
|
||||
// collect.forEach(stringBigDecimalEntry -> {
|
||||
// String key = stringBigDecimalEntry.getKey();
|
||||
// BigDecimal value = stringBigDecimalEntry.getValue();
|
||||
//
|
||||
// BigDecimal bigDecimal = map.get(key);
|
||||
// if (bigDecimal == null) {
|
||||
// map.put(key, value);
|
||||
// } else {
|
||||
// map.put(key, bigDecimal.add(value));
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// return map;
|
||||
// }
|
||||
//
|
||||
//// public Dataset<Row> getData(JavaSparkContext sparkContext, SQLContext sqlContext, String tableId, List<DatasetTableField> fields) throws Exception {
|
||||
//// fields.sort((o1, o2) -> {
|
||||
//// if (o1.getOriginName() == null) {
|
||||
//// return -1;
|
||||
//// }
|
||||
//// if (o2.getOriginName() == null) {
|
||||
//// return 1;
|
||||
//// }
|
||||
//// return o1.getOriginName().compareTo(o2.getOriginName());
|
||||
//// });
|
||||
////
|
||||
//// JavaRDD<String> pairRDD = sparkContext.textFile(data_path + tableId + ".txt");
|
||||
////
|
||||
//// JavaRDD<Row> rdd = pairRDD.mapPartitions((FlatMapFunction<java.util.Iterator<String>, Row>) tuple2Iterator -> {
|
||||
//// List<Row> iterator = new ArrayList<>();
|
||||
//// while (tuple2Iterator.hasNext()) {
|
||||
//// String[] items = tuple2Iterator.next().split(";");
|
||||
//// List<Object> list = new ArrayList<>();
|
||||
//// for (int i = 0; i < items.length; i++) {
|
||||
//// String l = items[i];
|
||||
//// DatasetTableField x = fields.get(i);
|
||||
//// if (x.getDeType() == 0 || x.getDeType() == 1) {
|
||||
//// list.add(l);
|
||||
//// } else if (x.getDeType() == 2) {
|
||||
//// if (StringUtils.isEmpty(l)) {
|
||||
//// l = "0";
|
||||
//// }
|
||||
//// if (StringUtils.equalsIgnoreCase(l, "Y")) {
|
||||
//// l = "1";
|
||||
//// }
|
||||
//// if (StringUtils.equalsIgnoreCase(l, "N")) {
|
||||
//// l = "0";
|
||||
//// }
|
||||
//// list.add(Long.valueOf(l));
|
||||
//// } else if (x.getDeType() == 3) {
|
||||
//// if (StringUtils.isEmpty(l)) {
|
||||
//// l = "0.0";
|
||||
//// }
|
||||
//// list.add(Double.valueOf(l));
|
||||
//// }
|
||||
//// }
|
||||
//// iterator.add(RowFactory.create(list.toArray()));
|
||||
//// }
|
||||
//// return iterator.iterator();
|
||||
//// });
|
||||
////
|
||||
//// List<StructField> structFields = new ArrayList<>();
|
||||
//// // struct顺序要与rdd顺序一致
|
||||
//// fields.forEach(x -> {
|
||||
//// if (x.getDeType() == 0 || x.getDeType() == 1) {
|
||||
//// structFields.add(DataTypes.createStructField(x.getOriginName(), DataTypes.StringType, true));
|
||||
//// } else if (x.getDeType() == 2) {
|
||||
//// structFields.add(DataTypes.createStructField(x.getOriginName(), DataTypes.LongType, true));
|
||||
//// } else if (x.getDeType() == 3) {
|
||||
//// structFields.add(DataTypes.createStructField(x.getOriginName(), DataTypes.DoubleType, true));
|
||||
//// }
|
||||
//// });
|
||||
//// StructType structType = DataTypes.createStructType(structFields);
|
||||
////
|
||||
//// Dataset<Row> dataFrame = sqlContext.createDataFrame(rdd, structType);
|
||||
//// return dataFrame;
|
||||
//// }
|
||||
//
|
||||
// public Dataset<Row> getHBaseDataAndCache(JavaSparkContext sparkContext, SQLContext sqlContext, String hTable, List<DatasetTableField> fields) throws Exception {
|
||||
// Scan scan = new Scan();
|
||||
// scan.addFamily(Bytes.toBytes(column_family));
|
||||
// for (DatasetTableField field : fields) {
|
||||
// scan.addColumn(Bytes.toBytes(column_family), Bytes.toBytes(field.getOriginName()));
|
||||
// }
|
||||
// ClientProtos.Scan proto = ProtobufUtil.toScan(scan);
|
||||
// String scanToString = new String(Base64.getEncoder().encode(proto.toByteArray()));
|
||||
//
|
||||
// // HBase config
|
||||
// org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration();
|
||||
// conf.set("hbase.zookeeper.quorum", env.getProperty("hbase.zookeeper.quorum"));
|
||||
// conf.set("hbase.zookeeper.property.clientPort", env.getProperty("hbase.zookeeper.property.clientPort"));
|
||||
// conf.set("hbase.client.retries.number", env.getProperty("hbase.client.retries.number", "1"));
|
||||
// conf.set(TableInputFormat.INPUT_TABLE, hTable);
|
||||
// conf.set(TableInputFormat.SCAN, scanToString);
|
||||
//
|
||||
// JavaPairRDD<ImmutableBytesWritable, Result> pairRDD = sparkContext.newAPIHadoopRDD(conf, TableInputFormat.class, ImmutableBytesWritable.class, Result.class);
|
||||
//
|
||||
// JavaRDD<Row> rdd = pairRDD.mapPartitions((FlatMapFunction<Iterator<Tuple2<ImmutableBytesWritable, Result>>, Row>) tuple2Iterator -> {
|
||||
// List<Row> iterator = new ArrayList<>();
|
||||
// while (tuple2Iterator.hasNext()) {
|
||||
// Result result = tuple2Iterator.next()._2;
|
||||
// List<Object> list = new ArrayList<>();
|
||||
// fields.forEach(x -> {
|
||||
// String l = Bytes.toString(result.getValue(column_family.getBytes(), x.getOriginName().getBytes()));
|
||||
// if (x.getDeType() == 0 || x.getDeType() == 1) {
|
||||
// list.add(l);
|
||||
// } else if (x.getDeType() == 2) {
|
||||
// if (StringUtils.isEmpty(l)) {
|
||||
// l = "0";
|
||||
// }
|
||||
// list.add(Long.valueOf(l));
|
||||
// } else if (x.getDeType() == 3) {
|
||||
// if (StringUtils.isEmpty(l)) {
|
||||
// l = "0.0";
|
||||
// }
|
||||
// list.add(Double.valueOf(l));
|
||||
// }
|
||||
// });
|
||||
// iterator.add(RowFactory.create(list.toArray()));
|
||||
// }
|
||||
// return iterator.iterator();
|
||||
// });
|
||||
//
|
||||
// List<StructField> structFields = new ArrayList<>();
|
||||
// // struct顺序要与rdd顺序一致
|
||||
// fields.forEach(x -> {
|
||||
// if (x.getDeType() == 0 || x.getDeType() == 1) {
|
||||
// structFields.add(DataTypes.createStructField(x.getOriginName(), DataTypes.StringType, true));
|
||||
// } else if (x.getDeType() == 2) {
|
||||
// structFields.add(DataTypes.createStructField(x.getOriginName(), DataTypes.LongType, true));
|
||||
// } else if (x.getDeType() == 3) {
|
||||
// structFields.add(DataTypes.createStructField(x.getOriginName(), DataTypes.DoubleType, true));
|
||||
// }
|
||||
// });
|
||||
// StructType structType = DataTypes.createStructType(structFields);
|
||||
//
|
||||
// Dataset<Row> dataFrame = sqlContext.createDataFrame(rdd, structType).persist(StorageLevel.MEMORY_AND_DISK_SER());
|
||||
// CacheUtil.getInstance().addCacheData(hTable, dataFrame);
|
||||
// dataFrame.count();
|
||||
// return dataFrame;
|
||||
// }
|
||||
//
|
||||
// public String getSQL(List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, String table, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
// // 字段汇总 排序等
|
||||
// String[] field = yAxis.stream().map(y -> "CAST(" + y.getSummary() + "(" + y.getOriginName() + ") AS DECIMAL(20,2)) AS _" + y.getSummary() + "_" + y.getOriginName()).toArray(String[]::new);
|
||||
// String[] group = xAxis.stream().map(ChartViewFieldDTO::getOriginName).toArray(String[]::new);
|
||||
// String[] order = yAxis.stream().filter(y -> StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none"))
|
||||
// .map(y -> "_" + y.getSummary() + "_" + y.getOriginName() + " " + y.getSort()).toArray(String[]::new);
|
||||
//
|
||||
// String sql = MessageFormat.format("SELECT {0},{1} FROM {2} WHERE 1=1 {3} GROUP BY {4} ORDER BY null,{5}",
|
||||
// StringUtils.join(group, ","),
|
||||
// StringUtils.join(field, ","),
|
||||
// table,
|
||||
// transExtFilter(extFilterRequestList),// origin field filter and panel field filter,
|
||||
// StringUtils.join(group, ","),
|
||||
// StringUtils.join(order, ","));
|
||||
// if (sql.endsWith(",")) {
|
||||
// sql = sql.substring(0, sql.length() - 1);
|
||||
// }
|
||||
// // 如果是对结果字段过滤,则再包裹一层sql
|
||||
// String[] resultFilter = yAxis.stream().filter(y -> CollectionUtils.isNotEmpty(y.getFilter()) && y.getFilter().size() > 0)
|
||||
// .map(y -> {
|
||||
// String[] s = y.getFilter().stream().map(f -> "AND _" + y.getSummary() + "_" + y.getOriginName() + transFilterTerm(f.getTerm()) + f.getValue()).toArray(String[]::new);
|
||||
// return StringUtils.join(s, " ");
|
||||
// }).toArray(String[]::new);
|
||||
// if (resultFilter.length == 0) {
|
||||
// return sql;
|
||||
// } else {
|
||||
// String filterSql = MessageFormat.format("SELECT * FROM {0} WHERE 1=1 {1}",
|
||||
// "(" + sql + ") AS tmp",
|
||||
// StringUtils.join(resultFilter, " "));
|
||||
// return filterSql;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public String transFilterTerm(String term) {
|
||||
// switch (term) {
|
||||
// case "eq":
|
||||
// return " = ";
|
||||
// case "not_eq":
|
||||
// return " <> ";
|
||||
// case "lt":
|
||||
// return " < ";
|
||||
// case "le":
|
||||
// return " <= ";
|
||||
// case "gt":
|
||||
// return " > ";
|
||||
// case "ge":
|
||||
// return " >= ";
|
||||
// case "in":
|
||||
// return " IN ";
|
||||
// case "not in":
|
||||
// return " NOT IN ";
|
||||
// case "like":
|
||||
// return " LIKE ";
|
||||
// case "not like":
|
||||
// return " NOT LIKE ";
|
||||
// case "null":
|
||||
// return " IS NULL ";
|
||||
// case "not_null":
|
||||
// return " IS NOT NULL ";
|
||||
// default:
|
||||
// return "";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public String transExtFilter(List<ChartExtFilterRequest> requestList) {
|
||||
// if (CollectionUtils.isEmpty(requestList)) {
|
||||
// return "";
|
||||
// }
|
||||
// StringBuilder filter = new StringBuilder();
|
||||
// for (ChartExtFilterRequest request : requestList) {
|
||||
// List<String> value = request.getValue();
|
||||
// if (CollectionUtils.isEmpty(value)) {
|
||||
// continue;
|
||||
// }
|
||||
// DatasetTableField field = request.getDatasetTableField();
|
||||
// filter.append(" AND ")
|
||||
// .append(field.getOriginName())
|
||||
// .append(" ")
|
||||
// .append(transFilterTerm(request.getOperator()))
|
||||
// .append(" ");
|
||||
// if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
|
||||
// filter.append("('").append(StringUtils.join(value, "','")).append("')");
|
||||
// } else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
// filter.append("'%").append(value.get(0)).append("%'");
|
||||
// } else {
|
||||
// filter.append("'").append(value.get(0)).append("'");
|
||||
// }
|
||||
// }
|
||||
// return filter.toString();
|
||||
// }
|
||||
//}
|
@ -1,5 +1,6 @@
|
||||
package io.dataease.service.sys;
|
||||
|
||||
import io.dataease.base.domain.SysDept;
|
||||
import io.dataease.base.domain.SysMenu;
|
||||
import io.dataease.base.domain.SysMenuExample;
|
||||
import io.dataease.base.mapper.SysMenuMapper;
|
||||
@ -7,8 +8,10 @@ import io.dataease.base.mapper.ext.ExtMenuMapper;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.controller.sys.request.MenuCreateRequest;
|
||||
import io.dataease.controller.sys.request.MenuDeleteRequest;
|
||||
import io.dataease.controller.sys.response.DeptTreeNode;
|
||||
import io.dataease.controller.sys.response.MenuNodeResponse;
|
||||
|
||||
import io.dataease.controller.sys.response.MenuTreeNode;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -16,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -121,6 +125,24 @@ public class MenuService {
|
||||
return responses;
|
||||
}
|
||||
|
||||
public List<MenuTreeNode> searchTree(Long menuId) {
|
||||
List<SysMenu> roots = nodesByPid(0L);
|
||||
if (menuId == MENU_ROOT_PID) return roots.stream().map(this::format).collect(Collectors.toList());
|
||||
SysMenu sysMenu = sysMenuMapper.selectByPrimaryKey(menuId);
|
||||
if (roots.stream().anyMatch(node -> node.getMenuId() == menuId)) return roots.stream().map(this::format).collect(Collectors.toList());
|
||||
SysMenu current = sysMenu;
|
||||
MenuTreeNode currentNode = format(sysMenu);
|
||||
while (current.getPid() != MENU_ROOT_PID){
|
||||
SysMenu parent = sysMenuMapper.selectByPrimaryKey(current.getPid()); //pid上有索引 所以效率不会太差
|
||||
MenuTreeNode parentNode = format(parent);
|
||||
parentNode.setChildren(currentNode.toList());
|
||||
current = parent;
|
||||
currentNode = parentNode;
|
||||
}
|
||||
MenuTreeNode targetRootNode = currentNode;
|
||||
return roots.stream().map(node -> node.getMenuId() == targetRootNode.getId() ? targetRootNode : format(node)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Set<SysMenu> getChilds(List<SysMenu> lists, Set<SysMenu> sets){
|
||||
lists.forEach(menu -> {
|
||||
sets.add(menu);
|
||||
@ -132,6 +154,15 @@ public class MenuService {
|
||||
return sets;
|
||||
}
|
||||
|
||||
private MenuTreeNode format(SysMenu sysMenu) {
|
||||
MenuTreeNode menuTreeNode = new MenuTreeNode();
|
||||
menuTreeNode.setId(sysMenu.getMenuId());
|
||||
menuTreeNode.setLabel(sysMenu.getName());
|
||||
menuTreeNode.setHasChildren(false);
|
||||
Optional.ofNullable(sysMenu.getMenuSort()).ifPresent(num -> menuTreeNode.setHasChildren(num > 0));
|
||||
return menuTreeNode;
|
||||
}
|
||||
|
||||
public List<MenuNodeResponse> convert(List<SysMenu> menus){
|
||||
return menus.stream().map(node -> {
|
||||
MenuNodeResponse menuNodeResponse = BeanUtils.copyBean(new MenuNodeResponse(), node);
|
||||
|
@ -15,12 +15,12 @@ import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.SysUserCreateRequest;
|
||||
import io.dataease.controller.sys.request.SysUserPwdRequest;
|
||||
import io.dataease.controller.sys.request.SysUserStateRequest;
|
||||
import io.dataease.controller.sys.request.UserGridRequest;
|
||||
import io.dataease.controller.sys.response.SysUserGridResponse;
|
||||
import io.dataease.controller.sys.response.SysUserRole;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -31,7 +31,10 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class SysUserService {
|
||||
|
||||
private final static String DEFAULT_PWD = "DataEase123..";
|
||||
//private final static String DEFAULT_PWD = "DataEase123..";
|
||||
|
||||
@Value("${dataease.init_password:DataEase123..}")
|
||||
private String DEFAULT_PWD;
|
||||
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
@ -89,6 +92,7 @@ public class SysUserService {
|
||||
}
|
||||
|
||||
|
||||
@CacheEvict(value = AuthConstants.USER_CACHE_NAME, key = "'user' + #request.userId")
|
||||
public int updateStatus(SysUserStateRequest request){
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserId(request.getUserId());
|
||||
|
@ -62,6 +62,10 @@ spring.mvc.log-request-details=true
|
||||
pagehelper.PageRowBounds=true
|
||||
#excel等用户上传文件路径
|
||||
upload.file.path=/opt/dataease/data/upload/
|
||||
#用户初始密码,如果不设置默认是DataEase123..
|
||||
dataease.init_password=DataEase123456
|
||||
#登录超时时间单位s 设置默认30分钟 如果雨不设置 默认10分钟也就是10*60
|
||||
dataease.login_timeout=1800
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
ALTER TABLE `dataset_table_field` ADD COLUMN `size` INT NULL AFTER `type`;
|
@ -1,5 +1,7 @@
|
||||
DROP TABLE IF EXISTS `sys_dept` ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_dept
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_dept`;
|
||||
CREATE TABLE `sys_dept` (
|
||||
`dept_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`pid` bigint(20) DEFAULT NULL COMMENT '上级部门',
|
||||
@ -16,16 +18,25 @@ CREATE TABLE `sys_dept` (
|
||||
KEY `inx_enabled` (`enabled`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='部门';
|
||||
|
||||
INSERT INTO `sys_dept` (`dept_id`, `pid`, `sub_count`, `name`, `dept_sort`, `enabled`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('18','0','1','上海飞致云','1',b'1',null,null,'1614048906358','1614048906358');
|
||||
INSERT INTO `sys_dept` (`dept_id`, `pid`, `sub_count`, `name`, `dept_sort`, `enabled`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('19','0','1','北京飞致云','2',b'1',null,null,'1614048918465','1614048918465');
|
||||
INSERT INTO `sys_dept` (`dept_id`, `pid`, `sub_count`, `name`, `dept_sort`, `enabled`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('20','18','1','营销部','1',b'1',null,null,'1614048946370','1614049006759');
|
||||
INSERT INTO `sys_dept` (`dept_id`, `pid`, `sub_count`, `name`, `dept_sort`, `enabled`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('21','19','0','综合部','3',b'1',null,null,'1614048963483','1615783363091');
|
||||
INSERT INTO `sys_dept` (`dept_id`, `pid`, `sub_count`, `name`, `dept_sort`, `enabled`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('25','20','0','售前组','1',b'1',null,null,'1615791706945','1615791706945');
|
||||
-- ----------------------------
|
||||
-- Records of sys_dept
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `sys_dept` VALUES (18, 0, 1, '上海飞致云', 1, b'1', NULL, NULL, 1614048906358, 1614048906358);
|
||||
INSERT INTO `sys_dept` VALUES (19, 0, 1, '北京飞致云', 2, b'1', NULL, NULL, 1614048918465, 1614048918465);
|
||||
INSERT INTO `sys_dept` VALUES (20, 18, 1, '营销部', 1, b'1', NULL, NULL, 1614048946370, 1614049006759);
|
||||
INSERT INTO `sys_dept` VALUES (21, 19, 0, '综合部', 3, b'1', NULL, NULL, 1614048963483, 1619667528267);
|
||||
INSERT INTO `sys_dept` VALUES (25, 20, 0, '售前组', 1, b'1', NULL, NULL, 1615791706945, 1615791706945);
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `sys_menu` ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_menu
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_menu`;
|
||||
CREATE TABLE `sys_menu` (
|
||||
`menu_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`pid` bigint(20) DEFAULT NULL COMMENT '上级菜单ID',
|
||||
@ -49,44 +60,56 @@ CREATE TABLE `sys_menu` (
|
||||
UNIQUE KEY `uniq_title` (`title`),
|
||||
UNIQUE KEY `uniq_name` (`name`),
|
||||
KEY `inx_pid` (`pid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='系统菜单';
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='系统菜单';
|
||||
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('1','0','3','0','系统管理','系统管理','Layout','5','system','/system',null,b'0',b'0','dir:sys',null,null,null,'1614916695777');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('2','1','4','1','用户管理','用户管理','system/user/index','2','peoples','user',null,b'0',b'0','user:read',null,null,null,'1615786052463');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('3','1','3','1','菜单管理','菜单管理','system/menu/index','2','menu','menu',null,b'0',b'0','menu:read',null,null,null,null);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('4','1','3','1','组织管理','组织管理','system/dept/index','3','dept','dept',null,b'0',b'0','dept:read',null,null,null,null);
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('5','1','3','1','角色管理','角色管理','system/role/index','4','role','role',b'0',b'0',b'0','role:read',null,null,'1614683852133','1614683852133');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('6','1','0','1','参数管理','参数管理','system/systemParamSettings/index','13','sys-tools','systemParamSettings',null,b'0',b'0','sysparam:read',null,null,null,'1615790294169');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('7','0','1','0','数据集','数据管理','Layout','3','dataset','/dataset',null,b'0',b'0','dir:data',null,null,null,'1619081474697');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('8','7','0','1','数据管理1','数据管理1','dataset/index','1','dataset','index',null,b'0',b'0','data:read',null,null,null,'1614916684821');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('9','0','1','0','视图','视图管理','Layout','2','chart','/chart',null,b'0',b'0','dir:chart',null,null,null,'1619081462127');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('10','9','0','1','视图1','视图1','chart/index','1','chart','index',null,b'0',b'0','chart:read',null,null,null,'1614915491036');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('12','3','0','2','创建菜单',null,null,'999',null,null,b'0',b'0',b'0','menu:add',null,null,'1614924617327','1614924617327');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('13','3','0','2','删除菜单',null,null,'999',null,null,b'0',b'0',b'0','menu:del',null,null,'1614924667808','1614924667808');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('14','3','0','2','编辑菜单',null,null,'999',null,null,b'0',b'0',b'0','menu:edit',null,null,'1614930734224','1614936429773');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('15','2','0','2','创建用户',null,null,'999',null,null,b'0',b'0',b'0','user:add',null,null,'1614930862373','1614930862373');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('16','2','0','2','删除用户',null,null,'999',null,null,b'0',b'0',b'0','user:del',null,null,'1614930903502','1614930903502');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('17','2','0','2','编辑用户',null,null,'999',null,null,b'0',b'0',b'0','user:edit',null,null,'1614930935529','1614930935529');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('18','4','0','2','创建组织',null,null,'999',null,null,b'0',b'0',b'0','dept:add',null,null,'1614930976297','1614930976297');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('19','4','0','2','删除组织',null,null,'999',null,null,b'0',b'0',b'0','dept:del',null,null,'1614930997130','1614930997130');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('20','4','0','2','编辑组织',null,null,'999',null,null,b'0',b'0',b'0','dept:edit',null,null,'1614931022967','1614931022967');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('21','5','0','2','创建角色',null,null,'999',null,null,b'0',b'0',b'0','role:add',null,null,'1614931069408','1614931069408');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('22','5','0','2','删除角色',null,null,'999',null,null,b'0',b'0',b'0','role:del',null,null,'1614931097720','1614931097720');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('23','5','0','2','编辑角色',null,null,'999',null,null,b'0',b'0',b'0','role:edit',null,null,'1614931124782','1614931124782');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('24','34','0','2','创建连接',null,null,'997',null,null,b'0',b'0',b'0','datasource:add',null,null,'1614931168956','1615783705537');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('25','34','0','2','删除连接',null,null,'999',null,null,b'0',b'0',b'0','datasource:del',null,null,'1614931205899','1614931205899');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('26','34','0','2','编辑连接',null,null,'999',null,null,b'0',b'0',b'0','datasource:edit',null,null,'1614931234105','1614931234105');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('27','34','0','2','校验连接',null,null,'999',null,null,b'0',b'0',b'0','datasource:validate',null,null,'1614931268578','1614931268578');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('28','2','0','2','修改密码',null,null,'999',null,null,b'0',b'0',b'0','user:editPwd',null,null,'1615275128262','1615275128262');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('29','0','1','0','仪表盘','仪表盘管理','Layout','1',null,'/panel',null,b'0',b'0','panel:read',null,null,null,'1619081454146');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('30','29','0','1','仪表盘1','仪表盘','panel/index','1',null,'index',b'0',b'0',b'0','panel:read',null,null,null,'1619081449067');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('33','0','1','0','数据源','数据源','Layout','4',null,'/datasource',b'0',b'0',b'0','dir:datasource',null,null,'1619083205537','1619083205537');
|
||||
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('34','33','4','1','数据源1','数据源1','system/datasource/index','1',null,'index',b'0',b'0',b'0','datasource:read',null,null,null,null);
|
||||
-- ----------------------------
|
||||
-- Records of sys_menu
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `sys_menu` VALUES (1, 0, 3, 0, '系统管理', '系统管理', 'Layout', 5, 'system', '/system', NULL, b'0', b'0', 'dir:sys', NULL, NULL, NULL, 1614916695777);
|
||||
INSERT INTO `sys_menu` VALUES (2, 1, 4, 1, '用户管理', '用户管理', 'system/user/index', 2, 'peoples', 'user', NULL, b'0', b'0', 'user:read', NULL, NULL, NULL, 1615786052463);
|
||||
INSERT INTO `sys_menu` VALUES (3, 1, 3, 1, '菜单管理', '菜单管理', 'system/menu/index', 2, 'menu', 'menu', NULL, b'0', b'0', 'menu:read', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `sys_menu` VALUES (4, 1, 3, 1, '组织管理', '组织管理', 'system/dept/index', 3, 'dept', 'dept', NULL, b'0', b'0', 'dept:read', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `sys_menu` VALUES (5, 1, 3, 1, '角色管理', '角色管理', 'system/role/index', 4, 'role', 'role', b'0', b'0', b'0', 'role:read', NULL, NULL, 1614683852133, 1614683852133);
|
||||
INSERT INTO `sys_menu` VALUES (6, 1, 0, 1, '参数管理', '参数管理', 'system/systemParamSettings/index', 13, 'sys-tools', 'systemParamSettings', NULL, b'0', b'0', 'sysparam:read', NULL, NULL, NULL, 1615790294169);
|
||||
INSERT INTO `sys_menu` VALUES (7, 0, 1, 0, '数据集', '数据管理', 'Layout', 3, 'dataset', '/dataset', NULL, b'0', b'0', 'dir:data', NULL, NULL, NULL, 1619081474697);
|
||||
INSERT INTO `sys_menu` VALUES (8, 7, 0, 1, '数据管理1', '数据管理1', 'dataset/index', 1, 'dataset', 'index', NULL, b'0', b'0', 'data:read', NULL, NULL, NULL, 1614916684821);
|
||||
INSERT INTO `sys_menu` VALUES (9, 0, 1, 0, '视图', '视图管理', 'Layout', 2, 'chart', '/chart', NULL, b'0', b'0', 'dir:chart', NULL, NULL, NULL, 1619081462127);
|
||||
INSERT INTO `sys_menu` VALUES (10, 9, 0, 1, '视图1', '视图1', 'chart/index', 1, 'chart', 'index', NULL, b'0', b'0', 'chart:read', NULL, NULL, NULL, 1614915491036);
|
||||
INSERT INTO `sys_menu` VALUES (12, 3, 0, 2, '创建菜单', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'menu:add', NULL, NULL, 1614924617327, 1614924617327);
|
||||
INSERT INTO `sys_menu` VALUES (13, 3, 0, 2, '删除菜单', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'menu:del', NULL, NULL, 1614924667808, 1614924667808);
|
||||
INSERT INTO `sys_menu` VALUES (14, 3, 0, 2, '编辑菜单', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'menu:edit', NULL, NULL, 1614930734224, 1614936429773);
|
||||
INSERT INTO `sys_menu` VALUES (15, 2, 0, 2, '创建用户', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'user:add', NULL, NULL, 1614930862373, 1614930862373);
|
||||
INSERT INTO `sys_menu` VALUES (16, 2, 0, 2, '删除用户', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'user:del', NULL, NULL, 1614930903502, 1614930903502);
|
||||
INSERT INTO `sys_menu` VALUES (17, 2, 0, 2, '编辑用户', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'user:edit', NULL, NULL, 1614930935529, 1614930935529);
|
||||
INSERT INTO `sys_menu` VALUES (18, 4, 0, 2, '创建组织', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'dept:add', NULL, NULL, 1614930976297, 1614930976297);
|
||||
INSERT INTO `sys_menu` VALUES (19, 4, 0, 2, '删除组织', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'dept:del', NULL, NULL, 1614930997130, 1614930997130);
|
||||
INSERT INTO `sys_menu` VALUES (20, 4, 0, 2, '编辑组织', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'dept:edit', NULL, NULL, 1614931022967, 1614931022967);
|
||||
INSERT INTO `sys_menu` VALUES (21, 5, 0, 2, '创建角色', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'role:add', NULL, NULL, 1614931069408, 1614931069408);
|
||||
INSERT INTO `sys_menu` VALUES (22, 5, 0, 2, '删除角色', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'role:del', NULL, NULL, 1614931097720, 1614931097720);
|
||||
INSERT INTO `sys_menu` VALUES (23, 5, 0, 2, '编辑角色', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'role:edit', NULL, NULL, 1614931124782, 1614931124782);
|
||||
INSERT INTO `sys_menu` VALUES (24, 34, 0, 2, '创建连接', NULL, NULL, 997, NULL, NULL, b'0', b'0', b'0', 'datasource:add', NULL, NULL, 1614931168956, 1615783705537);
|
||||
INSERT INTO `sys_menu` VALUES (25, 34, 0, 2, '删除连接', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'datasource:del', NULL, NULL, 1614931205899, 1614931205899);
|
||||
INSERT INTO `sys_menu` VALUES (26, 34, 0, 2, '编辑连接', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'datasource:edit', NULL, NULL, 1614931234105, 1614931234105);
|
||||
INSERT INTO `sys_menu` VALUES (27, 34, 0, 2, '校验连接', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'datasource:validate', NULL, NULL, 1614931268578, 1614931268578);
|
||||
INSERT INTO `sys_menu` VALUES (28, 2, 0, 2, '修改密码', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'user:editPwd', NULL, NULL, 1615275128262, 1615275128262);
|
||||
INSERT INTO `sys_menu` VALUES (29, 0, 1, 0, '仪表盘', '仪表盘管理', 'Layout', 1, NULL, '/panel', NULL, b'0', b'0', 'panel:read', NULL, NULL, NULL, 1619081454146);
|
||||
INSERT INTO `sys_menu` VALUES (30, 29, 0, 1, '仪表盘1', '仪表盘', 'panel/index', 1, NULL, 'index', b'0', b'0', b'0', 'panel:read', NULL, NULL, NULL, 1619081449067);
|
||||
INSERT INTO `sys_menu` VALUES (33, 0, 1, 0, '数据源', '数据源', 'Layout', 4, NULL, '/datasource', b'0', b'0', b'0', 'dir:datasource', NULL, NULL, 1619083205537, 1619083205537);
|
||||
INSERT INTO `sys_menu` VALUES (34, 33, 4, 1, '数据源1', '数据源1', 'system/datasource/index', 1, NULL, 'index', b'0', b'0', b'0', 'datasource:read', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `sys_menu` VALUES (35, 1, 0, 1, '用户表单', '用户表单', 'system/user/form', 10, 'peoples', 'user-form', b'0', b'0', b'1', NULL, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `sys_menu` VALUES (36, 1, 0, 1, '菜单表单', '菜单表单', 'system/menu/form', 11, 'menu', 'menu-form', b'0', b'0', b'1', NULL, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `sys_menu` VALUES (37, 1, 0, 1, '组织表单', '组织表单', 'system/dept/form', 12, 'dept', 'dept-form', b'0', b'0', b'1', NULL, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `sys_menu` VALUES (38, 1, 0, 1, '角色表单', '角色表单', 'system/role/form', 13, 'role', 'role-form', b'0', b'0', b'1', NULL, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `sys_menu` VALUES (39, 33, 0, 1, '数据源表单', '数据源表单', 'system/datasource/form', 2, NULL, 'ds-form', b'0', b'0', b'1', NULL, NULL, NULL, NULL, NULL);
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `sys_user` ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_user
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_user`;
|
||||
CREATE TABLE `sys_user` (
|
||||
`user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`dept_id` bigint(20) DEFAULT NULL COMMENT '部门名称',
|
||||
@ -110,18 +133,25 @@ CREATE TABLE `sys_user` (
|
||||
UNIQUE KEY `uniq_email` (`email`),
|
||||
KEY `FK5rwmryny6jthaaxkogownknqp` (`dept_id`) USING BTREE,
|
||||
KEY `inx_enabled` (`enabled`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='系统用户';
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='系统用户';
|
||||
|
||||
INSERT INTO `sys_user` (`user_id`, `dept_id`, `username`, `nick_name`, `gender`, `phone`, `email`, `password`, `is_admin`, `enabled`, `create_by`, `update_by`, `pwd_reset_time`, `create_time`, `update_time`) VALUES ('4','0','admin','管理员','男',null,'admin@fit2cloud.com','e10adc3949ba59abbe56e057f20f883e',b'1','1',null,null,null,null,'1615184951534');
|
||||
INSERT INTO `sys_user` (`user_id`, `dept_id`, `username`, `nick_name`, `gender`, `phone`, `email`, `password`, `is_admin`, `enabled`, `create_by`, `update_by`, `pwd_reset_time`, `create_time`, `update_time`) VALUES ('19','25','demo','demo','男',null,'demo@fit2cloud.com','e10adc3949ba59abbe56e057f20f883e',b'0','1',null,null,null,'1619086036234','1619086036234');
|
||||
-- ----------------------------
|
||||
-- Records of sys_user
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `sys_user` VALUES (4, 0, 'admin', '管理员', '男', NULL, 'admin@fit2cloud.com', 'e10adc3949ba59abbe56e057f20f883e', b'1', 1, NULL, NULL, NULL, NULL, 1615184951534);
|
||||
INSERT INTO `sys_user` VALUES (19, 25, 'demo', 'demo', '男', NULL, 'demo@fit2cloud.com', 'e10adc3949ba59abbe56e057f20f883e', b'0', 0, NULL, NULL, NULL, 1619086036234, 1619086036234);
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `sys_role` ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_role
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_role`;
|
||||
CREATE TABLE `sys_role` (
|
||||
`role_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`code` varchar(100) NOT NULL COMMENT '代码',
|
||||
`name` varchar(255) NOT NULL COMMENT '名称',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '描述',
|
||||
`create_by` varchar(255) DEFAULT NULL COMMENT '创建者',
|
||||
@ -131,15 +161,22 @@ CREATE TABLE `sys_role` (
|
||||
PRIMARY KEY (`role_id`) USING BTREE,
|
||||
UNIQUE KEY `uniq_name` (`name`),
|
||||
KEY `role_name_index` (`name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='角色表';
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='角色表';
|
||||
|
||||
INSERT INTO `sys_role` (`role_id`, `code`, `name`, `description`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('3','admin','管理员',null,null,null,null,null);
|
||||
INSERT INTO `sys_role` (`role_id`, `code`, `name`, `description`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ('4','emp','普通员工',null,null,null,null,null);
|
||||
-- ----------------------------
|
||||
-- Records of sys_role
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `sys_role` VALUES (3, '管理员', 'www', NULL, NULL, NULL, 1619685033918);
|
||||
INSERT INTO `sys_role` VALUES (4, '普通员工', 'ceshi', NULL, NULL, NULL, 1619684053527);
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `sys_roles_menus` ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_roles_menus
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_roles_menus`;
|
||||
CREATE TABLE `sys_roles_menus` (
|
||||
`menu_id` bigint(20) NOT NULL COMMENT '菜单ID',
|
||||
`role_id` bigint(20) NOT NULL COMMENT '角色ID',
|
||||
@ -147,46 +184,54 @@ CREATE TABLE `sys_roles_menus` (
|
||||
KEY `FKcngg2qadojhi3a651a5adkvbq` (`role_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='角色菜单关联';
|
||||
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('1','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('2','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('3','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('4','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('5','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('6','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('7','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('8','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('9','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('10','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('11','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('14','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('15','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('16','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('17','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('18','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('19','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('20','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('21','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('22','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('23','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('24','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('25','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('26','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('27','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('28','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('29','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('30','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('31','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('32','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('33','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('34','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('101','3');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('29','4');
|
||||
INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES ('30','4');
|
||||
-- ----------------------------
|
||||
-- Records of sys_roles_menus
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `sys_roles_menus` VALUES (1, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (2, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (3, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (4, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (5, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (6, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (7, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (8, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (9, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (10, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (11, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (14, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (15, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (16, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (17, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (18, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (19, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (20, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (21, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (22, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (23, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (24, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (25, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (26, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (27, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (28, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (29, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (30, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (31, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (32, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (33, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (34, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (101, 3);
|
||||
INSERT INTO `sys_roles_menus` VALUES (29, 4);
|
||||
INSERT INTO `sys_roles_menus` VALUES (30, 4);
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `sys_users_roles` ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_users_roles
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_users_roles`;
|
||||
CREATE TABLE `sys_users_roles` (
|
||||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||
`role_id` bigint(20) NOT NULL COMMENT '角色ID',
|
||||
@ -194,6 +239,12 @@ CREATE TABLE `sys_users_roles` (
|
||||
KEY `FKq4eq273l04bpu4efj0jd0jb98` (`role_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户角色关联';
|
||||
|
||||
INSERT INTO `sys_users_roles` (`user_id`, `role_id`) VALUES ('4','3');
|
||||
INSERT INTO `sys_users_roles` (`user_id`, `role_id`) VALUES ('19','4');
|
||||
-- ----------------------------
|
||||
-- Records of sys_users_roles
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `sys_users_roles` VALUES (4, 3);
|
||||
INSERT INTO `sys_users_roles` VALUES (19, 4);
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
@ -67,7 +67,7 @@
|
||||
<!-- <table tableName="datasource"/>-->
|
||||
<!-- <table tableName="sys_dict"/>-->
|
||||
<!-- <table tableName="sys_dict_item"/>-->
|
||||
<table tableName="panel_template"/>
|
||||
<table tableName="sys_role"/>
|
||||
<!-- <table tableName="panel_design"/>-->
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
"element-resize-detector": "^1.2.2",
|
||||
"element-ui": "2.13.0",
|
||||
"file-saver": "^2.0.5",
|
||||
"fit2cloud-ui": "^0.1.12",
|
||||
"fit2cloud-ui": "^1.1.1",
|
||||
"html2canvas": "^1.0.0-rc.7",
|
||||
"js-cookie": "2.2.0",
|
||||
"jsencrypt": "^3.0.0-rc.1",
|
||||
|
@ -46,4 +46,11 @@ export function editMenu(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { addMenu, editMenu, delMenu, getMenusTree, getChild }
|
||||
export function treeByMenuId(menuId) {
|
||||
return request({
|
||||
url: '/api/menu/nodesByMenuId/' + menuId,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
export default { addMenu, editMenu, delMenu, getMenusTree, getChild, treeByMenuId }
|
||||
|
46
frontend/src/components/back-button/index.vue
Normal file
46
frontend/src/components/back-button/index.vue
Normal file
@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<el-icon name="back" class="back-button" @click.native="jump" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'BackButton',
|
||||
props: {
|
||||
// eslint-disable-next-line vue/require-default-prop
|
||||
path: String,
|
||||
// eslint-disable-next-line vue/require-default-prop
|
||||
name: String,
|
||||
// eslint-disable-next-line vue/require-default-prop
|
||||
to: Object
|
||||
},
|
||||
methods: {
|
||||
jump() {
|
||||
const { path, name, to } = this
|
||||
if (path) {
|
||||
this.$router.push(path)
|
||||
}
|
||||
if (name) {
|
||||
this.$router.push({ name: this.name })
|
||||
}
|
||||
if (to) {
|
||||
this.$router.push(to)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@import "~@/styles/mixin.scss";
|
||||
@import "~@/styles/variables.scss";
|
||||
|
||||
.back-button {
|
||||
cursor: pointer;
|
||||
margin-right: 10px;
|
||||
font-weight: 600;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.85);
|
||||
}
|
||||
}
|
||||
</style>
|
@ -1,17 +1,45 @@
|
||||
<template>
|
||||
<div class="content-container">
|
||||
<div v-if="$slots.header || header" class="content-container__header">
|
||||
<slot name="header">
|
||||
<back-button v-if="showBack" :path="backPath" :name="backName" :to="backTo" />
|
||||
{{ header }}
|
||||
</slot>
|
||||
</div>
|
||||
<div v-if="$slots.toolbar" class="content-container__toolbar">
|
||||
<slot name="toolbar" />
|
||||
</div>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BackButton from '@/components/back-button'
|
||||
|
||||
export default {
|
||||
name: 'LayoutContent'
|
||||
name: 'LayoutContent',
|
||||
components: { BackButton },
|
||||
props: {
|
||||
// eslint-disable-next-line vue/require-default-prop
|
||||
header: String,
|
||||
// eslint-disable-next-line vue/require-default-prop
|
||||
backPath: String,
|
||||
// eslint-disable-next-line vue/require-default-prop
|
||||
backName: String,
|
||||
// eslint-disable-next-line vue/require-default-prop
|
||||
backTo: Object
|
||||
},
|
||||
computed: {
|
||||
showBack({ backPath, backName, backTo }) {
|
||||
return backPath || backName || backTo
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@import "~@/styles/variables";
|
||||
@import "~@/styles/mixin.scss";
|
||||
@import "~@/styles/variables.scss";
|
||||
|
||||
.content-container {
|
||||
transition: 0.3s;
|
||||
@ -23,5 +51,15 @@ export default {
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 14%);
|
||||
box-sizing: border-box;
|
||||
|
||||
.content-container__header {
|
||||
line-height: 60px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.content-container__toolbar {
|
||||
@include flex-row(space-between, center);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
<template>
|
||||
<div class="complex-table">
|
||||
<div v-if="$slots.header || header" class="complex-table__header">
|
||||
@ -5,12 +6,16 @@
|
||||
</div>
|
||||
|
||||
<div v-if="$slots.toolbar || searchConfig" class="complex-table__toolbar">
|
||||
<slot name="toolbar">
|
||||
<fu-search-bar v-bind="searchConfig" @exec="search">
|
||||
<slot name="buttons" />
|
||||
<fu-table-column-select :columns="columns" />
|
||||
</fu-search-bar>
|
||||
</slot>
|
||||
<div>
|
||||
<slot name="toolbar" />
|
||||
</div>
|
||||
<fu-search-bar v-bind="searchConfig" @exec="search">
|
||||
<template #complex>
|
||||
<slot name="complex" />
|
||||
</template>
|
||||
<slot name="buttons" />
|
||||
<fu-table-column-select :columns="columns" />
|
||||
</fu-search-bar>
|
||||
</div>
|
||||
|
||||
<div class="complex-table__body">
|
||||
@ -72,12 +77,16 @@ export default {
|
||||
.complex-table {
|
||||
.complex-table__header {
|
||||
@include flex-row(flex-start, center);
|
||||
height: 60px;
|
||||
font-size: 20px;
|
||||
line-height: 60px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.complex-table__toolbar {
|
||||
@include flex-row(flex-end, center);
|
||||
@include flex-row(space-between, center);
|
||||
|
||||
.fu-search-bar {
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.complex-table__pagination {
|
||||
|
@ -5,12 +5,22 @@
|
||||
</div>
|
||||
|
||||
<div v-if="$slots.toolbar || searchConfig" class="complex-table__toolbar">
|
||||
<slot name="toolbar">
|
||||
<!-- <slot name="toolbar">
|
||||
<fu-search-bar v-bind="searchConfig" @exec="search">
|
||||
<slot name="buttons" />
|
||||
<fu-table-column-select :columns="columns" />
|
||||
</fu-search-bar>
|
||||
</slot>
|
||||
</slot> -->
|
||||
<div>
|
||||
<slot name="toolbar" />
|
||||
</div>
|
||||
<fu-search-bar v-bind="searchConfig" @exec="search">
|
||||
<template #complex>
|
||||
<slot name="complex" />
|
||||
</template>
|
||||
<slot name="buttons" />
|
||||
<fu-table-column-select :columns="columns" />
|
||||
</fu-search-bar>
|
||||
</div>
|
||||
|
||||
<div class="complex-table__body">
|
||||
@ -73,12 +83,16 @@ export default {
|
||||
.complex-table {
|
||||
.complex-table__header {
|
||||
@include flex-row(flex-start, center);
|
||||
height: 60px;
|
||||
font-size: 20px;
|
||||
line-height: 60px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.complex-table__toolbar {
|
||||
@include flex-row(flex-end, center);
|
||||
@include flex-row(space-between, center);
|
||||
|
||||
.fu-search-bar {
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.complex-table__pagination {
|
||||
|
@ -791,7 +791,14 @@ export default {
|
||||
type: '类型',
|
||||
create_by: '创建者',
|
||||
create_time: '创建时间',
|
||||
preview_100_data: '预览前100行数据'
|
||||
preview_100_data: '预览前100行数据',
|
||||
preview_show: '显示',
|
||||
preview_item: '条数据',
|
||||
preview_total: '共',
|
||||
pls_input_less_9: '请输入9位以内的正整数',
|
||||
field_edit: '编辑字段',
|
||||
table_already_add_to: '该表已添加至',
|
||||
uploading: '上传中...'
|
||||
},
|
||||
datasource: {
|
||||
datasource: '数据源',
|
||||
|
@ -2,9 +2,9 @@
|
||||
<section class="app-main">
|
||||
<transition name="fade-transform" mode="out-in">
|
||||
<el-main class="ms-main-container">
|
||||
<keep-alive>
|
||||
<router-view :key="key" />
|
||||
</keep-alive>
|
||||
<!-- <keep-alive> -->
|
||||
<router-view :key="key" />
|
||||
<!-- </keep-alive> -->
|
||||
</el-main>
|
||||
</transition>
|
||||
</section>
|
||||
|
@ -187,12 +187,20 @@ export default {
|
||||
},
|
||||
// 设置侧边栏的显示和隐藏
|
||||
setSidebarHide(route) {
|
||||
if (!route.children || route.children.length === 1) {
|
||||
// if (!route.children || route.children.length === 1) {
|
||||
if (!route.children || this.showChildLength(route) === 1) {
|
||||
this.$store.dispatch('app/toggleSideBarHide', true)
|
||||
} else {
|
||||
this.$store.dispatch('app/toggleSideBarHide', false)
|
||||
}
|
||||
},
|
||||
// 获取非隐藏子路由的个数
|
||||
showChildLength(route) {
|
||||
if (!route || !route.children) {
|
||||
return 0
|
||||
}
|
||||
return route.children.filter(kid => !kid.hidden).length
|
||||
},
|
||||
async logout() {
|
||||
await this.$store.dispatch('user/logout')
|
||||
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
|
||||
|
@ -1,9 +1,16 @@
|
||||
@mixin flex-row($justify: flex-start, $align: stretch) {
|
||||
display: flex;
|
||||
@if $justify != flex-start {
|
||||
justify-content: $justify;
|
||||
display: flex;
|
||||
@if $justify != flex-start {
|
||||
justify-content: $justify;
|
||||
}
|
||||
@if $align != stretch {
|
||||
align-items: $align;
|
||||
}
|
||||
}
|
||||
@if $align != stretch {
|
||||
align-items: $align;
|
||||
|
||||
@mixin variant($color, $background-color, $border-color) {
|
||||
color: $color;
|
||||
background-color: $background-color;
|
||||
border-color: $border-color;
|
||||
}
|
||||
}
|
||||
|
@ -36,4 +36,10 @@
|
||||
align-items: $align;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin variant($color, $background-color, $border-color) {
|
||||
color: $color;
|
||||
background-color: $background-color;
|
||||
border-color: $border-color;
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,9 @@ export const BASE_BAR = {
|
||||
title: {
|
||||
text: ''
|
||||
},
|
||||
// grid: {
|
||||
// containLabel: true
|
||||
// },
|
||||
tooltip: {},
|
||||
legend: {
|
||||
show: true,
|
||||
@ -114,6 +117,9 @@ export const HORIZONTAL_BAR = {
|
||||
title: {
|
||||
text: ''
|
||||
},
|
||||
// grid: {
|
||||
// containLabel: true
|
||||
// },
|
||||
tooltip: {},
|
||||
legend: {
|
||||
show: true,
|
||||
@ -141,6 +147,9 @@ export const BASE_LINE = {
|
||||
title: {
|
||||
text: ''
|
||||
},
|
||||
// grid: {
|
||||
// containLabel: true
|
||||
// },
|
||||
tooltip: {},
|
||||
legend: {
|
||||
show: true,
|
||||
@ -169,6 +178,9 @@ export const BASE_PIE = {
|
||||
title: {
|
||||
text: ''
|
||||
},
|
||||
// grid: {
|
||||
// containLabel: true
|
||||
// },
|
||||
tooltip: {},
|
||||
legend: {
|
||||
show: true,
|
||||
@ -199,6 +211,9 @@ export const BASE_FUNNEL = {
|
||||
title: {
|
||||
text: ''
|
||||
},
|
||||
// grid: {
|
||||
// containLabel: true
|
||||
// },
|
||||
tooltip: {
|
||||
trigger: 'item'
|
||||
},
|
||||
@ -252,6 +267,9 @@ export const BASE_RADAR = {
|
||||
title: {
|
||||
text: ''
|
||||
},
|
||||
// grid: {
|
||||
// containLabel: true
|
||||
// },
|
||||
tooltip: {},
|
||||
legend: {
|
||||
show: true,
|
||||
|
@ -26,7 +26,7 @@
|
||||
<el-radio-button label="right">{{ $t('chart.text_pos_right') }}</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="chart.type && !chart.type.includes('table')" :label="$t('chart.text_v_position')" class="form-item">
|
||||
<el-form-item v-show="chart.type && !chart.type.includes('table')" :label="$t('chart.text_v_position')" class="form-item">
|
||||
<el-radio-group v-model="titleForm.vPosition" size="mini" @change="changeTitleStyle">
|
||||
<el-radio-button label="top">{{ $t('chart.text_pos_top') }}</el-radio-button>
|
||||
<el-radio-button label="center">{{ $t('chart.text_pos_center') }}</el-radio-button>
|
||||
|
@ -8,7 +8,7 @@
|
||||
>
|
||||
<el-col>
|
||||
<el-form ref="colorForm" :model="colorForm" label-width="80px" size="mini">
|
||||
<el-form-item v-if="chart.type && !chart.type.includes('table')" :label="$t('chart.color_case')" class="form-item">
|
||||
<el-form-item v-show="chart.type && !chart.type.includes('table')" :label="$t('chart.color_case')" class="form-item">
|
||||
<el-select v-model="colorForm.value" :placeholder="$t('chart.pls_slc_color_case')" size="mini" @change="changeColorCase">
|
||||
<el-option v-for="option in colorCases" :key="option.value" :label="option.name" :value="option.value" style="display: flex;align-items: center;">
|
||||
<div style="float: left">
|
||||
@ -19,16 +19,16 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="chart.type && chart.type.includes('table')" :label="$t('chart.table_header_bg')" class="form-item">
|
||||
<el-form-item v-show="chart.type && chart.type.includes('table')" :label="$t('chart.table_header_bg')" class="form-item">
|
||||
<colorPicker v-model="colorForm.tableHeaderBgColor" style="margin-top: 6px;cursor: pointer;z-index: 1004;border: solid 1px black" @change="changeColorCase" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="chart.type && chart.type.includes('table')" :label="$t('chart.table_item_bg')" class="form-item">
|
||||
<el-form-item v-show="chart.type && chart.type.includes('table')" :label="$t('chart.table_item_bg')" class="form-item">
|
||||
<colorPicker v-model="colorForm.tableItemBgColor" style="margin-top: 6px;cursor: pointer;z-index: 1003;border: solid 1px black" @change="changeColorCase" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="chart.type && chart.type.includes('table')" :label="$t('chart.table_item_font_color')" class="form-item">
|
||||
<el-form-item v-show="chart.type && chart.type.includes('table')" :label="$t('chart.table_item_font_color')" class="form-item">
|
||||
<colorPicker v-model="colorForm.tableFontColor" style="margin-top: 6px;cursor: pointer;z-index: 1002;border: solid 1px black" @change="changeColorCase" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="chart.type && chart.type.includes('table')" :label="$t('chart.stripe')" class="form-item">
|
||||
<el-form-item v-show="chart.type && chart.type.includes('table')" :label="$t('chart.stripe')" class="form-item">
|
||||
<el-checkbox v-model="colorForm.tableStripe" @change="changeColorCase">{{ $t('chart.stripe') }}</el-checkbox>
|
||||
</el-form-item>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
trigger="click"
|
||||
>
|
||||
<el-col>
|
||||
<el-form v-if="chart.type && chart.type.includes('bar')" ref="sizeFormBar" :model="sizeForm" label-width="80px" size="mini">
|
||||
<el-form v-show="chart.type && chart.type.includes('bar')" ref="sizeFormBar" :model="sizeForm" label-width="80px" size="mini">
|
||||
<el-form-item :label="$t('chart.adapt')" class="form-item">
|
||||
<el-checkbox v-model="sizeForm.barDefault" @change="changeBarSizeCase">{{ $t('chart.adapt') }}</el-checkbox>
|
||||
</el-form-item>
|
||||
@ -19,7 +19,7 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-form v-if="chart.type && chart.type.includes('line')" ref="sizeFormLine" :model="sizeForm" label-width="80px" size="mini">
|
||||
<el-form v-show="chart.type && chart.type.includes('line')" ref="sizeFormLine" :model="sizeForm" label-width="80px" size="mini">
|
||||
<el-form-item :label="$t('chart.line_width')" class="form-item form-item-slider">
|
||||
<el-slider v-model="sizeForm.lineWidth" show-input :show-input-controls="false" input-size="mini" :min="0" :max="10" @change="changeBarSizeCase" />
|
||||
</el-form-item>
|
||||
@ -50,7 +50,7 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-form v-if="chart.type && chart.type.includes('pie')" ref="sizeFormPie" :model="sizeForm" label-width="80px" size="mini">
|
||||
<el-form v-show="chart.type && chart.type.includes('pie')" ref="sizeFormPie" :model="sizeForm" label-width="80px" size="mini">
|
||||
<el-form-item :label="$t('chart.pie_inner_radius')" class="form-item form-item-slider">
|
||||
<el-slider v-model="sizeForm.pieInnerRadius" show-input :show-input-controls="false" input-size="mini" :min="0" :max="100" @change="changeBarSizeCase" />
|
||||
</el-form-item>
|
||||
@ -58,7 +58,7 @@
|
||||
<el-slider v-model="sizeForm.pieOuterRadius" show-input :show-input-controls="false" input-size="mini" :min="0" :max="100" @change="changeBarSizeCase" />
|
||||
</el-form-item>
|
||||
|
||||
<span v-if="chart.type && chart.type.includes('pie-rose')">
|
||||
<span v-show="chart.type && chart.type.includes('pie-rose')">
|
||||
<el-form-item :label="$t('chart.rose_type')" class="form-item">
|
||||
<el-radio-group v-model="sizeForm.pieRoseType" size="mini" @change="changeBarSizeCase">
|
||||
<el-radio-button label="radius">{{ $t('chart.radius_mode') }}</el-radio-button>
|
||||
@ -71,13 +71,13 @@
|
||||
</span>
|
||||
</el-form>
|
||||
|
||||
<el-form v-if="chart.type && chart.type.includes('funnel')" ref="sizeFormPie" :model="sizeForm" label-width="80px" size="mini">
|
||||
<el-form v-show="chart.type && chart.type.includes('funnel')" ref="sizeFormPie" :model="sizeForm" label-width="80px" size="mini">
|
||||
<el-form-item :label="$t('chart.funnel_width')" class="form-item form-item-slider">
|
||||
<el-slider v-model="sizeForm.funnelWidth" show-input :show-input-controls="false" input-size="mini" :min="0" :max="100" @change="changeBarSizeCase" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-form v-if="chart.type && chart.type.includes('radar')" ref="sizeFormPie" :model="sizeForm" label-width="80px" size="mini">
|
||||
<el-form v-show="chart.type && chart.type.includes('radar')" ref="sizeFormPie" :model="sizeForm" label-width="80px" size="mini">
|
||||
<el-form-item :label="$t('chart.shape')" class="form-item">
|
||||
<el-radio-group v-model="sizeForm.radarShape" size="mini" @change="changeBarSizeCase">
|
||||
<el-radio-button label="polygon">{{ $t('chart.polygon') }}</el-radio-button>
|
||||
@ -86,7 +86,7 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-form v-if="chart.type && chart.type.includes('table')" ref="sizeFormPie" :model="sizeForm" label-width="100px" size="mini">
|
||||
<el-form v-show="chart.type && chart.type.includes('table')" ref="sizeFormPie" :model="sizeForm" label-width="100px" size="mini">
|
||||
<el-form-item :label="$t('chart.table_title_fontsize')" class="form-item">
|
||||
<el-select v-model="sizeForm.tableTitleFontSize" :placeholder="$t('chart.table_title_fontsize')" @change="changeBarSizeCase">
|
||||
<el-option v-for="option in fontSize" :key="option.value" :label="option.name" :value="option.value" />
|
||||
|
@ -164,7 +164,7 @@ export default {
|
||||
// console.log(s_table)
|
||||
let s = ''
|
||||
for (const i in this.table_header_class) {
|
||||
s += i + ':' + this.table_header_class[i] + ';'
|
||||
s += (i === 'fontSize' ? 'font-size' : i) + ':' + this.table_header_class[i] + ';'
|
||||
}
|
||||
s_table.setAttribute('style', s)
|
||||
},
|
||||
@ -176,23 +176,28 @@ export default {
|
||||
}
|
||||
},
|
||||
summaryMethod({ columns, data }) {
|
||||
const that = this
|
||||
const means = [] // 合计
|
||||
columns.forEach((column, columnIndex) => {
|
||||
if (columnIndex === 0) {
|
||||
means.push('合计')
|
||||
} else {
|
||||
const values = data.map(item => Number(item[column.property]))
|
||||
// 合计
|
||||
if (!values.every(value => isNaN(value))) {
|
||||
means[columnIndex] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr)
|
||||
if (!isNaN(value)) {
|
||||
return prev + curr
|
||||
} else {
|
||||
return prev
|
||||
}
|
||||
}, 0)
|
||||
means[columnIndex] = (means[columnIndex] + '').includes('.') ? means[columnIndex].toFixed(2) : means[columnIndex]
|
||||
if (columnIndex >= that.chart.data.fields.length - that.chart.data.series.length) {
|
||||
const values = data.map(item => Number(item[column.property]))
|
||||
// 合计
|
||||
if (!values.every(value => isNaN(value))) {
|
||||
means[columnIndex] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr)
|
||||
if (!isNaN(value)) {
|
||||
return prev + curr
|
||||
} else {
|
||||
return prev
|
||||
}
|
||||
}, 0)
|
||||
means[columnIndex] = (means[columnIndex] + '').includes('.') ? means[columnIndex].toFixed(2) : means[columnIndex]
|
||||
} else {
|
||||
means[columnIndex] = ''
|
||||
}
|
||||
} else {
|
||||
means[columnIndex] = ''
|
||||
}
|
||||
|
@ -147,6 +147,7 @@
|
||||
node-key="id"
|
||||
:expand-on-click-node="true"
|
||||
class="tree-list"
|
||||
highlight-current
|
||||
@node-click="sceneClick"
|
||||
>
|
||||
<span slot-scope="{ node, data }" class="custom-tree-node-list">
|
||||
@ -275,7 +276,7 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
sceneData: function() {
|
||||
this.chartTree()
|
||||
this.reviewChartList()
|
||||
return this.$store.state.chart.chartSceneData
|
||||
}
|
||||
},
|
||||
@ -483,6 +484,7 @@ export default {
|
||||
this.sceneMode = true
|
||||
this.currGroup = data
|
||||
this.$store.dispatch('chart/setSceneId', this.currGroup.id)
|
||||
this.chartTree()
|
||||
}
|
||||
if (node.expanded) {
|
||||
this.expandedArray.push(data.id)
|
||||
@ -521,6 +523,17 @@ export default {
|
||||
this.$emit('switchComponent', { name: 'ChartEdit', param: { 'id': data.id }})
|
||||
},
|
||||
|
||||
reviewChartList() {
|
||||
if (this.$store.state.chart.chartSceneData) {
|
||||
const that = this
|
||||
this.chartData.forEach(function(ele) {
|
||||
if (ele.id === that.$store.state.chart.chartSceneData.id) {
|
||||
ele.type = that.$store.state.chart.chartSceneData.type
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
selectTable() {
|
||||
this.selectTableFlag = true
|
||||
},
|
||||
|
@ -129,14 +129,14 @@
|
||||
<el-tab-pane :label="$t('chart.shape_attr')" class="padding-lr">
|
||||
<color-selector class="attr-selector" :chart="chart" @onColorChange="onColorChange" />
|
||||
<size-selector class="attr-selector" :chart="chart" @onSizeChange="onSizeChange" />
|
||||
<label-selector v-if="!view.type.includes('table')" class="attr-selector" :chart="chart" @onLabelChange="onLabelChange" />
|
||||
<tooltip-selector v-if="!view.type.includes('table')" class="attr-selector" :chart="chart" @onTooltipChange="onTooltipChange" />
|
||||
<label-selector v-show="!view.type.includes('table')" class="attr-selector" :chart="chart" @onLabelChange="onLabelChange" />
|
||||
<tooltip-selector v-show="!view.type.includes('table')" class="attr-selector" :chart="chart" @onTooltipChange="onTooltipChange" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('chart.module_style')" class="padding-lr">
|
||||
<title-selector class="attr-selector" :chart="chart" @onTextChange="onTextChange" />
|
||||
<legend-selector v-if="!view.type.includes('table')" class="attr-selector" :chart="chart" @onLegendChange="onLegendChange" />
|
||||
<x-axis-selector v-if="view.type.includes('bar') || view.type.includes('line')" class="attr-selector" :chart="chart" @onChangeXAxisForm="onChangeXAxisForm" />
|
||||
<y-axis-selector v-if="view.type.includes('bar') || view.type.includes('line')" class="attr-selector" :chart="chart" @onChangeYAxisForm="onChangeYAxisForm" />
|
||||
<legend-selector v-show="!view.type.includes('table')" class="attr-selector" :chart="chart" @onLegendChange="onLegendChange" />
|
||||
<x-axis-selector v-show="view.type.includes('bar') || view.type.includes('line')" class="attr-selector" :chart="chart" @onChangeXAxisForm="onChangeXAxisForm" />
|
||||
<y-axis-selector v-show="view.type.includes('bar') || view.type.includes('line')" class="attr-selector" :chart="chart" @onChangeYAxisForm="onChangeYAxisForm" />
|
||||
<background-color-selector class="attr-selector" :chart="chart" @onChangeBackgroundForm="onChangeBackgroundForm" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
@ -419,7 +419,7 @@ export default {
|
||||
// this.get(response.data.id);
|
||||
this.getData(response.data.id)
|
||||
this.$store.dispatch('chart/setChartSceneData', null)
|
||||
this.$store.dispatch('chart/setChartSceneData', this.sceneId)
|
||||
this.$store.dispatch('chart/setChartSceneData', response.data)
|
||||
})
|
||||
},
|
||||
closeEdit() {
|
||||
|
@ -17,10 +17,10 @@
|
||||
<el-divider />
|
||||
<el-row>
|
||||
<el-col>
|
||||
123
|
||||
自助数据集
|
||||
</el-col>
|
||||
<el-col>
|
||||
456
|
||||
TODO
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-row>
|
||||
|
@ -1,61 +1,60 @@
|
||||
<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" :disabled="checkTableList.length < 1" @click="save">
|
||||
{{ $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-select>
|
||||
</el-form-item>
|
||||
<el-form-item class="form-item">
|
||||
<el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
|
||||
<el-option :label="$t('dataset.direct_connect')" value="0" />
|
||||
<el-option :label="$t('dataset.sync_data')" value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item class="form-item" style="float: right;">
|
||||
<el-input
|
||||
v-model="searchTable"
|
||||
size="mini"
|
||||
:placeholder="$t('dataset.search')"
|
||||
prefix-icon="el-icon-search"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<el-row style="overflow: auto;height: 60vh;">
|
||||
<el-checkbox-group v-model="checkTableList" size="small">
|
||||
<el-checkbox
|
||||
v-for="t in tableData"
|
||||
:key="t"
|
||||
border
|
||||
:label="t"
|
||||
/>
|
||||
</el-checkbox-group>
|
||||
<el-row style="display: flex;flex-direction: column;height: 100%">
|
||||
<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" :disabled="checkTableList.length < 1" @click="save">
|
||||
{{ $t('dataset.confirm') }}
|
||||
</el-button>
|
||||
</el-row>
|
||||
</el-row>
|
||||
</el-col>
|
||||
<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-select>
|
||||
</el-form-item>
|
||||
<el-form-item class="form-item">
|
||||
<el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
|
||||
<el-option :label="$t('dataset.direct_connect')" value="0" />
|
||||
<el-option :label="$t('dataset.sync_data')" value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item class="form-item" style="float: right;">
|
||||
<el-input
|
||||
v-model="searchTable"
|
||||
size="mini"
|
||||
:placeholder="$t('dataset.search')"
|
||||
prefix-icon="el-icon-search"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<el-col style="overflow-y: auto;">
|
||||
<el-checkbox-group v-model="checkTableList" size="small">
|
||||
<el-tooltip v-for="t in tableData" :key="t.name" :disabled="t.enableCheck" effect="dark" :content="$t('dataset.table_already_add_to')+': '+t.datasetPath" placement="bottom">
|
||||
<el-checkbox
|
||||
border
|
||||
:label="t.name"
|
||||
:disabled="!t.enableCheck"
|
||||
/>
|
||||
</el-tooltip>
|
||||
</el-checkbox-group>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@ -91,7 +90,7 @@ export default {
|
||||
},
|
||||
searchTable(val) {
|
||||
if (val && val !== '') {
|
||||
this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.includes(val) })))
|
||||
this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.name.includes(val) })))
|
||||
} else {
|
||||
this.tableData = JSON.parse(JSON.stringify(this.tables))
|
||||
}
|
||||
|
@ -19,21 +19,26 @@
|
||||
<el-row>
|
||||
<el-col style="width: 500px;">
|
||||
<el-form :inline="true" size="mini" class="row-style">
|
||||
<el-form-item>
|
||||
<el-form-item class="form-item">
|
||||
<el-input v-model="name" :placeholder="$t('commons.name')" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-form-item class="form-item">
|
||||
<el-upload
|
||||
:action="baseUrl+'dataset/table/excel/upload'"
|
||||
:multiple="false"
|
||||
:show-file-list="false"
|
||||
:file-list="fileList"
|
||||
accept=".xls,.xlsx,.csv"
|
||||
:before-upload="beforeUpload"
|
||||
:on-success="uploadSuccess"
|
||||
:on-error="uploadFail"
|
||||
name="file"
|
||||
:headers="headers"
|
||||
>
|
||||
<el-button size="mini" type="primary">{{ $t('dataset.upload_file') }}</el-button>
|
||||
<el-button size="mini" type="primary" :disabled="uploading">
|
||||
<span v-if="!uploading" style="font-size: 12px;">{{ $t('dataset.upload_file') }}</span>
|
||||
<span v-if="uploading" style="font-size: 12px;"><i class="el-icon-loading" /> {{ $t('dataset.uploading') }}</span>
|
||||
</el-button>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@ -41,7 +46,7 @@
|
||||
</el-row>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-row style="margin-top: 10px;">
|
||||
<el-card class="box-card dataPreview" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>{{ $t('dataset.data_preview') }}</span>
|
||||
@ -96,31 +101,18 @@ export default {
|
||||
fileList: [],
|
||||
headers: { Authorization: token },
|
||||
baseUrl: process.env.VUE_APP_BASE_API,
|
||||
path: ''
|
||||
path: '',
|
||||
uploading: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// dataSource(val) {
|
||||
// if (val) {
|
||||
// post('/datasource/getTables', { id: val }).then(response => {
|
||||
// this.tables = response.data
|
||||
// this.tableData = JSON.parse(JSON.stringify(this.tables))
|
||||
// })
|
||||
// }
|
||||
// },
|
||||
// searchTable(val) {
|
||||
// if (val && val !== '') {
|
||||
// this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.includes(val) })))
|
||||
// } else {
|
||||
// this.tableData = JSON.parse(JSON.stringify(this.tables))
|
||||
// }
|
||||
// }
|
||||
},
|
||||
mounted() {
|
||||
// this.initDataSource()
|
||||
},
|
||||
activated() {
|
||||
// this.initDataSource()
|
||||
window.onresize = () => {
|
||||
this.calHeight()
|
||||
}
|
||||
this.calHeight()
|
||||
},
|
||||
methods: {
|
||||
// initDataSource() {
|
||||
@ -128,6 +120,19 @@ export default {
|
||||
// this.options = response.data
|
||||
// })
|
||||
// },
|
||||
calHeight() {
|
||||
const that = this
|
||||
setTimeout(function() {
|
||||
const currentHeight = document.documentElement.clientHeight
|
||||
that.height = currentHeight - 56 - 30 - 26 - 25 - 35 - 10 - 37 - 20 - 10
|
||||
}, 10)
|
||||
},
|
||||
beforeUpload(file) {
|
||||
this.uploading = true
|
||||
},
|
||||
uploadFail(response, file, fileList) {
|
||||
this.uploading = false
|
||||
},
|
||||
uploadSuccess(response, file, fileList) {
|
||||
// console.log(response)
|
||||
// console.log(file)
|
||||
@ -142,6 +147,7 @@ export default {
|
||||
this.name = file.name.substring(0, file.name.lastIndexOf('.'))
|
||||
}
|
||||
this.fileList = fileList
|
||||
this.uploading = false
|
||||
},
|
||||
|
||||
save() {
|
||||
@ -186,7 +192,7 @@ export default {
|
||||
}
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 6px;
|
||||
margin-bottom: 6px !important;
|
||||
}
|
||||
|
||||
.el-checkbox {
|
||||
|
@ -76,6 +76,11 @@
|
||||
/>
|
||||
</ux-grid>
|
||||
</div>
|
||||
<span class="table-count">
|
||||
{{ $t('dataset.preview_show') }}
|
||||
<span class="span-number">1000</span>
|
||||
{{ $t('dataset.preview_item') }}
|
||||
</span>
|
||||
</el-card>
|
||||
</el-row>
|
||||
</el-row>
|
||||
@ -155,11 +160,9 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
window.onresize = () => {
|
||||
return (() => {
|
||||
this.height = window.innerHeight / 2
|
||||
})()
|
||||
this.calHeight()
|
||||
}
|
||||
this.height = window.innerHeight / 2
|
||||
this.calHeight()
|
||||
this.initDataSource()
|
||||
this.$refs.myCm.codemirror.on('keypress', () => {
|
||||
this.$refs.myCm.codemirror.showHint()
|
||||
@ -168,6 +171,13 @@ export default {
|
||||
this.initTableInfo()
|
||||
},
|
||||
methods: {
|
||||
calHeight() {
|
||||
const that = this
|
||||
setTimeout(function() {
|
||||
const currentHeight = document.documentElement.clientHeight
|
||||
that.height = currentHeight - 56 - 30 - 26 - 25 - 43 - 160 - 10 - 37 - 20 - 10 - 16
|
||||
}, 10)
|
||||
},
|
||||
initDataSource() {
|
||||
listDatasource().then(response => {
|
||||
this.options = response.data
|
||||
@ -243,7 +253,11 @@ export default {
|
||||
|
||||
cancel() {
|
||||
// this.dataReset()
|
||||
this.$emit('switchComponent', { name: '' })
|
||||
if (this.param.tableId) {
|
||||
this.$emit('switchComponent', { name: 'ViewTable', param: this.param.tableId })
|
||||
} else {
|
||||
this.$emit('switchComponent', { name: '' })
|
||||
}
|
||||
},
|
||||
|
||||
showSQL(val) {
|
||||
@ -303,4 +317,10 @@ export default {
|
||||
span{
|
||||
font-size: 14px;
|
||||
}
|
||||
.span-number{
|
||||
color: #f18126;
|
||||
}
|
||||
.table-count{
|
||||
color: #606266;
|
||||
}
|
||||
</style>
|
||||
|
@ -58,7 +58,7 @@ export default {
|
||||
this.resetData()
|
||||
if (this.table.id) {
|
||||
this.table.row = 10
|
||||
post('/dataset/table/getPreviewData', this.table).then(response => {
|
||||
post('/dataset/table/getPreviewData/1/10', this.table).then(response => {
|
||||
this.fields = response.data.fields
|
||||
this.data = response.data.data
|
||||
const datas = this.data
|
||||
|
111
frontend/src/views/dataset/data/FieldEdit.vue
Normal file
111
frontend/src/views/dataset/data/FieldEdit.vue
Normal file
@ -0,0 +1,111 @@
|
||||
<template>
|
||||
<el-row>
|
||||
<el-row style="height: 26px;">
|
||||
<span style="line-height: 26px;">
|
||||
{{ $t('dataset.field_edit') }}
|
||||
<span>{{ param.table.name }}</span>
|
||||
</span>
|
||||
<el-row style="float: right">
|
||||
<el-button size="mini" @click="closeEdit">{{ $t('dataset.cancel') }}</el-button>
|
||||
<el-button type="primary" size="mini" @click="saveEdit">{{ $t('dataset.confirm') }}</el-button>
|
||||
</el-row>
|
||||
</el-row>
|
||||
<el-divider />
|
||||
<el-table :data="tableFields" size="mini" :max-height="maxHeight">
|
||||
<el-table-column property="type" :label="$t('dataset.field_type')" width="100">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.deType === 0">
|
||||
<svg-icon v-if="scope.row.deType === 0" icon-class="field_text" class="field-icon-text" />
|
||||
<span class="field-class">{{ $t('dataset.text') }}</span>
|
||||
</span>
|
||||
<span v-if="scope.row.deType === 1">
|
||||
<svg-icon v-if="scope.row.deType === 1" icon-class="field_time" class="field-icon-time" />
|
||||
<span class="field-class">{{ $t('dataset.time') }}</span>
|
||||
</span>
|
||||
<span v-if="scope.row.deType === 2 || scope.row.deType === 3">
|
||||
<svg-icon v-if="scope.row.deType === 2 || scope.row.deType === 3" icon-class="field_value" class="field-icon-value" />
|
||||
<span class="field-class">{{ $t('dataset.value') }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column property="name" :label="$t('dataset.field_name')" width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.name" size="mini" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column property="originName" :label="$t('dataset.field_origin_name')" width="180" />
|
||||
<el-table-column property="checked" :label="$t('dataset.field_check')" width="80">
|
||||
<template slot-scope="scope">
|
||||
<el-checkbox v-model="scope.row.checked" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!--下面这一列占位-->
|
||||
<el-table-column property="" />
|
||||
</el-table>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fieldList, batchEdit } from '@/api/dataset/dataset'
|
||||
export default {
|
||||
name: 'FieldEdit',
|
||||
props: {
|
||||
param: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
maxHeight: 'auto',
|
||||
tableFields: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
mounted() {
|
||||
window.onresize = () => {
|
||||
this.calcHeight()
|
||||
}
|
||||
this.calcHeight()
|
||||
this.initField()
|
||||
},
|
||||
methods: {
|
||||
calcHeight() {
|
||||
const that = this
|
||||
setTimeout(function() {
|
||||
const currentHeight = document.documentElement.clientHeight
|
||||
that.maxHeight = (currentHeight - 56 - 30 - 35 - 26 - 10) + 'px'
|
||||
}, 10)
|
||||
},
|
||||
initField() {
|
||||
fieldList(this.param.table.id).then(response => {
|
||||
this.tableFields = response.data
|
||||
})
|
||||
},
|
||||
saveEdit() {
|
||||
// console.log(this.tableFields)
|
||||
batchEdit(this.tableFields).then(response => {
|
||||
this.closeEdit()
|
||||
})
|
||||
},
|
||||
|
||||
closeEdit() {
|
||||
this.$emit('switchComponent', { name: 'ViewTable', param: this.param.table.id })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-divider--horizontal {
|
||||
margin: 12px 0;
|
||||
}
|
||||
span{
|
||||
font-size: 14px;
|
||||
}
|
||||
.field-class{
|
||||
font-size: 12px !important;
|
||||
}
|
||||
</style>
|
@ -34,6 +34,32 @@
|
||||
</template>
|
||||
</ux-table-column>
|
||||
</ux-grid>
|
||||
<el-row style="margin-top: 4px;">
|
||||
<span class="table-count">
|
||||
<span v-if="page.total <= currentPage.show">
|
||||
{{ $t('dataset.preview_total') }}
|
||||
<span class="span-number">{{ page.total }}</span>
|
||||
{{ $t('dataset.preview_item') }}
|
||||
</span>
|
||||
<span v-if="page.total > currentPage.show">
|
||||
{{ $t('dataset.preview_show') }}
|
||||
<span class="span-number">{{ currentPage.show }}</span>
|
||||
{{ $t('dataset.preview_item') }}
|
||||
,{{ $t('dataset.preview_total') }}
|
||||
<span class="span-number">{{ page.total }}</span>
|
||||
{{ $t('dataset.preview_item') }}
|
||||
</span>
|
||||
</span>
|
||||
<el-pagination
|
||||
:current-page="currentPage.page"
|
||||
:page-sizes="[100]"
|
||||
:page-size="currentPage.pageSize"
|
||||
:pager-count="5"
|
||||
layout="sizes, prev, pager, next"
|
||||
:total="currentPage.show"
|
||||
@current-change="pageChange"
|
||||
/>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</template>
|
||||
|
||||
@ -56,11 +82,20 @@ export default {
|
||||
form: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
page: {
|
||||
type: Object,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
height: 500
|
||||
height: 500,
|
||||
currentPage: {
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
show: parseInt(this.form.row)
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -69,28 +104,68 @@ export default {
|
||||
data() {
|
||||
const datas = this.data
|
||||
this.$refs.plxTable.reloadData(datas)
|
||||
},
|
||||
page() {
|
||||
if (this.page.total < parseInt(this.form.row)) {
|
||||
this.currentPage.show = this.page.total
|
||||
} else {
|
||||
this.currentPage.show = parseInt(this.form.row)
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
window.onresize = () => {
|
||||
return (() => {
|
||||
this.height = window.innerHeight / 2
|
||||
})()
|
||||
}
|
||||
this.height = window.innerHeight / 2
|
||||
},
|
||||
activated() {
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.calHeight()
|
||||
},
|
||||
calHeight() {
|
||||
const that = this
|
||||
setTimeout(function() {
|
||||
const currentHeight = document.documentElement.clientHeight
|
||||
that.height = currentHeight - 56 - 30 - 26 - 25 - 55 - 38 - 28 - 10
|
||||
}, 10)
|
||||
},
|
||||
reSearch() {
|
||||
this.$emit('reSearch', this.form)
|
||||
if (!this.form.row || this.form.row === '' || this.form.row.length > 8 || isNaN(Number(this.form.row)) || String(this.form.row).includes('.')) {
|
||||
this.$message({
|
||||
message: this.$t('dataset.pls_input_less_9'),
|
||||
type: 'error',
|
||||
showClose: true
|
||||
})
|
||||
return
|
||||
}
|
||||
this.currentPage.show = parseInt(this.form.row)
|
||||
this.currentPage.page = 1
|
||||
this.$emit('reSearch', { form: this.form, page: this.currentPage })
|
||||
},
|
||||
pageChange(val) {
|
||||
this.currentPage.page = val
|
||||
// console.log(this.currentPage)
|
||||
this.$emit('reSearch', { form: this.form, page: this.currentPage })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.row-style>>>.el-form-item__label{
|
||||
font-size: 12px;
|
||||
}
|
||||
.row-style>>>.el-form-item__label{
|
||||
font-size: 12px;
|
||||
}
|
||||
.row-style>>>.el-form-item--mini.el-form-item{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.el-pagination{
|
||||
float: right;
|
||||
}
|
||||
span{
|
||||
font-size: 12px;
|
||||
}
|
||||
.span-number{
|
||||
color: #f18126;
|
||||
}
|
||||
.table-count{
|
||||
color: #606266;
|
||||
}
|
||||
</style>
|
||||
|
@ -464,9 +464,11 @@ export default {
|
||||
})
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.page.pageSize = val
|
||||
this.listTaskLog()
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.page.currentPage = val
|
||||
this.listTaskLog()
|
||||
},
|
||||
resetTaskForm() {
|
||||
|
@ -1,93 +1,48 @@
|
||||
<template>
|
||||
<el-col>
|
||||
<el-row>
|
||||
<el-row style="height: 26px;">
|
||||
<span v-show="false">{{ tableId }}</span>
|
||||
<el-popover
|
||||
placement="right-start"
|
||||
width="400"
|
||||
trigger="click"
|
||||
@show="showTab"
|
||||
@hide="hideTab"
|
||||
>
|
||||
<dataset-chart-detail type="dataset" :data="table" :tab-status="tabStatus" />
|
||||
<span slot="reference" style="line-height: 26px;cursor: pointer;">
|
||||
{{ table.name }}
|
||||
</span>
|
||||
</el-popover>
|
||||
<el-row style="float: right">
|
||||
<el-button v-if="table.type ==='sql'" size="mini" @click="editSql">
|
||||
{{ $t('dataset.edit_sql') }}
|
||||
</el-button>
|
||||
<el-button size="mini" @click="edit">
|
||||
{{ $t('dataset.edit') }}
|
||||
</el-button>
|
||||
<!-- <el-button size="mini" type="primary" @click="createChart">-->
|
||||
<!-- {{$t('dataset.create_view')}}-->
|
||||
<!-- </el-button>-->
|
||||
</el-row>
|
||||
<el-row style="height: 100%;overflow-y: hidden;width: 100%;">
|
||||
<el-row style="height: 26px;">
|
||||
<el-popover
|
||||
placement="right-start"
|
||||
width="400"
|
||||
trigger="click"
|
||||
@show="showTab"
|
||||
@hide="hideTab"
|
||||
>
|
||||
<dataset-chart-detail type="dataset" :data="table" :tab-status="tabStatus" />
|
||||
<span slot="reference" style="line-height: 26px;cursor: pointer;">
|
||||
{{ table.name }}
|
||||
</span>
|
||||
</el-popover>
|
||||
<el-row style="float: right">
|
||||
<el-button v-if="table.type ==='sql'" size="mini" @click="editSql">
|
||||
{{ $t('dataset.edit_sql') }}
|
||||
</el-button>
|
||||
<el-button size="mini" @click="edit">
|
||||
{{ $t('dataset.edit') }}
|
||||
</el-button>
|
||||
<!-- <el-button size="mini" type="primary" @click="createChart">-->
|
||||
<!-- {{$t('dataset.create_view')}}-->
|
||||
<!-- </el-button>-->
|
||||
</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" :form="tableViewRowForm" @reSearch="reSearch" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('dataset.join_view')" name="joinView">
|
||||
关联视图 TODO
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="table.mode === 1 && (table.type === 'db' || table.type === 'sql')" :label="$t('dataset.update_info')" name="updateInfo">
|
||||
<update-info :table="table" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<el-dialog :title="table.name" :visible.sync="editField" :fullscreen="true" :show-close="false" class="dialog-css">
|
||||
<el-table :data="tableFields" size="mini" max-height="600px">
|
||||
<el-table-column property="type" :label="$t('dataset.field_type')" width="100">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.deType === 0">
|
||||
<svg-icon v-if="scope.row.deType === 0" icon-class="field_text" class="field-icon-text" />
|
||||
{{ $t('dataset.text') }}
|
||||
</span>
|
||||
<span v-if="scope.row.deType === 1">
|
||||
<svg-icon v-if="scope.row.deType === 1" icon-class="field_time" class="field-icon-time" />
|
||||
{{ $t('dataset.time') }}
|
||||
</span>
|
||||
<span v-if="scope.row.deType === 2 || scope.row.deType === 3">
|
||||
<svg-icon v-if="scope.row.deType === 2 || scope.row.deType === 3" icon-class="field_value" class="field-icon-value" />
|
||||
{{ $t('dataset.value') }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column property="name" :label="$t('dataset.field_name')" width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.name" size="mini" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column property="originName" :label="$t('dataset.field_origin_name')" width="180" />
|
||||
<el-table-column property="checked" :label="$t('dataset.field_check')" width="80">
|
||||
<template slot-scope="scope">
|
||||
<el-checkbox v-model="scope.row.checked" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!--下面这一列占位-->
|
||||
<el-table-column property="" />
|
||||
</el-table>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" @click="closeEdit">{{ $t('dataset.cancel') }}</el-button>
|
||||
<el-button type="primary" size="mini" @click="saveEdit">{{ $t('dataset.confirm') }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- <el-dialog title="view" :visible.sync="createViewDialog" :fullscreen="true">-->
|
||||
<!-- <chart-edit/>-->
|
||||
<!-- </el-dialog>-->
|
||||
</el-row>
|
||||
</el-col>
|
||||
<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" :page="page" :form="tableViewRowForm" @reSearch="reSearch" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('dataset.join_view')" name="joinView">
|
||||
关联视图 TODO
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="table.mode === 1 && (table.type === 'db' || table.type === 'sql')" :label="$t('dataset.update_info')" name="updateInfo">
|
||||
<update-info :table="table" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getTable, getPreviewData, fieldList, batchEdit } from '@/api/dataset/dataset'
|
||||
import { getTable, post } from '@/api/dataset/dataset'
|
||||
import TabDataPreview from './TabDataPreview'
|
||||
import UpdateInfo from './UpdateInfo'
|
||||
import DatasetChartDetail from '../common/DatasetChartDetail'
|
||||
@ -95,32 +50,38 @@ import DatasetChartDetail from '../common/DatasetChartDetail'
|
||||
export default {
|
||||
name: 'ViewTable',
|
||||
components: { DatasetChartDetail, UpdateInfo, TabDataPreview },
|
||||
props: {
|
||||
param: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
createViewDialog: false,
|
||||
editField: false,
|
||||
table: {
|
||||
name: ''
|
||||
},
|
||||
fields: [],
|
||||
data: [],
|
||||
page: {
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
show: 1000
|
||||
},
|
||||
tabActive: 'dataPreview',
|
||||
tableFields: [],
|
||||
tableViewRowForm: {
|
||||
row: 1000
|
||||
},
|
||||
tabStatus: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
tableId() {
|
||||
this.initTable(this.$store.state.dataset.table)
|
||||
return this.$store.state.dataset.table
|
||||
watch: {
|
||||
'param': function() {
|
||||
this.initTable(this.param)
|
||||
}
|
||||
},
|
||||
watch: {},
|
||||
mounted() {
|
||||
this.initTable(this.$store.state.dataset.table)
|
||||
this.initTable(this.param)
|
||||
},
|
||||
methods: {
|
||||
initTable(id) {
|
||||
@ -132,49 +93,24 @@ export default {
|
||||
this.data = []
|
||||
getTable(id).then(response => {
|
||||
this.table = response.data
|
||||
this.initPreviewData()
|
||||
this.initPreviewData(this.page)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
initPreviewData() {
|
||||
initPreviewData(page) {
|
||||
if (this.table.id) {
|
||||
this.table.row = this.tableViewRowForm.row
|
||||
getPreviewData(this.table).then(response => {
|
||||
post('/dataset/table/getPreviewData/' + page.page + '/' + page.pageSize, this.table).then(response => {
|
||||
this.fields = response.data.fields
|
||||
this.data = response.data.data
|
||||
this.page = response.data.page
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
initTableFields() {
|
||||
fieldList(this.table.id).then(response => {
|
||||
this.tableFields = response.data
|
||||
})
|
||||
},
|
||||
|
||||
edit() {
|
||||
this.editField = true
|
||||
// 请求当前表的所有字段,进行编辑
|
||||
this.initTableFields()
|
||||
},
|
||||
|
||||
// createChart() {
|
||||
// console.log(this.table);
|
||||
// this.createViewDialog = true;
|
||||
// },
|
||||
|
||||
saveEdit() {
|
||||
console.log(this.tableFields)
|
||||
batchEdit(this.tableFields).then(response => {
|
||||
this.closeEdit()
|
||||
this.initTable(this.table.id)
|
||||
})
|
||||
},
|
||||
|
||||
closeEdit() {
|
||||
this.editField = false
|
||||
this.tableFields = []
|
||||
this.$emit('switchComponent', { name: 'FieldEdit', param: { table: this.table }})
|
||||
},
|
||||
|
||||
editSql() {
|
||||
@ -182,8 +118,8 @@ export default {
|
||||
},
|
||||
|
||||
reSearch(val) {
|
||||
this.tableViewRowForm = val
|
||||
this.initPreviewData()
|
||||
this.tableViewRowForm = val.form
|
||||
this.initPreviewData(val.page)
|
||||
},
|
||||
|
||||
showTab() {
|
||||
@ -204,17 +140,4 @@ export default {
|
||||
.form-item {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.dialog-css>>>.el-dialog__title {
|
||||
font-size: 14px;
|
||||
}
|
||||
.dialog-css >>> .el-dialog__header {
|
||||
padding: 20px 20px 0;
|
||||
}
|
||||
.dialog-css >>> .el-dialog__body {
|
||||
padding: 10px 20px;
|
||||
}
|
||||
.dialog-css >>> .el-dialog__footer {
|
||||
padding-top: 30px;
|
||||
}
|
||||
</style>
|
||||
|
@ -176,6 +176,7 @@
|
||||
node-key="id"
|
||||
:expand-on-click-node="true"
|
||||
class="tree-list"
|
||||
highlight-current
|
||||
@node-click="sceneClick"
|
||||
>
|
||||
<span slot-scope="{ node, data }" class="custom-tree-node-list">
|
||||
@ -204,7 +205,7 @@
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item icon="el-icon-edit-outline" :command="beforeClickMore('editTable',data,node)">
|
||||
{{ $t('dataset.edit') }}
|
||||
{{ $t('dataset.rename') }}
|
||||
</el-dropdown-item>
|
||||
<!-- <el-dropdown-item icon="el-icon-right" :command="beforeClickMore('move',data,node)">-->
|
||||
<!-- {{$t('dataset.move_to')}}-->
|
||||
@ -523,10 +524,6 @@ export default {
|
||||
|
||||
back() {
|
||||
this.sceneMode = false
|
||||
// const route = this.$store.state.permission.currentRoutes
|
||||
// console.log(route)
|
||||
// this.$router.push('/dataset/index')
|
||||
this.$store.dispatch('dataset/setSceneData', null)
|
||||
this.$emit('switchComponent', { name: '' })
|
||||
},
|
||||
|
||||
@ -559,16 +556,7 @@ export default {
|
||||
},
|
||||
|
||||
sceneClick(data, node) {
|
||||
// console.log(data);
|
||||
this.$store.dispatch('dataset/setTable', null)
|
||||
this.$store.dispatch('dataset/setTable', data.id)
|
||||
// this.$router.push({
|
||||
// name: 'table',
|
||||
// params: {
|
||||
// table: data
|
||||
// }
|
||||
// })
|
||||
this.$emit('switchComponent', { name: 'ViewTable' })
|
||||
this.$emit('switchComponent', { name: 'ViewTable', param: data.id })
|
||||
},
|
||||
|
||||
refresh() {
|
||||
|
@ -24,6 +24,7 @@ import AddDB from './add/AddDB'
|
||||
import AddSQL from './add/AddSQL'
|
||||
import AddExcel from './add/AddExcel'
|
||||
import AddCustom from './add/AddCustom'
|
||||
import FieldEdit from './data/FieldEdit'
|
||||
|
||||
export default {
|
||||
name: 'DataSet',
|
||||
@ -54,6 +55,9 @@ export default {
|
||||
case 'AddCustom':
|
||||
this.component = AddCustom
|
||||
break
|
||||
case 'FieldEdit':
|
||||
this.component = FieldEdit
|
||||
break
|
||||
default:
|
||||
this.component = DataHome
|
||||
break
|
||||
|
135
frontend/src/views/system/datasource/form.vue
Normal file
135
frontend/src/views/system/datasource/form.vue
Normal file
@ -0,0 +1,135 @@
|
||||
<template>
|
||||
<layout-content :header="formType=='add' ? $t('datasource.create') : $t('datasource.modify')" back-name="数据源1">
|
||||
<el-form ref="dsForm" :model="form" :rules="rule" size="small" label-width="auto" label-position="right">
|
||||
<el-form-item :label="$t('commons.name')" prop="name">
|
||||
<el-input v-model="form.name" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.description')" prop="desc">
|
||||
|
||||
<el-input v-model="form.desc" autocomplete="off" type="textarea" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('datasource.type')" prop="type">
|
||||
<el-select v-model="form.type" :placeholder="$t('datasource.please_choose_type')" class="select-width" @change="changeType()">
|
||||
<el-option
|
||||
v-for="item in allTypes"
|
||||
:key="item.name"
|
||||
:label="item.name"
|
||||
:value="item.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.data_base')" prop="configuration.dataBase">
|
||||
<el-input v-model="form.configuration.dataBase" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.user_name')" prop="configuration.username">
|
||||
<el-input v-model="form.configuration.username" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.password')" prop="configuration.password">
|
||||
<el-input v-model="form.configuration.password" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.host')" prop="configuration.host">
|
||||
<el-input v-model="form.configuration.host" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.port')" prop="configuration.port">
|
||||
<el-input v-model="form.configuration.port" autocomplete="off" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="save">保存</el-button>
|
||||
<el-button type="primary" @click="validaDatasource">{{ $t('commons.validate') }}</el-button>
|
||||
<el-button @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</layout-content>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import { addDs, editDs, validateDs } from '@/api/system/datasource'
|
||||
export default {
|
||||
|
||||
components: { LayoutContent },
|
||||
data() {
|
||||
return {
|
||||
form: { configuration: {}},
|
||||
rule: {
|
||||
name: [{ required: true, message: this.$t('datasource.input_name'), trigger: 'blur' },
|
||||
{ min: 2, max: 25, message: this.$t('commons.input_limit', [2, 25]), trigger: 'blur' }],
|
||||
desc: [{ required: true, message: this.$t('datasource.input_desc'), trigger: 'blur' },
|
||||
{ min: 2, max: 50, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur' }],
|
||||
type: [{ required: true, message: this.$t('datasource.please_choose_type'), trigger: 'change' }],
|
||||
|
||||
'configuration.dataBase': [{ required: true, message: this.$t('datasource.please_input_data_base'), trigger: 'blur' }],
|
||||
'configuration.username': [{ required: true, message: this.$t('datasource.please_input_user_name'), trigger: 'blur' }],
|
||||
'configuration.password': [{ required: true, message: this.$t('datasource.please_input_password'), trigger: 'change' }],
|
||||
'configuration.host': [{ required: true, message: this.$t('datasource.please_input_host'), trigger: 'change' }],
|
||||
'configuration.port': [{ required: true, message: this.$t('datasource.please_input_port'), trigger: 'change' }]
|
||||
},
|
||||
allTypes: [{ name: 'mysql', type: 'jdbc' }, { name: 'sqlServer', type: 'jdbc' }]
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
if (this.$router.currentRoute.params && this.$router.currentRoute.params.id) {
|
||||
const row = this.$router.currentRoute.params
|
||||
this.edit(row)
|
||||
} else {
|
||||
this.create()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
create() {
|
||||
this.formType = 'add'
|
||||
},
|
||||
edit(row) {
|
||||
this.formType = 'modify'
|
||||
this.form = Object.assign({}, row)
|
||||
this.form.configuration = JSON.parse(this.form.configuration)
|
||||
},
|
||||
|
||||
reset() {
|
||||
this.$refs.dsForm.resetFields()
|
||||
},
|
||||
save() {
|
||||
this.$refs.dsForm.validate(valid => {
|
||||
if (valid) {
|
||||
const method = this.formType === 'add' ? addDs : editDs
|
||||
this.form.configuration = JSON.stringify(this.form.configuration)
|
||||
method(this.form).then(res => {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.backToList()
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
validaDatasource() {
|
||||
this.$refs.dsForm.validate(valid => {
|
||||
if (valid) {
|
||||
const data = JSON.parse(JSON.stringify(this.form))
|
||||
data.configuration = JSON.stringify(data.configuration)
|
||||
|
||||
validateDs(data).then(res => {
|
||||
this.$success(this.$t('datasource.validate_success'))
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
changeType() {
|
||||
for (let i = 0; i < this.allTypes.length; i++) {
|
||||
if (this.allTypes[i].name === this.form.type) {
|
||||
this.form.configuration.dataSourceType = this.allTypes[i].type
|
||||
}
|
||||
}
|
||||
},
|
||||
backToList() {
|
||||
this.$router.push({ name: '数据源1' })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -3,14 +3,14 @@
|
||||
<complex-table
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
:buttons="buttons"
|
||||
:header="header"
|
||||
|
||||
:search-config="searchConfig"
|
||||
:pagination-config="paginationConfig"
|
||||
@select="select"
|
||||
@search="search"
|
||||
>
|
||||
<template #buttons>
|
||||
|
||||
<template #toolbar>
|
||||
<fu-table-button v-permission="['datasource:add']" icon="el-icon-circle-plus-outline" :label="$t('datasource.create')" @click="create" />
|
||||
</template>
|
||||
|
||||
@ -125,7 +125,7 @@ export default {
|
||||
label: this.$t('commons.edit'), icon: 'el-icon-edit', click: this.edit,
|
||||
show: checkPermission(['datasource:edit'])
|
||||
}, {
|
||||
label: this.$t('commons.delete'), icon: 'el-icon-delete', type: 'danger', click: this.del,
|
||||
label: this.$t('commons.delete'), icon: 'el-icon-delete', type: 'danger', click: this._handleDelete,
|
||||
show: checkPermission(['datasource:del'])
|
||||
}
|
||||
],
|
||||
@ -154,23 +154,29 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
mounted() {
|
||||
this.search()
|
||||
},
|
||||
methods: {
|
||||
select(selection) {
|
||||
console.log(selection)
|
||||
},
|
||||
// create() {
|
||||
// this.formType = 'add'
|
||||
// this.dialogVisible = true
|
||||
// },
|
||||
create() {
|
||||
this.formType = 'add'
|
||||
this.dialogVisible = true
|
||||
this.$router.push({ name: '数据源表单' })
|
||||
},
|
||||
|
||||
// edit(row) {
|
||||
// this.formType = 'modify'
|
||||
// this.dialogVisible = true
|
||||
// this.form = Object.assign({}, row)
|
||||
// this.form.configuration = JSON.parse(this.form.configuration)
|
||||
// },
|
||||
edit(row) {
|
||||
this.formType = 'modify'
|
||||
this.dialogVisible = true
|
||||
this.form = Object.assign({}, row)
|
||||
this.form.configuration = JSON.parse(this.form.configuration)
|
||||
this.$router.push({ name: '数据源表单', params: row })
|
||||
},
|
||||
|
||||
_handleDelete(datasource) {
|
||||
@ -199,7 +205,7 @@ export default {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.search()
|
||||
this.dialogVisible = false
|
||||
});
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
173
frontend/src/views/system/dept/form.vue
Normal file
173
frontend/src/views/system/dept/form.vue
Normal file
@ -0,0 +1,173 @@
|
||||
<template>
|
||||
<layout-content :header="formType=='add' ? $t('organization.create') : $t('organization.modify')" back-name="组织管理">
|
||||
<el-form ref="deptForm" :model="form" :rules="rule" size="small" label-width="auto" label-position="right">
|
||||
<el-form-item label="组织名称" prop="name">
|
||||
<el-input v-model="form.name" />
|
||||
</el-form-item>
|
||||
<el-form-item label="组织排序" prop="deptSort">
|
||||
<el-input-number
|
||||
|
||||
v-model.number="form.deptSort"
|
||||
:min="0"
|
||||
:max="999"
|
||||
controls-position="right"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="顶级组织" prop="top">
|
||||
<el-radio-group v-model="form.top" @change="topChange">
|
||||
<el-radio :label="true">是</el-radio>
|
||||
<el-radio :label="false">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="状态" prop="enabled">
|
||||
<el-radio-group v-model="form.enabled" disabled>
|
||||
<el-radio :label="true">启用</el-radio>
|
||||
<el-radio :label="false">停用</el-radio>
|
||||
</el-radio-group>
|
||||
|
||||
<!-- <el-radio v-for="item in dict.dept_status" :key="item.id" v-model="form.enabled" :label="item.value">{{ item.label }}</el-radio> -->
|
||||
</el-form-item>
|
||||
<el-form-item v-if="!form.top" label="上级组织" prop="pid">
|
||||
<treeselect
|
||||
v-model="form.pid"
|
||||
:auto-load-root-options="false"
|
||||
:load-options="loadDepts"
|
||||
:options="depts"
|
||||
|
||||
placeholder="选择上级类目"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="save">保存</el-button>
|
||||
<el-button @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</layout-content>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { getDeptTree, treeByDeptId, addDept, editDept } from '@/api/system/dept'
|
||||
export default {
|
||||
|
||||
components: { LayoutContent, Treeselect },
|
||||
data() {
|
||||
return {
|
||||
defaultForm: { deptId: null, top: true, enabled: true, pid: null },
|
||||
maps: new Map(),
|
||||
form: {},
|
||||
rule: {
|
||||
name: [
|
||||
{ required: true, message: this.$t('organization.input_name'), trigger: 'blur' },
|
||||
{ min: 2, max: 25, message: this.$t('commons.input_limit', [2, 25]), trigger: 'blur' }
|
||||
],
|
||||
description: [
|
||||
{ max: 50, message: this.$t('commons.input_limit', [0, 50]), trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
depts: null,
|
||||
|
||||
formType: 'add'
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
if (this.$router.currentRoute.params && this.$router.currentRoute.params.deptId) {
|
||||
const row = this.$router.currentRoute.params
|
||||
this.edit(row)
|
||||
} else {
|
||||
this.create()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
create() {
|
||||
this.formType = 'add'
|
||||
this.form = Object.assign({}, this.defaultForm)
|
||||
},
|
||||
edit(row) {
|
||||
this.formType = 'modify'
|
||||
this.form = Object.assign({}, row)
|
||||
this.initDeptTree()
|
||||
},
|
||||
|
||||
initDeptTree() {
|
||||
treeByDeptId(this.form.pid || 0).then(res => {
|
||||
const results = res.data.map(node => {
|
||||
if (node.hasChildren && !node.children) {
|
||||
node.children = null
|
||||
}
|
||||
return node
|
||||
})
|
||||
this.depts = results
|
||||
})
|
||||
},
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === LOAD_ROOT_OPTIONS && !this.form.pid) {
|
||||
const _self = this
|
||||
treeByDeptId(0).then(res => {
|
||||
const results = res.data.map(node => {
|
||||
if (node.hasChildren && !node.children) {
|
||||
node.children = null
|
||||
}
|
||||
return node
|
||||
})
|
||||
_self.depts = results
|
||||
callback()
|
||||
})
|
||||
}
|
||||
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
const _self = this
|
||||
getDeptTree(parentNode.id).then(res => {
|
||||
parentNode.children = res.data.map(function(obj) {
|
||||
return _self.normalizer(obj)
|
||||
})
|
||||
callback()
|
||||
})
|
||||
}
|
||||
},
|
||||
normalizer(node) {
|
||||
if (node.hasChildren) {
|
||||
node.children = null
|
||||
}
|
||||
return {
|
||||
id: node.deptId,
|
||||
label: node.name,
|
||||
children: node.children
|
||||
}
|
||||
},
|
||||
topChange(value) {
|
||||
if (!value) {
|
||||
this.form.pid = null
|
||||
this.depts = null
|
||||
}
|
||||
},
|
||||
reset() {
|
||||
this.$refs.deptForm.resetFields()
|
||||
},
|
||||
save() {
|
||||
this.$refs.deptForm.validate(valid => {
|
||||
if (valid) {
|
||||
const method = this.formType === 'add' ? addDept : editDept
|
||||
method(this.form).then(res => {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.backToList()
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
backToList() {
|
||||
this.$router.push({ name: '组织管理' })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -18,12 +18,11 @@
|
||||
> -->
|
||||
<tree-table
|
||||
:columns="columns"
|
||||
:buttons="buttons"
|
||||
:header="header"
|
||||
|
||||
:search-config="searchConfig"
|
||||
@search="search"
|
||||
>
|
||||
<template #buttons>
|
||||
<template #toolbar>
|
||||
<fu-table-button v-permission="['dept:add']" icon="el-icon-circle-plus-outline" :label="$t('organization.create')" @click="create" />
|
||||
</template>
|
||||
<el-table
|
||||
@ -86,7 +85,7 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="顶级组织" prop="top">
|
||||
<el-radio-group v-model="form.top" style="width: 140px">
|
||||
<el-radio-group v-model="form.top" style="width: 140px" @change="topChange">
|
||||
<el-radio :label="true">是</el-radio>
|
||||
<el-radio :label="false">否</el-radio>
|
||||
</el-radio-group>
|
||||
@ -199,22 +198,28 @@ export default {
|
||||
isLazy: true
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
mounted() {
|
||||
this.form = Object.assign({}, this.defaultForm)
|
||||
this.search()
|
||||
},
|
||||
methods: {
|
||||
// create() {
|
||||
// this.form = Object.assign({}, this.defaultForm)
|
||||
// this.dialogOrgAddVisible = true
|
||||
// this.formType = 'add'
|
||||
// },
|
||||
// edit(row) {
|
||||
// this.dialogOrgAddVisible = true
|
||||
// this.formType = 'modify'
|
||||
// this.oldPid = row.pid
|
||||
// this.form = Object.assign({}, row)
|
||||
// this.treeByRow(row)
|
||||
// },
|
||||
create() {
|
||||
this.form = Object.assign({}, this.defaultForm)
|
||||
this.dialogOrgAddVisible = true
|
||||
this.formType = 'add'
|
||||
this.$router.push({ name: '组织表单' })
|
||||
},
|
||||
edit(row) {
|
||||
this.dialogOrgAddVisible = true
|
||||
this.formType = 'modify'
|
||||
this.oldPid = row.pid
|
||||
this.form = Object.assign({}, row)
|
||||
this.treeByRow(row)
|
||||
this.$router.push({ name: '组织表单', params: row })
|
||||
},
|
||||
|
||||
treeByRow(row) {
|
||||
@ -507,6 +512,10 @@ export default {
|
||||
}
|
||||
})
|
||||
return roots
|
||||
},
|
||||
topChange(value) {
|
||||
// console.log(value)
|
||||
!value && (this.depts = null)
|
||||
}
|
||||
|
||||
}
|
||||
|
187
frontend/src/views/system/menu/form.vue
Normal file
187
frontend/src/views/system/menu/form.vue
Normal file
@ -0,0 +1,187 @@
|
||||
<template>
|
||||
<layout-content :header="formType=='add' ? $t('menu.create') : $t('menu.modify')" back-name="菜单管理">
|
||||
<el-form ref="menuForm" :model="form" :rules="rule" size="small" label-width="auto" label-position="right">
|
||||
<el-form-item label="菜单类型" prop="type">
|
||||
<el-radio-group v-model="form.type" size="mini" :disabled="formType!=='add'">
|
||||
<el-radio-button label="0">目录</el-radio-button>
|
||||
<el-radio-button label="1">菜单</el-radio-button>
|
||||
<el-radio-button label="2">按钮</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.type!== 2" label="菜单图标" prop="icon">
|
||||
<el-popover
|
||||
placement="bottom-start"
|
||||
width="425"
|
||||
trigger="click"
|
||||
@show="$refs['iconSelect'].reset()"
|
||||
>
|
||||
<IconSelect ref="iconSelect" @selected="selected" />
|
||||
<el-input slot="reference" v-model="form.icon" placeholder="点击选择图标" readonly>
|
||||
<svg-icon v-if="form.icon" slot="prefix" :icon-class="form.icon" class="el-input__icon" style="height: 32px;width: 16px;" />
|
||||
<i v-else slot="prefix" class="el-icon-search el-input__icon" />
|
||||
</el-input>
|
||||
</el-popover>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="form.type !== 2" label="菜单标题" prop="title">
|
||||
<el-input v-model="form.title" placeholder="菜单标题" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.type === 2" label="按钮名称" prop="title">
|
||||
<el-input v-model="form.title" placeholder="按钮名称" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.type !== 0" label="权限标识" prop="permission">
|
||||
<el-input v-model="form.permission" :disabled="form.iframe || formType!=='add'" placeholder="权限标识" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.type !== 2" label="路由地址" prop="path">
|
||||
<el-input v-model="form.path" placeholder="路由地址" :disabled="formType!=='add'" />
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单排序" prop="menuSort">
|
||||
<el-input-number v-model.number="form.menuSort" :min="0" :max="999" controls-position="right" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="!form.iframe && form.type === 1" label="组件名称" prop="componentName">
|
||||
<el-input v-model="form.componentName" :disabled="formType!=='add'" placeholder="匹配组件内Name字段" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="!form.iframe && form.type === 1" label="组件路径" prop="component">
|
||||
<el-input v-model="form.component" :disabled="formType!=='add'" placeholder="组件路径" />
|
||||
</el-form-item>
|
||||
<el-form-item label="上级类目" prop="pid">
|
||||
<treeselect
|
||||
v-model="form.pid"
|
||||
:disabled="formType!=='add'"
|
||||
:options="menus"
|
||||
:load-options="loadMenus"
|
||||
|
||||
placeholder="选择上级类目"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="save">保存</el-button>
|
||||
<el-button @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</layout-content>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import IconSelect from '@/components/IconSelect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { addMenu, editMenu, getMenusTree, treeByMenuId } from '@/api/system/menu'
|
||||
export default {
|
||||
|
||||
components: { LayoutContent, Treeselect, IconSelect },
|
||||
data() {
|
||||
return {
|
||||
topMunu: { id: 0, label: '顶级目录', children: null },
|
||||
defaultForm: { menuId: null, title: null, menuSort: 999, path: null, component: null, componentName: null, iframe: false, pid: 0, icon: null, cache: false, hidden: false, type: 0, permission: null },
|
||||
form: {},
|
||||
rule: {
|
||||
name: [
|
||||
{ required: true, message: this.$t('organization.input_name'), trigger: 'blur' },
|
||||
{ min: 2, max: 25, message: this.$t('commons.input_limit', [2, 25]), trigger: 'blur' }
|
||||
],
|
||||
description: [
|
||||
{ max: 50, message: this.$t('commons.input_limit', [0, 50]), trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
menus: null,
|
||||
maps: new Map(),
|
||||
formType: 'add'
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
if (this.$router.currentRoute.params && this.$router.currentRoute.params.menuId) {
|
||||
const row = this.$router.currentRoute.params
|
||||
this.edit(row)
|
||||
} else {
|
||||
this.create()
|
||||
}
|
||||
this.initData()
|
||||
},
|
||||
methods: {
|
||||
create() {
|
||||
this.formType = 'add'
|
||||
this.form = Object.assign({}, this.defaultForm)
|
||||
},
|
||||
edit(row) {
|
||||
this.formType = 'modify'
|
||||
this.form = Object.assign({}, row)
|
||||
this.initMenuTree()
|
||||
},
|
||||
initMenuTree() {
|
||||
treeByMenuId(this.form.pid || 0).then(res => {
|
||||
const results = res.data.map(node => {
|
||||
if (node.hasChildren && !node.children) {
|
||||
node.children = null
|
||||
}
|
||||
return node
|
||||
})
|
||||
this.menus = results
|
||||
})
|
||||
},
|
||||
|
||||
// 获取弹窗内部门数据
|
||||
loadMenus({ action, parentNode, callback }) {
|
||||
if (action === LOAD_ROOT_OPTIONS) {
|
||||
const _self = this
|
||||
!this.menus && getMenusTree('0').then(res => {
|
||||
_self.menus = res.data.map(node => _self.normalizer(node))
|
||||
callback()
|
||||
})
|
||||
}
|
||||
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
const _self = this
|
||||
getMenusTree(parentNode.id).then(res => {
|
||||
parentNode.children = res.data.map(function(obj) {
|
||||
return _self.normalizer(obj)
|
||||
})
|
||||
callback()
|
||||
})
|
||||
}
|
||||
},
|
||||
initData() {
|
||||
this.menus = []
|
||||
this.menus.push(this.topMunu)
|
||||
},
|
||||
normalizer(node) {
|
||||
if (node.hasChildren) {
|
||||
node.children = null
|
||||
}
|
||||
return {
|
||||
id: node.menuId,
|
||||
label: node.title,
|
||||
children: node.children
|
||||
}
|
||||
},
|
||||
|
||||
selected(name) {
|
||||
this.form.icon = name
|
||||
},
|
||||
|
||||
reset() {
|
||||
this.$refs.menuForm.resetFields()
|
||||
},
|
||||
save() {
|
||||
this.$refs.menuForm.validate(valid => {
|
||||
if (valid) {
|
||||
const method = this.formType === 'add' ? addMenu : editMenu
|
||||
method(this.form).then(res => {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.backToList()
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
backToList() {
|
||||
this.$router.push({ name: '菜单管理' })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -2,12 +2,11 @@
|
||||
<layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
|
||||
<tree-table
|
||||
:columns="columns"
|
||||
:buttons="buttons"
|
||||
:header="header"
|
||||
|
||||
:search-config="searchConfig"
|
||||
@search="initTableData"
|
||||
>
|
||||
<template v-permission="['menu:add']" #buttons>
|
||||
<template #toolbar>
|
||||
<fu-table-button v-permission="['menu:add']" icon="el-icon-circle-plus-outline" :label="$t('menu.create')" @click="create" />
|
||||
</template>
|
||||
|
||||
@ -173,7 +172,7 @@ export default {
|
||||
}
|
||||
],
|
||||
searchConfig: {
|
||||
useQuickSearch: false,
|
||||
useQuickSearch: true,
|
||||
useComplexSearch: false,
|
||||
quickPlaceholder: '按姓名搜索',
|
||||
components: [
|
||||
@ -195,26 +194,32 @@ export default {
|
||||
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
mounted() {
|
||||
this.form = Object.assign({}, this.defaultForm)
|
||||
this.initTableData()
|
||||
},
|
||||
methods: {
|
||||
// create() {
|
||||
// this.form = Object.assign({}, this.defaultForm)
|
||||
// this.dialogVisible = true
|
||||
// this.formType = 'add'
|
||||
// },
|
||||
create() {
|
||||
this.form = Object.assign({}, this.defaultForm)
|
||||
this.dialogVisible = true
|
||||
this.formType = 'add'
|
||||
this.$router.push({ name: '菜单表单' })
|
||||
},
|
||||
search(condition) {
|
||||
console.log(condition)
|
||||
},
|
||||
|
||||
// edit(row) {
|
||||
// this.dialogVisible = true
|
||||
// this.formType = 'modify'
|
||||
// this.oldPid = row.pid
|
||||
// this.form = Object.assign({}, row)
|
||||
// this.treeByRow(row)
|
||||
// },
|
||||
edit(row) {
|
||||
this.dialogVisible = true
|
||||
this.formType = 'modify'
|
||||
this.oldPid = row.pid
|
||||
this.form = Object.assign({}, row)
|
||||
this.treeByRow(row)
|
||||
this.$router.push({ name: '菜单表单', params: row })
|
||||
},
|
||||
|
||||
treeByRow(row) {
|
||||
|
109
frontend/src/views/system/role/form.vue
Normal file
109
frontend/src/views/system/role/form.vue
Normal file
@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<layout-content :header="formType=='add' ? $t('role.add') : $t('role.modify')" back-name="角色管理">
|
||||
<el-form ref="roleForm" :model="form" :rules="rule" size="small" label-width="auto" label-position="right">
|
||||
<el-form-item label="角色名称" prop="name">
|
||||
<el-input v-model="form.name" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="角色代码" prop="code">
|
||||
<el-input v-model="form.code" :disabled="formType !== 'add'" />
|
||||
</el-form-item> -->
|
||||
|
||||
<el-form-item label="描述信息" prop="description">
|
||||
<el-input v-model="form.description" type="textarea" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="save">保存</el-button>
|
||||
<el-button @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</layout-content>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import { addRole, editRole, allRoles } from '@/api/system/role'
|
||||
export default {
|
||||
|
||||
components: { LayoutContent },
|
||||
data() {
|
||||
return {
|
||||
formType: 'add',
|
||||
form: {},
|
||||
rule: {
|
||||
name: [
|
||||
{ required: true, trigger: 'blur', validator: this.roleValidator }
|
||||
],
|
||||
code: [{ required: true, message: '请输入代码', trigger: 'blur' }]
|
||||
},
|
||||
roles: [],
|
||||
originName: null
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
if (this.$router.currentRoute.params && this.$router.currentRoute.params.roleId) {
|
||||
const row = this.$router.currentRoute.params
|
||||
this.edit(row)
|
||||
} else {
|
||||
this.create()
|
||||
}
|
||||
this.queryAllRoles()
|
||||
},
|
||||
methods: {
|
||||
create() {
|
||||
this.formType = 'add'
|
||||
},
|
||||
edit(row) {
|
||||
this.formType = 'modify'
|
||||
this.form = Object.assign({}, row)
|
||||
this.originName = row.name
|
||||
},
|
||||
|
||||
reset() {
|
||||
this.$refs.roleForm.resetFields()
|
||||
},
|
||||
save() {
|
||||
this.$refs.roleForm.validate(valid => {
|
||||
if (valid) {
|
||||
const method = this.formType === 'add' ? addRole : editRole
|
||||
method(this.form).then(res => {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.backToList()
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
queryAllRoles() {
|
||||
allRoles().then(res => {
|
||||
this.roles = res.data
|
||||
})
|
||||
},
|
||||
nameRepeat(value) {
|
||||
if (!this.roles || this.roles.length === 0) {
|
||||
return false
|
||||
}
|
||||
// 编辑场景 不能 因为名称重复而报错
|
||||
if (this.formType === 'modify' && this.originName === value) {
|
||||
return false
|
||||
}
|
||||
return this.roles.some(role => role.name === value)
|
||||
},
|
||||
roleValidator(rule, value, callback) {
|
||||
if (!value || value.length === 0) {
|
||||
callback(new Error('请输入名称'))
|
||||
} else if (this.nameRepeat(value)) {
|
||||
callback(new Error('角色名称已存在'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
backToList() {
|
||||
this.$router.push({ name: '角色管理' })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -7,19 +7,18 @@
|
||||
highlight-current-row
|
||||
:data="tableData"
|
||||
:columns="columns"
|
||||
:buttons="buttons"
|
||||
:header="header"
|
||||
|
||||
:search-config="searchConfig"
|
||||
:pagination-config="paginationConfig"
|
||||
@search="search"
|
||||
@row-click="rowClick"
|
||||
>
|
||||
<template #buttons>
|
||||
<template #toolbar>
|
||||
<fu-table-button icon="el-icon-circle-plus-outline" :label="$t('role.add')" @click="create" />
|
||||
</template>
|
||||
|
||||
<el-table-column prop="name" label="名称" />
|
||||
<el-table-column prop="code" label="代码" />
|
||||
<!-- <el-table-column prop="code" label="代码" /> -->
|
||||
<el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建日期">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
|
||||
@ -62,9 +61,9 @@
|
||||
<el-input v-model="form.name" style="width: 380px;" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="角色代码" prop="code">
|
||||
<!-- <el-form-item label="角色代码" prop="code">
|
||||
<el-input v-model="form.code" style="width: 380px;" />
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
|
||||
<el-form-item label="描述信息" prop="description">
|
||||
<el-input v-model="form.description" style="width: 380px;" rows="5" type="textarea" />
|
||||
@ -107,7 +106,8 @@ export default {
|
||||
rule: {
|
||||
name: [
|
||||
{ required: true, message: '请输入名称', trigger: 'blur' }
|
||||
]
|
||||
],
|
||||
code: [{ required: true, message: '请输入代码', trigger: 'blur' }]
|
||||
},
|
||||
currentRow: null,
|
||||
permission: {
|
||||
@ -145,17 +145,20 @@ export default {
|
||||
watch: {
|
||||
currentRow: 'currentRowChange'
|
||||
},
|
||||
activated() {
|
||||
mounted() {
|
||||
this.search()
|
||||
},
|
||||
methods: {
|
||||
handleClick(tab, event) {
|
||||
console.log(tab, event)
|
||||
},
|
||||
// create() {
|
||||
// this.form = {}
|
||||
// this.formType = 'add'
|
||||
// this.dialogVisible = true
|
||||
// },
|
||||
create() {
|
||||
this.form = {}
|
||||
this.formType = 'add'
|
||||
this.dialogVisible = true
|
||||
this.$router.push({ name: '角色表单' })
|
||||
},
|
||||
search(condition) {
|
||||
const temp = formatCondition(condition)
|
||||
@ -167,10 +170,13 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
// edit(row) {
|
||||
// this.formType = 'modify'
|
||||
// this.dialogVisible = true
|
||||
// this.form = Object.assign({}, row)
|
||||
// },
|
||||
edit(row) {
|
||||
this.formType = 'modify'
|
||||
this.dialogVisible = true
|
||||
this.form = Object.assign({}, row)
|
||||
this.$router.push({ name: '角色表单', params: row })
|
||||
},
|
||||
|
||||
saveRole(roleForm) {
|
||||
|
263
frontend/src/views/system/user/form.vue
Normal file
263
frontend/src/views/system/user/form.vue
Normal file
@ -0,0 +1,263 @@
|
||||
<template>
|
||||
<layout-content :header="formType=='add' ? $t('user.create') : $t('user.modify')" back-name="用户管理">
|
||||
<el-form ref="createUserForm" :model="form" :rules="rule" size="small" label-width="auto" label-position="right">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="form.username" />
|
||||
</el-form-item>
|
||||
<el-form-item label="电话" prop="phone">
|
||||
<el-input v-model="form.phone" />
|
||||
</el-form-item>
|
||||
<el-form-item label="昵称" prop="nickName">
|
||||
<el-input v-model="form.nickName" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="form.email" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="性别">
|
||||
<el-radio-group v-model="form.gender" style="width: 178px">
|
||||
<el-radio label="男">男</el-radio>
|
||||
<el-radio label="女">女</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-radio-group v-model="form.enabled" style="width: 140px">
|
||||
<el-radio :label="1">启用</el-radio>
|
||||
<el-radio :label="0">停用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="部门" prop="dept">
|
||||
<treeselect
|
||||
v-model="form.deptId"
|
||||
:options="depts"
|
||||
:load-options="loadDepts"
|
||||
:auto-load-root-options="false"
|
||||
placeholder="选择部门"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色" prop="roleIds">
|
||||
<el-select
|
||||
v-model="form.roleIds"
|
||||
style="width: 100%"
|
||||
multiple
|
||||
placeholder="请选择"
|
||||
@remove-tag="deleteTag"
|
||||
@change="changeRole"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in roles"
|
||||
:key="item.name"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="save">保存</el-button>
|
||||
<el-button @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</layout-content>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import { PHONE_REGEX } from '@/utils/validate'
|
||||
import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { getDeptTree, treeByDeptId } from '@/api/system/dept'
|
||||
import { allRoles } from '@/api/system/role'
|
||||
import { addUser, editUser } from '@/api/system/user'
|
||||
export default {
|
||||
|
||||
components: { LayoutContent, Treeselect },
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
roles: [{
|
||||
id: ''
|
||||
}]
|
||||
},
|
||||
rule: {
|
||||
username: [
|
||||
{ required: true, message: this.$t('user.input_id'), trigger: 'blur' },
|
||||
{ min: 1, max: 50, message: this.$t('commons.input_limit', [1, 50]), trigger: 'blur' },
|
||||
{
|
||||
required: true,
|
||||
pattern: '^[^\u4e00-\u9fa5]+$',
|
||||
message: this.$t('user.special_characters_are_not_supported'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
nickName: [
|
||||
{ required: true, message: this.$t('user.input_name'), trigger: 'blur' },
|
||||
{ min: 2, max: 50, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur' },
|
||||
{
|
||||
required: true,
|
||||
message: this.$t('user.special_characters_are_not_supported'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
phone: [
|
||||
{
|
||||
pattern: PHONE_REGEX,
|
||||
message: this.$t('user.mobile_number_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
email: [
|
||||
{ required: true, message: this.$t('user.input_email'), trigger: 'blur' },
|
||||
{
|
||||
required: true,
|
||||
pattern: /^[a-zA-Z0-9_._-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
|
||||
message: this.$t('user.email_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: this.$t('user.input_password'), trigger: 'blur' },
|
||||
{
|
||||
required: true,
|
||||
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,30}$/,
|
||||
message: this.$t('member.password_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
newPassword: [
|
||||
{ required: true, message: this.$t('user.input_password'), trigger: 'blur' },
|
||||
{
|
||||
required: true,
|
||||
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,30}$/,
|
||||
message: this.$t('member.password_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
roleIds: [{ required: true, message: this.$t('user.input_roles'), trigger: 'change' }]
|
||||
|
||||
},
|
||||
defaultForm: { id: null, username: null, nickName: null, gender: '男', email: null, enabled: 1, deptId: null, phone: null, roleIds: [] },
|
||||
depts: null,
|
||||
roles: [],
|
||||
roleDatas: [],
|
||||
userRoles: [],
|
||||
formType: 'add'
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
if (this.$router.currentRoute.params && this.$router.currentRoute.params.id) {
|
||||
const row = this.$router.currentRoute.params
|
||||
this.edit(row)
|
||||
} else {
|
||||
this.create()
|
||||
}
|
||||
this.initRoles()
|
||||
},
|
||||
methods: {
|
||||
create() {
|
||||
this.depts = null
|
||||
this.formType = 'add'
|
||||
this.form = Object.assign({}, this.defaultForm)
|
||||
console.log(this.form)
|
||||
},
|
||||
edit(row) {
|
||||
this.depts = null
|
||||
this.formType = 'modify'
|
||||
this.dialogVisible = true
|
||||
this.form = Object.assign({}, row)
|
||||
if (this.form.deptId === 0) {
|
||||
this.form.deptId = null
|
||||
}
|
||||
this.initDeptTree()
|
||||
},
|
||||
initRoles() {
|
||||
allRoles().then(res => {
|
||||
this.roles = res.data
|
||||
})
|
||||
},
|
||||
initDeptTree() {
|
||||
treeByDeptId(this.form.deptId || 0).then(res => {
|
||||
const results = res.data.map(node => {
|
||||
if (node.hasChildren && !node.children) {
|
||||
node.children = null
|
||||
// delete node.children
|
||||
}
|
||||
return node
|
||||
})
|
||||
this.depts = results
|
||||
})
|
||||
},
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === LOAD_ROOT_OPTIONS && !this.form.deptId) {
|
||||
const _self = this
|
||||
treeByDeptId(0).then(res => {
|
||||
const results = res.data.map(node => {
|
||||
if (node.hasChildren && !node.children) {
|
||||
node.children = null
|
||||
}
|
||||
return node
|
||||
})
|
||||
_self.depts = results
|
||||
callback()
|
||||
})
|
||||
}
|
||||
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
const _self = this
|
||||
getDeptTree(parentNode.id).then(res => {
|
||||
parentNode.children = res.data.map(function(obj) {
|
||||
return _self.normalizer(obj)
|
||||
})
|
||||
callback()
|
||||
})
|
||||
}
|
||||
},
|
||||
normalizer(node) {
|
||||
if (node.hasChildren) {
|
||||
node.children = null
|
||||
}
|
||||
return {
|
||||
id: node.deptId,
|
||||
label: node.name,
|
||||
children: node.children
|
||||
}
|
||||
},
|
||||
deleteTag(value) {
|
||||
this.userRoles.forEach(function(data, index) {
|
||||
if (data.id === value) {
|
||||
this.userRoles.splice(index, value)
|
||||
}
|
||||
}.bind(this))
|
||||
},
|
||||
changeRole(value) {
|
||||
this.userRoles = []
|
||||
value.forEach(function(data, index) {
|
||||
const role = { id: data }
|
||||
this.userRoles.push(role)
|
||||
}.bind(this))
|
||||
},
|
||||
reset() {
|
||||
this.$refs.createUserForm.resetFields()
|
||||
},
|
||||
save() {
|
||||
this.$refs.createUserForm.validate(valid => {
|
||||
if (valid) {
|
||||
const method = this.formType === 'add' ? addUser : editUser
|
||||
method(this.form).then(res => {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.backToList()
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
backToList() {
|
||||
this.$router.push({ name: '用户管理' })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -3,18 +3,16 @@
|
||||
<complex-table
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
:buttons="buttons"
|
||||
:header="header"
|
||||
|
||||
:search-config="searchConfig"
|
||||
:pagination-config="paginationConfig"
|
||||
@select="select"
|
||||
@search="search"
|
||||
>
|
||||
<template #buttons>
|
||||
<template #toolbar>
|
||||
<fu-table-button v-permission="['user:add']" icon="el-icon-circle-plus-outline" :label="$t('user.create')" @click="create" />
|
||||
</template>
|
||||
|
||||
<!-- <el-table-column type="selection" fix /> -->
|
||||
<el-table-column prop="username" label="ID" width="80" />
|
||||
<el-table-column prop="nickName" :label="$t('commons.name')" width="140" />
|
||||
<el-table-column prop="gender" label="性别" width="50" />
|
||||
@ -109,7 +107,6 @@
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!--Changing user password in system settings-->
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
:title="$t('member.edit_password')"
|
||||
@ -145,9 +142,7 @@
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import ComplexTable from '@/components/business/complex-table'
|
||||
// import conditionTable from '@/components/business/condition-table'
|
||||
// import CustomCondition from './CustomCondtion'
|
||||
// import { GridButton } from '@/components/GridButton'
|
||||
|
||||
import { checkPermission } from '@/utils/permission'
|
||||
import { formatCondition } from '@/utils/index'
|
||||
import { PHONE_REGEX } from '@/utils/validate'
|
||||
@ -285,7 +280,7 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
mounted() {
|
||||
// this.form = Object.assign({}, this.defaultForm);
|
||||
this.allRoles()
|
||||
this.search()
|
||||
@ -306,23 +301,28 @@ export default {
|
||||
this.paginationConfig.total = response.data.itemCount
|
||||
})
|
||||
},
|
||||
|
||||
create() {
|
||||
this.depts = null
|
||||
this.formType = 'add'
|
||||
this.form = Object.assign({}, this.defaultForm)
|
||||
this.dialogVisible = true
|
||||
this.$router.push({ name: '用户表单' })
|
||||
},
|
||||
// create() {
|
||||
// this.depts = null
|
||||
// this.formType = 'add'
|
||||
// this.form = Object.assign({}, this.defaultForm)
|
||||
// this.dialogVisible = true
|
||||
// },
|
||||
edit(row) {
|
||||
this.depts = null
|
||||
this.formType = 'modify'
|
||||
this.dialogVisible = true
|
||||
this.form = Object.assign({}, row)
|
||||
if (this.form.deptId === 0) {
|
||||
this.form.deptId = null
|
||||
}
|
||||
this.initDeptTree()
|
||||
this.$router.push({ name: '用户表单', params: row })
|
||||
},
|
||||
// edit(row) {
|
||||
// this.depts = null
|
||||
// this.formType = 'modify'
|
||||
// this.dialogVisible = true
|
||||
// this.form = Object.assign({}, row)
|
||||
// if (this.form.deptId === 0) {
|
||||
// this.form.deptId = null
|
||||
// }
|
||||
// this.initDeptTree()
|
||||
// },
|
||||
editPassword(row) {
|
||||
this.editPasswordVisible = true
|
||||
const tempForm = Object.assign({}, row)
|
||||
|
Loading…
Reference in New Issue
Block a user