Unverified 提交 2778d9eb authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw 提交者: GitHub

Merge branch 'dev' into pr@dev@feat_de_tabs

......@@ -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;
}
......
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;
......
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;
......
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;
}
\ No newline at end of file
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;
}
\ No newline at end of file
......@@ -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},
......
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);
}
\ No newline at end of file
......@@ -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>
\ No newline at end of file
......@@ -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));
}
} */
}
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();
}
}
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;
......
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());
}
}
\ No newline at end of file
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());
......
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;
}
}
package io.dataease.datasource.dto.es;
import lombok.Data;
@Data
public class Requst {
private String query;
private Integer fetch_size = 10000;
}
package io.dataease.datasource.dto.es;
import lombok.Data;
@Data
public class RequstWithCursor extends Requst{
private String cursor;
}
......@@ -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");
}
}
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);
......
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;
}
});
}
}
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;
}
}
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();
}
}
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;
};
/**
* 单指标汇总
*
......
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)";
}
......@@ -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) {
......
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论