forked from github/dataease
Merge branch 'dev' into pr@dev@feat_de_tabs
This commit is contained in:
commit
2778d9eb43
1
.gitignore
vendored
1
.gitignore
vendored
@ -52,6 +52,7 @@ pnpm-debug.log*
|
||||
*.classpath
|
||||
*.project
|
||||
.settings/
|
||||
.lh
|
||||
|
||||
|
||||
package-lock.json
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>dataease-server</artifactId>
|
||||
<groupId>io.dataease</groupId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.3.0</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@ -214,7 +214,7 @@
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.10.3</version>
|
||||
<version>1.14.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -226,7 +226,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>1.20</version>
|
||||
<version>1.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -252,11 +252,11 @@
|
||||
<version>20171018</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.6</version>
|
||||
</dependency>
|
||||
<version>4.5.13</version>
|
||||
</dependency>-->
|
||||
<!-- 反射工具包 -->
|
||||
<dependency>
|
||||
<groupId>net.oneandone.reflections8</groupId>
|
||||
@ -316,7 +316,7 @@
|
||||
<dependency>
|
||||
<groupId>io.dataease</groupId>
|
||||
<artifactId>dataease-plugin-interface</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -338,10 +338,21 @@
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.1.2</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-ldap</artifactId>
|
||||
</dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>io.dataease.kettle</groupId>-->
|
||||
<!-- <artifactId>ck-plugin</artifactId>-->
|
||||
<!-- <version>1.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>ru.yandex.clickhouse</groupId>
|
||||
<artifactId>clickhouse-jdbc</artifactId>
|
||||
<version>0.3.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -5,7 +5,6 @@ import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.auth.api.dto.LoginDto;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@ -41,4 +40,13 @@ public interface AuthApi {
|
||||
@PostMapping("/validateName")
|
||||
Boolean validateName(Map<String, String> nameDto);
|
||||
|
||||
@ApiOperation("是否开启ldap")
|
||||
@PostMapping("/isOpenLdap")
|
||||
boolean isOpenLdap();
|
||||
|
||||
|
||||
@ApiOperation("是否开启oidc")
|
||||
@PostMapping("/isOpenOidc")
|
||||
boolean isOpenOidc();
|
||||
|
||||
}
|
||||
|
@ -13,4 +13,12 @@ public class LoginDto implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "密码", required = true)
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 0: 默认登录
|
||||
* 1:ldap登录
|
||||
* 2:单点登录
|
||||
*/
|
||||
@ApiModelProperty(value = "登录方式", required = true, allowableValues = "0, 1, 2")
|
||||
private int loginType;
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ public class TokenInfo implements Serializable {
|
||||
|
||||
private Long userId;
|
||||
|
||||
/* private String idToken; */
|
||||
|
||||
public String format(){
|
||||
return username + "," +userId;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.web.filter.authc.LogoutFilter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
|
@ -14,20 +14,26 @@ import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.util.PluginUtils;
|
||||
import io.dataease.plugins.xpack.ldap.dto.request.LdapValidateRequest;
|
||||
import io.dataease.plugins.xpack.ldap.dto.response.ValidateResult;
|
||||
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
||||
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
public class AuthServer implements AuthApi {
|
||||
|
||||
@ -35,10 +41,29 @@ public class AuthServer implements AuthApi {
|
||||
private AuthUserService authUserService;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Object login(@RequestBody LoginDto loginDto) throws Exception {
|
||||
String username = loginDto.getUsername();
|
||||
String password = loginDto.getPassword();
|
||||
|
||||
|
||||
String pwd = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, password);
|
||||
// 增加ldap登录方式
|
||||
Integer loginType = loginDto.getLoginType();
|
||||
boolean isSupportLdap = authUserService.supportLdap();
|
||||
if (loginType == 1 && isSupportLdap) {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
LdapValidateRequest request = LdapValidateRequest.builder().userName(username).password(pwd).build();
|
||||
ValidateResult validateResult = ldapXpackService.login(request);
|
||||
if (!validateResult.isSuccess()) {
|
||||
DataEaseException.throwException(validateResult.getMsg());
|
||||
}
|
||||
username = validateResult.getUserName();
|
||||
}
|
||||
// 增加ldap登录方式
|
||||
|
||||
SysUserEntity user = authUserService.getUserByName(username);
|
||||
|
||||
if (ObjectUtils.isEmpty(user)) {
|
||||
@ -48,14 +73,19 @@ public class AuthServer implements AuthApi {
|
||||
DataEaseException.throwException(Translator.get("i18n_id_or_pwd_error"));
|
||||
}
|
||||
String realPwd = user.getPassword();
|
||||
//私钥解密
|
||||
String pwd = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, password);
|
||||
//md5加密
|
||||
pwd = CodingUtil.md5(pwd);
|
||||
|
||||
if (!StringUtils.equals(pwd, realPwd)) {
|
||||
DataEaseException.throwException(Translator.get("i18n_id_or_pwd_error"));
|
||||
// 普通登录需要验证密码
|
||||
if (loginType == 0 || !isSupportLdap) {
|
||||
//私钥解密
|
||||
|
||||
//md5加密
|
||||
pwd = CodingUtil.md5(pwd);
|
||||
|
||||
if (!StringUtils.equals(pwd, realPwd)) {
|
||||
DataEaseException.throwException(Translator.get("i18n_id_or_pwd_error"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(username).build();
|
||||
String token = JWTUtils.sign(tokenInfo, realPwd);
|
||||
@ -85,6 +115,16 @@ public class AuthServer implements AuthApi {
|
||||
@Override
|
||||
public String logout() {
|
||||
String token = ServletUtils.getToken();
|
||||
|
||||
if (isOpenOidc()) {
|
||||
HttpServletRequest request = ServletUtils.request();
|
||||
String idToken = request.getHeader("IdToken");
|
||||
if (StringUtils.isNotBlank(idToken)) {
|
||||
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||
oidcXpackService.logout(idToken);
|
||||
}
|
||||
|
||||
}
|
||||
if (StringUtils.isEmpty(token) || StringUtils.equals("null", token) || StringUtils.equals("undefined", token)) {
|
||||
return "success";
|
||||
}
|
||||
@ -108,6 +148,23 @@ public class AuthServer implements AuthApi {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenLdap() {
|
||||
Boolean licValid = PluginUtils.licValid();
|
||||
if(!licValid) return false;
|
||||
boolean open = authUserService.supportLdap();
|
||||
return open;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenOidc() {
|
||||
Boolean licValid = PluginUtils.licValid();
|
||||
if(!licValid) return false;
|
||||
return authUserService.supportOidc();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*@Override
|
||||
public Boolean isLogin() {
|
||||
return null;
|
||||
|
@ -13,6 +13,8 @@ public interface AuthUserService {
|
||||
|
||||
SysUserEntity getUserByName(String username);
|
||||
|
||||
SysUserEntity getUserBySub(String sub);
|
||||
|
||||
List<String> roles(Long userId);
|
||||
|
||||
List<String> permissions(Long userId);
|
||||
@ -21,6 +23,10 @@ public interface AuthUserService {
|
||||
|
||||
void clearCache(Long userId);
|
||||
|
||||
boolean supportLdap();
|
||||
|
||||
Boolean supportOidc();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,11 @@ import io.dataease.base.mapper.ext.AuthMapper;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
||||
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@ -16,6 +21,7 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -46,6 +52,11 @@ public class AuthUserServiceImpl implements AuthUserService {
|
||||
return authMapper.findUserByName(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserEntity getUserBySub(String sub) {
|
||||
return authMapper.findUserBySub(sub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> roles(Long userId){
|
||||
return authMapper.roleCodes(userId);
|
||||
@ -102,4 +113,23 @@ public class AuthUserServiceImpl implements AuthUserService {
|
||||
LogUtil.info("正在清除用户缓存【{}】",userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportLdap() {
|
||||
Map<String, LdapXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((LdapXpackService.class));
|
||||
if(beansOfType.keySet().size() == 0) return false;
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
if(ObjectUtils.isEmpty(ldapXpackService)) return false;
|
||||
return ldapXpackService.isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean supportOidc() {
|
||||
Map<String, OidcXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((OidcXpackService.class));
|
||||
if(beansOfType.keySet().size() == 0) return false;
|
||||
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||
if(ObjectUtils.isEmpty(oidcXpackService)) return false;
|
||||
return oidcXpackService.isSuuportOIDC();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -56,8 +56,15 @@ public class ShiroServiceImpl implements ShiroService {
|
||||
// filterChainDefinitionMap.put("/axios.map", ANON);
|
||||
|
||||
filterChainDefinitionMap.put("/api/auth/login", ANON);
|
||||
filterChainDefinitionMap.put("/api/auth/logout", ANON);
|
||||
// filterChainDefinitionMap.put("/api/auth/logout", ANON);
|
||||
filterChainDefinitionMap.put("/api/auth/validateName", ANON);
|
||||
filterChainDefinitionMap.put("/api/auth/isOpenLdap", ANON);
|
||||
filterChainDefinitionMap.put("/api/auth/isOpenOidc", ANON);
|
||||
filterChainDefinitionMap.put("/api/pluginCommon/component/*", ANON);
|
||||
filterChainDefinitionMap.put("/plugin/oidc/authInfo", ANON);
|
||||
filterChainDefinitionMap.put("/sso/callBack*", ANON);
|
||||
|
||||
|
||||
filterChainDefinitionMap.put("/unauth", ANON);
|
||||
filterChainDefinitionMap.put("/display/**", ANON);
|
||||
filterChainDefinitionMap.put("/tokenExpired", ANON);
|
||||
|
@ -2,16 +2,18 @@ package io.dataease.auth.util;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.JWTCreator.Builder;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.exceptions.JWTDecodeException;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.auth0.jwt.interfaces.Verification;
|
||||
import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.entity.TokenInfo.TokenInfoBuilder;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@ -34,10 +36,13 @@ public class JWTUtils {
|
||||
*/
|
||||
public static boolean verify(String token, TokenInfo tokenInfo, String secret) {
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
JWTVerifier verifier = JWT.require(algorithm)
|
||||
Verification verification = JWT.require(algorithm)
|
||||
.withClaim("username", tokenInfo.getUsername())
|
||||
.withClaim("userId", tokenInfo.getUserId())
|
||||
.build();
|
||||
.withClaim("userId", tokenInfo.getUserId());
|
||||
/* if (StringUtils.isNotBlank(tokenInfo.getIdToken())) {
|
||||
verification.withClaim("idToken", tokenInfo.getIdToken());
|
||||
} */
|
||||
JWTVerifier verifier = verification.build();
|
||||
verifier.verify(token);
|
||||
return true;
|
||||
}
|
||||
@ -50,10 +55,15 @@ public class JWTUtils {
|
||||
DecodedJWT jwt = JWT.decode(token);
|
||||
String username = jwt.getClaim("username").asString();
|
||||
Long userId = jwt.getClaim("userId").asLong();
|
||||
// String idToken = jwt.getClaim("idToken").asString();
|
||||
if (StringUtils.isEmpty(username) || ObjectUtils.isEmpty(userId) ){
|
||||
DataEaseException.throwException("token格式错误!");
|
||||
}
|
||||
TokenInfo tokenInfo = TokenInfo.builder().username(username).userId(userId).build();
|
||||
TokenInfoBuilder tokenInfoBuilder = TokenInfo.builder().username(username).userId(userId);
|
||||
/* if (StringUtils.isNotBlank(idToken)) {
|
||||
tokenInfoBuilder.idToken(idToken);
|
||||
} */
|
||||
TokenInfo tokenInfo = tokenInfoBuilder.build();
|
||||
return tokenInfo;
|
||||
}
|
||||
|
||||
@ -107,12 +117,14 @@ public class JWTUtils {
|
||||
try {
|
||||
Date date = new Date(System.currentTimeMillis()+EXPIRE_TIME);
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
// 附带username信息
|
||||
return JWT.create()
|
||||
Builder builder = JWT.create()
|
||||
.withClaim("username", tokenInfo.getUsername())
|
||||
.withClaim("userId", tokenInfo.getUserId())
|
||||
.withExpiresAt(date)
|
||||
.sign(algorithm);
|
||||
.withClaim("userId", tokenInfo.getUserId());
|
||||
/* if (StringUtils.isNotBlank(tokenInfo.getIdToken())) {
|
||||
builder.withClaim("idToken", tokenInfo.getIdToken());
|
||||
} */
|
||||
return builder.withExpiresAt(date).sign(algorithm);
|
||||
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -1,31 +1,28 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ChartView implements Serializable {
|
||||
@ApiModelProperty("ID")
|
||||
private String id;
|
||||
@ApiModelProperty("名称")
|
||||
|
||||
private String name;
|
||||
@ApiModelProperty("场景ID")
|
||||
|
||||
private String sceneId;
|
||||
@ApiModelProperty("表ID")
|
||||
|
||||
private String tableId;
|
||||
@ApiModelProperty("类型")
|
||||
|
||||
private String type;
|
||||
@ApiModelProperty("标题")
|
||||
|
||||
private String title;
|
||||
@ApiModelProperty("创建者")
|
||||
|
||||
private String createBy;
|
||||
@ApiModelProperty("创建时间")
|
||||
|
||||
private Long createTime;
|
||||
@ApiModelProperty("更新时间")
|
||||
|
||||
private Long updateTime;
|
||||
@ApiModelProperty("样式优先级")
|
||||
|
||||
private String stylePriority;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -15,15 +15,17 @@ public class ChartViewWithBLOBs extends ChartView implements Serializable {
|
||||
private String xAxis;
|
||||
@ApiModelProperty("y轴")
|
||||
private String yAxis;
|
||||
@ApiModelProperty("副y轴")
|
||||
private String yAxisExt;
|
||||
@ApiModelProperty("堆叠")
|
||||
private String extStack;
|
||||
@ApiModelProperty("气泡")
|
||||
private String extBubble;
|
||||
@ApiModelProperty("客户端属性")
|
||||
@ApiModelProperty("图形属性")
|
||||
private String customAttr;
|
||||
@ApiModelProperty("客户端样式")
|
||||
@ApiModelProperty("组件样式")
|
||||
private String customStyle;
|
||||
@ApiModelProperty("客户端过滤条件")
|
||||
@ApiModelProperty("过滤条件")
|
||||
private String customFilter;
|
||||
@ApiModelProperty("下钻字段")
|
||||
private String drillFields;
|
||||
|
@ -1,29 +1,26 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Datasource implements Serializable {
|
||||
@ApiModelProperty("ID")
|
||||
private String id;
|
||||
@ApiModelProperty("名称")
|
||||
|
||||
private String name;
|
||||
@ApiModelProperty("描述")
|
||||
|
||||
private String desc;
|
||||
@ApiModelProperty("类型")
|
||||
|
||||
private String type;
|
||||
@ApiModelProperty("创建时间")
|
||||
|
||||
private Long createTime;
|
||||
@ApiModelProperty("更新时间")
|
||||
|
||||
private Long updateTime;
|
||||
@ApiModelProperty("创建者")
|
||||
|
||||
private String createBy;
|
||||
@ApiModelProperty("状态")
|
||||
|
||||
private String status;
|
||||
@ApiModelProperty("配置")
|
||||
|
||||
private String configuration;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -0,0 +1,21 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PanelPdfTemplate implements Serializable {
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private String createUser;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private String templateContent;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,530 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PanelPdfTemplateExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public PanelPdfTemplateExample() {
|
||||
oredCriteria = new ArrayList<Criteria>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<Criterion>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(String value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(String value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(String value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(String value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLike(String value) {
|
||||
addCriterion("id like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotLike(String value) {
|
||||
addCriterion("id not like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<String> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<String> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(String value1, String value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(String value1, String value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNull() {
|
||||
addCriterion("`name` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNotNull() {
|
||||
addCriterion("`name` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameEqualTo(String value) {
|
||||
addCriterion("`name` =", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotEqualTo(String value) {
|
||||
addCriterion("`name` <>", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThan(String value) {
|
||||
addCriterion("`name` >", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("`name` >=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThan(String value) {
|
||||
addCriterion("`name` <", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThanOrEqualTo(String value) {
|
||||
addCriterion("`name` <=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLike(String value) {
|
||||
addCriterion("`name` like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotLike(String value) {
|
||||
addCriterion("`name` not like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIn(List<String> values) {
|
||||
addCriterion("`name` in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotIn(List<String> values) {
|
||||
addCriterion("`name` not in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameBetween(String value1, String value2) {
|
||||
addCriterion("`name` between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotBetween(String value1, String value2) {
|
||||
addCriterion("`name` not between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNull() {
|
||||
addCriterion("create_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNotNull() {
|
||||
addCriterion("create_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeEqualTo(Long value) {
|
||||
addCriterion("create_time =", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotEqualTo(Long value) {
|
||||
addCriterion("create_time <>", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThan(Long value) {
|
||||
addCriterion("create_time >", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time >=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThan(Long value) {
|
||||
addCriterion("create_time <", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time <=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIn(List<Long> values) {
|
||||
addCriterion("create_time in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotIn(List<Long> values) {
|
||||
addCriterion("create_time not in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time not between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIsNull() {
|
||||
addCriterion("create_user is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIsNotNull() {
|
||||
addCriterion("create_user is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserEqualTo(String value) {
|
||||
addCriterion("create_user =", value, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserNotEqualTo(String value) {
|
||||
addCriterion("create_user <>", value, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserGreaterThan(String value) {
|
||||
addCriterion("create_user >", value, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("create_user >=", value, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserLessThan(String value) {
|
||||
addCriterion("create_user <", value, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserLessThanOrEqualTo(String value) {
|
||||
addCriterion("create_user <=", value, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserLike(String value) {
|
||||
addCriterion("create_user like", value, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserNotLike(String value) {
|
||||
addCriterion("create_user not like", value, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserIn(List<String> values) {
|
||||
addCriterion("create_user in", values, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserNotIn(List<String> values) {
|
||||
addCriterion("create_user not in", values, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserBetween(String value1, String value2) {
|
||||
addCriterion("create_user between", value1, value2, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserNotBetween(String value1, String value2) {
|
||||
addCriterion("create_user not between", value1, value2, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortIsNull() {
|
||||
addCriterion("sort is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortIsNotNull() {
|
||||
addCriterion("sort is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortEqualTo(Integer value) {
|
||||
addCriterion("sort =", value, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortNotEqualTo(Integer value) {
|
||||
addCriterion("sort <>", value, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortGreaterThan(Integer value) {
|
||||
addCriterion("sort >", value, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("sort >=", value, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortLessThan(Integer value) {
|
||||
addCriterion("sort <", value, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("sort <=", value, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortIn(List<Integer> values) {
|
||||
addCriterion("sort in", values, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortNotIn(List<Integer> values) {
|
||||
addCriterion("sort not in", values, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortBetween(Integer value1, Integer value2) {
|
||||
addCriterion("sort between", value1, value2, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("sort not between", value1, value2, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,59 +1,45 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysUser implements Serializable {
|
||||
@ApiModelProperty(value = "用户ID" , allowEmptyValue = false, position = 0)
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "组织ID" , allowEmptyValue = false, position = 7)
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty(value = "账号" , required = true)
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "姓名" , required = true, position = 2)
|
||||
private String nickName;
|
||||
|
||||
@ApiModelProperty(value = "性别" ,allowableValues = "男,女", allowEmptyValue = true, position = 5)
|
||||
private String gender;
|
||||
|
||||
@ApiModelProperty(value = "电话" , allowEmptyValue = true, position = 1)
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "邮箱" , required = true, position = 3)
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "密码" , required = true, position = 4)
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Boolean isAdmin;
|
||||
|
||||
@ApiModelProperty(value = "状态" , allowableValues = "1,0", required = true, position = 6)
|
||||
private Long enabled;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String updateBy;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long pwdResetTime;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long createTime;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long updateTime;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String language;
|
||||
|
||||
private Integer from;
|
||||
|
||||
private String sub;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -1153,6 +1153,136 @@ public class SysUserExample {
|
||||
addCriterion("`language` not between", value1, value2, "language");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromIsNull() {
|
||||
addCriterion("`from` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromIsNotNull() {
|
||||
addCriterion("`from` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromEqualTo(Integer value) {
|
||||
addCriterion("`from` =", value, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromNotEqualTo(Integer value) {
|
||||
addCriterion("`from` <>", value, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromGreaterThan(Integer value) {
|
||||
addCriterion("`from` >", value, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("`from` >=", value, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromLessThan(Integer value) {
|
||||
addCriterion("`from` <", value, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("`from` <=", value, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromIn(List<Integer> values) {
|
||||
addCriterion("`from` in", values, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromNotIn(List<Integer> values) {
|
||||
addCriterion("`from` not in", values, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromBetween(Integer value1, Integer value2) {
|
||||
addCriterion("`from` between", value1, value2, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("`from` not between", value1, value2, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubIsNull() {
|
||||
addCriterion("sub is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubIsNotNull() {
|
||||
addCriterion("sub is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubEqualTo(String value) {
|
||||
addCriterion("sub =", value, "sub");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubNotEqualTo(String value) {
|
||||
addCriterion("sub <>", value, "sub");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubGreaterThan(String value) {
|
||||
addCriterion("sub >", value, "sub");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("sub >=", value, "sub");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubLessThan(String value) {
|
||||
addCriterion("sub <", value, "sub");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubLessThanOrEqualTo(String value) {
|
||||
addCriterion("sub <=", value, "sub");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubLike(String value) {
|
||||
addCriterion("sub like", value, "sub");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubNotLike(String value) {
|
||||
addCriterion("sub not like", value, "sub");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubIn(List<String> values) {
|
||||
addCriterion("sub in", values, "sub");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubNotIn(List<String> values) {
|
||||
addCriterion("sub not in", values, "sub");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubBetween(String value1, String value2) {
|
||||
addCriterion("sub between", value1, value2, "sub");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubNotBetween(String value1, String value2) {
|
||||
addCriterion("sub not between", value1, value2, "sub");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
@ -16,6 +16,7 @@
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.dataease.base.domain.ChartViewWithBLOBs">
|
||||
<result column="x_axis" jdbcType="LONGVARCHAR" property="xAxis" />
|
||||
<result column="y_axis" jdbcType="LONGVARCHAR" property="yAxis" />
|
||||
<result column="y_axis_ext" jdbcType="LONGVARCHAR" property="yAxisExt" />
|
||||
<result column="ext_stack" jdbcType="LONGVARCHAR" property="extStack" />
|
||||
<result column="ext_bubble" jdbcType="LONGVARCHAR" property="extBubble" />
|
||||
<result column="custom_attr" jdbcType="LONGVARCHAR" property="customAttr" />
|
||||
@ -87,7 +88,7 @@
|
||||
style_priority
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
x_axis, y_axis, ext_stack, ext_bubble, custom_attr, custom_style, custom_filter,
|
||||
x_axis, y_axis, y_axis_ext, ext_stack, ext_bubble, custom_attr, custom_style, custom_filter,
|
||||
drill_fields, snapshot
|
||||
</sql>
|
||||
<select id="selectByExampleWithBLOBs" parameterType="io.dataease.base.domain.ChartViewExample" resultMap="ResultMapWithBLOBs">
|
||||
@ -143,16 +144,16 @@
|
||||
table_id, `type`, title,
|
||||
create_by, create_time, update_time,
|
||||
style_priority, x_axis, y_axis,
|
||||
ext_stack, ext_bubble, custom_attr,
|
||||
custom_style, custom_filter, drill_fields,
|
||||
snapshot)
|
||||
y_axis_ext, ext_stack, ext_bubble,
|
||||
custom_attr, custom_style, custom_filter,
|
||||
drill_fields, snapshot)
|
||||
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{sceneId,jdbcType=VARCHAR},
|
||||
#{tableId,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR},
|
||||
#{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
|
||||
#{stylePriority,jdbcType=VARCHAR}, #{xAxis,jdbcType=LONGVARCHAR}, #{yAxis,jdbcType=LONGVARCHAR},
|
||||
#{extStack,jdbcType=LONGVARCHAR}, #{extBubble,jdbcType=LONGVARCHAR}, #{customAttr,jdbcType=LONGVARCHAR},
|
||||
#{customStyle,jdbcType=LONGVARCHAR}, #{customFilter,jdbcType=LONGVARCHAR}, #{drillFields,jdbcType=LONGVARCHAR},
|
||||
#{snapshot,jdbcType=LONGVARCHAR})
|
||||
#{yAxisExt,jdbcType=LONGVARCHAR}, #{extStack,jdbcType=LONGVARCHAR}, #{extBubble,jdbcType=LONGVARCHAR},
|
||||
#{customAttr,jdbcType=LONGVARCHAR}, #{customStyle,jdbcType=LONGVARCHAR}, #{customFilter,jdbcType=LONGVARCHAR},
|
||||
#{drillFields,jdbcType=LONGVARCHAR}, #{snapshot,jdbcType=LONGVARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.dataease.base.domain.ChartViewWithBLOBs">
|
||||
insert into chart_view
|
||||
@ -193,6 +194,9 @@
|
||||
<if test="yAxis != null">
|
||||
y_axis,
|
||||
</if>
|
||||
<if test="yAxisExt != null">
|
||||
y_axis_ext,
|
||||
</if>
|
||||
<if test="extStack != null">
|
||||
ext_stack,
|
||||
</if>
|
||||
@ -252,6 +256,9 @@
|
||||
<if test="yAxis != null">
|
||||
#{yAxis,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="yAxisExt != null">
|
||||
#{yAxisExt,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="extStack != null">
|
||||
#{extStack,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
@ -320,6 +327,9 @@
|
||||
<if test="record.yAxis != null">
|
||||
y_axis = #{record.yAxis,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="record.yAxisExt != null">
|
||||
y_axis_ext = #{record.yAxisExt,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="record.extStack != null">
|
||||
ext_stack = #{record.extStack,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
@ -360,6 +370,7 @@
|
||||
style_priority = #{record.stylePriority,jdbcType=VARCHAR},
|
||||
x_axis = #{record.xAxis,jdbcType=LONGVARCHAR},
|
||||
y_axis = #{record.yAxis,jdbcType=LONGVARCHAR},
|
||||
y_axis_ext = #{record.yAxisExt,jdbcType=LONGVARCHAR},
|
||||
ext_stack = #{record.extStack,jdbcType=LONGVARCHAR},
|
||||
ext_bubble = #{record.extBubble,jdbcType=LONGVARCHAR},
|
||||
custom_attr = #{record.customAttr,jdbcType=LONGVARCHAR},
|
||||
@ -423,6 +434,9 @@
|
||||
<if test="yAxis != null">
|
||||
y_axis = #{yAxis,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="yAxisExt != null">
|
||||
y_axis_ext = #{yAxisExt,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="extStack != null">
|
||||
ext_stack = #{extStack,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
@ -460,6 +474,7 @@
|
||||
style_priority = #{stylePriority,jdbcType=VARCHAR},
|
||||
x_axis = #{xAxis,jdbcType=LONGVARCHAR},
|
||||
y_axis = #{yAxis,jdbcType=LONGVARCHAR},
|
||||
y_axis_ext = #{yAxisExt,jdbcType=LONGVARCHAR},
|
||||
ext_stack = #{extStack,jdbcType=LONGVARCHAR},
|
||||
ext_bubble = #{extBubble,jdbcType=LONGVARCHAR},
|
||||
custom_attr = #{customAttr,jdbcType=LONGVARCHAR},
|
||||
|
@ -0,0 +1,36 @@
|
||||
package io.dataease.base.mapper;
|
||||
|
||||
import io.dataease.base.domain.PanelPdfTemplate;
|
||||
import io.dataease.base.domain.PanelPdfTemplateExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface PanelPdfTemplateMapper {
|
||||
long countByExample(PanelPdfTemplateExample example);
|
||||
|
||||
int deleteByExample(PanelPdfTemplateExample example);
|
||||
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
int insert(PanelPdfTemplate record);
|
||||
|
||||
int insertSelective(PanelPdfTemplate record);
|
||||
|
||||
List<PanelPdfTemplate> selectByExampleWithBLOBs(PanelPdfTemplateExample example);
|
||||
|
||||
List<PanelPdfTemplate> selectByExample(PanelPdfTemplateExample example);
|
||||
|
||||
PanelPdfTemplate selectByPrimaryKey(String id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") PanelPdfTemplate record, @Param("example") PanelPdfTemplateExample example);
|
||||
|
||||
int updateByExampleWithBLOBs(@Param("record") PanelPdfTemplate record, @Param("example") PanelPdfTemplateExample example);
|
||||
|
||||
int updateByExample(@Param("record") PanelPdfTemplate record, @Param("example") PanelPdfTemplateExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(PanelPdfTemplate record);
|
||||
|
||||
int updateByPrimaryKeyWithBLOBs(PanelPdfTemplate record);
|
||||
|
||||
int updateByPrimaryKey(PanelPdfTemplate record);
|
||||
}
|
@ -0,0 +1,270 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.dataease.base.mapper.PanelPdfTemplateMapper">
|
||||
<resultMap id="BaseResultMap" type="io.dataease.base.domain.PanelPdfTemplate">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
|
||||
<result column="sort" jdbcType="INTEGER" property="sort" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.dataease.base.domain.PanelPdfTemplate">
|
||||
<result column="template_content" jdbcType="LONGVARCHAR" property="templateContent" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, `name`, create_time, create_user, sort
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
template_content
|
||||
</sql>
|
||||
<select id="selectByExampleWithBLOBs" parameterType="io.dataease.base.domain.PanelPdfTemplateExample" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from panel_pdf_template
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByExample" parameterType="io.dataease.base.domain.PanelPdfTemplateExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from panel_pdf_template
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from panel_pdf_template
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from panel_pdf_template
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.dataease.base.domain.PanelPdfTemplateExample">
|
||||
delete from panel_pdf_template
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.dataease.base.domain.PanelPdfTemplate">
|
||||
insert into panel_pdf_template (id, `name`, create_time,
|
||||
create_user, sort, template_content
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
|
||||
#{createUser,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, #{templateContent,jdbcType=LONGVARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.dataease.base.domain.PanelPdfTemplate">
|
||||
insert into panel_pdf_template
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`name`,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="createUser != null">
|
||||
create_user,
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
sort,
|
||||
</if>
|
||||
<if test="templateContent != null">
|
||||
template_content,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createUser != null">
|
||||
#{createUser,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
#{sort,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="templateContent != null">
|
||||
#{templateContent,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.dataease.base.domain.PanelPdfTemplateExample" resultType="java.lang.Long">
|
||||
select count(*) from panel_pdf_template
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update panel_pdf_template
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.createUser != null">
|
||||
create_user = #{record.createUser,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.sort != null">
|
||||
sort = #{record.sort,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.templateContent != null">
|
||||
template_content = #{record.templateContent,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExampleWithBLOBs" parameterType="map">
|
||||
update panel_pdf_template
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
create_user = #{record.createUser,jdbcType=VARCHAR},
|
||||
sort = #{record.sort,jdbcType=INTEGER},
|
||||
template_content = #{record.templateContent,jdbcType=LONGVARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update panel_pdf_template
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
create_user = #{record.createUser,jdbcType=VARCHAR},
|
||||
sort = #{record.sort,jdbcType=INTEGER}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.PanelPdfTemplate">
|
||||
update panel_pdf_template
|
||||
<set>
|
||||
<if test="name != null">
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createUser != null">
|
||||
create_user = #{createUser,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
sort = #{sort,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="templateContent != null">
|
||||
template_content = #{templateContent,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.dataease.base.domain.PanelPdfTemplate">
|
||||
update panel_pdf_template
|
||||
set `name` = #{name,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
create_user = #{createUser,jdbcType=VARCHAR},
|
||||
sort = #{sort,jdbcType=INTEGER},
|
||||
template_content = #{templateContent,jdbcType=LONGVARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.PanelPdfTemplate">
|
||||
update panel_pdf_template
|
||||
set `name` = #{name,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
create_user = #{createUser,jdbcType=VARCHAR},
|
||||
sort = #{sort,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
@ -18,6 +18,8 @@
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
<result column="language" jdbcType="VARCHAR" property="language" />
|
||||
<result column="from" jdbcType="INTEGER" property="from" />
|
||||
<result column="sub" jdbcType="VARCHAR" property="sub" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
@ -79,7 +81,8 @@
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
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, `language`
|
||||
enabled, create_by, update_by, pwd_reset_time, create_time, update_time, `language`,
|
||||
`from`, sub
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.dataease.base.domain.SysUserExample" resultMap="BaseResultMap">
|
||||
select
|
||||
@ -117,13 +120,15 @@
|
||||
email, `password`, is_admin,
|
||||
enabled, create_by, update_by,
|
||||
pwd_reset_time, create_time, update_time,
|
||||
`language`)
|
||||
`language`, `from`, sub
|
||||
)
|
||||
values (#{userId,jdbcType=BIGINT}, #{deptId,jdbcType=BIGINT}, #{username,jdbcType=VARCHAR},
|
||||
#{nickName,jdbcType=VARCHAR}, #{gender,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
|
||||
#{email,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{isAdmin,jdbcType=BIT},
|
||||
#{enabled,jdbcType=BIGINT}, #{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR},
|
||||
#{pwdResetTime,jdbcType=BIGINT}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
|
||||
#{language,jdbcType=VARCHAR})
|
||||
#{language,jdbcType=VARCHAR}, #{from,jdbcType=INTEGER}, #{sub,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.dataease.base.domain.SysUser">
|
||||
insert into sys_user
|
||||
@ -176,6 +181,12 @@
|
||||
<if test="language != null">
|
||||
`language`,
|
||||
</if>
|
||||
<if test="from != null">
|
||||
`from`,
|
||||
</if>
|
||||
<if test="sub != null">
|
||||
sub,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">
|
||||
@ -226,6 +237,12 @@
|
||||
<if test="language != null">
|
||||
#{language,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="from != null">
|
||||
#{from,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="sub != null">
|
||||
#{sub,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.dataease.base.domain.SysUserExample" resultType="java.lang.Long">
|
||||
@ -285,6 +302,12 @@
|
||||
<if test="record.language != null">
|
||||
`language` = #{record.language,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.from != null">
|
||||
`from` = #{record.from,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.sub != null">
|
||||
sub = #{record.sub,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
@ -307,7 +330,9 @@
|
||||
pwd_reset_time = #{record.pwdResetTime,jdbcType=BIGINT},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
`language` = #{record.language,jdbcType=VARCHAR}
|
||||
`language` = #{record.language,jdbcType=VARCHAR},
|
||||
`from` = #{record.from,jdbcType=INTEGER},
|
||||
sub = #{record.sub,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
@ -360,6 +385,12 @@
|
||||
<if test="language != null">
|
||||
`language` = #{language,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="from != null">
|
||||
`from` = #{from,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="sub != null">
|
||||
sub = #{sub,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where user_id = #{userId,jdbcType=BIGINT}
|
||||
</update>
|
||||
@ -379,7 +410,9 @@
|
||||
pwd_reset_time = #{pwdResetTime,jdbcType=BIGINT},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
`language` = #{language,jdbcType=VARCHAR}
|
||||
`language` = #{language,jdbcType=VARCHAR},
|
||||
`from` = #{from,jdbcType=INTEGER},
|
||||
sub = #{sub,jdbcType=VARCHAR}
|
||||
where user_id = #{userId,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
@ -25,6 +25,8 @@ public interface AuthMapper {
|
||||
|
||||
SysUserEntity findUserByName(@Param("username") String username);
|
||||
|
||||
SysUserEntity findUserBySub(@Param("sub") String sub);
|
||||
|
||||
|
||||
List<CurrentRoleDto> roles(@Param("userId") Long userId);
|
||||
|
||||
|
@ -28,6 +28,10 @@
|
||||
select user_id, username,nick_name, dept_id, password, enabled,email, phone, language ,is_admin from sys_user where username = #{username}
|
||||
</select>
|
||||
|
||||
<select id="findUserBySub" resultMap="baseMap">
|
||||
select user_id, username,nick_name, dept_id, password, enabled,email, phone, language ,is_admin from sys_user where sub = #{sub}
|
||||
</select>
|
||||
|
||||
<select id="roleCodes" resultType="String">
|
||||
select r.id from sys_role r
|
||||
left join sys_users_roles sur on sur.role_id = r.role_id
|
||||
|
@ -8,7 +8,7 @@
|
||||
</resultMap>
|
||||
|
||||
<select id="query" parameterType="io.dataease.base.mapper.ext.query.GridExample" resultMap="BaseResultMapDTO">
|
||||
select id , name , `desc` ,`type` , configuration ,create_time ,update_time,
|
||||
select datasource.*,
|
||||
authInfo.privileges as `privileges`
|
||||
from (select GET_V_AUTH_MODEL_ID_P_USE (#{extendCondition}, 'link') cids) t,datasource
|
||||
left join (
|
||||
@ -55,7 +55,7 @@
|
||||
</select>
|
||||
|
||||
<select id="queryUnion" resultMap="BaseResultMapDTO">
|
||||
select id , name , `desc` ,`type` , configuration ,create_time ,update_time, status,
|
||||
select datasource.*,
|
||||
authInfo.privileges as `privileges`
|
||||
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'link') cids) t,datasource
|
||||
left join (
|
||||
|
@ -17,7 +17,7 @@
|
||||
<where>
|
||||
FIND_IN_SET(chart_group.id,cids)
|
||||
</where>
|
||||
order by create_time desc
|
||||
order by `type` desc,name asc
|
||||
|
||||
</select>
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<where>
|
||||
FIND_IN_SET(chart_view.id,cids)
|
||||
</where>
|
||||
order by create_time desc
|
||||
order by `type` desc,name asc
|
||||
</select>
|
||||
|
||||
|
||||
|
@ -7,4 +7,6 @@ import java.util.List;
|
||||
|
||||
public interface ExtSysUserMapper {
|
||||
List<SysUserGridResponse> query(GridExample example);
|
||||
|
||||
List<String> ldapUserNames(Integer from);
|
||||
}
|
||||
|
@ -62,4 +62,8 @@
|
||||
left join sys_role r on r.role_id = sur.role_id
|
||||
where sur.user_id = #{user_id}
|
||||
</select>
|
||||
|
||||
<select id="ldapUserNames" resultType="java.lang.String" parameterType="java.lang.Integer">
|
||||
select username from sys_user u where u.from = #{from}
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -6,6 +6,7 @@ public class AuthConstants {
|
||||
public final static String USER_CACHE_NAME = "users_info";
|
||||
public final static String USER_ROLE_CACHE_NAME = "users_roles_info";
|
||||
public final static String USER_PERMISSION_CACHE_NAME = "users_permissions_info";
|
||||
public final static String ID_TOKEN_KEY = "IdToken";
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ public class DeTypeConstants {
|
||||
public final static Integer DE_INT = 2;
|
||||
public final static Integer DE_FLOAT = 3;
|
||||
public final static Integer DE_BOOL = 4;
|
||||
public final static Integer DE_Binary = 5;
|
||||
public final static Integer DE_LOCATION = 5;
|
||||
public final static Integer DE_BINARY = 6;
|
||||
|
||||
}
|
||||
|
@ -45,9 +45,12 @@ public class DefaultLicenseService {
|
||||
}
|
||||
return f2CLicenseResponse;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return F2CLicenseResponse.invalid(e.getMessage());
|
||||
LogUtil.error(e.getMessage());
|
||||
// e.printStackTrace();
|
||||
// return F2CLicenseResponse.invalid(e.getMessage());
|
||||
return F2CLicenseResponse.noRecord();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class DateUtils {
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
/* public static void main(String[] args) throws Exception {
|
||||
// System.out.println("start:");
|
||||
Date paramTime = getTime(getTimeString(new Long("1607672440731")));
|
||||
|
||||
@ -110,7 +110,7 @@ public class DateUtils {
|
||||
|
||||
// System.out.println(getTimeString(--countTimeLong));
|
||||
|
||||
}
|
||||
} */
|
||||
|
||||
|
||||
/**
|
||||
|
@ -68,8 +68,8 @@ public class ExcelReaderUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
/* public static void main(String[] args) throws Exception {
|
||||
String file ="Metersphere_case_DataEase功能用例.xlsx";
|
||||
ExcelReaderUtil.readExcel(file, new FileInputStream("/Users/taojinlong/Desktop/" + file));
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
package io.dataease.controller.panel;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.base.domain.PanelPdfTemplate;
|
||||
import io.dataease.service.panel.PanelPdfTemplateService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Author: wangjiahao
|
||||
* Date: 2021-03-05
|
||||
* Description:
|
||||
*/
|
||||
@Api(tags = "仪表板:PDF导出模板")
|
||||
@ApiSupport(order = 170)
|
||||
@RestController
|
||||
@RequestMapping("pdf-template")
|
||||
public class PanelPdfTemplateController {
|
||||
|
||||
@Resource
|
||||
private PanelPdfTemplateService panelPdfTemplateService;
|
||||
|
||||
@GetMapping("queryAll")
|
||||
public List<PanelPdfTemplate> queryAll(){
|
||||
return panelPdfTemplateService.queryAll();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -6,7 +6,6 @@ import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.base.domain.SysMsgChannel;
|
||||
import io.dataease.base.domain.SysMsgSetting;
|
||||
import io.dataease.base.domain.SysMsgType;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.PageUtils;
|
||||
import io.dataease.commons.utils.Pager;
|
||||
@ -71,6 +70,12 @@ public class MsgController {
|
||||
sysMsgService.setBatchReaded(msgIds);
|
||||
}
|
||||
|
||||
@ApiOperation("全部设置已读")
|
||||
@PostMapping("/allRead")
|
||||
public void allRead() {
|
||||
sysMsgService.setAllRead();
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除")
|
||||
@PostMapping("/batchDelete")
|
||||
public void batchDelete(@RequestBody List<Long> msgIds) {
|
||||
|
@ -10,6 +10,7 @@ import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.PageUtils;
|
||||
import io.dataease.commons.utils.Pager;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.LdapAddRequest;
|
||||
import io.dataease.controller.sys.request.SysUserCreateRequest;
|
||||
import io.dataease.controller.sys.request.SysUserPwdRequest;
|
||||
import io.dataease.controller.sys.request.SysUserStateRequest;
|
||||
@ -127,4 +128,18 @@ public class SysUserController {
|
||||
Pager<List<SysRole>> listPager = PageUtils.setPageInfo(page, sysRoleService.query(request));
|
||||
return listPager;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("同步用户")
|
||||
@PostMapping("/sync")
|
||||
public void importLdap(@RequestBody LdapAddRequest request) {
|
||||
sysUserService.saveLdapUsers(request);
|
||||
}
|
||||
|
||||
@ApiOperation("已同步用户")
|
||||
@PostMapping("/existLdapUsers")
|
||||
public List<String> getExistLdapUsers() {
|
||||
return sysUserService.ldapUserNames();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package io.dataease.controller.sys.request;
|
||||
|
||||
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class LdapAddRequest implements Serializable {
|
||||
|
||||
private Long deptId;
|
||||
|
||||
private List<Long> roleIds;
|
||||
|
||||
private Long enabled;
|
||||
|
||||
private List<XpackLdapUserEntity> users;
|
||||
}
|
@ -6,7 +6,9 @@ public enum DatasourceTypes {
|
||||
pg("pg", "pg", "org.postgresql.Driver", "\"", "\"", "\"", "\""),
|
||||
sqlServer("sqlServer", "sqlServer", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "\"", "\"", "\"", "\""),
|
||||
doris("doris", "doris", "com.mysql.jdbc.Driver", "`", "`", "", ""),
|
||||
oracle("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\"");
|
||||
oracle("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\""),
|
||||
ck("ch", "ch", "ru.yandex.clickhouse.ClickHouseDriver", "`", "`", "'", "'"),
|
||||
es("es", "es", "", "\"", "\"", "\"", "\"");
|
||||
|
||||
private String feature;
|
||||
private String desc;
|
||||
|
@ -0,0 +1,19 @@
|
||||
package io.dataease.datasource.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class CHConfigration extends JdbcDTO {
|
||||
|
||||
private String driver = "ru.yandex.clickhouse.ClickHouseDriver";
|
||||
|
||||
public String getJdbc() {
|
||||
// 连接参数先写死,后边要把编码、时区等参数放到数据源的设置中
|
||||
return "jdbc:clickhouse://HOSTNAME:PORT/DATABASE"
|
||||
.replace("HOSTNAME", getHost().trim())
|
||||
.replace("PORT", getPort().toString().trim())
|
||||
.replace("DATABASE", getDataBase().trim());
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package io.dataease.datasource.dto;
|
||||
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class EsConfigDTO {
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
private String version;
|
||||
private String uri;
|
||||
private String dataSourceType = "es";
|
||||
}
|
@ -11,7 +11,7 @@ public class MysqlConfigration extends JdbcDTO {
|
||||
|
||||
public String getJdbc() {
|
||||
// 连接参数先写死,后边要把编码、时区等参数放到数据源的设置中
|
||||
return "jdbc:mysql://HOSTNAME:PORT/DATABASE?characterEncoding=UTF-8&connectTimeout=5000"
|
||||
return "jdbc:mysql://HOSTNAME:PORT/DATABASE?characterEncoding=UTF-8&connectTimeout=5000&useSSL=false"
|
||||
.replace("HOSTNAME", getHost().trim())
|
||||
.replace("PORT", getPort().toString().trim())
|
||||
.replace("DATABASE", getDataBase().trim());
|
||||
|
@ -0,0 +1,29 @@
|
||||
package io.dataease.datasource.dto.es;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class EsReponse {
|
||||
private List<Column>columns = new ArrayList<>();
|
||||
private List<String[]>rows = new ArrayList<>();
|
||||
private String cursor;
|
||||
private Integer status;
|
||||
private Error error;
|
||||
private String version;
|
||||
|
||||
@Data
|
||||
public class Error{
|
||||
private String type;
|
||||
private String reason;
|
||||
}
|
||||
|
||||
@Data
|
||||
public class Column {
|
||||
private String name;
|
||||
private String type;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package io.dataease.datasource.dto.es;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Requst {
|
||||
private String query;
|
||||
private Integer fetch_size = 10000;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package io.dataease.datasource.dto.es;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RequstWithCursor extends Requst{
|
||||
private String cursor;
|
||||
}
|
@ -0,0 +1,258 @@
|
||||
package io.dataease.datasource.provider;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||
import io.dataease.commons.utils.HttpClientConfig;
|
||||
import io.dataease.commons.utils.HttpClientUtil;
|
||||
import io.dataease.datasource.dto.*;
|
||||
import io.dataease.datasource.dto.es.EsReponse;
|
||||
import io.dataease.datasource.dto.es.Requst;
|
||||
import io.dataease.datasource.dto.es.RequstWithCursor;
|
||||
import io.dataease.datasource.request.DatasourceRequest;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.provider.es.EsQueryProvider;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
@Service("es")
|
||||
public class EsProvider extends DatasourceProvider {
|
||||
|
||||
private static Map<String, ComboPooledDataSource> jdbcConnection = new HashMap<>();
|
||||
private static int initPoolSize = 5;
|
||||
private static int maxConnections = 200;
|
||||
|
||||
/**
|
||||
* 增加缓存机制 key 由 'provider_sql_' dsr.datasource.id dsr.table dsr.query共4部分组成,命中则使用缓存直接返回不再执行sql逻辑
|
||||
* @param dsr
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
/**
|
||||
* 这里使用声明式缓存不是很妥当
|
||||
* 改为chartViewService中使用编程式缓存
|
||||
@Cacheable(
|
||||
value = JdbcConstants.JDBC_PROVIDER_KEY,
|
||||
key = "'provider_sql_' + #dsr.datasource.id + '_' + #dsr.table + '_' + #dsr.query",
|
||||
condition = "#dsr.pageSize == null || #dsr.pageSize == 0L"
|
||||
)
|
||||
*/
|
||||
@Override
|
||||
public List<String[]> getData(DatasourceRequest dsr) throws Exception {
|
||||
List<String[]> list = new LinkedList<>();
|
||||
try {
|
||||
EsConfigDTO esConfigDTO = new Gson().fromJson(dsr.getDatasource().getConfiguration(), EsConfigDTO.class);
|
||||
|
||||
HttpClientConfig httpClientConfig = new HttpClientConfig();
|
||||
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
|
||||
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
|
||||
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
|
||||
Requst requst = new Requst();
|
||||
requst.setQuery(dsr.getQuery());
|
||||
requst.setFetch_size(dsr.getFetchSize());
|
||||
String url = esConfigDTO.getUrl().endsWith("/") ? esConfigDTO.getUrl() + esConfigDTO.getUri() + "?format=json" : esConfigDTO.getUrl() + "/" + esConfigDTO.getUri() + "?format=json";
|
||||
String response = HttpClientUtil.post(url, new Gson().toJson(requst), httpClientConfig);
|
||||
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
|
||||
|
||||
list.addAll(fetchResult(esReponse));
|
||||
if(dsr.isPageable()){
|
||||
Integer realSize = dsr.getPage() * dsr.getPageSize() < list.size() ? dsr.getPage() * dsr.getPageSize(): list.size();
|
||||
list = list.subList((dsr.getPage() - 1) * dsr.getPageSize(), realSize);
|
||||
}
|
||||
if(!dsr.isPreviewData()){
|
||||
while (StringUtils.isNotEmpty(esReponse.getCursor())) {
|
||||
RequstWithCursor requstWithCursor = new RequstWithCursor();
|
||||
requstWithCursor.setQuery(dsr.getQuery());
|
||||
requstWithCursor.setFetch_size(dsr.getFetchSize());
|
||||
requstWithCursor.setCursor(esReponse.getCursor());
|
||||
response = HttpClientUtil.post(url, new Gson().toJson(requstWithCursor), httpClientConfig);
|
||||
esReponse = new Gson().fromJson(response, EsReponse.class);
|
||||
list.addAll(fetchResult(esReponse));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String[]> fetchResult(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<String[]> list = new LinkedList<>();
|
||||
try {
|
||||
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "?format=json");
|
||||
list = fetchResult(response);
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<String[]> fetchResult(String response) throws Exception {
|
||||
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
|
||||
return fetchResult(esReponse);
|
||||
}
|
||||
|
||||
private List<String[]> fetchResult(EsReponse esReponse) throws Exception {
|
||||
List<String[]> list = new LinkedList<>();
|
||||
if(esReponse.getError() != null){
|
||||
throw new Exception(esReponse.getError().getReason());
|
||||
}
|
||||
list.addAll(esReponse.getRows());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableFiled> fetchResultField(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<TableFiled> tableFileds = new ArrayList<>();
|
||||
try {
|
||||
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "?format=json");
|
||||
tableFileds = fetchResultField(response);
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return tableFileds;
|
||||
}
|
||||
|
||||
private List<TableFiled> fetchResultField(String response) throws Exception {
|
||||
List<TableFiled> fieldList = new ArrayList<>();
|
||||
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
|
||||
if(esReponse.getError() != null){
|
||||
throw new Exception(esReponse.getError().getReason());
|
||||
}
|
||||
|
||||
for (String[] row : esReponse.getRows()) {
|
||||
TableFiled field = new TableFiled();
|
||||
field.setFieldName(row[0]);
|
||||
field.setRemarks(row[0]);
|
||||
field.setFieldType(row[2]);
|
||||
field.setFieldSize(EsQueryProvider.transFieldTypeSize(row[2]));
|
||||
fieldList.add(field);
|
||||
}
|
||||
return fieldList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List> fetchResultAndField(DatasourceRequest datasourceRequest) throws Exception {
|
||||
Map<String, List> result = new HashMap<>();
|
||||
try {
|
||||
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "?format=json");
|
||||
result.put("dataList", fetchResult(response));
|
||||
result.put("fieldList", fetchResultField(response));
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDatasource(DatasourceRequest datasourceRequest, String type) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTables(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<String> tables = new ArrayList<>();
|
||||
try {
|
||||
String response = exexQuery(datasourceRequest, "show tables", "?format=json");
|
||||
tables = fetchTables(response);
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return tables;
|
||||
}
|
||||
|
||||
private List<String> fetchTables(String response) throws Exception {
|
||||
List<String> tables = new ArrayList<>();
|
||||
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
|
||||
if(esReponse.getError() != null){
|
||||
throw new Exception(esReponse.getError().getReason());
|
||||
}
|
||||
|
||||
for (String[] row : esReponse.getRows()) {
|
||||
if(row.length == 3 && row[1].equalsIgnoreCase("TABLE") && row[2].equalsIgnoreCase("INDEX")){
|
||||
tables.add(row[0]);
|
||||
}
|
||||
if(row.length == 2 && row[1].equalsIgnoreCase("BASE TABLE")){
|
||||
tables.add(row[0]);
|
||||
}
|
||||
}
|
||||
return tables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSchema(DatasourceRequest datasourceRequest) throws Exception {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableFiled> getTableFileds(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<TableFiled> tableFileds = new ArrayList<>();
|
||||
try {
|
||||
String response = exexQuery(datasourceRequest, "desc " + datasourceRequest.getTable(), "?format=json");
|
||||
tableFileds = fetchResultField(response);
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return tableFileds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkStatus(DatasourceRequest datasourceRequest) throws Exception {
|
||||
EsConfigDTO esConfigDTO = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), EsConfigDTO.class);
|
||||
String response = exexGetQuery(datasourceRequest);
|
||||
String version = JSONObject.parseObject(response).getJSONObject("version").getString("number");
|
||||
if(Integer.valueOf(version.substring(0,1)) < 6 ){
|
||||
throw new Exception(Translator.get("i18n_es_limit"));
|
||||
}
|
||||
if(Integer.valueOf(version.substring(2,3)) < 3 ){
|
||||
throw new Exception(Translator.get("i18n_es_limit"));
|
||||
}
|
||||
if(Integer.valueOf(version.substring(0,1)) == 6 ) {
|
||||
esConfigDTO.setUri("_xpack/sql");
|
||||
}
|
||||
if(Integer.valueOf(version.substring(0,1)) == 7 ) {
|
||||
esConfigDTO.setUri("_sql");
|
||||
}
|
||||
datasourceRequest.getDatasource().setConfiguration(new Gson().toJson(esConfigDTO));
|
||||
getTables(datasourceRequest);
|
||||
}
|
||||
|
||||
private String exexQuery(DatasourceRequest datasourceRequest, String sql, String uri){
|
||||
EsConfigDTO esConfigDTO = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), EsConfigDTO.class);
|
||||
uri = esConfigDTO.getUri()+uri;
|
||||
HttpClientConfig httpClientConfig = new HttpClientConfig();
|
||||
if(StringUtils.isNotEmpty(esConfigDTO.getUsername()) && StringUtils.isNotEmpty(esConfigDTO.getPassword())){
|
||||
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
|
||||
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
|
||||
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
|
||||
}
|
||||
|
||||
Requst requst = new Requst();
|
||||
requst.setQuery(sql);
|
||||
requst.setFetch_size(datasourceRequest.getFetchSize());
|
||||
String url = esConfigDTO.getUrl().endsWith("/") ? esConfigDTO.getUrl() + uri : esConfigDTO.getUrl() + "/" + uri;
|
||||
String response = HttpClientUtil.post(url, new Gson().toJson(requst), httpClientConfig);
|
||||
return response;
|
||||
}
|
||||
|
||||
private String exexGetQuery(DatasourceRequest datasourceRequest){
|
||||
EsConfigDTO esConfigDTO = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), EsConfigDTO.class);
|
||||
HttpClientConfig httpClientConfig = new HttpClientConfig();
|
||||
if(StringUtils.isNotEmpty(esConfigDTO.getUsername()) && StringUtils.isNotEmpty(esConfigDTO.getPassword())){
|
||||
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
|
||||
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
|
||||
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
|
||||
}
|
||||
|
||||
String response = HttpClientUtil.get(esConfigDTO.getUrl(), httpClientConfig);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ import io.dataease.datasource.dto.*;
|
||||
import io.dataease.datasource.request.DatasourceRequest;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.provider.QueryProvider;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.beans.PropertyVetoException;
|
||||
@ -40,7 +41,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
List<String[]> list = new LinkedList<>();
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = getConnectionFromPool(dsr);
|
||||
connection = getConnection(dsr);
|
||||
Statement stat = connection.createStatement();
|
||||
ResultSet rs = stat.executeQuery(dsr.getQuery());
|
||||
list = fetchResult(rs);
|
||||
@ -127,7 +128,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
connection = getConnectionFromPool(datasourceRequest);
|
||||
Statement stat = connection.createStatement();
|
||||
rs = stat.executeQuery(datasourceRequest.getQuery());
|
||||
return fetchResultField(rs);
|
||||
return fetchResultField(rs, datasourceRequest);
|
||||
} catch (SQLException e) {
|
||||
DataEaseException.throwException(e);
|
||||
} catch (Exception e) {
|
||||
@ -152,7 +153,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
Statement stat = connection.createStatement();
|
||||
rs = stat.executeQuery(datasourceRequest.getQuery());
|
||||
dataList = fetchResult(rs);
|
||||
fieldList = fetchResultField(rs);
|
||||
fieldList = fetchResultField(rs, datasourceRequest);
|
||||
result.put("dataList", dataList);
|
||||
result.put("fieldList", fieldList);
|
||||
return result;
|
||||
@ -168,10 +169,11 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
private List<TableFiled> fetchResultField(ResultSet rs) throws Exception {
|
||||
private List<TableFiled> fetchResultField(ResultSet rs, DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<TableFiled> fieldList = new ArrayList<>();
|
||||
ResultSetMetaData metaData = rs.getMetaData();
|
||||
int columnCount = metaData.getColumnCount();
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(datasourceRequest.getDatasource().getType());
|
||||
for (int j = 0; j < columnCount; j++) {
|
||||
String f = metaData.getColumnName(j + 1);
|
||||
String l = StringUtils.isNotEmpty(metaData.getColumnLabel(j + 1)) ? metaData.getColumnLabel(j + 1) : f;
|
||||
@ -180,7 +182,12 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
field.setFieldName(l);
|
||||
field.setRemarks(l);
|
||||
field.setFieldType(t);
|
||||
field.setFieldSize(metaData.getColumnDisplaySize(j + 1));
|
||||
|
||||
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name())){
|
||||
field.setFieldSize(qp.transFieldSize(t));
|
||||
}else {
|
||||
field.setFieldSize(metaData.getColumnDisplaySize(j + 1));
|
||||
}
|
||||
if(t.equalsIgnoreCase("LONG")){field.setFieldSize(65533);} //oracle LONG
|
||||
if(StringUtils.isNotEmpty(t) && t.toLowerCase().contains("date") && field.getFieldSize() < 50 ){
|
||||
field.setFieldSize(50);
|
||||
@ -196,7 +203,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
String queryStr = getTablesSql(datasourceRequest);
|
||||
Connection con = null;
|
||||
try {
|
||||
con = getConnectionFromPool(datasourceRequest);
|
||||
con = getConnection(datasourceRequest);
|
||||
Statement statement = con.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery(queryStr);
|
||||
while (resultSet.next()) {
|
||||
@ -250,15 +257,20 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
ResultSet resultSet = databaseMetaData.getColumns(null, "%", datasourceRequest.getTable(), "%");
|
||||
while (resultSet.next()) {
|
||||
String tableName = resultSet.getString("TABLE_NAME");
|
||||
String database = resultSet.getString("TABLE_CAT");
|
||||
String database = null;
|
||||
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name())){
|
||||
database = resultSet.getString("TABLE_SCHEM");
|
||||
}else {
|
||||
database = resultSet.getString("TABLE_CAT");
|
||||
}
|
||||
if(database != null){
|
||||
if (tableName.equals(datasourceRequest.getTable()) && database.equalsIgnoreCase(getDatabase(datasourceRequest))) {
|
||||
TableFiled tableFiled = getTableFiled(resultSet);
|
||||
TableFiled tableFiled = getTableFiled(resultSet, datasourceRequest);
|
||||
list.add(tableFiled);
|
||||
}
|
||||
}else {
|
||||
if (tableName.equals(datasourceRequest.getTable())) {
|
||||
TableFiled tableFiled = getTableFiled(resultSet);
|
||||
TableFiled tableFiled = getTableFiled(resultSet, datasourceRequest);
|
||||
list.add(tableFiled);
|
||||
}
|
||||
}
|
||||
@ -276,7 +288,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
return list;
|
||||
}
|
||||
|
||||
private TableFiled getTableFiled(ResultSet resultSet) throws SQLException {
|
||||
private TableFiled getTableFiled(ResultSet resultSet, DatasourceRequest datasourceRequest) throws SQLException {
|
||||
TableFiled tableFiled = new TableFiled();
|
||||
String colName = resultSet.getString("COLUMN_NAME");
|
||||
tableFiled.setFieldName(colName);
|
||||
@ -285,13 +297,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").toUpperCase();
|
||||
tableFiled.setFieldType(dbType);
|
||||
if(dbType.equalsIgnoreCase("LONG")){tableFiled.setFieldSize(65533);}
|
||||
if(StringUtils.isNotEmpty(dbType) && dbType.toLowerCase().contains("date") && tableFiled.getFieldSize() < 50 ){
|
||||
tableFiled.setFieldSize(50);
|
||||
}
|
||||
|
||||
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name())){
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(datasourceRequest.getDatasource().getType());
|
||||
tableFiled.setFieldSize(qp.transFieldSize(dbType));
|
||||
}else {
|
||||
tableFiled.setFieldSize(Integer.valueOf(resultSet.getString("COLUMN_SIZE")));
|
||||
}
|
||||
return tableFiled;
|
||||
}
|
||||
|
||||
@ -436,6 +454,14 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
password = pgConfigration.getPassword();
|
||||
driver = pgConfigration.getDriver();
|
||||
jdbcurl = pgConfigration.getJdbc();
|
||||
break;
|
||||
case ck:
|
||||
CHConfigration chConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), CHConfigration.class);
|
||||
username = chConfigration.getUsername();
|
||||
password = chConfigration.getPassword();
|
||||
driver = chConfigration.getDriver();
|
||||
jdbcurl = chConfigration.getJdbc();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -493,6 +519,14 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
dataSource.setJdbcUrl(pgConfigration.getJdbc());
|
||||
jdbcDTO = pgConfigration;
|
||||
break;
|
||||
case ck:
|
||||
CHConfigration chConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), CHConfigration.class);
|
||||
dataSource.setUser(chConfigration.getUsername());
|
||||
dataSource.setDriverClass(chConfigration.getDriver());
|
||||
dataSource.setPassword(chConfigration.getPassword());
|
||||
dataSource.setJdbcUrl(chConfigration.getJdbc());
|
||||
jdbcDTO = chConfigration;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -515,7 +549,8 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
PgConfigration pgConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), PgConfigration.class);
|
||||
return pgConfigration.getDataBase();
|
||||
default:
|
||||
return null;
|
||||
JdbcDTO jdbcDTO = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), JdbcDTO.class);
|
||||
return jdbcDTO.getDataBase();
|
||||
}
|
||||
}
|
||||
|
||||
@ -528,6 +563,9 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
return "show tables;";
|
||||
case sqlServer:
|
||||
SqlServerConfigration sqlServerConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), SqlServerConfigration.class);
|
||||
if(StringUtils.isEmpty(sqlServerConfigration.getSchema())){
|
||||
throw new Exception(Translator.get("i18n_schema_is_empty"));
|
||||
}
|
||||
return "SELECT TABLE_NAME FROM DATABASE.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = 'DS_SCHEMA' ;"
|
||||
.replace("DATABASE", sqlServerConfigration.getDataBase())
|
||||
.replace("DS_SCHEMA", sqlServerConfigration.getSchema());
|
||||
@ -543,6 +581,9 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
throw new Exception(Translator.get("i18n_schema_is_empty"));
|
||||
}
|
||||
return "SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg%' AND tablename NOT LIKE 'sql_%' AND schemaname='SCHEMA' ;".replace("SCHEMA", pgConfigration.getSchema());
|
||||
case ck:
|
||||
CHConfigration chConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), CHConfigration.class);
|
||||
return "SELECT name FROM system.tables where database='DATABASE';".replace("DATABASE", chConfigration.getDataBase());
|
||||
default:
|
||||
return "show tables;";
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ public class ProviderFactory implements ApplicationContextAware {
|
||||
return context.getBean("jdbc", DatasourceProvider.class);
|
||||
case pg:
|
||||
return context.getBean("jdbc", DatasourceProvider.class);
|
||||
case es:
|
||||
return context.getBean("es", DatasourceProvider.class);
|
||||
default:
|
||||
return context.getBean("jdbc", DatasourceProvider.class);
|
||||
}
|
||||
@ -48,6 +50,10 @@ public class ProviderFactory implements ApplicationContextAware {
|
||||
return context.getBean("pgQuery", QueryProvider.class);
|
||||
case oracle:
|
||||
return context.getBean("oracleQuery", QueryProvider.class);
|
||||
case es:
|
||||
return context.getBean("esQuery", QueryProvider.class);
|
||||
case ck:
|
||||
return context.getBean("ckQuery", QueryProvider.class);
|
||||
default:
|
||||
return context.getBean("mysqlQuery", QueryProvider.class);
|
||||
}
|
||||
|
@ -11,8 +11,12 @@ public class DatasourceRequest {
|
||||
protected String query;
|
||||
protected String table;
|
||||
protected Datasource datasource;
|
||||
private Long pageSize;
|
||||
private Long startPage;
|
||||
private Integer pageSize;
|
||||
private Integer page;
|
||||
private Integer realSize;
|
||||
private Integer fetchSize = 10000;
|
||||
private boolean pageable = false;
|
||||
private boolean previewData = false;
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import io.dataease.base.mapper.*;
|
||||
import io.dataease.base.mapper.ext.ExtDataSourceMapper;
|
||||
import io.dataease.base.mapper.ext.query.GridExample;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.model.AuthURD;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.CommonThreadPool;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
@ -25,6 +26,8 @@ import io.dataease.dto.dataset.DataTableInfoDTO;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.service.dataset.DataSetGroupService;
|
||||
import io.dataease.service.message.DeMsgutil;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -34,7 +37,10 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@ -59,9 +65,10 @@ public class DatasourceService {
|
||||
datasource.setUpdateTime(currentTimeMillis);
|
||||
datasource.setCreateTime(currentTimeMillis);
|
||||
datasource.setCreateBy(String.valueOf(AuthUtils.getUser().getUsername()));
|
||||
checkAndUpdateDatasourceStatus(datasource);
|
||||
datasourceMapper.insertSelective(datasource);
|
||||
handleConnectionPool(datasource, "add");
|
||||
checkAndUpdateDatasourceStatus(datasource);
|
||||
|
||||
return datasource;
|
||||
}
|
||||
|
||||
@ -123,9 +130,9 @@ public class DatasourceService {
|
||||
checkName(datasource);
|
||||
datasource.setCreateTime(null);
|
||||
datasource.setUpdateTime(System.currentTimeMillis());
|
||||
checkAndUpdateDatasourceStatus(datasource);
|
||||
datasourceMapper.updateByPrimaryKeySelective(datasource);
|
||||
handleConnectionPool(datasource, "edit");
|
||||
checkAndUpdateDatasourceStatus(datasource);
|
||||
}
|
||||
|
||||
public ResultHolder validate(Datasource datasource) throws Exception {
|
||||
@ -238,7 +245,8 @@ public class DatasourceService {
|
||||
public void updateDatasourceStatus(){
|
||||
List<Datasource> datasources = datasourceMapper.selectByExampleWithBLOBs(new DatasourceExample());
|
||||
datasources.forEach(datasource -> {
|
||||
checkAndUpdateDatasourceStatus(datasource);
|
||||
// checkAndUpdateDatasourceStatus(datasource);
|
||||
checkAndUpdateDatasourceStatus(datasource, true);
|
||||
});
|
||||
}
|
||||
|
||||
@ -249,10 +257,47 @@ public class DatasourceService {
|
||||
datasourceRequest.setDatasource(datasource);
|
||||
datasourceProvider.checkStatus(datasourceRequest);
|
||||
datasource.setStatus("Success");
|
||||
datasourceMapper.updateByPrimaryKeySelective(datasource);
|
||||
} catch (Exception e) {
|
||||
datasource.setStatus("Error");
|
||||
datasourceMapper.updateByPrimaryKeySelective(datasource);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAndUpdateDatasourceStatus(Datasource datasource, Boolean withMsg){
|
||||
try {
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(datasource);
|
||||
datasourceProvider.checkStatus(datasourceRequest);
|
||||
datasource.setStatus("Success");
|
||||
datasourceMapper.updateByPrimaryKeySelective(datasource);
|
||||
} catch (Exception e) {
|
||||
Datasource temp = datasourceMapper.selectByPrimaryKey(datasource.getId());
|
||||
datasource.setStatus("Error");
|
||||
if (!StringUtils.equals(temp.getStatus(), "Error")) {
|
||||
sendWebMsg(datasource);
|
||||
datasourceMapper.updateByPrimaryKeySelective(datasource);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void sendWebMsg(Datasource datasource) {
|
||||
|
||||
String id = datasource.getId();
|
||||
AuthURD authURD = AuthUtils.authURDR(id);
|
||||
Set<Long> userIds = AuthUtils.userIdsByURD(authURD);
|
||||
Long typeId = 8L;// 代表数据源失效
|
||||
Gson gson = new Gson();
|
||||
userIds.forEach(userId -> {
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("id", id);
|
||||
param.put("name", datasource.getName());
|
||||
|
||||
|
||||
String content = "数据源【" + datasource.getName() + "】无效";
|
||||
|
||||
DeMsgutil.sendMsg(userId, typeId, 1L, content, gson.toJson(param));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -44,4 +44,6 @@ public class ChartViewFieldDTO implements Serializable {
|
||||
private String datePattern;
|
||||
|
||||
private Integer extField;
|
||||
|
||||
private String chartType;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package io.dataease.plugins.config;
|
||||
|
||||
import io.dataease.base.domain.MyPlugin;
|
||||
import io.dataease.plugins.loader.ClassloaderResponsity;
|
||||
import io.dataease.plugins.loader.ControllerLoader;
|
||||
import io.dataease.plugins.loader.ModuleClassLoader;
|
||||
import io.dataease.plugins.loader.MybatisLoader;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -19,6 +20,9 @@ public class LoadjarUtil {
|
||||
@Autowired
|
||||
private MybatisLoader mybatisLoader;
|
||||
|
||||
@Autowired
|
||||
private ControllerLoader controllerLoader;
|
||||
|
||||
public List<?> loadJar(String jarPath, MyPlugin myPlugin) throws Exception{
|
||||
File jar = new File(jarPath);
|
||||
URI uri = jar.toURI();
|
||||
@ -34,6 +38,10 @@ public class LoadjarUtil {
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
classLoader.initBean();
|
||||
mybatisLoader.loadMybatis(myPlugin);
|
||||
|
||||
List<String> controllers = classLoader.getRegisteredController();
|
||||
controllerLoader.registerController(controllers);
|
||||
|
||||
ClassloaderResponsity.getInstance().addClassLoader(moduleName,classLoader);
|
||||
|
||||
|
||||
|
@ -0,0 +1,95 @@
|
||||
package io.dataease.plugins.loader;
|
||||
|
||||
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class ControllerLoader {
|
||||
|
||||
/**
|
||||
* 去掉Controller的Mapping
|
||||
* @param controllerBeanName
|
||||
*/
|
||||
private void unregisterController(String controllerBeanName){
|
||||
final RequestMappingHandlerMapping requestMappingHandlerMapping=(RequestMappingHandlerMapping)SpringContextUtil.getBean("requestMappingHandlerMapping");
|
||||
|
||||
if(requestMappingHandlerMapping!=null){
|
||||
String handler=controllerBeanName;
|
||||
Object controller= SpringContextUtil.getBean(handler);
|
||||
if(controller==null){
|
||||
return;
|
||||
}
|
||||
final Class<?> targetClass=controller.getClass();
|
||||
ReflectionUtils.doWithMethods(targetClass, new ReflectionUtils.MethodCallback() {
|
||||
public void doWith(Method method) {
|
||||
Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
|
||||
try {
|
||||
Method createMappingMethod = RequestMappingHandlerMapping.class.
|
||||
getDeclaredMethod("getMappingForMethod", Method.class, Class.class);
|
||||
createMappingMethod.setAccessible(true);
|
||||
RequestMappingInfo requestMappingInfo =(RequestMappingInfo)
|
||||
createMappingMethod.invoke(requestMappingHandlerMapping,specificMethod,targetClass);
|
||||
if(requestMappingInfo != null) {
|
||||
requestMappingHandlerMapping.unregisterMapping(requestMappingInfo);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, ReflectionUtils.USER_DECLARED_METHODS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册Controller
|
||||
* @param controllerBeanName
|
||||
* @throws Exception
|
||||
*/
|
||||
private void registerController(String controllerBeanName) throws Exception{
|
||||
final RequestMappingHandlerMapping requestMappingHandlerMapping=(RequestMappingHandlerMapping) SpringContextUtil.getBean("requestMappingHandlerMapping");
|
||||
|
||||
if(requestMappingHandlerMapping!=null){
|
||||
String handler=controllerBeanName;
|
||||
Object controller= SpringContextUtil.getBean(handler);
|
||||
if(controller==null){
|
||||
return;
|
||||
}
|
||||
unregisterController(controllerBeanName);
|
||||
//注册Controller
|
||||
Method method=requestMappingHandlerMapping.getClass().getSuperclass().getSuperclass().getDeclaredMethod("detectHandlerMethods",Object.class);
|
||||
|
||||
method.setAccessible(true);
|
||||
method.invoke(requestMappingHandlerMapping,handler);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerController(List<String> beanNames) {
|
||||
beanNames.forEach(name -> {
|
||||
try {
|
||||
registerController(name);
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
LogUtil.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -7,10 +7,14 @@ import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.ibatis.type.TypeAliasRegistry;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -35,6 +39,8 @@ public class ModuleClassLoader extends URLClassLoader {
|
||||
//需要注册的spring bean的name集合
|
||||
private List<String> registeredBean = new ArrayList<>();
|
||||
|
||||
private List<String> registeredController = new ArrayList<>();
|
||||
|
||||
|
||||
//构造
|
||||
public ModuleClassLoader(URL[] urls, ClassLoader parent) {
|
||||
@ -150,8 +156,12 @@ public class ModuleClassLoader extends URLClassLoader {
|
||||
beanName = StringUtils.uncapitalize(beanName);
|
||||
|
||||
SpringContextUtil.getBeanFactory().registerBeanDefinition(beanName,beanDefinition);
|
||||
|
||||
if (isHandler(cla)) {
|
||||
registeredController.add(beanName);
|
||||
}
|
||||
|
||||
registeredBean.add(beanName);
|
||||
// System.out.println("注册bean:"+beanName);
|
||||
}
|
||||
|
||||
}
|
||||
@ -164,6 +174,10 @@ public class ModuleClassLoader extends URLClassLoader {
|
||||
return registeredBean;
|
||||
}
|
||||
|
||||
public List<String> getRegisteredController() {
|
||||
return registeredController;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 方法描述 判断class对象是否带有spring的注解
|
||||
@ -184,6 +198,9 @@ public class ModuleClassLoader extends URLClassLoader {
|
||||
if( Modifier.isAbstract(cla.getModifiers())){
|
||||
return false;
|
||||
}
|
||||
if (isHandler(cla)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(cla.getAnnotation(Component.class)!=null){
|
||||
return true;
|
||||
@ -194,8 +211,15 @@ public class ModuleClassLoader extends URLClassLoader {
|
||||
if(cla.getAnnotation(Service.class)!=null){
|
||||
return true;
|
||||
}
|
||||
if(cla.getAnnotation(Service.class)!=null){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isHandler(Class<?> beanType) {
|
||||
return AnnotatedElementUtils.hasAnnotation(beanType, Controller.class) || AnnotatedElementUtils.hasAnnotation(beanType, RequestMapping.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package io.dataease.plugins.server;
|
||||
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.plugins.common.dto.PluginSysMenu;
|
||||
import io.dataease.plugins.common.service.PluginComponentService;
|
||||
import io.dataease.plugins.common.service.PluginMenuService;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -9,7 +10,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
public class PluginCommonServer {
|
||||
|
||||
@GetMapping("/async/{menuId}")
|
||||
public void componentInfo(@PathVariable Long menuId) {
|
||||
public void menuInfo(@PathVariable Long menuId) {
|
||||
Map<String, PluginMenuService> pluginMenuServiceMap = SpringContextUtil.getApplicationContext().getBeansOfType(PluginMenuService.class);
|
||||
pluginMenuServiceMap.values().stream().forEach(service -> {
|
||||
AtomicReference<PluginSysMenu> atomicReference = new AtomicReference<>();
|
||||
@ -65,4 +65,41 @@ public class PluginCommonServer {
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
@GetMapping("/component/{componentName}")
|
||||
public void componentInfo(@PathVariable String componentName) {
|
||||
Map<String, PluginComponentService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType(PluginComponentService.class);
|
||||
beansOfType.values().stream().forEach(service -> {
|
||||
List<String> components = service.components();
|
||||
if (components.contains(componentName)) {
|
||||
HttpServletResponse response = ServletUtils.response();
|
||||
BufferedInputStream bis = null;
|
||||
InputStream inputStream = null;
|
||||
OutputStream os = null; //输出流
|
||||
try{
|
||||
inputStream = service.vueResource(componentName);
|
||||
byte[] buffer = new byte[1024];
|
||||
os = response.getOutputStream();
|
||||
bis = new BufferedInputStream(inputStream);
|
||||
int i = bis.read(buffer);
|
||||
while(i != -1){
|
||||
os.write(buffer, 0, i);
|
||||
i = bis.read(buffer);
|
||||
}
|
||||
os.flush();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
bis.close();
|
||||
inputStream.close();
|
||||
os.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,85 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.dataease.auth.entity.SysUserEntity;
|
||||
import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
||||
import io.dataease.plugins.xpack.oidc.dto.SSOToken;
|
||||
import io.dataease.plugins.xpack.oidc.dto.SSOUserInfo;
|
||||
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
|
||||
import io.dataease.service.sys.SysUserService;
|
||||
|
||||
@RequestMapping("/sso")
|
||||
@Controller
|
||||
public class SSOServer {
|
||||
|
||||
@Autowired
|
||||
private AuthUserService authUserService;
|
||||
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@GetMapping("/callBack")
|
||||
public ModelAndView callBack(@RequestParam("code") String code, @RequestParam("state") String state) {
|
||||
Map<String, OidcXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((OidcXpackService.class));
|
||||
if(beansOfType.keySet().size() == 0) {
|
||||
DEException.throwException("缺少oidc插件");
|
||||
}
|
||||
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||
Boolean suuportOIDC = oidcXpackService.isSuuportOIDC();
|
||||
if (!suuportOIDC) {
|
||||
DEException.throwException("未开启oidc");
|
||||
}
|
||||
Map<String, String> config = config(oidcXpackService);
|
||||
SSOToken ssoToken = oidcXpackService.requestSsoToken(config, code, state);
|
||||
|
||||
SSOUserInfo ssoUserInfo = oidcXpackService.requestUserInfo(config, ssoToken.getAccessToken());
|
||||
SysUserEntity sysUserEntity = authUserService.getUserBySub(ssoUserInfo.getSub());
|
||||
if(null == sysUserEntity){
|
||||
sysUserService.saveOIDCUser(ssoUserInfo);
|
||||
sysUserEntity = authUserService.getUserBySub(ssoUserInfo.getSub());
|
||||
}
|
||||
TokenInfo tokenInfo = TokenInfo.builder().userId(sysUserEntity.getUserId()).username(sysUserEntity.getUsername()).build();
|
||||
String realPwd = CodingUtil.md5(sysUserService.defaultPWD());
|
||||
String token = JWTUtils.sign(tokenInfo, realPwd);
|
||||
ServletUtils.setToken(token);
|
||||
HttpServletResponse response = ServletUtils.response();
|
||||
|
||||
Cookie cookie_token = new Cookie("Authorization", token);cookie_token.setPath("/");
|
||||
Cookie cookie_id_token = new Cookie("IdToken", ssoToken.getIdToken());cookie_id_token.setPath("/");
|
||||
Cookie cookie_ac_token = new Cookie("AccessToken", ssoToken.getAccessToken());cookie_ac_token.setPath("/");
|
||||
|
||||
response.addCookie(cookie_token);
|
||||
response.addCookie(cookie_id_token);
|
||||
response.addCookie(cookie_ac_token);
|
||||
ModelAndView modelAndView = new ModelAndView("redirect:/");
|
||||
return modelAndView;
|
||||
}
|
||||
private Map<String, String> config(OidcXpackService oidcXpackService) {
|
||||
List<SysSettingDto> sysSettingDtos = oidcXpackService.oidcSettings();
|
||||
Map<String, String> config = sysSettingDtos.stream().collect(Collectors.toMap(SysSettingDto::getParamKey, SysSettingDto::getParamValue));
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
|
||||
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
||||
import io.dataease.plugins.xpack.ldap.dto.response.LdapInfo;
|
||||
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RequestMapping("/plugin/ldap")
|
||||
@RestController
|
||||
public class XLdapServer {
|
||||
|
||||
|
||||
@GetMapping("/info")
|
||||
public LdapInfo getLdapInfo() {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
return ldapXpackService.info();
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
public void save(@RequestBody List<SysSettingDto> settings) {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
ldapXpackService.save(settings);
|
||||
}
|
||||
|
||||
@PostMapping("/testConn")
|
||||
public void testConn() {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
ldapXpackService.testConn();
|
||||
}
|
||||
|
||||
@PostMapping("/users")
|
||||
public List<XpackLdapUserEntity> users() {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
return ldapXpackService.users();
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
||||
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RequestMapping("/plugin/oidc")
|
||||
@RestController
|
||||
public class XOidcServer {
|
||||
|
||||
|
||||
@PostMapping("/info")
|
||||
public List<SysSettingDto> getOidcInfo() {
|
||||
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||
return oidcXpackService.oidcSettings();
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
public void save(@RequestBody List<SysSettingDto> settings) {
|
||||
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||
oidcXpackService.save(settings);
|
||||
}
|
||||
|
||||
@PostMapping(value="/authInfo")
|
||||
public Map<String, Object> authInfo() {
|
||||
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
List<SysSettingDto> oidcSettings = oidcXpackService.oidcSettings();
|
||||
|
||||
Map<String, String> authParam = new HashMap<>();
|
||||
authParam.put("response_type", "code");
|
||||
authParam.put("state", "state");
|
||||
// authParam.put("redirect_uri", "http://localhost:9528");
|
||||
|
||||
|
||||
oidcSettings.forEach(param -> {
|
||||
if(StringUtils.isNotBlank(param.getParamKey())) {
|
||||
if (StringUtils.equals(param.getParamKey(), "oidc.authEndpoint")) {
|
||||
result.put("authEndpoint", param.getParamValue());
|
||||
}
|
||||
if (StringUtils.equals(param.getParamKey(), "oidc.scope")) {
|
||||
authParam.put("scope", param.getParamValue());
|
||||
}
|
||||
if (StringUtils.equals(param.getParamKey(), "oidc.clientId")) {
|
||||
authParam.put("client_id", param.getParamValue());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
result.put("authParam", authParam);
|
||||
return result;
|
||||
}
|
||||
}
|
@ -46,6 +46,16 @@ public class PluginUtils {
|
||||
return f2CLicenseResponse;
|
||||
}
|
||||
|
||||
public static Boolean licValid() {
|
||||
try{
|
||||
F2CLicenseResponse f2CLicenseResponse = PluginUtils.currentLic();
|
||||
if (f2CLicenseResponse.getStatus() != F2CLicenseResponse.Status.valid) return false;
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -38,6 +38,10 @@ public abstract class QueryProvider {
|
||||
|
||||
public abstract String getSQLAsTmp(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList);
|
||||
|
||||
public abstract String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds);
|
||||
|
||||
public abstract String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds);
|
||||
|
||||
public abstract String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds);
|
||||
|
||||
public abstract String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack);
|
||||
@ -50,6 +54,9 @@ public abstract class QueryProvider {
|
||||
|
||||
public abstract String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList);
|
||||
|
||||
public Integer transFieldSize(String type){
|
||||
return 50;
|
||||
};
|
||||
/**
|
||||
* 单指标汇总
|
||||
*
|
||||
|
@ -0,0 +1,41 @@
|
||||
package io.dataease.provider.ck;
|
||||
|
||||
import io.dataease.provider.SQLConstants;
|
||||
|
||||
import static io.dataease.datasource.constants.DatasourceTypes.ck;
|
||||
|
||||
/**
|
||||
* @Author gin
|
||||
* @Date 2021/7/8 7:22 下午
|
||||
*/
|
||||
public class CKConstants extends SQLConstants {
|
||||
public static final String KEYWORD_TABLE = ck.getKeywordPrefix() + "%s" + ck.getKeywordSuffix();
|
||||
|
||||
public static final String KEYWORD_FIX = "%s." + ck.getKeywordPrefix() + "%s" + ck.getKeywordSuffix();
|
||||
|
||||
public static final String toInt32 = "toInt32(%s)";
|
||||
|
||||
public static final String toDateTime = "toDateTime(%s)";
|
||||
|
||||
public static final String toInt64 = "toInt64(%s)";
|
||||
|
||||
public static final String toFloat64 = "toFloat64(%s)";
|
||||
|
||||
public static final String formatDateTime = "formatDateTime(%s,'%s')";
|
||||
|
||||
public static final String toDecimal = "toDecimal64(%s,2)";
|
||||
|
||||
public static final String DEFAULT_DATE_FORMAT = "%Y-%m-%d %H:%M:%S";
|
||||
|
||||
public static final String WHERE_VALUE_NULL = "(NULL,'')";
|
||||
|
||||
public static final String WHERE_VALUE_VALUE = "'%s'";
|
||||
|
||||
public static final String AGG_COUNT = "COUNT(*)";
|
||||
|
||||
public static final String AGG_FIELD = "%s(%s)";
|
||||
|
||||
public static final String WHERE_BETWEEN = "'%s' AND '%s'";
|
||||
|
||||
public static final String BRACKETS = "(%s)";
|
||||
}
|
1027
backend/src/main/java/io/dataease/provider/ck/CKQueryProvider.java
Normal file
1027
backend/src/main/java/io/dataease/provider/ck/CKQueryProvider.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,8 @@ public class DorisConstants extends SQLConstants {
|
||||
|
||||
public static final String FROM_UNIXTIME = "FROM_UNIXTIME(%s,'%s')";
|
||||
|
||||
public static final String STR_TO_DATE = "STR_TO_DATE(%s,'%s')";
|
||||
|
||||
public static final String CAST = "CAST(%s AS %s)";
|
||||
|
||||
public static final String DEFAULT_DATE_FORMAT = "%Y-%m-%d %H:%i:%S";
|
||||
@ -31,6 +33,8 @@ public class DorisConstants extends SQLConstants {
|
||||
|
||||
public static final String WHERE_VALUE_VALUE = "'%s'";
|
||||
|
||||
public static final String WHERE_NUMBER_VALUE = "%s";
|
||||
|
||||
public static final String AGG_COUNT = "COUNT(*)";
|
||||
|
||||
public static final String AGG_FIELD = "%s(%s)";
|
||||
|
@ -281,6 +281,83 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(DorisConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
|
||||
} else {
|
||||
originField = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("previewSql");
|
||||
st_sql.add("isGroup", false);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("previewSql");
|
||||
st.add("isGroup", false);
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(DorisConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, customFilter, extFilterRequestList, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
return getSQL("(" + sql + ")", xAxis, yAxis, customFilter, extFilterRequestList, null);
|
||||
@ -686,9 +763,14 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
originName = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
|
||||
}
|
||||
|
||||
if (field.getDeType() == 1 && field.getDeExtractType() != 1) {
|
||||
String cast = String.format(DorisConstants.CAST, originName, DorisConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(DorisConstants.FROM_UNIXTIME, cast, DorisConstants.DEFAULT_DATE_FORMAT);
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5 || field.getDeExtractType() == 1) {
|
||||
whereName = String.format(DorisConstants.STR_TO_DATE, originName, DorisConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(DorisConstants.CAST, originName, DorisConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(DorisConstants.FROM_UNIXTIME, cast, DorisConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
} else if (field.getDeType() == 0) {
|
||||
whereName = String.format(DorisConstants.CAST, originName, DorisConstants.VARCHAR);
|
||||
} else {
|
||||
@ -703,7 +785,11 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
} else if (StringUtils.containsIgnoreCase(request.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
whereValue = String.format(DorisConstants.WHERE_VALUE_VALUE, value);
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereValue = String.format(DorisConstants.WHERE_NUMBER_VALUE, value);
|
||||
} else {
|
||||
whereValue = String.format(DorisConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
}
|
||||
list.add(SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
@ -738,9 +824,14 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
originName = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
|
||||
}
|
||||
|
||||
if (field.getDeType() == 1 && field.getDeExtractType() != 1) {
|
||||
String cast = String.format(DorisConstants.CAST, originName, DorisConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(DorisConstants.FROM_UNIXTIME, cast, DorisConstants.DEFAULT_DATE_FORMAT);
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5 || field.getDeExtractType() == 1) {
|
||||
whereName = String.format(DorisConstants.STR_TO_DATE, originName, DorisConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(DorisConstants.CAST, originName, DorisConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(DorisConstants.FROM_UNIXTIME, cast, DorisConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
} else if (field.getDeType() == 0) {
|
||||
whereName = String.format(DorisConstants.CAST, originName, DorisConstants.VARCHAR);
|
||||
} else {
|
||||
@ -762,7 +853,11 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
whereValue = String.format(DorisConstants.WHERE_BETWEEN, value.get(0), value.get(1));
|
||||
}
|
||||
} else {
|
||||
whereValue = String.format(DorisConstants.WHERE_VALUE_VALUE, value.get(0));
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereValue = String.format(DorisConstants.WHERE_NUMBER_VALUE, value.get(0));
|
||||
} else {
|
||||
whereValue = String.format(DorisConstants.WHERE_VALUE_VALUE, value.get(0));
|
||||
}
|
||||
}
|
||||
list.add(SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
@ -778,6 +873,12 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
split = "-";
|
||||
} else if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
|
||||
split = "/";
|
||||
} else {
|
||||
split = "-";
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(dateStyle)) {
|
||||
return "%Y-%m-%d %H:%i:%S";
|
||||
}
|
||||
|
||||
switch (dateStyle) {
|
||||
|
@ -0,0 +1,949 @@
|
||||
package io.dataease.provider.es;
|
||||
|
||||
import io.dataease.base.domain.DatasetTableField;
|
||||
import io.dataease.base.domain.DatasetTableFieldExample;
|
||||
import io.dataease.base.domain.Datasource;
|
||||
import io.dataease.base.mapper.DatasetTableFieldMapper;
|
||||
import io.dataease.commons.constants.DeTypeConstants;
|
||||
import io.dataease.controller.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.dto.chart.ChartCustomFilterDTO;
|
||||
import io.dataease.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.dto.sqlObj.SQLObj;
|
||||
import io.dataease.provider.QueryProvider;
|
||||
import io.dataease.provider.SQLConstants;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.stringtemplate.v4.ST;
|
||||
import org.stringtemplate.v4.STGroup;
|
||||
import org.stringtemplate.v4.STGroupFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static io.dataease.provider.SQLConstants.TABLE_ALIAS_PREFIX;
|
||||
|
||||
@Service("esQuery")
|
||||
public class EsQueryProvider extends QueryProvider {
|
||||
@Resource
|
||||
private DatasetTableFieldMapper datasetTableFieldMapper;
|
||||
|
||||
@Override
|
||||
public Integer transFieldType(String field) {
|
||||
switch (field) {
|
||||
case "keyword":
|
||||
case "text":
|
||||
case "binary":
|
||||
case "object":
|
||||
case "nested":
|
||||
case "null":
|
||||
case "ip":
|
||||
case "unsupported":
|
||||
return DeTypeConstants.DE_STRING;
|
||||
case "boolean":
|
||||
case "byte":
|
||||
case "short":
|
||||
case "integer":
|
||||
case "long":
|
||||
return DeTypeConstants.DE_INT;
|
||||
case "double":
|
||||
case "float":
|
||||
case "half_float":
|
||||
case "scaled_float":
|
||||
return DeTypeConstants.DE_FLOAT;
|
||||
case "datetime":
|
||||
return DeTypeConstants.DE_TIME;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer transFieldTypeSize(String field) {
|
||||
switch (field) {
|
||||
case "null":
|
||||
return 1;
|
||||
case "boolean":
|
||||
return 1;
|
||||
case "byte":
|
||||
return 3;
|
||||
case "short":
|
||||
return 5;
|
||||
case "integer":
|
||||
return 10;
|
||||
case "long":
|
||||
return 19;
|
||||
case "double":
|
||||
case "float":
|
||||
case "half_float":
|
||||
case "scaled_float":
|
||||
return 15;
|
||||
case "keyword":
|
||||
case "text":
|
||||
case "binary":
|
||||
case "object":
|
||||
case "nested":
|
||||
return 65532;
|
||||
case "datetime":
|
||||
return 50;
|
||||
case "ip":
|
||||
return 50;
|
||||
case "unsupported":
|
||||
return 50;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createSQLPreview(String sql, String orderBy) {
|
||||
return "SELECT * FROM (" + sqlFix(sql) + ") AS tmp ORDER BY null " + " LIMIT 1000";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(fields)) {
|
||||
for (int i = 0; i < fields.size(); i++) {
|
||||
DatasetTableField f = fields.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(f.getExtField()) && f.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(f.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(f.getExtField()) && f.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
String fieldName = "";
|
||||
// 处理横轴字段
|
||||
if (f.getDeExtractType() == DeTypeConstants.DE_TIME) {
|
||||
if (f.getDeType() == DeTypeConstants.DE_INT || f.getDeType() == DeTypeConstants.DE_FLOAT) {
|
||||
fieldName = String.format(EsSqlLConstants.CAST, originField, "bigint");
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
} else if (f.getDeExtractType() == DeTypeConstants.DE_STRING) {
|
||||
if (f.getDeType() == DeTypeConstants.DE_INT) {
|
||||
fieldName = String.format(EsSqlLConstants.CAST, originField, "bigint");
|
||||
} else if (f.getDeType() == DeTypeConstants.DE_FLOAT) {
|
||||
fieldName = String.format(EsSqlLConstants.CAST, originField, "double");
|
||||
} else if (f.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
fieldName = String.format(EsSqlLConstants.CAST, originField, "timestamp");
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
} else {
|
||||
if (f.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originField, "timestamp");
|
||||
fieldName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, EsSqlLConstants.DEFAULT_DATE_FORMAT);
|
||||
} else if (f.getDeType() == DeTypeConstants.DE_INT) {
|
||||
fieldName = String.format(EsSqlLConstants.CAST, originField, "timestamp");
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
}
|
||||
xFields.add(SQLObj.builder()
|
||||
.fieldName(fieldName)
|
||||
.fieldAlias(fieldAlias)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("previewSql");
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
return st_sql.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmpWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yFields = new ArrayList<>();
|
||||
List<SQLObj> yWheres = new ArrayList<>();
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(yAxis)) {
|
||||
for (int i = 0; i < yAxis.size(); i++) {
|
||||
ChartViewFieldDTO y = yAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
|
||||
// 处理纵轴字段
|
||||
yFields.add(getYFields(y, originField, fieldAlias));
|
||||
// 处理纵轴过滤
|
||||
yWheres.addAll(getYWheres(y, originField, fieldAlias));
|
||||
// 处理纵轴排序
|
||||
if (StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none")) {
|
||||
yOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(y.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<SQLObj> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(EsSqlLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, customFilter, extFilterRequestList, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
List<ChartViewFieldDTO> xList = new ArrayList<>();
|
||||
xList.addAll(xAxis);
|
||||
xList.addAll(extStack);
|
||||
if (CollectionUtils.isNotEmpty(xList)) {
|
||||
for (int i = 0; i < xList.size(); i++) {
|
||||
ChartViewFieldDTO x = xList.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yFields = new ArrayList<>();
|
||||
List<SQLObj> yWheres = new ArrayList<>();
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(yAxis)) {
|
||||
for (int i = 0; i < yAxis.size(); i++) {
|
||||
ChartViewFieldDTO y = yAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
|
||||
// 处理纵轴字段
|
||||
yFields.add(getYFields(y, originField, fieldAlias));
|
||||
// 处理纵轴过滤
|
||||
yWheres.addAll(getYWheres(y, originField, fieldAlias));
|
||||
// 处理纵轴排序
|
||||
if (StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none")) {
|
||||
yOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(y.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<SQLObj> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(EsSqlLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, customFilter, extFilterRequestList, extStack, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yFields = new ArrayList<>();
|
||||
List<SQLObj> yWheres = new ArrayList<>();
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
List<ChartViewFieldDTO> yList = new ArrayList<>();
|
||||
yList.addAll(yAxis);
|
||||
yList.addAll(extBubble);
|
||||
if (CollectionUtils.isNotEmpty(yList)) {
|
||||
for (int i = 0; i < yList.size(); i++) {
|
||||
ChartViewFieldDTO y = yList.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
|
||||
// 处理纵轴字段
|
||||
yFields.add(getYFields(y, originField, fieldAlias));
|
||||
// 处理纵轴过滤
|
||||
yWheres.addAll(getYWheres(y, originField, fieldAlias));
|
||||
// 处理纵轴排序
|
||||
if (StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none")) {
|
||||
yOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(y.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<SQLObj> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(EsSqlLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, customFilter, extFilterRequestList, extBubble, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> yFields = new ArrayList<>();
|
||||
List<SQLObj> yWheres = new ArrayList<>();
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(yAxis)) {
|
||||
for (int i = 0; i < yAxis.size(); i++) {
|
||||
ChartViewFieldDTO y = yAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
|
||||
// 处理纵轴字段
|
||||
yFields.add(getYFields(y, originField, fieldAlias));
|
||||
// 处理纵轴过滤
|
||||
yWheres.addAll(getYWheres(y, originField, fieldAlias));
|
||||
// 处理纵轴排序
|
||||
if (StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none")) {
|
||||
yOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(y.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(yFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(yOrders);
|
||||
List<SQLObj> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(EsSqlLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, customFilter, extFilterRequestList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String wrapSql(String sql) {
|
||||
sql = sql.trim();
|
||||
if (sql.lastIndexOf(";") == (sql.length() - 1)) {
|
||||
sql = sql.substring(0, sql.length() - 1);
|
||||
}
|
||||
String tmpSql = "SELECT * FROM (" + sql + ") AS tmp " + " LIMIT 0";
|
||||
return tmpSql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createRawQuerySQL(String table, List<DatasetTableField> fields, Datasource ds) {
|
||||
String[] array = fields.stream().map(f -> {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("\"").append(f.getOriginName()).append("\" AS ").append(f.getDataeaseName());
|
||||
return stringBuilder.toString();
|
||||
}).toArray(String[]::new);
|
||||
return MessageFormat.format("SELECT {0} FROM {1} ORDER BY null", StringUtils.join(array, ","), table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createRawQuerySQLAsTmp(String sql, List<DatasetTableField> fields) {
|
||||
return createRawQuerySQL(" (" + sqlFix(sql) + ") AS tmp ", fields, null);
|
||||
}
|
||||
|
||||
public String transMysqlFilterTerm(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 " IN ";
|
||||
case "not_null":
|
||||
return " IS NOT NULL AND %s <> ''";
|
||||
case "between":
|
||||
return " BETWEEN ";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public List<SQLObj> transCustomFilterList(SQLObj tableObj, List<ChartCustomFilterDTO> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
}
|
||||
List<SQLObj> list = new ArrayList<>();
|
||||
for (ChartCustomFilterDTO request : requestList) {
|
||||
DatasetTableField field = request.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
continue;
|
||||
}
|
||||
String value = request.getValue();
|
||||
String whereName = "";
|
||||
String whereTerm = transMysqlFilterTerm(request.getTerm());
|
||||
String whereValue = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(EsSqlLConstants.CAST, originName, "timestamp");
|
||||
}
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == DeTypeConstants.DE_BOOL) {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originName, "timestamp");
|
||||
whereName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, EsSqlLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(request.getTerm(), "null")) {
|
||||
whereValue = EsSqlLConstants.WHERE_VALUE_NULL;
|
||||
} else if (StringUtils.equalsIgnoreCase(request.getTerm(), "not_null")) {
|
||||
whereTerm = String.format(whereTerm, originName);
|
||||
} else if (StringUtils.containsIgnoreCase(request.getTerm(), "in")) {
|
||||
whereValue = "('" + StringUtils.join(value, "','") + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
whereValue = String.format(EsSqlLConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
list.add(SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<SQLObj> transExtFilterList(SQLObj tableObj, List<ChartExtFilterRequest> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
}
|
||||
List<SQLObj> list = new ArrayList<>();
|
||||
for (ChartExtFilterRequest request : requestList) {
|
||||
List<String> value = request.getValue();
|
||||
DatasetTableField field = request.getDatasetTableField();
|
||||
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
|
||||
continue;
|
||||
}
|
||||
String whereName = "";
|
||||
String whereTerm = transMysqlFilterTerm(request.getOperator());
|
||||
String whereValue = "";
|
||||
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(EsSqlLConstants.CAST, originName, "timestamp");
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originName, "timestamp");
|
||||
whereName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, EsSqlLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
|
||||
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
|
||||
whereValue = "('" + StringUtils.join(value, "','") + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
whereValue = "'%" + value.get(0) + "%'";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == 1) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String startTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(0))));
|
||||
String endTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(1))));
|
||||
whereValue = String.format(EsSqlLConstants.WHERE_BETWEEN, startTime, endTime);
|
||||
} else {
|
||||
whereValue = String.format(EsSqlLConstants.WHERE_BETWEEN, value.get(0), value.get(1));
|
||||
}
|
||||
} else {
|
||||
whereValue = String.format(EsSqlLConstants.WHERE_VALUE_VALUE, value.get(0));
|
||||
}
|
||||
list.add(SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private String sqlFix(String sql) {
|
||||
if (sql.lastIndexOf(";") == (sql.length() - 1)) {
|
||||
sql = sql.substring(0, sql.length() - 1);
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
private String transDateFormat(String dateStyle, String datePattern) {
|
||||
String split = "-";
|
||||
if (StringUtils.equalsIgnoreCase(datePattern, "date_sub")) {
|
||||
split = "-";
|
||||
} else if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
|
||||
split = "/";
|
||||
} else {
|
||||
split = "-";
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(dateStyle)) {
|
||||
return "YYYY-MM-dd HH:mm:ss";
|
||||
}
|
||||
|
||||
switch (dateStyle) {
|
||||
case "y":
|
||||
return "YYYY";
|
||||
case "y_M":
|
||||
return "YYYY" + split + "MM";
|
||||
case "y_M_d":
|
||||
return "YYYY" + split + "MM" + split + "dd";
|
||||
case "H_m_s":
|
||||
return "HH:mm:ss";
|
||||
case "y_M_d_H_m":
|
||||
return "YYYY" + split + "MM" + split + "dd" + " HH:mm";
|
||||
case "y_M_d_H_m_s":
|
||||
return "YYYY" + split + "MM" + split + "dd" + " HH:mm:ss";
|
||||
default:
|
||||
return "YYYY-MM-dd HH:mm:ss";
|
||||
}
|
||||
}
|
||||
|
||||
private SQLObj getXFields(ChartViewFieldDTO x, String originField, String fieldAlias) {
|
||||
String fieldName = "";
|
||||
if (x.getDeExtractType() == DeTypeConstants.DE_TIME) {
|
||||
if (x.getDeType() == DeTypeConstants.DE_INT || x.getDeType() == DeTypeConstants.DE_FLOAT) {
|
||||
fieldName = String.format(EsSqlLConstants.CAST, originField, "bigint");
|
||||
} else if (x.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
|
||||
fieldName = String.format(EsSqlLConstants.DATETIME_FORMAT, originField, format);
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
} else {
|
||||
if (x.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
|
||||
if (x.getDeExtractType() == DeTypeConstants.DE_STRING) {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originField, "timestamp");
|
||||
fieldName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, format);
|
||||
} else {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originField, "timestamp");
|
||||
fieldName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, format);
|
||||
}
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
}
|
||||
return SQLObj.builder()
|
||||
.fieldName(fieldName)
|
||||
.fieldAlias(fieldAlias)
|
||||
.build();
|
||||
}
|
||||
|
||||
private SQLObj getYFields(ChartViewFieldDTO y, String originField, String fieldAlias) {
|
||||
String fieldName = "";
|
||||
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
|
||||
fieldName = EsSqlLConstants.AGG_COUNT;
|
||||
} else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) {
|
||||
fieldName = String.format(EsSqlLConstants.AGG_FIELD, y.getSummary(), originField);
|
||||
} else {
|
||||
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originField, y.getDeType() == DeTypeConstants.DE_INT ? "bigint" : "double");
|
||||
String agg = String.format(EsSqlLConstants.AGG_FIELD, y.getSummary(), cast);
|
||||
fieldName = String.format(EsSqlLConstants.CAST, agg, EsSqlLConstants.DEFAULT_FLOAT_FORMAT);
|
||||
} else {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originField, y.getDeType() == DeTypeConstants.DE_INT ? "bigint" : "double");
|
||||
fieldName = String.format(EsSqlLConstants.AGG_FIELD, y.getSummary(), cast);
|
||||
}
|
||||
}
|
||||
return SQLObj.builder()
|
||||
.fieldName(fieldName)
|
||||
.fieldAlias(fieldAlias)
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<SQLObj> getYWheres(ChartViewFieldDTO y, String originField, String fieldAlias) {
|
||||
List<SQLObj> list = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(y.getFilter()) && y.getFilter().size() > 0) {
|
||||
y.getFilter().forEach(f -> {
|
||||
String whereTerm = transMysqlFilterTerm(f.getTerm());
|
||||
String whereValue = "";
|
||||
// 原始类型不是时间,在de中被转成时间的字段做处理
|
||||
if (StringUtils.equalsIgnoreCase(f.getTerm(), "null")) {
|
||||
whereValue = EsSqlLConstants.WHERE_VALUE_NULL;
|
||||
} else if (StringUtils.equalsIgnoreCase(f.getTerm(), "not_null")) {
|
||||
whereTerm = String.format(whereTerm, originField);
|
||||
} else if (StringUtils.containsIgnoreCase(f.getTerm(), "in")) {
|
||||
whereValue = "('" + StringUtils.join(f.getValue(), "','") + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(f.getTerm(), "like")) {
|
||||
whereValue = "'%" + f.getValue() + "%'";
|
||||
} else {
|
||||
whereValue = String.format(EsSqlLConstants.WHERE_VALUE_VALUE, f.getValue());
|
||||
}
|
||||
list.add(SQLObj.builder()
|
||||
.whereField(fieldAlias)
|
||||
.whereAlias(fieldAlias)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build());
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package io.dataease.provider.es;
|
||||
|
||||
import io.dataease.provider.SQLConstants;
|
||||
|
||||
import static io.dataease.datasource.constants.DatasourceTypes.es;
|
||||
|
||||
/**
|
||||
* @Author gin
|
||||
* @Date 2021/7/8 7:22 下午
|
||||
*/
|
||||
public class EsSqlLConstants extends SQLConstants {
|
||||
public static final String KEYWORD_TABLE = es.getKeywordPrefix() + "%s" + es.getKeywordSuffix();
|
||||
|
||||
public static final String KEYWORD_FIX = "%s." + es.getKeywordPrefix() + "%s" + es.getKeywordSuffix();
|
||||
|
||||
public static final String UNIX_TIMESTAMP = "UNIX_TIMESTAMP(%s)";
|
||||
|
||||
public static final String DATETIME_FORMAT = "DATETIME_FORMAT(%s,'%s')";
|
||||
|
||||
public static final String CAST = "CAST(%s AS %s)";
|
||||
|
||||
public static final String DEFAULT_DATE_FORMAT = "YYYY-MM-dd HH:mm:ss";
|
||||
|
||||
public static final String DEFAULT_INT_FORMAT = "DECIMAL(20,0)";
|
||||
|
||||
public static final String DEFAULT_FLOAT_FORMAT = "DECIMAL(20,2)";
|
||||
|
||||
public static final String WHERE_VALUE_NULL = "(NULL,'')";
|
||||
|
||||
public static final String WHERE_VALUE_VALUE = "'%s'";
|
||||
|
||||
public static final String AGG_COUNT = "COUNT(*)";
|
||||
|
||||
public static final String AGG_FIELD = "%s(%s)";
|
||||
|
||||
public static final String WHERE_BETWEEN = "'%s' AND '%s'";
|
||||
|
||||
public static final String BRACKETS = "(%s)";
|
||||
}
|
@ -19,6 +19,8 @@ public class MySQLConstants extends SQLConstants {
|
||||
|
||||
public static final String FROM_UNIXTIME = "FROM_UNIXTIME(%s,'%s')";
|
||||
|
||||
public static final String STR_TO_DATE = "STR_TO_DATE(%s,'%s')";
|
||||
|
||||
public static final String CAST = "CAST(%s AS %s)";
|
||||
|
||||
public static final String DEFAULT_DATE_FORMAT = "%Y-%m-%d %H:%i:%S";
|
||||
|
@ -270,6 +270,83 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("previewSql");
|
||||
st_sql.add("isGroup", false);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("previewSql");
|
||||
st.add("isGroup", false);
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(MySQLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, customFilter, extFilterRequestList, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
@ -671,9 +748,17 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
} else {
|
||||
originName = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == 1 && field.getDeExtractType() != 1) {
|
||||
String cast = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(MySQLConstants.FROM_UNIXTIME, cast, MySQLConstants.DEFAULT_DATE_FORMAT);
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(MySQLConstants.STR_TO_DATE, originName, MySQLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(MySQLConstants.FROM_UNIXTIME, cast, MySQLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
@ -721,9 +806,17 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
originName = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
|
||||
if (field.getDeType() == 1 && field.getDeExtractType() != 1) {
|
||||
String cast = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(MySQLConstants.FROM_UNIXTIME, cast, MySQLConstants.DEFAULT_DATE_FORMAT);
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(MySQLConstants.STR_TO_DATE, originName, MySQLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(MySQLConstants.FROM_UNIXTIME, cast, MySQLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
@ -766,6 +859,12 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
split = "-";
|
||||
} else if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
|
||||
split = "/";
|
||||
} else {
|
||||
split = "-";
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(dateStyle)) {
|
||||
return "%Y-%m-%d %H:%i:%S";
|
||||
}
|
||||
|
||||
switch (dateStyle) {
|
||||
|
@ -17,7 +17,7 @@ public class OracleConstants extends SQLConstants {
|
||||
|
||||
public static final String UNIX_TIMESTAMP = "UNIX_TIMESTAMP(%s)";
|
||||
|
||||
public static final String DATE_FORMAT = "DATE_FORMAT(%s,'%s')";
|
||||
public static final String DATE_FORMAT = "to_timestamp(%s,'%s')";
|
||||
|
||||
public static final String FROM_UNIXTIME = "FROM_UNIXTIME(%s,'%s')";
|
||||
|
||||
|
@ -304,6 +304,83 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(OracleConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(OracleConstants.ALIAS_FIX, String.format(TABLE_ALIAS_PREFIX, 0)))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(OracleConstants.ALIAS_FIX, String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i));
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("previewSql");
|
||||
st_sql.add("isGroup", false);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("previewSql");
|
||||
st.add("isGroup", false);
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(OracleConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, customFilter, extFilterRequestList, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, customFilter, extFilterRequestList, null);
|
||||
@ -635,12 +712,17 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
stringBuilder.append(" \"").append(f.getOriginName()).append("\"");
|
||||
return stringBuilder.toString();
|
||||
}).toArray(String[]::new);
|
||||
return MessageFormat.format("SELECT {0} FROM {1} ORDER BY null", StringUtils.join(array, ","), table );
|
||||
return MessageFormat.format("SELECT {0} FROM {1} ORDER BY null", StringUtils.join(array, ","), "\"" + table + "\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createRawQuerySQLAsTmp(String sql, List<DatasetTableField> fields) {
|
||||
return createRawQuerySQL(" (" + sqlFix(sql) + ") DE_TMP ", fields, null);
|
||||
String[] array = fields.stream().map(f -> {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(" \"").append(f.getOriginName()).append("\"");
|
||||
return stringBuilder.toString();
|
||||
}).toArray(String[]::new);
|
||||
return MessageFormat.format("SELECT {0} FROM {1} ORDER BY null", StringUtils.join(array, ","), " (" + sqlFix(sql) + ") DE_TMP ");
|
||||
}
|
||||
|
||||
public String transMysqlFilterTerm(String term) {
|
||||
@ -701,9 +783,17 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
originName = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
|
||||
if (field.getDeType() == 1 && field.getDeExtractType() != 1) {
|
||||
String cast = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(OracleConstants.FROM_UNIXTIME, cast, OracleConstants.DEFAULT_DATE_FORMAT);
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(OracleConstants.TO_DATE, originName, OracleConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(OracleConstants.FROM_UNIXTIME, cast, OracleConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
@ -716,7 +806,11 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
} else if (StringUtils.containsIgnoreCase(request.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
whereValue = String.format(OracleConstants.WHERE_VALUE_VALUE, value);
|
||||
if (field.getDeType() == 1) {
|
||||
whereValue = String.format(OracleConstants.TO_DATE, "'" + value + "'", OracleConstants.DEFAULT_DATE_FORMAT);
|
||||
} else {
|
||||
whereValue = String.format(OracleConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
}
|
||||
list.add(SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
@ -751,9 +845,17 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
originName = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
|
||||
if (field.getDeType() == 1 && field.getDeExtractType() != 1) {
|
||||
String cast = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(OracleConstants.FROM_UNIXTIME, cast, OracleConstants.DEFAULT_DATE_FORMAT);
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(OracleConstants.TO_DATE, originName, OracleConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(OracleConstants.FROM_UNIXTIME, cast, OracleConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
@ -767,7 +869,9 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String startTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(0))));
|
||||
String endTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(1))));
|
||||
whereValue = String.format(OracleConstants.WHERE_BETWEEN, startTime, endTime);
|
||||
String st = String.format(OracleConstants.TO_DATE, "'" + startTime + "'", OracleConstants.DEFAULT_DATE_FORMAT);
|
||||
String et = String.format(OracleConstants.TO_DATE, "'" + endTime + "'", OracleConstants.DEFAULT_DATE_FORMAT);
|
||||
whereValue = st + " AND " + et;
|
||||
} else {
|
||||
whereValue = String.format(OracleConstants.WHERE_BETWEEN, value.get(0), value.get(1));
|
||||
}
|
||||
@ -795,6 +899,12 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
split = "-";
|
||||
} else if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
|
||||
split = "/";
|
||||
} else {
|
||||
split = "-";
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(dateStyle)) {
|
||||
return OracleConstants.DEFAULT_DATE_FORMAT;
|
||||
}
|
||||
|
||||
switch (dateStyle) {
|
||||
|
@ -19,6 +19,8 @@ public class PgConstants extends SQLConstants {
|
||||
|
||||
public static final String FROM_UNIXTIME = "to_timestamp(%s)";
|
||||
|
||||
public static final String TO_DATE = "to_date(%s,'%s')";
|
||||
|
||||
public static final String CAST = "CAST(%s AS %s)";
|
||||
|
||||
public static final String DEFAULT_DATE_FORMAT = "'YYYY-MM-DD HH24:MI:SS'";
|
||||
|
@ -32,7 +32,6 @@ import java.util.regex.Pattern;
|
||||
import static io.dataease.provider.SQLConstants.TABLE_ALIAS_PREFIX;
|
||||
|
||||
|
||||
|
||||
@Service("pgQuery")
|
||||
public class PgQueryProvider extends QueryProvider {
|
||||
@Resource
|
||||
@ -86,7 +85,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
case "TINYINT":
|
||||
return DeTypeConstants.DE_BOOL;// 布尔
|
||||
case "bytea":
|
||||
return DeTypeConstants.DE_Binary;// 二进制
|
||||
return DeTypeConstants.DE_BINARY;// 二进制
|
||||
default:
|
||||
return DeTypeConstants.DE_STRING;
|
||||
}
|
||||
@ -100,11 +99,11 @@ public class PgQueryProvider extends QueryProvider {
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format( PgConstants.KEYWORD_TABLE, table))
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
|
||||
setSchema(tableObj,ds);
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(fields)) {
|
||||
for (int i = 0; i < fields.size(); i++) {
|
||||
@ -114,35 +113,35 @@ public class PgQueryProvider extends QueryProvider {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(f.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(f.getExtField()) && f.getExtField() == 1) {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
|
||||
} else {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
String fieldName = "";
|
||||
// 处理横轴字段
|
||||
if (f.getDeExtractType() == DeTypeConstants.DE_TIME) {
|
||||
if (f.getDeType() == DeTypeConstants.DE_INT || f.getDeType() == DeTypeConstants.DE_FLOAT) {
|
||||
fieldName = String.format( PgConstants.UNIX_TIMESTAMP, originField);
|
||||
fieldName = String.format(PgConstants.UNIX_TIMESTAMP, originField);
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
} else if (f.getDeExtractType() == DeTypeConstants.DE_STRING) {
|
||||
if (f.getDeType() == DeTypeConstants.DE_INT) {
|
||||
fieldName = String.format( PgConstants.CAST, originField, PgConstants.DEFAULT_INT_FORMAT);
|
||||
fieldName = String.format(PgConstants.CAST, originField, PgConstants.DEFAULT_INT_FORMAT);
|
||||
} else if (f.getDeType() == DeTypeConstants.DE_FLOAT) {
|
||||
fieldName = String.format( PgConstants.CAST, originField, PgConstants.DEFAULT_FLOAT_FORMAT);
|
||||
fieldName = String.format(PgConstants.CAST, originField, PgConstants.DEFAULT_FLOAT_FORMAT);
|
||||
} else if (f.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
fieldName = String.format( PgConstants.CAST, originField, "timestamp");
|
||||
fieldName = String.format(PgConstants.CAST, originField, "timestamp");
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
} else {
|
||||
if (f.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String cast = String.format( PgConstants.CAST, originField, "bigint");
|
||||
fieldName = String.format( PgConstants.FROM_UNIXTIME, cast );
|
||||
String cast = String.format(PgConstants.CAST, originField, "bigint");
|
||||
fieldName = String.format(PgConstants.FROM_UNIXTIME, cast);
|
||||
} else if (f.getDeType() == DeTypeConstants.DE_INT) {
|
||||
fieldName = String.format( PgConstants.CAST, originField, PgConstants.DEFAULT_INT_FORMAT);
|
||||
fieldName = String.format(PgConstants.CAST, originField, PgConstants.DEFAULT_INT_FORMAT);
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
@ -190,10 +189,10 @@ public class PgQueryProvider extends QueryProvider {
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format( PgConstants.KEYWORD_TABLE, table))
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj,ds);
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
@ -205,9 +204,9 @@ public class PgQueryProvider extends QueryProvider {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
@ -235,9 +234,9 @@ public class PgQueryProvider extends QueryProvider {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
|
||||
// 处理纵轴字段
|
||||
@ -285,7 +284,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format( PgConstants.BRACKETS, sql))
|
||||
.tableName(String.format(PgConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
@ -294,6 +293,84 @@ public class PgQueryProvider extends QueryProvider {
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("previewSql");
|
||||
st_sql.add("isGroup", false);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("previewSql");
|
||||
st.add("isGroup", false);
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(PgConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, customFilter, extFilterRequestList, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
@ -303,10 +380,10 @@ public class PgQueryProvider extends QueryProvider {
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format( PgConstants.KEYWORD_TABLE, table))
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj,ds);
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
@ -321,9 +398,9 @@ public class PgQueryProvider extends QueryProvider {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
@ -351,9 +428,9 @@ public class PgQueryProvider extends QueryProvider {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
|
||||
// 处理纵轴字段
|
||||
@ -401,7 +478,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format( PgConstants.BRACKETS, sql))
|
||||
.tableName(String.format(PgConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
@ -418,10 +495,10 @@ public class PgQueryProvider extends QueryProvider {
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format( PgConstants.KEYWORD_TABLE, table))
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj,ds);
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
@ -433,9 +510,9 @@ public class PgQueryProvider extends QueryProvider {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
@ -466,9 +543,9 @@ public class PgQueryProvider extends QueryProvider {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
|
||||
// 处理纵轴字段
|
||||
@ -516,7 +593,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format( PgConstants.BRACKETS, sql))
|
||||
.tableName(String.format(PgConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
@ -539,7 +616,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format( PgConstants.KEYWORD_TABLE, table))
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> yFields = new ArrayList<>();
|
||||
@ -553,9 +630,9 @@ public class PgQueryProvider extends QueryProvider {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
|
||||
// 处理纵轴字段
|
||||
@ -598,7 +675,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format( PgConstants.BRACKETS, sql))
|
||||
.tableName(String.format(PgConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
@ -629,11 +706,11 @@ public class PgQueryProvider extends QueryProvider {
|
||||
stringBuilder.append("\"").append(f.getOriginName()).append("\" AS ").append(f.getDataeaseName());
|
||||
return stringBuilder.toString();
|
||||
}).toArray(String[]::new);
|
||||
if(ds != null){
|
||||
if (ds != null) {
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcDTO.class).getSchema();
|
||||
String tableWithSchema = String.format(SqlServerSQLConstants.KEYWORD_TABLE, schema) + "." + String.format(SqlServerSQLConstants.KEYWORD_TABLE, table);
|
||||
return MessageFormat.format("SELECT {0} FROM {1} ", StringUtils.join(array, ","), tableWithSchema);
|
||||
}else {
|
||||
} else {
|
||||
return MessageFormat.format("SELECT {0} FROM {1} ", StringUtils.join(array, ","), table);
|
||||
}
|
||||
}
|
||||
@ -695,18 +772,26 @@ public class PgQueryProvider extends QueryProvider {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == 1 && field.getDeExtractType() != 1) {
|
||||
String cast = String.format( PgConstants.CAST, originName, "bigint");
|
||||
whereName = String.format( PgConstants.FROM_UNIXTIME, cast);
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(PgConstants.TO_DATE, originName, PgConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(PgConstants.CAST, originName, "bigint");
|
||||
whereName = String.format(PgConstants.FROM_UNIXTIME, cast);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(request.getTerm(), "null")) {
|
||||
whereValue = PgConstants.WHERE_VALUE_NULL;
|
||||
whereValue = PgConstants.WHERE_VALUE_NULL;
|
||||
} else if (StringUtils.equalsIgnoreCase(request.getTerm(), "not_null")) {
|
||||
whereTerm = String.format(whereTerm, originName);
|
||||
} else if (StringUtils.containsIgnoreCase(request.getTerm(), "in")) {
|
||||
@ -714,7 +799,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
} else if (StringUtils.containsIgnoreCase(request.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
whereValue = String.format( PgConstants.WHERE_VALUE_VALUE, value);
|
||||
whereValue = String.format(PgConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
list.add(SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
@ -744,14 +829,22 @@ public class PgQueryProvider extends QueryProvider {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
|
||||
if (field.getDeType() == 1 && field.getDeExtractType() != 1) {
|
||||
String cast = String.format( PgConstants.CAST, originName, "bigint");
|
||||
whereName = String.format( PgConstants.FROM_UNIXTIME, cast);
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(PgConstants.TO_DATE, originName, PgConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(PgConstants.CAST, originName, "bigint");
|
||||
whereName = String.format(PgConstants.FROM_UNIXTIME, cast);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
@ -765,12 +858,12 @@ public class PgQueryProvider extends QueryProvider {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String startTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(0))));
|
||||
String endTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(1))));
|
||||
whereValue = String.format( PgConstants.WHERE_BETWEEN, startTime, endTime);
|
||||
whereValue = String.format(PgConstants.WHERE_BETWEEN, startTime, endTime);
|
||||
} else {
|
||||
whereValue = String.format( PgConstants.WHERE_BETWEEN, value.get(0), value.get(1));
|
||||
whereValue = String.format(PgConstants.WHERE_BETWEEN, value.get(0), value.get(1));
|
||||
}
|
||||
} else {
|
||||
whereValue = String.format( PgConstants.WHERE_VALUE_VALUE, value.get(0));
|
||||
whereValue = String.format(PgConstants.WHERE_VALUE_VALUE, value.get(0));
|
||||
}
|
||||
list.add(SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
@ -793,6 +886,12 @@ public class PgQueryProvider extends QueryProvider {
|
||||
split = "-";
|
||||
} else if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
|
||||
split = "/";
|
||||
} else {
|
||||
split = "-";
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(dateStyle)) {
|
||||
return "'YYYY-MM-DD HH24:MI:SS'";
|
||||
}
|
||||
|
||||
switch (dateStyle) {
|
||||
@ -817,10 +916,10 @@ public class PgQueryProvider extends QueryProvider {
|
||||
String fieldName = "";
|
||||
if (x.getDeExtractType() == DeTypeConstants.DE_TIME) {
|
||||
if (x.getDeType() == 2 || x.getDeType() == 3) {
|
||||
fieldName = String.format( PgConstants.UNIX_TIMESTAMP, originField);
|
||||
fieldName = String.format(PgConstants.UNIX_TIMESTAMP, originField);
|
||||
} else if (x.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
|
||||
fieldName = String.format( PgConstants.DATE_FORMAT, originField, format);
|
||||
fieldName = String.format(PgConstants.DATE_FORMAT, originField, format);
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
@ -828,11 +927,11 @@ public class PgQueryProvider extends QueryProvider {
|
||||
if (x.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
|
||||
if (x.getDeExtractType() == DeTypeConstants.DE_STRING) {
|
||||
fieldName = String.format( PgConstants.DATE_FORMAT, originField, format);
|
||||
fieldName = String.format(PgConstants.DATE_FORMAT, originField, format);
|
||||
} else {
|
||||
String cast = String.format( PgConstants.CAST, originField, "bigint");
|
||||
String from_unixtime = String.format( PgConstants.FROM_UNIXTIME, cast);
|
||||
fieldName = String.format( PgConstants.DATE_FORMAT, from_unixtime, format);
|
||||
String cast = String.format(PgConstants.CAST, originField, "bigint");
|
||||
String from_unixtime = String.format(PgConstants.FROM_UNIXTIME, cast);
|
||||
fieldName = String.format(PgConstants.DATE_FORMAT, from_unixtime, format);
|
||||
}
|
||||
} else {
|
||||
fieldName = originField;
|
||||
@ -847,17 +946,17 @@ public class PgQueryProvider extends QueryProvider {
|
||||
private SQLObj getYFields(ChartViewFieldDTO y, String originField, String fieldAlias) {
|
||||
String fieldName = "";
|
||||
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
|
||||
fieldName = PgConstants.AGG_COUNT;
|
||||
fieldName = PgConstants.AGG_COUNT;
|
||||
} else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) {
|
||||
fieldName = String.format( PgConstants.AGG_FIELD, y.getSummary(), originField);
|
||||
fieldName = String.format(PgConstants.AGG_FIELD, y.getSummary(), originField);
|
||||
} else {
|
||||
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
||||
String cast = String.format( PgConstants.CAST, originField, y.getDeType() == DeTypeConstants.DE_INT ? PgConstants.DEFAULT_INT_FORMAT : PgConstants.DEFAULT_FLOAT_FORMAT);
|
||||
String agg = String.format( PgConstants.AGG_FIELD, y.getSummary(), cast);
|
||||
fieldName = String.format( PgConstants.CAST, agg, PgConstants.DEFAULT_FLOAT_FORMAT);
|
||||
String cast = String.format(PgConstants.CAST, originField, y.getDeType() == DeTypeConstants.DE_INT ? PgConstants.DEFAULT_INT_FORMAT : PgConstants.DEFAULT_FLOAT_FORMAT);
|
||||
String agg = String.format(PgConstants.AGG_FIELD, y.getSummary(), cast);
|
||||
fieldName = String.format(PgConstants.CAST, agg, PgConstants.DEFAULT_FLOAT_FORMAT);
|
||||
} else {
|
||||
String cast = String.format( PgConstants.CAST, originField, y.getDeType() == DeTypeConstants.DE_INT ? PgConstants.DEFAULT_INT_FORMAT : PgConstants.DEFAULT_FLOAT_FORMAT);
|
||||
fieldName = String.format( PgConstants.AGG_FIELD, y.getSummary(), cast);
|
||||
String cast = String.format(PgConstants.CAST, originField, y.getDeType() == DeTypeConstants.DE_INT ? PgConstants.DEFAULT_INT_FORMAT : PgConstants.DEFAULT_FLOAT_FORMAT);
|
||||
fieldName = String.format(PgConstants.AGG_FIELD, y.getSummary(), cast);
|
||||
}
|
||||
}
|
||||
return SQLObj.builder()
|
||||
@ -874,7 +973,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
String whereValue = "";
|
||||
// 原始类型不是时间,在de中被转成时间的字段做处理
|
||||
if (StringUtils.equalsIgnoreCase(f.getTerm(), "null")) {
|
||||
whereValue = PgConstants.WHERE_VALUE_NULL;
|
||||
whereValue = PgConstants.WHERE_VALUE_NULL;
|
||||
} else if (StringUtils.equalsIgnoreCase(f.getTerm(), "not_null")) {
|
||||
whereTerm = String.format(whereTerm, originField);
|
||||
} else if (StringUtils.containsIgnoreCase(f.getTerm(), "in")) {
|
||||
@ -882,7 +981,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
} else if (StringUtils.containsIgnoreCase(f.getTerm(), "like")) {
|
||||
whereValue = "'%" + f.getValue() + "%'";
|
||||
} else {
|
||||
whereValue = String.format( PgConstants.WHERE_VALUE_VALUE, f.getValue());
|
||||
whereValue = String.format(PgConstants.WHERE_VALUE_VALUE, f.getValue());
|
||||
}
|
||||
list.add(SQLObj.builder()
|
||||
.whereField(fieldAlias)
|
||||
@ -913,7 +1012,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format( PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import io.dataease.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.dto.sqlObj.SQLObj;
|
||||
import io.dataease.provider.QueryProvider;
|
||||
import io.dataease.provider.SQLConstants;
|
||||
import io.dataease.provider.oracle.OracleConstants;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -73,7 +74,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
case "TINYINT":
|
||||
return DeTypeConstants.DE_BOOL;// 布尔
|
||||
case "TIMESTAMP":
|
||||
return DeTypeConstants.DE_Binary;// 二进制
|
||||
return DeTypeConstants.DE_BINARY;// 二进制
|
||||
default:
|
||||
return DeTypeConstants.DE_STRING;
|
||||
}
|
||||
@ -91,7 +92,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj,ds);
|
||||
setSchema(tableObj, ds);
|
||||
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(fields)) {
|
||||
@ -159,12 +160,12 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, ds) + " ORDER BY \"" + fields.get(0).getOriginName() + "\" offset 0 rows fetch next " + limit + " rows only";
|
||||
return createQuerySQL(table, fields, isGroup, ds) + " ORDER BY \"" + fields.get(0).getOriginName() + "\" offset 0 rows fetch next " + limit + " rows only";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " ORDER BY \"" + fields.get(0).getOriginName() + "\" offset 0 rows fetch next " + limit + " rows only";
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " ORDER BY \"" + fields.get(0).getOriginName() + "\" offset 0 rows fetch next " + limit + " rows only";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -173,7 +174,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj,ds);
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
@ -258,6 +259,76 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("previewSql");
|
||||
st_sql.add("isGroup", false);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("previewSql");
|
||||
st.add("isGroup", false);
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(SqlServerSQLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, customFilter, extFilterRequestList, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
@ -270,7 +341,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj,ds);
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
@ -388,7 +459,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj,ds);
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
@ -588,11 +659,11 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
stringBuilder.append("\"").append(f.getOriginName()).append("\" AS ").append(f.getDataeaseName());
|
||||
return stringBuilder.toString();
|
||||
}).toArray(String[]::new);
|
||||
if(ds != null){
|
||||
if (ds != null) {
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcDTO.class).getSchema();
|
||||
String tableWithSchema = String.format(SqlServerSQLConstants.KEYWORD_TABLE, schema) + "." + String.format(SqlServerSQLConstants.KEYWORD_TABLE, table);
|
||||
return MessageFormat.format("SELECT {0} FROM {1} ", StringUtils.join(array, ","), tableWithSchema);
|
||||
}else {
|
||||
} else {
|
||||
return MessageFormat.format("SELECT {0} FROM {1} ", StringUtils.join(array, ","), table);
|
||||
}
|
||||
}
|
||||
@ -651,9 +722,18 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
String whereTerm = transMysqlFilterTerm(request.getTerm());
|
||||
String whereValue = "";
|
||||
String originName = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
if (field.getDeType() == DeTypeConstants.DE_TIME && field.getDeExtractType() != DeTypeConstants.DE_TIME) {
|
||||
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originName + "/1000");
|
||||
whereName = String.format(SqlServerSQLConstants.FROM_UNIXTIME, cast);
|
||||
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(SqlServerSQLConstants.STRING_TO_DATE, originName);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originName + "/1000");
|
||||
whereName = String.format(SqlServerSQLConstants.FROM_UNIXTIME, cast);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
@ -692,9 +772,17 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
String whereValue = "";
|
||||
String originName = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
|
||||
if (field.getDeType() == 1 && field.getDeExtractType() != 1) {
|
||||
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originName + "/1000");
|
||||
whereName = String.format(SqlServerSQLConstants.FROM_UNIXTIME, cast);
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(SqlServerSQLConstants.STRING_TO_DATE, originName);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originName + "/1000");
|
||||
whereName = String.format(SqlServerSQLConstants.FROM_UNIXTIME, cast);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
@ -738,36 +826,42 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
split = "-";
|
||||
} else if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
|
||||
split = "/";
|
||||
} else {
|
||||
split = "-";
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(dateStyle)) {
|
||||
return "convert(varchar," + originField + ",120)";
|
||||
}
|
||||
|
||||
switch (dateStyle) {
|
||||
case "y":
|
||||
return "CONVERT(varchar(100), datepart(yy, " + originField + "))";
|
||||
case "y_M":
|
||||
if(split.equalsIgnoreCase("-")){
|
||||
if (split.equalsIgnoreCase("-")) {
|
||||
return "substring( convert(varchar," + originField + ",120),1,7)";
|
||||
}else {
|
||||
return "replace("+ "substring( convert(varchar," + originField + ",120),1,7), '-','/')";
|
||||
} else {
|
||||
return "replace(" + "substring( convert(varchar," + originField + ",120),1,7), '-','/')";
|
||||
}
|
||||
case "y_M_d":
|
||||
if(split.equalsIgnoreCase("-")){
|
||||
if (split.equalsIgnoreCase("-")) {
|
||||
return "CONVERT(varchar(100), " + originField + ", 23)";
|
||||
}else {
|
||||
} else {
|
||||
return "CONVERT(varchar(100), " + originField + ", 111)";
|
||||
}
|
||||
case "H_m_s":
|
||||
return "CONVERT(varchar(100), " + originField + ", 8)";
|
||||
case "y_M_d_H_m":
|
||||
if(split.equalsIgnoreCase("-")){
|
||||
if (split.equalsIgnoreCase("-")) {
|
||||
return "substring( convert(varchar," + originField + ",120),1,16)";
|
||||
}else {
|
||||
return "replace("+ "substring( convert(varchar," + originField + ",120),1,16), '-','/')";
|
||||
} else {
|
||||
return "replace(" + "substring( convert(varchar," + originField + ",120),1,16), '-','/')";
|
||||
}
|
||||
case "y_M_d_H_m_s":
|
||||
if(split.equalsIgnoreCase("-")){
|
||||
if (split.equalsIgnoreCase("-")) {
|
||||
return "convert(varchar," + originField + ",120)";
|
||||
}else {
|
||||
return "replace("+ "convert(varchar," + originField + ",120), '-','/')";
|
||||
} else {
|
||||
return "replace(" + "convert(varchar," + originField + ",120), '-','/')";
|
||||
}
|
||||
default:
|
||||
return "convert(varchar," + originField + ",120)";
|
||||
@ -790,7 +884,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
String cast = String.format(SqlServerSQLConstants.STRING_TO_DATE, originField);
|
||||
fieldName = transDateFormat(x.getDateStyle(), x.getDatePattern(), cast);
|
||||
} else {// 数值转时间
|
||||
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originField+ "/1000");
|
||||
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originField + "/1000");
|
||||
fieldName = transDateFormat(x.getDateStyle(), x.getDatePattern(), cast);
|
||||
}
|
||||
} else {
|
||||
|
@ -184,6 +184,11 @@ public class ChartViewService {
|
||||
}.getType());
|
||||
List<ChartViewFieldDTO> yAxis = new Gson().fromJson(view.getYAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
if (StringUtils.equalsIgnoreCase(view.getType(), "chart-mix")) {
|
||||
List<ChartViewFieldDTO> yAxisExt = new Gson().fromJson(view.getYAxisExt(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
yAxis.addAll(yAxisExt);
|
||||
}
|
||||
List<ChartViewFieldDTO> extStack = new Gson().fromJson(view.getExtStack(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
List<ChartViewFieldDTO> extBubble = new Gson().fromJson(view.getExtBubble(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
@ -203,13 +208,22 @@ public class ChartViewService {
|
||||
customFilter.addAll(collect);
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType())) {
|
||||
if (StringUtils.equalsIgnoreCase("text", view.getType())
|
||||
|| StringUtils.equalsIgnoreCase("gauge", view.getType())
|
||||
|| StringUtils.equalsIgnoreCase("liquid", view.getType())) {
|
||||
xAxis = new ArrayList<>();
|
||||
if (CollectionUtils.isEmpty(yAxis)) {
|
||||
ChartViewDTO dto = new ChartViewDTO();
|
||||
BeanUtils.copyBean(dto, view);
|
||||
return dto;
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
yAxis = new ArrayList<>();
|
||||
if (CollectionUtils.isEmpty(xAxis)) {
|
||||
ChartViewDTO dto = new ChartViewDTO();
|
||||
BeanUtils.copyBean(dto, view);
|
||||
return dto;
|
||||
}
|
||||
} else {
|
||||
if (CollectionUtils.isEmpty(xAxis) && CollectionUtils.isEmpty(yAxis)) {
|
||||
ChartViewDTO dto = new ChartViewDTO();
|
||||
@ -315,22 +329,26 @@ public class ChartViewService {
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
if (StringUtils.equalsIgnoreCase(table.getType(), "db")) {
|
||||
datasourceRequest.setTable(dataTableInfoDTO.getTable());
|
||||
if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType())) {
|
||||
if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType()) || StringUtils.equalsIgnoreCase("liquid", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLSummary(dataTableInfoDTO.getTable(), yAxis, customFilter, extFilterList));
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) {
|
||||
datasourceRequest.setQuery(qp.getSQLStack(dataTableInfoDTO.getTable(), xAxis, yAxis, customFilter, extFilterList, extStack, ds));
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "scatter")) {
|
||||
datasourceRequest.setQuery(qp.getSQLScatter(dataTableInfoDTO.getTable(), xAxis, yAxis, customFilter, extFilterList, extBubble, ds));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLTableInfo(dataTableInfoDTO.getTable(), xAxis, customFilter, extFilterList, ds));
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQL(dataTableInfoDTO.getTable(), xAxis, yAxis, customFilter, extFilterList, ds));
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(table.getType(), "sql")) {
|
||||
if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType())) {
|
||||
if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType()) || StringUtils.equalsIgnoreCase("liquid", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLSummaryAsTmp(dataTableInfoDTO.getSql(), yAxis, customFilter, extFilterList));
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpStack(dataTableInfoDTO.getSql(), xAxis, yAxis, customFilter, extFilterList, extStack));
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "scatter")) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpScatter(dataTableInfoDTO.getSql(), xAxis, yAxis, customFilter, extFilterList, extBubble));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpTableInfo(dataTableInfoDTO.getSql(), xAxis, customFilter, extFilterList, ds));
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmp(dataTableInfoDTO.getSql(), xAxis, yAxis, customFilter, extFilterList));
|
||||
}
|
||||
@ -338,12 +356,14 @@ public class ChartViewService {
|
||||
DataTableInfoDTO dt = new Gson().fromJson(table.getInfo(), DataTableInfoDTO.class);
|
||||
List<DataSetTableUnionDTO> list = dataSetTableUnionService.listByTableId(dt.getList().get(0).getTableId());
|
||||
String sql = dataSetTableService.getCustomSQLDatasource(dt, list, ds);
|
||||
if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType())) {
|
||||
if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType()) || StringUtils.equalsIgnoreCase("liquid", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLSummaryAsTmp(sql, yAxis, customFilter, extFilterList));
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpStack(sql, xAxis, yAxis, customFilter, extFilterList, extStack));
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "scatter")) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpScatter(sql, xAxis, yAxis, customFilter, extFilterList, extBubble));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpTableInfo(sql, xAxis, customFilter, extFilterList, ds));
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmp(sql, xAxis, yAxis, customFilter, extFilterList));
|
||||
}
|
||||
@ -368,12 +388,14 @@ public class ChartViewService {
|
||||
String tableName = "ds_" + table.getId().replaceAll("-", "_");
|
||||
datasourceRequest.setTable(tableName);
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType())) {
|
||||
if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType()) || StringUtils.equalsIgnoreCase("liquid", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLSummary(tableName, yAxis, customFilter, extFilterList));
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) {
|
||||
datasourceRequest.setQuery(qp.getSQLStack(tableName, xAxis, yAxis, customFilter, extFilterList, extStack, ds));
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "scatter")) {
|
||||
datasourceRequest.setQuery(qp.getSQLScatter(tableName, xAxis, yAxis, customFilter, extFilterList, extBubble, ds));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLTableInfo(tableName, xAxis, customFilter, extFilterList, ds));
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQL(tableName, xAxis, yAxis, customFilter, extFilterList, ds));
|
||||
}
|
||||
@ -427,6 +449,8 @@ public class ChartViewService {
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "text")
|
||||
|| StringUtils.containsIgnoreCase(view.getType(), "gauge")) {
|
||||
mapChart = transNormalChartData(xAxis, yAxis, view, data, isDrill);
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "chart-mix")) {
|
||||
mapChart = transMixChartData(xAxis, yAxis, view, data, isDrill);
|
||||
} else {
|
||||
mapChart = transChartData(xAxis, yAxis, view, data, isDrill);
|
||||
}
|
||||
@ -436,6 +460,9 @@ public class ChartViewService {
|
||||
map.putAll(mapChart);
|
||||
map.putAll(mapTableNormal);
|
||||
|
||||
List<DatasetTableField> sourceFields = dataSetTableFieldsService.getFieldsByTableId(view.getTableId());
|
||||
map.put("sourceFields",sourceFields);
|
||||
|
||||
ChartViewDTO dto = new ChartViewDTO();
|
||||
BeanUtils.copyBean(dto, view);
|
||||
dto.setData(map);
|
||||
@ -561,6 +588,67 @@ public class ChartViewService {
|
||||
return map;
|
||||
}
|
||||
|
||||
// 组合图形
|
||||
private Map<String, Object> transMixChartData(List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, ChartViewWithBLOBs view, List<String[]> data, boolean isDrill) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
List<String> x = new ArrayList<>();
|
||||
List<Series> series = new ArrayList<>();
|
||||
for (ChartViewFieldDTO y : yAxis) {
|
||||
Series series1 = new Series();
|
||||
series1.setName(y.getName());
|
||||
series1.setType(y.getChartType());
|
||||
series1.setData(new ArrayList<>());
|
||||
series.add(series1);
|
||||
}
|
||||
for (int i1 = 0; i1 < data.size(); i1++) {
|
||||
String[] d = data.get(i1);
|
||||
|
||||
StringBuilder a = new StringBuilder();
|
||||
for (int i = xAxis.size(); i < xAxis.size() + yAxis.size(); i++) {
|
||||
List<ChartDimensionDTO> dimensionList = new ArrayList<>();
|
||||
List<ChartQuotaDTO> quotaList = new ArrayList<>();
|
||||
AxisChartDataDTO axisChartDataDTO = new AxisChartDataDTO();
|
||||
|
||||
for (int j = 0; j < xAxis.size(); j++) {
|
||||
ChartDimensionDTO chartDimensionDTO = new ChartDimensionDTO();
|
||||
chartDimensionDTO.setId(xAxis.get(j).getId());
|
||||
chartDimensionDTO.setValue(d[j]);
|
||||
dimensionList.add(chartDimensionDTO);
|
||||
}
|
||||
axisChartDataDTO.setDimensionList(dimensionList);
|
||||
|
||||
int j = i - xAxis.size();
|
||||
ChartQuotaDTO chartQuotaDTO = new ChartQuotaDTO();
|
||||
chartQuotaDTO.setId(yAxis.get(j).getId());
|
||||
quotaList.add(chartQuotaDTO);
|
||||
axisChartDataDTO.setQuotaList(quotaList);
|
||||
try {
|
||||
axisChartDataDTO.setValue(new BigDecimal(StringUtils.isEmpty(d[i]) ? "0" : d[i]));
|
||||
} catch (Exception e) {
|
||||
axisChartDataDTO.setValue(new BigDecimal(0));
|
||||
}
|
||||
series.get(j).getData().add(axisChartDataDTO);
|
||||
}
|
||||
if (isDrill) {
|
||||
a.append(d[xAxis.size() - 1]);
|
||||
} else {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
if (i == xAxis.size() - 1) {
|
||||
a.append(d[i]);
|
||||
} else {
|
||||
a.append(d[i]).append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
x.add(a.toString());
|
||||
}
|
||||
|
||||
map.put("x", x);
|
||||
map.put("series", series);
|
||||
return map;
|
||||
}
|
||||
|
||||
// 常规图形
|
||||
private Map<String, Object> transNormalChartData(List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, ChartViewWithBLOBs view, List<String[]> data, boolean isDrill) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.service.dataset;
|
||||
|
||||
|
||||
import com.fit2cloud.quartz.anno.QuartzScheduled;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.base.domain.*;
|
||||
import io.dataease.base.mapper.*;
|
||||
@ -115,9 +114,9 @@ public class DataSetTableService {
|
||||
}
|
||||
}
|
||||
|
||||
public void saveExcel(DataSetTableRequest datasetTable)throws Exception {
|
||||
public void saveExcel(DataSetTableRequest datasetTable) throws Exception {
|
||||
if (StringUtils.isEmpty(datasetTable.getId())) {
|
||||
if(datasetTable.isMergeSheet()){
|
||||
if (datasetTable.isMergeSheet()) {
|
||||
Map<String, List<ExcelSheetData>> map = datasetTable.getSheets().stream().collect(Collectors.groupingBy(ExcelSheetData::getFieldsMd5));
|
||||
for (String s : map.keySet()) {
|
||||
DataSetTableRequest sheetTable = new DataSetTableRequest();
|
||||
@ -147,7 +146,7 @@ public class DataSetTableService {
|
||||
});
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
for (ExcelSheetData sheet : datasetTable.getSheets()) {
|
||||
String[] fieldArray = sheet.getFields().stream().map(TableFiled::getFieldName).toArray(String[]::new);
|
||||
if (checkIsRepeat(fieldArray)) {
|
||||
@ -183,7 +182,7 @@ public class DataSetTableService {
|
||||
List<String> oldFields = datasetTable.getSheets().get(0).getFields().stream().map(TableFiled::getRemarks).collect(Collectors.toList());
|
||||
for (ExcelSheetData sheet : datasetTable.getSheets()) {
|
||||
//替换时,
|
||||
if(datasetTable.getEditType() == 0){
|
||||
if (datasetTable.getEditType() == 0) {
|
||||
List<String> newFields = sheet.getFields().stream().map(TableFiled::getRemarks).collect(Collectors.toList());
|
||||
if (!oldFields.equals(newFields)) {
|
||||
DataEaseException.throwException(Translator.get("i18n_excel_colume_change"));
|
||||
@ -240,7 +239,7 @@ public class DataSetTableService {
|
||||
if (datasetTable.getIsRename() == null || !datasetTable.getIsRename()) {
|
||||
// 更新数据和字段
|
||||
if (update == 1) {
|
||||
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql") || StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom") ) {
|
||||
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql") || StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom")) {
|
||||
// 删除所有字段,重新抽象
|
||||
dataSetTableFieldsService.deleteByTableId(datasetTable.getId());
|
||||
saveTableField(datasetTable);
|
||||
@ -251,7 +250,7 @@ public class DataSetTableService {
|
||||
return datasetTable;
|
||||
}
|
||||
|
||||
public void alter(DataSetTableRequest request)throws Exception {
|
||||
public void alter(DataSetTableRequest request) throws Exception {
|
||||
checkName(request);
|
||||
datasetTableMapper.updateByPrimaryKeySelective(request);
|
||||
}
|
||||
@ -470,14 +469,23 @@ public class DataSetTableService {
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
System.out.println(datasourceRequest.getQuery());
|
||||
datasourceRequest.setPage(page);
|
||||
datasourceRequest.setFetchSize(Integer.parseInt(dataSetTableRequest.getRow()));
|
||||
datasourceRequest.setPageSize(pageSize);
|
||||
datasourceRequest.setRealSize(realSize);
|
||||
datasourceRequest.setPreviewData(true);
|
||||
try {
|
||||
datasourceRequest.setPageable(true);
|
||||
data.addAll(datasourceProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
|
||||
datasourceRequest.setPageable(false);
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -496,8 +504,12 @@ public class DataSetTableService {
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
System.out.println(datasourceRequest.getQuery());
|
||||
try {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
for(int i=0;i< data.size(); i++){
|
||||
System.out.println(data.get(i)[2]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
@ -551,8 +563,12 @@ public class DataSetTableService {
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
System.out.println(datasourceRequest.getQuery());
|
||||
try {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
for(int i=0;i< data.size(); i++){
|
||||
System.out.println(data.get(i)[2]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
@ -578,8 +594,12 @@ public class DataSetTableService {
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
System.out.println(datasourceRequest.getQuery());
|
||||
try {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
for(int i=0;i< data.size(); i++){
|
||||
System.out.println(data.get(i)[2]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
@ -798,18 +818,35 @@ public class DataSetTableService {
|
||||
String f = field.substring(0, field.length() - 1);
|
||||
|
||||
StringBuilder join = new StringBuilder();
|
||||
List<DataSetTableUnionDTO> unions = new ArrayList<>();
|
||||
for (DataTableInfoCustomUnion dataTableInfoCustomUnion : dataTableInfoDTO.getList()) {
|
||||
for (DataSetTableUnionDTO dto : list) {
|
||||
// 被关联表和自助数据集的表相等
|
||||
if (StringUtils.equals(dto.getTargetTableId(), dataTableInfoCustomUnion.getTableId())) {
|
||||
DatasetTableField sourceField = dataSetTableFieldsService.get(dto.getSourceTableFieldId());
|
||||
DatasetTableField targetField = dataSetTableFieldsService.get(dto.getTargetTableFieldId());
|
||||
unions.add(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(unions)) {
|
||||
for (int i = 0; i < unions.size(); i++) {
|
||||
DataSetTableUnionDTO dto = unions.get(i);
|
||||
DatasetTableField sourceField = dataSetTableFieldsService.get(dto.getSourceTableFieldId());
|
||||
DatasetTableField targetField = dataSetTableFieldsService.get(dto.getTargetTableFieldId());
|
||||
if (ObjectUtils.isEmpty(sourceField) || ObjectUtils.isEmpty(targetField)) {
|
||||
DEException.throwException(Translator.get("i18n_dataset_field_delete"));
|
||||
}
|
||||
if (i == 0) {
|
||||
join.append(convertUnionTypeToSQL(dto.getSourceUnionRelation()))
|
||||
.append(DorisTableUtils.dorisName(dto.getTargetTableId()))
|
||||
.append(" ON ")
|
||||
.append(DorisTableUtils.dorisName(dto.getSourceTableId())).append(".").append(sourceField.getDataeaseName())
|
||||
.append(" = ")
|
||||
.append(DorisTableUtils.dorisName(dto.getTargetTableId())).append(".").append(targetField.getDataeaseName());
|
||||
} else {
|
||||
join.append(" AND ")
|
||||
.append(DorisTableUtils.dorisName(dto.getSourceTableId())).append(".").append(sourceField.getDataeaseName())
|
||||
.append(" = ")
|
||||
.append(DorisTableUtils.dorisName(dto.getTargetTableId())).append(".").append(targetField.getDataeaseName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -855,22 +892,39 @@ public class DataSetTableService {
|
||||
String f = field.substring(0, field.length() - 1);
|
||||
|
||||
StringBuilder join = new StringBuilder();
|
||||
List<DataSetTableUnionDTO> unions = new ArrayList<>();
|
||||
for (DataTableInfoCustomUnion dataTableInfoCustomUnion : dataTableInfoDTO.getList()) {
|
||||
for (DataSetTableUnionDTO dto : list) {
|
||||
// 被关联表和自助数据集的表相等
|
||||
if (StringUtils.equals(dto.getTargetTableId(), dataTableInfoCustomUnion.getTableId())) {
|
||||
DatasetTableField sourceField = dataSetTableFieldsService.get(dto.getSourceTableFieldId());
|
||||
DatasetTableField targetField = dataSetTableFieldsService.get(dto.getTargetTableFieldId());
|
||||
DatasetTable sourceTable = datasetTableMapper.selectByPrimaryKey(dto.getSourceTableId());
|
||||
String sourceTableName = new Gson().fromJson(sourceTable.getInfo(), DataTableInfoDTO.class).getTable();
|
||||
DatasetTable targetTable = datasetTableMapper.selectByPrimaryKey(dto.getTargetTableId());
|
||||
String targetTableName = new Gson().fromJson(targetTable.getInfo(), DataTableInfoDTO.class).getTable();
|
||||
unions.add(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(unions)) {
|
||||
for (int i = 0; i < unions.size(); i++) {
|
||||
DataSetTableUnionDTO dto = unions.get(i);
|
||||
DatasetTableField sourceField = dataSetTableFieldsService.get(dto.getSourceTableFieldId());
|
||||
DatasetTableField targetField = dataSetTableFieldsService.get(dto.getTargetTableFieldId());
|
||||
if (ObjectUtils.isEmpty(sourceField) || ObjectUtils.isEmpty(targetField)) {
|
||||
DEException.throwException(Translator.get("i18n_dataset_field_delete"));
|
||||
}
|
||||
DatasetTable sourceTable = datasetTableMapper.selectByPrimaryKey(dto.getSourceTableId());
|
||||
String sourceTableName = new Gson().fromJson(sourceTable.getInfo(), DataTableInfoDTO.class).getTable();
|
||||
DatasetTable targetTable = datasetTableMapper.selectByPrimaryKey(dto.getTargetTableId());
|
||||
String targetTableName = new Gson().fromJson(targetTable.getInfo(), DataTableInfoDTO.class).getTable();
|
||||
if (i == 0) {
|
||||
join.append(convertUnionTypeToSQL(dto.getSourceUnionRelation()))
|
||||
.append(String.format(keyword, targetTableName))
|
||||
.append(" ON ")
|
||||
.append(String.format(keyword, sourceTableName)).append(".").append(String.format(keyword, sourceField.getOriginName()))
|
||||
.append(" = ")
|
||||
.append(String.format(keyword, targetTableName)).append(".").append(String.format(keyword, targetField.getOriginName()));
|
||||
} else {
|
||||
join.append(" AND ")
|
||||
.append(String.format(keyword, sourceTableName)).append(".").append(String.format(keyword, sourceField.getOriginName()))
|
||||
.append(" = ")
|
||||
.append(String.format(keyword, targetTableName)).append(".").append(String.format(keyword, targetField.getOriginName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -901,7 +955,7 @@ public class DataSetTableService {
|
||||
}
|
||||
}
|
||||
|
||||
public List<DatasetTableField> saveExcelTableField(String datasetTableId, List<TableFiled> fields, boolean insert){
|
||||
public List<DatasetTableField> saveExcelTableField(String datasetTableId, List<TableFiled> fields, boolean insert) {
|
||||
List<DatasetTableField> datasetTableFields = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(fields)) {
|
||||
for (int i = 0; i < fields.size(); i++) {
|
||||
@ -920,7 +974,7 @@ public class DataSetTableService {
|
||||
datasetTableField.setLastSyncTime(System.currentTimeMillis());
|
||||
datasetTableField.setExtField(0);
|
||||
datasetTableField.setGroupType(datasetTableField.getDeType() < 2 ? "d" : "q");
|
||||
if(insert){
|
||||
if (insert) {
|
||||
dataSetTableFieldsService.save(datasetTableField);
|
||||
}
|
||||
datasetTableFields.add(datasetTableField);
|
||||
@ -1120,11 +1174,11 @@ public class DataSetTableService {
|
||||
.replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString());
|
||||
datasourceRequest.setQuery(qp.wrapSql(sql));
|
||||
List<String> sqlFileds = new ArrayList<>();
|
||||
try{
|
||||
try {
|
||||
datasourceProvider.fetchResultField(datasourceRequest).stream().map(TableFiled::getFieldName).forEach(filed -> {
|
||||
sqlFileds.add(filed);
|
||||
});
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(Translator.get("i18n_check_sql_error") + e.getMessage());
|
||||
}
|
||||
|
||||
@ -1137,11 +1191,11 @@ public class DataSetTableService {
|
||||
.replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString());
|
||||
datasourceRequest.setQuery(qp.wrapSql(sql));
|
||||
List<String> sqlFileds = new ArrayList<>();
|
||||
try{
|
||||
try {
|
||||
datasourceProvider.fetchResultField(datasourceRequest).stream().map(TableFiled::getFieldName).forEach(filed -> {
|
||||
sqlFileds.add(filed);
|
||||
});
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(Translator.get("i18n_check_sql_error") + e.getMessage());
|
||||
}
|
||||
|
||||
@ -1186,7 +1240,7 @@ public class DataSetTableService {
|
||||
List<ExcelSheetData> excelSheetDataList = parseExcel2(filename, file.getInputStream(), true);
|
||||
List<ExcelSheetData> retrunSheetDataList = new ArrayList<>();
|
||||
|
||||
if (StringUtils.isNotEmpty(tableId) && editType == 1 ) {
|
||||
if (StringUtils.isNotEmpty(tableId) && editType == 1) {
|
||||
List<DatasetTableField> datasetTableFields = dataSetTableFieldsService.getFieldsByTableId(tableId);
|
||||
datasetTableFields.stream().filter(datasetTableField -> datasetTableField.getExtField() == 0).collect(Collectors.toList());
|
||||
datasetTableFields.sort((o1, o2) -> {
|
||||
@ -1210,7 +1264,7 @@ public class DataSetTableService {
|
||||
if (retrunSheetDataList.size() == 0) {
|
||||
DataEaseException.throwException(Translator.get("i18n_excel_colume_change"));
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
retrunSheetDataList = excelSheetDataList;
|
||||
}
|
||||
|
||||
@ -1223,12 +1277,12 @@ public class DataSetTableService {
|
||||
excelFileData.setPath(filePath);
|
||||
|
||||
filename = filename.substring(0, filename.lastIndexOf('.'));
|
||||
if(retrunSheetDataList.size() == 1){
|
||||
if (retrunSheetDataList.size() == 1) {
|
||||
retrunSheetDataList.get(0).setDatasetName(filename);
|
||||
retrunSheetDataList.get(0).setSheetExcelId(excelId);
|
||||
retrunSheetDataList.get(0).setId(UUID.randomUUID().toString());
|
||||
retrunSheetDataList.get(0).setPath(filePath);
|
||||
}else {
|
||||
} else {
|
||||
for (ExcelSheetData excelSheetData : retrunSheetDataList) {
|
||||
excelSheetData.setDatasetName(filename + "-" + excelSheetData.getExcelLable());
|
||||
excelSheetData.setSheetExcelId(excelId);
|
||||
|
@ -191,6 +191,11 @@ public class DataSetTableTaskService {
|
||||
if(dataSetTaskDTOS.get(0).getNextExecTime() == null || dataSetTaskDTOS.get(0).getNextExecTime() <= 0){
|
||||
datasetTableTask.setStatus(TaskStatus.Stopped.name());
|
||||
update(datasetTableTask);
|
||||
return;
|
||||
}
|
||||
if(dataSetTaskDTOS.get(0).getNextExecTime() > datasetTableTask.getEndTime()){
|
||||
datasetTableTask.setStatus(TaskStatus.Stopped.name());
|
||||
update(datasetTableTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -312,6 +312,7 @@ public class ExtractDataService {
|
||||
msg = true;
|
||||
lastExecStatus = JobStatus.Completed;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
saveErrorLog(datasetTableId, taskId, e);
|
||||
msg = false;
|
||||
lastExecStatus = JobStatus.Error;
|
||||
@ -456,7 +457,7 @@ public class ExtractDataService {
|
||||
for (DatasetTableField datasetTableField : datasetTableFields) {
|
||||
Column_Fields = Column_Fields + datasetTableField.getDataeaseName() + "` ";
|
||||
Integer size = datasetTableField.getSize() * 3;
|
||||
if (datasetTableField.getSize() > 65533 || datasetTableField.getSize() * 3 > 65533) {
|
||||
if (datasetTableField.getSize() == 0 || datasetTableField.getSize() > 65533 || datasetTableField.getSize() * 3 > 65533) {
|
||||
size = 65533;
|
||||
}
|
||||
switch (datasetTableField.getDeExtractType()) {
|
||||
@ -468,7 +469,7 @@ public class ExtractDataService {
|
||||
Column_Fields = Column_Fields + "varchar(lenth)".replace("lenth", String.valueOf(size)) + ",`";
|
||||
break;
|
||||
case 2:
|
||||
Column_Fields = Column_Fields + "bigint(lenth)".replace("lenth", String.valueOf(size)) + ",`";
|
||||
Column_Fields = Column_Fields + "bigint" + ",`";
|
||||
break;
|
||||
case 3:
|
||||
Column_Fields = Column_Fields + "DOUBLE" + ",`";
|
||||
@ -555,7 +556,7 @@ public class ExtractDataService {
|
||||
datasetTableTaskLog.setTaskId(taskId);
|
||||
datasetTableTaskLog.setStatus(JobStatus.Underway.name());
|
||||
datasetTableTaskLog.setTriggerType(TriggerType.Custom.name());
|
||||
for (int i = 0; i < 5; i++) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
List<DatasetTableTaskLog> datasetTableTaskLogs = dataSetTableTaskLogService.select(datasetTableTaskLog);
|
||||
if (CollectionUtils.isNotEmpty(datasetTableTaskLogs)) {
|
||||
return datasetTableTaskLogs.get(0);
|
||||
@ -616,7 +617,8 @@ public class ExtractDataService {
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
if (!transStatus.getStatusDescription().equals("Finished")) {
|
||||
DataEaseException.throwException((transStatus.getLoggingString()));
|
||||
DataEaseException.throwException(transStatus.getLoggingString());
|
||||
return;
|
||||
}
|
||||
|
||||
executing = true;
|
||||
@ -637,11 +639,6 @@ public class ExtractDataService {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isExitFile(String fileName) {
|
||||
File file = new File(root_path + fileName);
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
private SlaveServer getSlaveServer() {
|
||||
SlaveServer remoteSlaveServer = new SlaveServer();
|
||||
remoteSlaveServer.setHostname(carte);// 设置远程IP
|
||||
@ -768,7 +765,7 @@ public class ExtractDataService {
|
||||
switch (datasourceType) {
|
||||
case mysql:
|
||||
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());
|
||||
dataMeta = new DatabaseMeta("db", "MYSQL", "Native", mysqlConfigration.getHost().trim(), mysqlConfigration.getDataBase().trim(), mysqlConfigration.getPort().toString(), mysqlConfigration.getUsername(), mysqlConfigration.getPassword());
|
||||
dataMeta.addExtraOption("MYSQL", "characterEncoding", "UTF-8");
|
||||
transMeta.addDatabase(dataMeta);
|
||||
selectSQL = getSelectSQL(extractType, datasetTable, datasource, datasetTableFields, selectSQL);
|
||||
@ -777,7 +774,7 @@ public class ExtractDataService {
|
||||
break;
|
||||
case sqlServer:
|
||||
SqlServerConfigration sqlServerConfigration = new Gson().fromJson(datasource.getConfiguration(), SqlServerConfigration.class);
|
||||
dataMeta = new DatabaseMeta("db", "MSSQLNATIVE", "Native", sqlServerConfigration.getHost(), sqlServerConfigration.getDataBase(), sqlServerConfigration.getPort().toString(), sqlServerConfigration.getUsername(), sqlServerConfigration.getPassword());
|
||||
dataMeta = new DatabaseMeta("db", "MSSQLNATIVE", "Native", sqlServerConfigration.getHost().trim(), sqlServerConfigration.getDataBase(), sqlServerConfigration.getPort().toString(), sqlServerConfigration.getUsername(), sqlServerConfigration.getPassword());
|
||||
transMeta.addDatabase(dataMeta);
|
||||
selectSQL = getSelectSQL(extractType, datasetTable, datasource, datasetTableFields, selectSQL);
|
||||
inputStep = inputStep(transMeta, selectSQL);
|
||||
@ -785,7 +782,7 @@ public class ExtractDataService {
|
||||
break;
|
||||
case pg:
|
||||
PgConfigration pgConfigration = new Gson().fromJson(datasource.getConfiguration(), PgConfigration.class);
|
||||
dataMeta = new DatabaseMeta("db", "POSTGRESQL", "Native", pgConfigration.getHost(), pgConfigration.getDataBase(), pgConfigration.getPort().toString(), pgConfigration.getUsername(), pgConfigration.getPassword());
|
||||
dataMeta = new DatabaseMeta("db", "POSTGRESQL", "Native", pgConfigration.getHost().trim(), pgConfigration.getDataBase(), pgConfigration.getPort().toString(), pgConfigration.getUsername(), pgConfigration.getPassword());
|
||||
transMeta.addDatabase(dataMeta);
|
||||
selectSQL = getSelectSQL(extractType, datasetTable, datasource, datasetTableFields, selectSQL);
|
||||
inputStep = inputStep(transMeta, selectSQL);
|
||||
@ -797,7 +794,7 @@ public class ExtractDataService {
|
||||
String database = "(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE_HOSTNAME)(PORT = ORACLE_PORT))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = ORACLE_SERVICE_NAME )))".replace("ORACLE_HOSTNAME", oracleConfigration.getHost()).replace("ORACLE_PORT", oracleConfigration.getPort().toString()).replace("ORACLE_SERVICE_NAME", oracleConfigration.getDataBase());
|
||||
dataMeta = new DatabaseMeta("db", "ORACLE", "Native", "", database, "-1", oracleConfigration.getUsername(), oracleConfigration.getPassword());
|
||||
} else {
|
||||
dataMeta = new DatabaseMeta("db", "ORACLE", "Native", oracleConfigration.getHost(), oracleConfigration.getDataBase(), oracleConfigration.getPort().toString(), oracleConfigration.getUsername(), oracleConfigration.getPassword());
|
||||
dataMeta = new DatabaseMeta("db", "ORACLE", "Native", oracleConfigration.getHost().trim(), oracleConfigration.getDataBase(), oracleConfigration.getPort().toString(), oracleConfigration.getUsername(), oracleConfigration.getPassword());
|
||||
}
|
||||
transMeta.addDatabase(dataMeta);
|
||||
|
||||
@ -805,6 +802,16 @@ public class ExtractDataService {
|
||||
inputStep = inputStep(transMeta, selectSQL);
|
||||
udjcStep = udjc(datasetTableFields, DatasourceTypes.oracle);
|
||||
break;
|
||||
case ck:
|
||||
CHConfigration chConfigration = new Gson().fromJson(datasource.getConfiguration(), CHConfigration.class);
|
||||
dataMeta = new DatabaseMeta("db", "ORACLE", "Native", chConfigration.getHost().trim(), chConfigration.getDataBase().trim(), chConfigration.getPort().toString(), chConfigration.getUsername(), chConfigration.getPassword());
|
||||
// dataMeta.addExtraOption("MYSQL", "characterEncoding", "UTF-8");
|
||||
dataMeta.setDatabaseType("Clickhouse");
|
||||
transMeta.addDatabase(dataMeta);
|
||||
selectSQL = getSelectSQL(extractType, datasetTable, datasource, datasetTableFields, selectSQL);
|
||||
inputStep = inputStep(transMeta, selectSQL);
|
||||
udjcStep = udjc(datasetTableFields, DatasourceTypes.ck);
|
||||
break;
|
||||
case excel:
|
||||
inputStep = excelInputStep(datasetTable.getInfo(), datasetTableFields);
|
||||
udjcStep = udjc(datasetTableFields, DatasourceTypes.excel);
|
||||
@ -1001,11 +1008,12 @@ public class ExtractDataService {
|
||||
}
|
||||
|
||||
private StepMeta udjc(List<DatasetTableField> datasetTableFields, DatasourceTypes datasourceType) {
|
||||
String needToChangeColumnType = "";
|
||||
// String needToChangeColumnType = "";
|
||||
String handleBinaryTypeCode = "";
|
||||
String excelCompletion = "";
|
||||
|
||||
for (DatasetTableField datasetTableField : datasetTableFields) {
|
||||
if(datasetTableField.getDeExtractType() == 5){
|
||||
if(datasetTableField.getDeExtractType() == DeTypeConstants.DE_BINARY){
|
||||
handleBinaryTypeCode = handleBinaryTypeCode + "\n" + this.handleBinaryType.replace("FEILD", datasetTableField.getDataeaseName());
|
||||
}
|
||||
}
|
||||
@ -1016,9 +1024,8 @@ public class ExtractDataService {
|
||||
fields.add(fieldInfo);
|
||||
userDefinedJavaClassMeta.setFieldInfo(fields);
|
||||
List<UserDefinedJavaClassDef> definitions = new ArrayList<UserDefinedJavaClassDef>();
|
||||
String tmp_code = code.replace("alterColumnTypeCode", needToChangeColumnType);
|
||||
String tmp_code = code.replace("handleWraps", handleWraps).replace("handleBinaryType", handleBinaryTypeCode);
|
||||
|
||||
tmp_code = tmp_code.replace("handleWraps", handleWraps);
|
||||
String Column_Fields = "";
|
||||
if (datasourceType.equals(DatasourceTypes.oracle)) {
|
||||
Column_Fields = String.join(",", datasetTableFields.stream().map(DatasetTableField::getOriginName).collect(Collectors.toList()));
|
||||
@ -1027,12 +1034,13 @@ public class ExtractDataService {
|
||||
}
|
||||
|
||||
if (datasourceType.equals(DatasourceTypes.excel)) {
|
||||
tmp_code = tmp_code.replace("handleExcelIntColumn", handleExcelIntColumn).replace("Column_Fields", Column_Fields);
|
||||
tmp_code = tmp_code.replace("handleExcelIntColumn", handleExcelIntColumn).replace("Column_Fields", Column_Fields)
|
||||
.replace("ExcelCompletion", excelCompletion);
|
||||
} else {
|
||||
tmp_code = tmp_code.replace("handleExcelIntColumn", "").replace("Column_Fields", Column_Fields);
|
||||
tmp_code = tmp_code.replace("handleExcelIntColumn", "").replace("Column_Fields", Column_Fields)
|
||||
.replace("ExcelCompletion", "");;
|
||||
}
|
||||
|
||||
tmp_code = tmp_code.replace("handleBinaryType", handleBinaryTypeCode);
|
||||
UserDefinedJavaClassDef userDefinedJavaClassDef = new UserDefinedJavaClassDef(UserDefinedJavaClassDef.ClassType.TRANSFORM_CLASS, "Processor", tmp_code);
|
||||
|
||||
userDefinedJavaClassDef.setActive(true);
|
||||
@ -1121,15 +1129,15 @@ public class ExtractDataService {
|
||||
" \t}";
|
||||
|
||||
|
||||
private final static String alterColumnTypeCode = " if(\"FILED\".equalsIgnoreCase(filed)){\n" +
|
||||
"\t if(tmp != null && tmp.equalsIgnoreCase(\"Y\")){\n" +
|
||||
" get(Fields.Out, filed).setValue(r, 1);\n" +
|
||||
" get(Fields.Out, filed).getValueMeta().setType(2);\n" +
|
||||
" }else{\n" +
|
||||
" get(Fields.Out, filed).setValue(r, 0);\n" +
|
||||
" get(Fields.Out, filed).getValueMeta().setType(2);\n" +
|
||||
" }\n" +
|
||||
" }\n" ;
|
||||
// private final static String alterColumnTypeCode = " if(\"FILED\".equalsIgnoreCase(filed)){\n" +
|
||||
// "\t if(tmp != null && tmp.equalsIgnoreCase(\"Y\")){\n" +
|
||||
// " get(Fields.Out, filed).setValue(r, 1);\n" +
|
||||
// " get(Fields.Out, filed).getValueMeta().setType(2);\n" +
|
||||
// " }else{\n" +
|
||||
// " get(Fields.Out, filed).setValue(r, 0);\n" +
|
||||
// " get(Fields.Out, filed).getValueMeta().setType(2);\n" +
|
||||
// " }\n" +
|
||||
// " }\n" ;
|
||||
|
||||
private final static String handleExcelIntColumn = " \t\tif(tmp != null && tmp.endsWith(\".0\")){\n" +
|
||||
" try {\n" +
|
||||
@ -1144,8 +1152,9 @@ public class ExtractDataService {
|
||||
" tmp = tmp.replaceAll(\"\\r\",\" \");\n" +
|
||||
" tmp = tmp.replaceAll(\"\\n\",\" \");\n" +
|
||||
" get(Fields.Out, filed).setValue(r, tmp);\n" +
|
||||
" } \n" +
|
||||
"\t\tif(tmp == null){\n" +
|
||||
" } \n";
|
||||
|
||||
private final static String excelCompletion = "\t\tif(tmp == null){\n" +
|
||||
" \t\t\ttmp = \"\";\n" +
|
||||
"\t\t\tget(Fields.Out, filed).setValue(r, tmp);\n" +
|
||||
"\t\t}";
|
||||
@ -1180,7 +1189,7 @@ public class ExtractDataService {
|
||||
" for (String filed : fileds) {\n" +
|
||||
" String tmp = get(Fields.In, filed).getString(r);\n" +
|
||||
"handleWraps \n" +
|
||||
"alterColumnTypeCode \n" +
|
||||
"ExcelCompletion \n" +
|
||||
"handleBinaryType \n" +
|
||||
"handleExcelIntColumn \n" +
|
||||
" str = str + tmp;\n" +
|
||||
|
@ -312,4 +312,12 @@ public class SysMsgService {
|
||||
return sourceLists;
|
||||
}
|
||||
|
||||
public void setAllRead() {
|
||||
SysMsg record = new SysMsg();
|
||||
record.setStatus(true);
|
||||
SysMsgExample example = new SysMsgExample();
|
||||
example.createCriteria().andUserIdEqualTo(AuthUtils.getUser().getUserId()).andStatusEqualTo(false);
|
||||
sysMsgMapper.updateByExampleSelective(record, example);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -103,7 +103,34 @@ public class PanelGroupService {
|
||||
newDefaultPanel.setCreateBy(AuthUtils.getUser().getUsername());
|
||||
checkPanelName(newDefaultPanel.getName(), newDefaultPanel.getPid(), PanelConstants.OPT_TYPE_INSERT, newDefaultPanel.getId());
|
||||
panelGroupMapper.insertSelective(newDefaultPanel);
|
||||
} else {
|
||||
} else if ("copy".equals(request.getOptType())) {
|
||||
panelId = UUID.randomUUID().toString();
|
||||
// 复制模板
|
||||
PanelGroupWithBLOBs newPanel = panelGroupMapper.selectByPrimaryKey(request.getId());
|
||||
// 插入校验
|
||||
if (StringUtils.isNotEmpty(request.getName())) {
|
||||
checkPanelName(request.getName(), newPanel.getPid(), PanelConstants.OPT_TYPE_INSERT, request.getId());
|
||||
}
|
||||
newPanel.setName(request.getName());
|
||||
newPanel.setId(panelId);
|
||||
newPanel.setCreateBy(AuthUtils.getUser().getUsername());
|
||||
panelGroupMapper.insertSelective(newPanel);
|
||||
} else if ("move".equals(request.getOptType())) {
|
||||
PanelGroupWithBLOBs panelInfo = panelGroupMapper.selectByPrimaryKey(request.getId());
|
||||
if(panelInfo.getPid().equalsIgnoreCase(request.getPid())){
|
||||
DataEaseException.throwException(Translator.get("i18n_select_diff_folder"));
|
||||
}
|
||||
// 移动校验
|
||||
if (StringUtils.isNotEmpty(request.getName())) {
|
||||
checkPanelName(request.getName(), request.getPid(), PanelConstants.OPT_TYPE_INSERT, request.getId());
|
||||
}
|
||||
PanelGroupWithBLOBs record = new PanelGroupWithBLOBs();
|
||||
record.setName(request.getName());
|
||||
record.setId(request.getId());
|
||||
record.setPid(request.getPid());
|
||||
panelGroupMapper.updateByPrimaryKeySelective(record);
|
||||
|
||||
}else {
|
||||
// 更新
|
||||
if (StringUtils.isNotEmpty(request.getName())) {
|
||||
checkPanelName(request.getName(), request.getPid(), PanelConstants.OPT_TYPE_UPDATE, request.getId());
|
||||
|
@ -0,0 +1,27 @@
|
||||
package io.dataease.service.panel;
|
||||
|
||||
import io.dataease.base.domain.PanelPdfTemplate;
|
||||
import io.dataease.base.domain.PanelPdfTemplateExample;
|
||||
import io.dataease.base.mapper.PanelPdfTemplateMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: wangjiahao
|
||||
* Date: 9/1/21
|
||||
* Description:
|
||||
*/
|
||||
@Service
|
||||
public class PanelPdfTemplateService {
|
||||
|
||||
@Resource
|
||||
private PanelPdfTemplateMapper panelPdfTemplateMapper;
|
||||
|
||||
public List<PanelPdfTemplate> queryAll(){
|
||||
PanelPdfTemplateExample example = new PanelPdfTemplateExample();
|
||||
example.setOrderByClause("sort asc");
|
||||
return panelPdfTemplateMapper.selectByExampleWithBLOBs(example);
|
||||
}
|
||||
}
|
@ -14,12 +14,16 @@ import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.LdapAddRequest;
|
||||
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.response.SysUserGridResponse;
|
||||
import io.dataease.controller.sys.response.SysUserRole;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
|
||||
import io.dataease.plugins.xpack.oidc.dto.SSOUserInfo;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -29,6 +33,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -80,11 +86,13 @@ public class SysUserService {
|
||||
@Transactional
|
||||
public int save(SysUserCreateRequest request) {
|
||||
checkUsername(request);
|
||||
checkEmail(request);
|
||||
SysUser user = BeanUtils.copyBean(new SysUser(), request);
|
||||
long now = System.currentTimeMillis();
|
||||
user.setCreateTime(now);
|
||||
user.setUpdateTime(now);
|
||||
user.setIsAdmin(false);
|
||||
user.setFrom(0);
|
||||
if (ObjectUtils.isEmpty(user.getPassword()) || StringUtils.equals(user.getPassword(), DEFAULT_PWD)) {
|
||||
user.setPassword(CodingUtil.md5(DEFAULT_PWD));
|
||||
} else {
|
||||
@ -99,6 +107,70 @@ public class SysUserService {
|
||||
return insert;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveOIDCUser(SSOUserInfo ssoUserInfo) {
|
||||
long now = System.currentTimeMillis();
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUsername(ssoUserInfo.getUsername());
|
||||
sysUser.setNickName(ssoUserInfo.getNickName());
|
||||
sysUser.setEmail(ssoUserInfo.getEmail());
|
||||
sysUser.setPassword(CodingUtil.md5(DEFAULT_PWD));
|
||||
sysUser.setCreateTime(now);
|
||||
sysUser.setUpdateTime(now);
|
||||
sysUser.setEnabled(1L);
|
||||
sysUser.setLanguage("zh_CN");
|
||||
sysUser.setFrom(2);
|
||||
sysUser.setIsAdmin(false);
|
||||
sysUser.setSub(ssoUserInfo.getSub());
|
||||
sysUserMapper.insert(sysUser);
|
||||
SysUser dbUser = findOne(sysUser);
|
||||
if (null != dbUser && null != dbUser.getUserId()) {
|
||||
// oidc默认角色是普通员工
|
||||
List<Long> roleIds = new ArrayList<Long>();
|
||||
roleIds.add(2L);
|
||||
saveUserRoles( dbUser.getUserId(), roleIds);
|
||||
}
|
||||
}
|
||||
|
||||
public String defaultPWD() {
|
||||
return DEFAULT_PWD;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveLdapUsers(LdapAddRequest request) {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
List<XpackLdapUserEntity> users = request.getUsers();
|
||||
List<SysUser> sysUsers = users.stream().map(user -> {
|
||||
SysUser sysUser = BeanUtils.copyBean(new SysUser(), user);
|
||||
sysUser.setUsername(user.getUserName());
|
||||
sysUser.setDeptId(request.getDeptId());
|
||||
sysUser.setPassword(CodingUtil.md5(DEFAULT_PWD));
|
||||
sysUser.setCreateTime(now);
|
||||
sysUser.setUpdateTime(now);
|
||||
sysUser.setEnabled(request.getEnabled());
|
||||
sysUser.setLanguage("zh_CN");
|
||||
sysUser.setIsAdmin(false);
|
||||
sysUser.setFrom(1);
|
||||
return sysUser;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
sysUsers.forEach(sysUser -> {
|
||||
sysUserMapper.insert(sysUser);
|
||||
SysUser dbUser = findOne(sysUser);
|
||||
if (null != dbUser && null != dbUser.getUserId()) {
|
||||
saveUserRoles( dbUser.getUserId(), request.getRoleIds());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<String> ldapUserNames() {
|
||||
|
||||
List<String> usernames = extSysUserMapper.ldapUserNames(1);
|
||||
return usernames;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户密码清楚缓存
|
||||
*
|
||||
@ -109,6 +181,7 @@ public class SysUserService {
|
||||
@Transactional
|
||||
public int update(SysUserCreateRequest request) {
|
||||
checkUsername(request);
|
||||
checkEmail(request);
|
||||
if (StringUtils.isEmpty(request.getPassword())) {
|
||||
request.setPassword(null);
|
||||
}
|
||||
@ -251,4 +324,19 @@ public class SysUserService {
|
||||
throw new RuntimeException(Translator.get("i18n_username_exists"));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkEmail(SysUserCreateRequest request) {
|
||||
SysUserExample sysUserExample = new SysUserExample();
|
||||
SysUserExample.Criteria criteria = sysUserExample.createCriteria();
|
||||
if (request.getUserId() != null) {
|
||||
criteria.andUserIdNotEqualTo(request.getUserId());
|
||||
}
|
||||
criteria.andEmailEqualTo(request.getEmail());
|
||||
List<SysUser> sysUsers = sysUserMapper.selectByExample(sysUserExample);
|
||||
if (CollectionUtils.isNotEmpty(sysUsers)) {
|
||||
throw new RuntimeException(Translator.get("i18n_email_exists"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -229,9 +229,9 @@ public class SystemParameterService {
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
/* public static void main(String[] args) {
|
||||
String info="[{\"paramKey\":\"base.url\",\"paramValue\":null,\"type\":\"text\",\"sort\":1,\"file\":null,\"fileName\":null},{\"paramKey\":\"base.title\",\"paramValue\":\"DataEase Title\",\"type\":\"text\",\"sort\":3,\"file\":null,\"fileName\":null},{\"paramKey\":\"base.logo\",\"paramValue\":\"DataEase\",\"type\":\"text\",\"sort\":4,\"file\":null,\"fileName\":\"favicon.icon.png\"}]";
|
||||
List<SystemParameterDTO> temp = JSON.parseArray(info,SystemParameterDTO.class);
|
||||
// System.out.println("===>");
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
@ -383,3 +383,72 @@ INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_typ
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('dc1d32ff-064a-11ec-a2b0-0242ac130003', 'd78c6e77-9cc7-44f8-a730-32ca6ca33f60', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1629967913000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('dc1d3358-064a-11ec-a2b0-0242ac130003', 'd78c6e77-9cc7-44f8-a730-32ca6ca33f60', 'i18n_auth_manage', 5, 0, 'manage', '基础权限-管理', 'admin', 1629967913000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('dc1d33a4-064a-11ec-a2b0-0242ac130003', 'd78c6e77-9cc7-44f8-a730-32ca6ca33f60', 'i18n_auth_view', 1, 1, 'view', '基础权限-查看', 'admin', 1629967913000, NULL);
|
||||
|
||||
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('00590a7c-8e7b-45f4-8428-55532be07602', '10', 'menu', '1', 'role', 1630482462199, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('06ba0edb-143d-4b51-a864-8cfcf2b5d71e', '1', 'menu', '1', 'role', 1630482426344, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('1a18aa12-8daa-4f47-b5eb-999e473273df', '6', 'menu', '1', 'role', 1630482450994, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('1bf39d8d-7fe9-4832-8df3-f74b21a69288', '4', 'menu', '1', 'role', 1630482450458, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('359771bb-95b8-40ad-a6c5-b5c39c93cb10', '24', 'menu', '1', 'role', 1630482459156, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('5960fd93-013c-4636-8f6b-2e6b49b7e869', '5', 'menu', '1', 'role', 1630482450626, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('5e0a9ad5-81ed-4f83-91f6-a74be724bda7', '23', 'menu', '1', 'role', 1630482452131, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('5ec5c9a7-04c0-4655-9b63-9ca5a439e2f3', '18', 'menu', '1', 'role', 1630482451166, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('60b3644b-2493-4805-8204-90880cfac9c6', '8', 'menu', '1', 'role', 1630482460538, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('74ff225f-2a79-4221-9b32-c6eb9bcadd61', '19', 'menu', '1', 'role', 1630482451329, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('7823499e-dbb6-42a9-a28f-22377de18a39', '40', 'menu', '1', 'role', 1630482427369, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('88c778e6-ede3-4397-af4c-375e1feac8ef', '41', 'menu', '1', 'role', 1630482452340, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('998e402b-6f15-48dc-ae4d-2cd04460a3f3', '15', 'menu', '1', 'role', 1630482426695, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('9f01c7ef-753b-4dea-97d4-c199f84c2c74', '17', 'menu', '1', 'role', 1630482427049, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('a6837d68-80a6-4a26-a7c0-e84001dfc817', '34', 'menu', '1', 'role', 1630482458991, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('b319dc39-c499-423b-8e99-22e9a0caba6f', '58', 'menu', '1', 'role', 1630482427545, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('bdd3bed8-35d4-4aa8-84c2-85e2412d6cbb', '2', 'menu', '1', 'role', 1630482426513, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('c18b47e9-aa22-4f17-b12c-a3459ca4dd90', '28', 'menu', '1', 'role', 1630482427208, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('d3d558e5-b0b1-4475-bb69-f20fa5c47f4f', '22', 'menu', '1', 'role', 1630482451962, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('d400c00f-9c18-4eb6-a70f-9c8caf8dddfe', '21', 'menu', '1', 'role', 1630482451749, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('d8d18115-c7b9-4e99-96a8-fd1bbfddf543', '16', 'menu', '1', 'role', 1630482426857, NULL, 'admin', NULL);
|
||||
INSERT INTO `sys_auth` (`id`, `auth_source`, `auth_source_type`, `auth_target`, `auth_target_type`, `auth_time`, `auth_details`, `auth_user`, `update_time`) VALUES ('f17dc7f3-c97a-41b4-a2f4-1a04a857ae8a', '20', 'menu', '1', 'role', 1630482451497, NULL, 'admin', NULL);
|
||||
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cf3c570c-0af8-11ec-a2b0-0242ac130003', '06ba0edb-143d-4b51-a864-8cfcf2b5d71e', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482428000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cf3c59d1-0af8-11ec-a2b0-0242ac130003', '06ba0edb-143d-4b51-a864-8cfcf2b5d71e', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482428000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cf573296-0af8-11ec-a2b0-0242ac130003', 'bdd3bed8-35d4-4aa8-84c2-85e2412d6cbb', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482428000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cf57354a-0af8-11ec-a2b0-0242ac130003', 'bdd3bed8-35d4-4aa8-84c2-85e2412d6cbb', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482428000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cf705f77-0af8-11ec-a2b0-0242ac130003', '998e402b-6f15-48dc-ae4d-2cd04460a3f3', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482429000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cf7061d1-0af8-11ec-a2b0-0242ac130003', '998e402b-6f15-48dc-ae4d-2cd04460a3f3', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482429000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cf8b490d-0af8-11ec-a2b0-0242ac130003', 'd8d18115-c7b9-4e99-96a8-fd1bbfddf543', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482429000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cf8b4b35-0af8-11ec-a2b0-0242ac130003', 'd8d18115-c7b9-4e99-96a8-fd1bbfddf543', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482429000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cfa66a8d-0af8-11ec-a2b0-0242ac130003', '9f01c7ef-753b-4dea-97d4-c199f84c2c74', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482429000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cfa66ca4-0af8-11ec-a2b0-0242ac130003', '9f01c7ef-753b-4dea-97d4-c199f84c2c74', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482429000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cfbf0608-0af8-11ec-a2b0-0242ac130003', 'c18b47e9-aa22-4f17-b12c-a3459ca4dd90', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482429000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cfbf0839-0af8-11ec-a2b0-0242ac130003', 'c18b47e9-aa22-4f17-b12c-a3459ca4dd90', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482429000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cfd814bc-0af8-11ec-a2b0-0242ac130003', '7823499e-dbb6-42a9-a28f-22377de18a39', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482429000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cfd816d7-0af8-11ec-a2b0-0242ac130003', '7823499e-dbb6-42a9-a28f-22377de18a39', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482429000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cff28219-0af8-11ec-a2b0-0242ac130003', 'b319dc39-c499-423b-8e99-22e9a0caba6f', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482429000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('cff28507-0af8-11ec-a2b0-0242ac130003', 'b319dc39-c499-423b-8e99-22e9a0caba6f', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482429000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('dd9ba5c6-0af8-11ec-a2b0-0242ac130003', '1bf39d8d-7fe9-4832-8df3-f74b21a69288', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482452000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('dd9ba7e8-0af8-11ec-a2b0-0242ac130003', '1bf39d8d-7fe9-4832-8df3-f74b21a69288', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482452000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('ddb3094b-0af8-11ec-a2b0-0242ac130003', '5960fd93-013c-4636-8f6b-2e6b49b7e869', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482452000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('ddb30bd2-0af8-11ec-a2b0-0242ac130003', '5960fd93-013c-4636-8f6b-2e6b49b7e869', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482452000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('ddec6eab-0af8-11ec-a2b0-0242ac130003', '1a18aa12-8daa-4f47-b5eb-999e473273df', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482453000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('ddeccfa8-0af8-11ec-a2b0-0242ac130003', '1a18aa12-8daa-4f47-b5eb-999e473273df', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482453000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('de0719cb-0af8-11ec-a2b0-0242ac130003', '5ec5c9a7-04c0-4655-9b63-9ca5a439e2f3', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482453000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('de071bd9-0af8-11ec-a2b0-0242ac130003', '5ec5c9a7-04c0-4655-9b63-9ca5a439e2f3', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482453000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('de202758-0af8-11ec-a2b0-0242ac130003', '74ff225f-2a79-4221-9b32-c6eb9bcadd61', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482453000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('de202961-0af8-11ec-a2b0-0242ac130003', '74ff225f-2a79-4221-9b32-c6eb9bcadd61', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482453000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('de42f5ec-0af8-11ec-a2b0-0242ac130003', 'f17dc7f3-c97a-41b4-a2f4-1a04a857ae8a', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482453000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('de42f8b4-0af8-11ec-a2b0-0242ac130003', 'f17dc7f3-c97a-41b4-a2f4-1a04a857ae8a', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482453000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('de65f6d9-0af8-11ec-a2b0-0242ac130003', 'd400c00f-9c18-4eb6-a70f-9c8caf8dddfe', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482454000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('de65fa72-0af8-11ec-a2b0-0242ac130003', 'd400c00f-9c18-4eb6-a70f-9c8caf8dddfe', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482454000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('de80ddc9-0af8-11ec-a2b0-0242ac130003', 'd3d558e5-b0b1-4475-bb69-f20fa5c47f4f', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482454000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('de80e001-0af8-11ec-a2b0-0242ac130003', 'd3d558e5-b0b1-4475-bb69-f20fa5c47f4f', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482454000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('de9f30cd-0af8-11ec-a2b0-0242ac130003', '5e0a9ad5-81ed-4f83-91f6-a74be724bda7', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482454000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('de9f32d3-0af8-11ec-a2b0-0242ac130003', '5e0a9ad5-81ed-4f83-91f6-a74be724bda7', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482454000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('dec15e1b-0af8-11ec-a2b0-0242ac130003', '88c778e6-ede3-4397-af4c-375e1feac8ef', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482454000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('dec16031-0af8-11ec-a2b0-0242ac130003', '88c778e6-ede3-4397-af4c-375e1feac8ef', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482454000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('e2b029b9-0af8-11ec-a2b0-0242ac130003', 'a6837d68-80a6-4a26-a7c0-e84001dfc817', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482461000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('e2b02bcb-0af8-11ec-a2b0-0242ac130003', 'a6837d68-80a6-4a26-a7c0-e84001dfc817', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482461000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('e2c9aba7-0af8-11ec-a2b0-0242ac130003', '359771bb-95b8-40ad-a6c5-b5c39c93cb10', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482461000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('e2c9adc8-0af8-11ec-a2b0-0242ac130003', '359771bb-95b8-40ad-a6c5-b5c39c93cb10', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482461000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('e39cb3fe-0af8-11ec-a2b0-0242ac130003', '60b3644b-2493-4805-8204-90880cfac9c6', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482462000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('e39cb619-0af8-11ec-a2b0-0242ac130003', '60b3644b-2493-4805-8204-90880cfac9c6', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482462000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('e49bef48-0af8-11ec-a2b0-0242ac130003', '00590a7c-8e7b-45f4-8428-55532be07602', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1630482464000, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`, `privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`) VALUES ('e49bf17e-0af8-11ec-a2b0-0242ac130003', '00590a7c-8e7b-45f4-8428-55532be07602', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1630482464000, NULL);
|
||||
|
51
backend/src/main/resources/db/migration/V26__de1.3.sql
Normal file
51
backend/src/main/resources/db/migration/V26__de1.3.sql
Normal file
@ -0,0 +1,51 @@
|
||||
-- ----------------------------
|
||||
-- Records of sys_msg_type
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `sys_msg_type` VALUES (7, 0, 'i18n_msg_type_ds_invalid', 'datasource', 'to-msg-ds');
|
||||
INSERT INTO `sys_msg_type` VALUES (8, 7, 'i18n_msg_type_ds_invalid', 'datasource', 'to-msg-ds');
|
||||
COMMIT;
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for panel_pdf_template
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `panel_pdf_template`;
|
||||
CREATE TABLE `panel_pdf_template` (
|
||||
`id` varchar(50) NOT NULL COMMENT 'id',
|
||||
`name` varchar(255) DEFAULT NULL COMMENT '模板名称',
|
||||
`create_time` bigint(13) DEFAULT NULL COMMENT '创建时间',
|
||||
`create_user` varchar(255) DEFAULT NULL COMMENT '创建人',
|
||||
`template_content` longtext COMMENT '模板内容',
|
||||
`sort` int(8) DEFAULT NULL COMMENT '排序',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
ALTER TABLE `chart_view` ADD COLUMN `y_axis_ext` LONGTEXT COMMENT '副轴' AFTER `y_axis`;
|
||||
UPDATE `chart_view` SET `y_axis_ext` = '[]';
|
||||
|
||||
|
||||
ALTER TABLE `sys_user` ADD COLUMN `from` int(4) NOT NULL COMMENT '来源' AFTER `language`;
|
||||
|
||||
INSERT INTO `sys_menu` VALUES (60, 1, 0, 1, '导入LDAP用户', 'system-user-import', 'system/user/imp-ldap', 11, NULL, 'user-ldap', b'0', b'0', b'1', 'user:import', NULL, NULL, NULL, NULL);
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO `system_parameter` VALUES ('ldap.url', NULL, 'text', 1);
|
||||
INSERT INTO `system_parameter` VALUES ('ldap.dn', NULL, 'text', 2);
|
||||
INSERT INTO `system_parameter` VALUES ('ldap.password', NULL, 'password', 3);
|
||||
INSERT INTO `system_parameter` VALUES ('ldap.ou', NULL, 'text', 4);
|
||||
INSERT INTO `system_parameter` VALUES ('ldap.mapping', NULL, 'text', 6);
|
||||
INSERT INTO `system_parameter` VALUES ('ldap.open', NULL, 'text', 7);
|
||||
|
||||
INSERT INTO `system_parameter` VALUES ('oidc.authEndpoint', NULL, 'text', 1);
|
||||
INSERT INTO `system_parameter` VALUES ('oidc.tokenEndpoint', NULL, 'text', 2);
|
||||
INSERT INTO `system_parameter` VALUES ('oidc.userinfoEndpoint', NULL, 'text', 3);
|
||||
INSERT INTO `system_parameter` VALUES ('oidc.logoutEndpoint', NULL, 'text', 4);
|
||||
INSERT INTO `system_parameter` VALUES ('oidc.clientId', NULL, 'text', 5);
|
||||
INSERT INTO `system_parameter` VALUES ('oidc.secret', NULL, 'password', 6);
|
||||
INSERT INTO `system_parameter` VALUES ('oidc.scope', NULL, 'text', 7);
|
||||
INSERT INTO `system_parameter` VALUES ('oidc.redirectUrl', NULL, 'text', 8);
|
||||
INSERT INTO `system_parameter` VALUES ('oidc.open', NULL, 'text', 9);
|
||||
COMMIT;
|
||||
|
||||
ALTER TABLE `sys_user` ADD COLUMN `sub` varchar(255) COMMENT 'oidc用户ID' AFTER `from`;
|
@ -64,7 +64,9 @@
|
||||
|
||||
<!--要生成的数据库表 -->
|
||||
|
||||
|
||||
<table tableName="datasource"/>
|
||||
|
||||
<!-- <table tableName="sys_dict_item"/>-->
|
||||
<!-- <table tableName="dataset_table_field"/>-->
|
||||
<!-- <table tableName="v_chart">-->
|
||||
|
@ -198,6 +198,7 @@ authsource_configuration_is_null=Authentication source configuration cannot be e
|
||||
删除角色=Delete Role
|
||||
删除连接=Delete Connection
|
||||
显示设置=Display
|
||||
系统参数=System Param
|
||||
参数管理=Parameter
|
||||
数据源=Data Source
|
||||
数据源表单=Data source form
|
||||
@ -234,6 +235,7 @@ i18n_chart_count=Count*
|
||||
i18n_excel_have_merge_region=Excel has merged region
|
||||
i18n_cron_expression_error=Cron expression error
|
||||
i18n_same_folder_can_not_repeat=Name is already used in the same folder
|
||||
i18n_select_diff_folder= Select Diff Folder
|
||||
i18n_default_panel=Default Dashboard
|
||||
i18n_panel_list=Dashboard
|
||||
i18n_processing_data=Processing data now, Refresh later
|
||||
@ -242,6 +244,7 @@ i18n_union_field_exists=The same field can't in two dataset
|
||||
i18n_cron_time_error=Start time can't greater then end time
|
||||
i18n_auth_source_be_canceled=This Auth Resource Already Be Canceled,Please Connect Admin
|
||||
i18n_username_exists=ID is already exists
|
||||
i18n_email_exists=Email is already exists
|
||||
i18n_ds_name_exists=Datasource name used
|
||||
i18n_sync_job_exists=There is already a synchronization task running, please try again later
|
||||
i18n_datasource_check_fail=Invalid,please check config
|
||||
@ -280,4 +283,7 @@ i18n_datasource_connect_error=Data source connection exception:
|
||||
i18n_check_sql_error=Check incremental SQL exception,
|
||||
i18n_change_task_status_error=Suspension is not allowed. The task status is:
|
||||
i18n_Stopped=END
|
||||
i18n_Exec=Running
|
||||
i18n_Exec=Running
|
||||
i18n_no_trigger=The current setting does not trigger task generation.
|
||||
i18n_dataset_field_delete=Union field deleted,please set again and redo.
|
||||
i18n_es_limit=Elasticsearch version cannot be less than 6.3
|
@ -198,6 +198,7 @@ authsource_configuration_is_null=认证源配置不能为空
|
||||
删除角色=删除角色
|
||||
删除连接=删除连接
|
||||
显示设置=显示设置
|
||||
系统参数=系统参数
|
||||
数据源=数据源
|
||||
数据源表单=数据源表单
|
||||
数据集=数据集
|
||||
@ -233,6 +234,7 @@ i18n_chart_count=记录数*
|
||||
i18n_excel_have_merge_region=Excel 存在合并单元格
|
||||
i18n_cron_expression_error=Cron 表达式校验错误
|
||||
i18n_same_folder_can_not_repeat=同一目录下该名称已被使用
|
||||
i18n_select_diff_folder= 请选择不同的目录
|
||||
i18n_default_panel=默认仪表板
|
||||
i18n_panel_list=仪表板
|
||||
i18n_processing_data=正在处理数据,稍后刷新
|
||||
@ -241,6 +243,7 @@ i18n_union_field_exists=两个数据集之间关联不能出现多次相同字
|
||||
i18n_cron_time_error=开始时间不能大于结束时间
|
||||
i18n_auth_source_be_canceled=本用户当前资源所有授权权限已经被取消,如需再次开通,请联系管理员
|
||||
i18n_username_exists=用户 ID 已存在
|
||||
i18n_email_exists=邮箱已存在
|
||||
i18n_ds_name_exists=数据源名称已被使用
|
||||
i18n_sync_job_exists=已经有同步任务在运行,稍后重试
|
||||
i18n_datasource_check_fail=校验失败,请检查配置信息
|
||||
@ -280,4 +283,6 @@ i18n_check_sql_error=校验增量 SQL 异常,
|
||||
i18n_change_task_status_error=不允许暂停,任务状态为:
|
||||
i18n_Stopped=执行结束
|
||||
i18n_Exec=运行中
|
||||
|
||||
i18n_no_trigger=当前设置没有触发任务生成
|
||||
i18n_dataset_field_delete=该自定义数据集有关联字段被删除,请重新确认关联关系并重做该数据集
|
||||
i18n_es_limit=Elasticsearch 版本不能小于6.3
|
||||
|
@ -200,6 +200,7 @@ authsource_configuration_is_null=認證源配置不能為空
|
||||
删除角色=刪除角色
|
||||
刪除连接=刪除鏈接
|
||||
显示设置=顯示設置
|
||||
系统参数=系統參數
|
||||
参数管理=參數管理
|
||||
数据源=數據源
|
||||
数据源表单=數據源表單
|
||||
@ -236,6 +237,7 @@ i18n_chart_count=記錄數*
|
||||
i18n_excel_have_merge_region=Excel存在合並單元格
|
||||
i18n_cron_expression_error=Cron表達式校驗錯誤
|
||||
i18n_same_folder_can_not_repeat=同一目錄下該名稱已被使用
|
||||
i18n_select_diff_folder= 请选择不同的目录
|
||||
i18n_default_panel=默認儀表板
|
||||
i18n_panel_list=儀表板
|
||||
i18n_processing_data=正在處理數據,稍後刷新
|
||||
@ -244,6 +246,7 @@ i18n_union_field_exists=兩個數據集之間關聯不能出現多次相同字
|
||||
i18n_cron_time_error=開始時間不能大於結束時間
|
||||
i18n_auth_source_be_canceled=本用户当前资源所有授权权限已经被取消,如需再次开通,请联系管理员
|
||||
i18n_username_exists=用戶ID已存在
|
||||
i18n_email_exists=郵箱已存在
|
||||
i18n_ds_name_exists=數據源名稱已被使用
|
||||
i18n_sync_job_exists=已經有同步任務在運行,稍後重試
|
||||
i18n_datasource_check_fail=校驗失敗,請檢查配置信息
|
||||
@ -282,4 +285,7 @@ i18n_datasource_connect_error=數據源連接異常:
|
||||
i18n_check_sql_error=校驗增量SQL異常,
|
||||
i18n_change_task_status_error=不允許暫停,任務狀態為:
|
||||
i18n_Stopped=執行結束
|
||||
i18n_Exec=運行中
|
||||
i18n_Exec=運行中
|
||||
i18n_no_trigger=当前设置没有触发任务生成 當前設置沒有觸發任務生成.
|
||||
i18n_dataset_field_delete=該自定義數據集有關聯字段被刪除,請重新確認關聯關系並重做該數據集
|
||||
i18n_es_limit=Elasticsearch 版本不能小於6.3
|
@ -15,6 +15,7 @@
|
||||
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml"
|
||||
},
|
||||
"dependencies": {
|
||||
"@antv/g2plot": "^2.3.32",
|
||||
"@riophae/vue-treeselect": "0.4.0",
|
||||
"@tinymce/tinymce-vue": "^3.2.8",
|
||||
"axios": "^0.21.1",
|
||||
@ -28,6 +29,7 @@
|
||||
"html2canvasde": "^v1.1.4-de",
|
||||
"js-cookie": "2.2.0",
|
||||
"jsencrypt": "^3.0.0-rc.1",
|
||||
"jspdf": "^2.3.1",
|
||||
"lodash": "4.17.21",
|
||||
"normalize.css": "7.0.0",
|
||||
"nprogress": "0.2.0",
|
||||
@ -41,9 +43,10 @@
|
||||
"vue-axios": "3.2.4",
|
||||
"vue-clipboard2": "0.3.1",
|
||||
"vue-codemirror": "^4.0.6",
|
||||
"vue-fullscreen": "^2.5.1",
|
||||
"vue-fullscreen": "^2.5.2",
|
||||
"vue-i18n": "7.3.2",
|
||||
"vue-router": "3.0.6",
|
||||
"vue-to-pdf": "^1.0.0",
|
||||
"vue-uuid": "2.0.2",
|
||||
"vuedraggable": "^2.24.3",
|
||||
"vuex": "3.1.0",
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<artifactId>dataease-server</artifactId>
|
||||
<groupId>io.dataease</groupId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.3.0</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
11
frontend/src/api/panel/pdfTemplate.js
Normal file
11
frontend/src/api/panel/pdfTemplate.js
Normal file
@ -0,0 +1,11 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
|
||||
export function queryAll() {
|
||||
return request({
|
||||
url: '/pdf-template/queryAll',
|
||||
method: 'get',
|
||||
loading: true,
|
||||
timeout: 30000
|
||||
})
|
||||
}
|
@ -35,6 +35,14 @@ export function batchRead(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function allRead() {
|
||||
return request({
|
||||
url: '/api/sys_msg/allRead',
|
||||
method: 'post',
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
|
||||
export function batchDelete(data) {
|
||||
return request({
|
||||
url: '/api/sys_msg/batchDelete',
|
||||
|
@ -98,4 +98,29 @@ export function roleGrid(pageIndex, pageSize, data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { editPassword, delUser, editUser, addUser, userLists, editStatus, persionInfo, updatePerson, updatePersonPwd, allRoles, roleGrid }
|
||||
export function ldapUsers(data) {
|
||||
return request({
|
||||
url: '/plugin/ldap/users',
|
||||
method: 'post',
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
|
||||
export function saveLdapUser(data) {
|
||||
return request({
|
||||
url: '/api/user/sync',
|
||||
method: 'post',
|
||||
loading: true,
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function existLdapUsers() {
|
||||
return request({
|
||||
url: '/api/user/existLdapUsers',
|
||||
method: 'post',
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
||||
export default { editPassword, delUser, editUser, addUser, userLists, editStatus, persionInfo, updatePerson, updatePersonPwd, allRoles, roleGrid, ldapUsers, saveLdapUser, existLdapUsers }
|
||||
|
@ -50,3 +50,17 @@ export function languageApi(language) {
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
export function ldapStatus() {
|
||||
return request({
|
||||
url: '/api/auth/isOpenLdap',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
export function oidcStatus() {
|
||||
return request({
|
||||
url: '/api/auth/isOpenOidc',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
69
frontend/src/components/DeDrag/MoveInShadow.vue
Normal file
69
frontend/src/components/DeDrag/MoveInShadow.vue
Normal file
@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<div style="z-index:-1" :style="style" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
export default {
|
||||
replace: true,
|
||||
name: 'MoveInShadow',
|
||||
props: {
|
||||
w: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
h: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
x: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
y: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
z: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
style() {
|
||||
// 当前默认为自适应
|
||||
let left = this.x
|
||||
let top = this.y
|
||||
let width = this.w
|
||||
let height = this.h
|
||||
if (this.canvasStyleData.auxiliaryMatrix) {
|
||||
left = Math.round(left / this.curCanvasScale.matrixStyleWidth) * this.curCanvasScale.matrixStyleWidth
|
||||
width = Math.round(width / this.curCanvasScale.matrixStyleWidth) * this.curCanvasScale.matrixStyleWidth
|
||||
top = Math.round(top / this.curCanvasScale.matrixStyleHeight) * this.curCanvasScale.matrixStyleHeight
|
||||
height = Math.round(height / this.curCanvasScale.matrixStyleHeight) * this.curCanvasScale.matrixStyleHeight
|
||||
}
|
||||
const style = {
|
||||
transform: `translate(${left}px, ${top}px) rotate(0deg)`,
|
||||
width: width + 'px',
|
||||
height: height + 'px',
|
||||
opacity: 0.4,
|
||||
background: 'gray',
|
||||
position: 'absolute'
|
||||
}
|
||||
// console.log('style=>' + JSON.stringify(style))
|
||||
return style
|
||||
},
|
||||
...mapState([
|
||||
'curComponent',
|
||||
'editor',
|
||||
'curCanvasScale',
|
||||
'canvasStyleData',
|
||||
'linkageSettingStatus'
|
||||
])
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@ -20,7 +20,8 @@
|
||||
@mouseenter="enter"
|
||||
@mouseleave="leave"
|
||||
>
|
||||
<edit-bar style="transform: translateZ(10px)" v-if="active||linkageSettingStatus" :active-model="'edit'" :element="element" @showViewDetails="showViewDetails" />
|
||||
<edit-bar v-if="active||linkageSettingStatus" style="transform: translateZ(10px)" :active-model="'edit'" :element="element" @showViewDetails="showViewDetails" />
|
||||
<div v-if="resizing" style="transform: translateZ(11px);position: absolute; z-index: 3" :style="resizeShadowStyle" />
|
||||
<div
|
||||
v-for="(handlei, indexi) in actualHandles"
|
||||
:key="indexi"
|
||||
@ -31,7 +32,9 @@
|
||||
>
|
||||
<slot :name="handlei" />
|
||||
</div>
|
||||
<slot />
|
||||
<div :style="mainSlotStyle" :class="{'gap_class':canvasStyleData.panel.gap==='yes'}">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -49,7 +52,7 @@ import EditBar from '@/components/canvas/components/Editor/EditBar'
|
||||
|
||||
export default {
|
||||
replace: true,
|
||||
name: 'VueDragResizeRotate',
|
||||
name: 'Dedrag',
|
||||
components: { EditBar },
|
||||
props: {
|
||||
className: {
|
||||
@ -440,6 +443,14 @@ export default {
|
||||
...(this.dragging && this.disableUserSelect ? userSelectNone : userSelectAuto)
|
||||
}
|
||||
},
|
||||
resizeShadowStyle() {
|
||||
return {
|
||||
width: this.computedWidth,
|
||||
height: this.computedHeight,
|
||||
opacity: 0.4,
|
||||
background: 'gray'
|
||||
}
|
||||
},
|
||||
// 控制柄显示与否
|
||||
actualHandles() {
|
||||
if (!this.resizable) return []
|
||||
@ -464,9 +475,48 @@ export default {
|
||||
return this.height + 'px'
|
||||
},
|
||||
|
||||
// 根据left right 算出元素的宽度
|
||||
computedMainSlotWidth() {
|
||||
if (this.w === 'auto') {
|
||||
if (!this.widthTouched) {
|
||||
return 'auto'
|
||||
}
|
||||
}
|
||||
if (this.canvasStyleData.auxiliaryMatrix) {
|
||||
const width = Math.round(this.width / this.curCanvasScale.matrixStyleWidth) * this.curCanvasScale.matrixStyleWidth
|
||||
return width + 'px'
|
||||
} else {
|
||||
return this.width + 'px'
|
||||
}
|
||||
},
|
||||
// 根据top bottom 算出元素的宽度
|
||||
computedMainSlotHeight() {
|
||||
if (this.h === 'auto') {
|
||||
if (!this.heightTouched) {
|
||||
return 'auto'
|
||||
}
|
||||
}
|
||||
if (this.canvasStyleData.auxiliaryMatrix) {
|
||||
const height = Math.round(this.height / this.curCanvasScale.matrixStyleHeight) * this.curCanvasScale.matrixStyleHeight
|
||||
return height + 'px'
|
||||
} else {
|
||||
return this.height + 'px'
|
||||
}
|
||||
},
|
||||
|
||||
// private
|
||||
mainSlotStyle() {
|
||||
const style = {
|
||||
width: this.computedMainSlotWidth,
|
||||
height: this.computedMainSlotHeight
|
||||
}
|
||||
// console.log('style=>' + JSON.stringify(style))
|
||||
return style
|
||||
},
|
||||
curComponent() {
|
||||
return this.$store.state.curComponent
|
||||
},
|
||||
...mapState([
|
||||
'curComponent',
|
||||
'editor',
|
||||
'curCanvasScale',
|
||||
'canvasStyleData',
|
||||
@ -566,6 +616,18 @@ export default {
|
||||
this.beforeDestroyFunction()
|
||||
this.createdFunction()
|
||||
this.mountedFunction()
|
||||
},
|
||||
// private 监控dragging resizing
|
||||
dragging(val) {
|
||||
if (this.enabled) {
|
||||
this.curComponent.optStatus.dragging = val
|
||||
}
|
||||
},
|
||||
// private 监控dragging resizing
|
||||
resizing(val) {
|
||||
if (this.enabled) {
|
||||
this.curComponent.optStatus.resizing = val
|
||||
}
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
@ -610,7 +672,7 @@ export default {
|
||||
const rect = this.$el.parentNode.getBoundingClientRect()
|
||||
this.parentX = rect.x
|
||||
this.parentY = rect.y
|
||||
return [Math.round(parseFloat(style.getPropertyValue('width'), 10)), Math.round(parseFloat(style.getPropertyValue('height'), 10))]
|
||||
return [Math.round(parseFloat(style.getPropertyValue('width'), 10)), 100000]
|
||||
}
|
||||
if (typeof this.parent === 'string') {
|
||||
const parentNode = document.querySelector(this.parent)
|
||||
@ -629,7 +691,7 @@ export default {
|
||||
elementMouseDown(e) {
|
||||
// private 设置当前组件数据及状态
|
||||
this.$store.commit('setClickComponentStatus', true)
|
||||
if (this.element.component !== 'v-text' && this.element.component !== 'rect-shape' && this.element.component !== 'de-input-search' && this.element.component !== 'de-select-grid' && this.element.component !== 'de-number-range') {
|
||||
if (this.element.component !== 'v-text' && this.element.component !== 'rect-shape' && this.element.component !== 'de-input-search' && this.element.component !== 'de-select-grid' && this.element.component !== 'de-number-range' && this.element.component !== 'de-date') {
|
||||
e.preventDefault()
|
||||
}
|
||||
// 阻止冒泡事件
|
||||
@ -1176,7 +1238,7 @@ export default {
|
||||
if (this.canvasStyleData.auxiliaryMatrix) {
|
||||
this.recordMatrixCurStyle()
|
||||
}
|
||||
this.hasMove && this.$store.commit('recordSnapshot')
|
||||
this.hasMove && this.$store.commit('recordSnapshot', 'handleUp')
|
||||
// 记录snapshot后 移动已记录设置为false
|
||||
this.hasMove = false
|
||||
|
||||
@ -1490,7 +1552,7 @@ export default {
|
||||
// resize
|
||||
const self = this
|
||||
setTimeout(function() {
|
||||
self.$emit('resizestop')
|
||||
self.$emit('resizeView')
|
||||
}, 200)
|
||||
},
|
||||
mountedFunction() {
|
||||
@ -1650,6 +1712,10 @@ export default {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.gap_class{
|
||||
padding:5px;
|
||||
}
|
||||
|
||||
/*.mouseOn >>> .icon-shezhi{*/
|
||||
/* z-index: 2;*/
|
||||
/* display:block!important;*/
|
||||
|
96
frontend/src/components/DeDrag/shadow.vue
Normal file
96
frontend/src/components/DeDrag/shadow.vue
Normal file
@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<div style="z-index:-1" :style="styleInfo" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
export default {
|
||||
replace: true,
|
||||
name: 'Shadow',
|
||||
computed: {
|
||||
styleInfo() {
|
||||
// console.log('styleInfo==>')
|
||||
// debugger
|
||||
// console.log('dragComponentInfo==>' + this.dragComponentInfo.shadowStyle.x)
|
||||
let left = 0
|
||||
let top = 0
|
||||
let width = 0
|
||||
let height = 0
|
||||
if (this.dragComponentInfo) {
|
||||
// 组件移入
|
||||
left = this.dragComponentInfo.shadowStyle.x
|
||||
top = this.dragComponentInfo.shadowStyle.y
|
||||
width = this.dragComponentInfo.style.width
|
||||
height = this.dragComponentInfo.style.height
|
||||
// console.log('left:' + left + 'top:' + top + 'width:' + width + 'height:' + height)
|
||||
} else {
|
||||
left = this.curComponent.style.left * this.curCanvasScale.scaleWidth / 100
|
||||
top = this.curComponent.style.top * this.curCanvasScale.scaleHeight / 100
|
||||
width = this.curComponent.style.width * this.curCanvasScale.scaleWidth / 100
|
||||
height = this.curComponent.style.height * this.curCanvasScale.scaleHeight / 100
|
||||
// console.log('curComponent left:' + left + 'top:' + top + 'width:' + width + 'height:' + height)
|
||||
}
|
||||
// 当前默认为自适应
|
||||
if (this.canvasStyleData.auxiliaryMatrix) {
|
||||
left = Math.round(left / this.curCanvasScale.matrixStyleWidth) * this.curCanvasScale.matrixStyleWidth
|
||||
width = Math.round(width / this.curCanvasScale.matrixStyleWidth) * this.curCanvasScale.matrixStyleWidth
|
||||
top = Math.round(top / this.curCanvasScale.matrixStyleHeight) * this.curCanvasScale.matrixStyleHeight
|
||||
height = Math.round(height / this.curCanvasScale.matrixStyleHeight) * this.curCanvasScale.matrixStyleHeight
|
||||
}
|
||||
|
||||
// 防止阴影区超出边界
|
||||
const xGap = left + width - this.canvasWidth
|
||||
// console.log('canvasWidth:' + this.canvasWidth + ';xGap:' + xGap)
|
||||
if (xGap > 0) {
|
||||
left = left - xGap
|
||||
}
|
||||
const style = {
|
||||
transform: `translate(${left}px, ${top}px) rotate(0deg)`,
|
||||
width: width + 'px',
|
||||
height: height + 'px',
|
||||
opacity: 0.4,
|
||||
background: 'gray',
|
||||
position: 'absolute'
|
||||
}
|
||||
// console.log('style=>' + JSON.stringify(style))
|
||||
// 记录外部拖拽进入仪表板时阴影区域宽高
|
||||
if (this.dragComponentInfo) {
|
||||
this.recordShadowStyle(left, top, width, height)
|
||||
}
|
||||
return style
|
||||
},
|
||||
dragComponentInfo() {
|
||||
return this.$store.state.dragComponentInfo
|
||||
},
|
||||
canvasWidth() {
|
||||
const scaleWidth = this.curCanvasScale.scaleWidth / 100
|
||||
return this.canvasStyleData.width * scaleWidth
|
||||
},
|
||||
...mapState([
|
||||
'curComponent',
|
||||
'editor',
|
||||
'curCanvasScale',
|
||||
'canvasStyleData',
|
||||
'linkageSettingStatus'
|
||||
])
|
||||
},
|
||||
methods: {
|
||||
recordShadowStyle(x, y, width, height) {
|
||||
this.dragComponentInfo.shadowStyle.width = this.scaleW(width)
|
||||
this.dragComponentInfo.shadowStyle.x = this.scaleW(x)
|
||||
this.dragComponentInfo.shadowStyle.height = this.scaleH(height)
|
||||
this.dragComponentInfo.shadowStyle.y = this.scaleH(y)
|
||||
},
|
||||
scaleH(h) {
|
||||
return h * 100 / this.curCanvasScale.scaleHeight
|
||||
},
|
||||
scaleW(w) {
|
||||
return w * 100 / this.curCanvasScale.scaleWidth
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<el-dropdown style="display: flex;align-items: center;" trigger="click" class="international" @command="handleSetLanguage">
|
||||
<div>
|
||||
<svg-icon class-name="international-icon" icon-class="language" />
|
||||
<svg-icon :style="{color: topMenuTextColor}" class-name="international-icon" icon-class="language" />
|
||||
</div>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item :disabled="language==='zh_CN'" command="zh_CN">
|
||||
@ -24,10 +24,18 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import variables from '@/styles/variables.scss'
|
||||
export default {
|
||||
computed: {
|
||||
language() {
|
||||
return this.$store.getters.language
|
||||
},
|
||||
variables() {
|
||||
return variables
|
||||
},
|
||||
topMenuTextColor() {
|
||||
if (this.$store.getters.uiInfo && this.$store.getters.uiInfo['ui.topMenuTextColor'] && this.$store.getters.uiInfo['ui.topMenuTextColor'].paramValue) { return this.$store.getters.uiInfo['ui.topMenuTextColor'].paramValue }
|
||||
return this.variables.topBarMenuText
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -199,6 +199,7 @@ export default {
|
||||
query(currentPage, pageSize, param).then(response => {
|
||||
this.data = response.data.listObject
|
||||
this.paginationConfig.total = response.data.itemCount
|
||||
this.count = this.paginationConfig.total
|
||||
}).catch(() => {
|
||||
const token = getToken()
|
||||
if (!token || token === 'null' || token === 'undefined') {
|
||||
|
@ -1,145 +0,0 @@
|
||||
<template>
|
||||
<div ref="rightPanel" :class="{show:show}" class="rightPanel-container">
|
||||
<div class="rightPanel-background" />
|
||||
<div class="rightPanel">
|
||||
<!-- <div class="handle-button" :style="{'top':buttonTop+'px','background-color':theme}" @click="show=!show">-->
|
||||
<!-- <i :class="show?'el-icon-close':'el-icon-setting'" />-->
|
||||
<!-- </div>-->
|
||||
<div class="rightPanel-items">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { addClass, removeClass } from '@/utils'
|
||||
|
||||
export default {
|
||||
name: 'RightPanel',
|
||||
props: {
|
||||
clickNotClose: {
|
||||
default: false,
|
||||
type: Boolean
|
||||
},
|
||||
buttonTop: {
|
||||
default: 250,
|
||||
type: Number
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
theme() {
|
||||
return this.$store.state.settings.theme
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
show(value) {
|
||||
if (value && !this.clickNotClose) {
|
||||
this.addEventClick()
|
||||
}
|
||||
if (value) {
|
||||
addClass(document.body, 'showRightPanel')
|
||||
} else {
|
||||
removeClass(document.body, 'showRightPanel')
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.insertToBody()
|
||||
},
|
||||
beforeDestroy() {
|
||||
const elx = this.$refs.rightPanel
|
||||
elx.remove()
|
||||
},
|
||||
methods: {
|
||||
addEventClick() {
|
||||
window.addEventListener('click', this.closeSidebar)
|
||||
},
|
||||
closeSidebar(evt) {
|
||||
const parent = evt.target.closest('.rightPanel')
|
||||
if (!parent) {
|
||||
this.show = false
|
||||
window.removeEventListener('click', this.closeSidebar)
|
||||
}
|
||||
},
|
||||
insertToBody() {
|
||||
const elx = this.$refs.rightPanel
|
||||
const body = document.querySelector('body')
|
||||
body.insertBefore(elx, body.firstChild)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.showRightPanel {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
width:100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.rightPanel-background {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
opacity: 0;
|
||||
transition: opacity .3s cubic-bezier(.7, .3, .1, 1);
|
||||
background: rgba(0, 0, 0, .2);
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.rightPanel {
|
||||
width: 100%;
|
||||
max-width: 260px;
|
||||
height: 100vh;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, .05);
|
||||
transition: all .25s cubic-bezier(.7, .3, .1, 1);
|
||||
transform: translate(100%);
|
||||
background: #fff;
|
||||
z-index: 40000;
|
||||
}
|
||||
|
||||
.show {
|
||||
transition: all .3s cubic-bezier(.7, .3, .1, 1);
|
||||
|
||||
.rightPanel-background {
|
||||
z-index: 20000;
|
||||
opacity: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.rightPanel {
|
||||
transform: translate(0);
|
||||
}
|
||||
}
|
||||
|
||||
.handle-button {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
position: absolute;
|
||||
left: -48px;
|
||||
text-align: center;
|
||||
font-size: 24px;
|
||||
border-radius: 6px 0 0 6px !important;
|
||||
z-index: 0;
|
||||
pointer-events: auto;
|
||||
cursor: pointer;
|
||||
color: #fff;
|
||||
line-height: 48px;
|
||||
i {
|
||||
font-size: 24px;
|
||||
line-height: 48px;
|
||||
}
|
||||
}
|
||||
</style>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user