Merge branch 'dev' into pr@dev@pg

This commit is contained in:
taojinlong 2021-08-10 17:06:57 +08:00
commit d9ebc295b4
44 changed files with 1665 additions and 85 deletions

View File

@ -2,18 +2,17 @@ package io.dataease.auth.config;
import io.dataease.auth.api.dto.CurrentRoleDto;
import io.dataease.auth.api.dto.CurrentUserDto;
import io.dataease.auth.entity.ASKToken;
import io.dataease.auth.entity.JWTToken;
import io.dataease.auth.entity.SysUserEntity;
import io.dataease.auth.entity.TokenInfo;
import io.dataease.auth.handler.ApiKeyHandler;
import io.dataease.auth.service.AuthUserService;
import io.dataease.auth.util.JWTUtils;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.LogUtil;
import io.dataease.listener.util.CacheUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
@ -37,7 +36,7 @@ public class F2CRealm extends AuthorizingRealm {
@Override
public boolean supports(AuthenticationToken token) {
return token instanceof JWTToken;
return token instanceof JWTToken || token instanceof ASKToken;
}
//验证资源权限
@ -56,12 +55,27 @@ public class F2CRealm extends AuthorizingRealm {
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
if (auth instanceof ASKToken) {
Object accessKey = auth.getPrincipal();
Object signature = auth.getCredentials();
Long userId = ApiKeyHandler.getUser(accessKey.toString(), signature.toString());
SysUserEntity userEntity = userWithId(userId);
CurrentUserDto currentUserDto = queryCacheUserDto(userEntity);
return new SimpleAuthenticationInfo(currentUserDto, signature, "f2cReam");
}
try {
CacheUtils.get("lic_info", "lic");
}catch (Exception e) {
LogUtil.error(e);
throw new AuthenticationException("lic error");
}
TokenInfo tokenInfo = null;
String token = null;
try {
@ -78,13 +92,14 @@ public class F2CRealm extends AuthorizingRealm {
throw new AuthenticationException("token invalid");
}
// 使用缓存
SysUserEntity user = authUserService.getUserById(userId);
/*SysUserEntity user = authUserService.getUserById(userId);
if (user == null) {
throw new AuthenticationException("User didn't existed!");
}
if (user.getEnabled()==0) {
throw new AuthenticationException("User is valid!");
}
}*/
SysUserEntity user = userWithId(userId);
String pass = null;
try {
pass = user.getPassword();
@ -94,6 +109,29 @@ public class F2CRealm extends AuthorizingRealm {
if (! JWTUtils.verify(token, tokenInfo, pass)) {
throw new AuthenticationException("Username or password error");
}
/*// 使用缓存
List<CurrentRoleDto> currentRoleDtos = authUserService.roleInfos(user.getUserId());
// 使用缓存
List<String> permissions = authUserService.permissions(user.getUserId());
CurrentUserDto currentUserDto = BeanUtils.copyBean(new CurrentUserDto(), user);
currentUserDto.setRoles(currentRoleDtos);
currentUserDto.setPermissions(permissions);*/
CurrentUserDto currentUserDto = queryCacheUserDto(user);
return new SimpleAuthenticationInfo(currentUserDto, token, "f2cReam");
}
public SysUserEntity userWithId(Long userId) {
SysUserEntity user = authUserService.getUserById(userId);
if (user == null) {
throw new AuthenticationException("User didn't existed!");
}
if (user.getEnabled()==0) {
throw new AuthenticationException("User is valid!");
}
return user;
}
public CurrentUserDto queryCacheUserDto(SysUserEntity user) {
// 使用缓存
List<CurrentRoleDto> currentRoleDtos = authUserService.roleInfos(user.getUserId());
// 使用缓存
@ -101,6 +139,6 @@ public class F2CRealm extends AuthorizingRealm {
CurrentUserDto currentUserDto = BeanUtils.copyBean(new CurrentUserDto(), user);
currentUserDto.setRoles(currentRoleDtos);
currentUserDto.setPermissions(permissions);
return new SimpleAuthenticationInfo(currentUserDto, token, "f2cReam");
return currentUserDto;
}
}

View File

@ -0,0 +1,25 @@
package io.dataease.auth.entity;
import org.apache.shiro.authc.AuthenticationToken;
public class ASKToken implements AuthenticationToken {
private String accessKey;
private String signature;
public ASKToken(String accessKey, String signature) {
this.accessKey = accessKey;
this.signature = signature;
}
@Override
public Object getPrincipal() {
return accessKey;
}
@Override
public Object getCredentials() {
return signature;
}
}

View File

@ -1,8 +1,10 @@
package io.dataease.auth.filter;
import io.dataease.auth.entity.ASKToken;
import io.dataease.auth.entity.JWTToken;
import io.dataease.auth.entity.SysUserEntity;
import io.dataease.auth.entity.TokenInfo;
import io.dataease.auth.handler.ApiKeyHandler;
import io.dataease.auth.service.AuthUserService;
import io.dataease.auth.util.JWTUtils;
import io.dataease.commons.utils.CommonBeanFactory;
@ -48,6 +50,18 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
@Override
protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
if (ApiKeyHandler.isApiKeyCall(httpServletRequest)) {
// Long userId = ApiKeyHandler.getUser(httpServletRequest);
ASKToken askToken = ApiKeyHandler.buildToken(httpServletRequest);
// UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(userId.toString(), ApiKeyHandler.random);
getSubject(request, response).login(askToken);
return true;
}
String authorization = httpServletRequest.getHeader("Authorization");
if (StringUtils.startsWith(authorization, "Basic")) {
return false;
@ -72,7 +86,10 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
*/
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
if (isLoginAttempt(request, response)) {
// 先判断是不是api调用
HttpServletRequest hRequest = (HttpServletRequest) request;
if (isLoginAttempt(request, response) || ApiKeyHandler.isApiKeyCall(hRequest)) {
try {
boolean loginSuccess = executeLogin(request, response);
return loginSuccess;

View File

@ -0,0 +1,88 @@
package io.dataease.auth.handler;
import io.dataease.auth.entity.ASKToken;
import io.dataease.commons.utils.CodingUtil;
import io.dataease.plugins.config.SpringContextUtil;
import io.dataease.plugins.xpack.ukey.dto.request.XpackUkeyDto;
import io.dataease.plugins.xpack.ukey.service.UkeyXpackService;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.UUID;
public class ApiKeyHandler {
public static final String API_ACCESS_KEY = "accessKey";
public static final String API_SIGNATURE = "signature";
public static String random = UUID.randomUUID().toString() + UUID.randomUUID().toString();
public static Long getUser(HttpServletRequest request) {
if (request == null) {
return null;
}
return getUser(request.getHeader(API_ACCESS_KEY), request.getHeader(API_SIGNATURE));
}
public static ASKToken buildToken(HttpServletRequest request) {
if (request == null) {
return null;
}
String accessKey = request.getHeader(API_ACCESS_KEY);
String signature = request.getHeader(API_SIGNATURE);
ASKToken askToken = new ASKToken(accessKey, signature);
return askToken;
}
public static Boolean isApiKeyCall(HttpServletRequest request) {
if (request == null) {
return false;
}
if (StringUtils.isBlank(request.getHeader(API_ACCESS_KEY)) || StringUtils.isBlank(request.getHeader(API_SIGNATURE))) {
return false;
}
return true;
}
public static XpackUkeyDto ukey(String accessKey) {
UkeyXpackService ukeyXpackService = SpringContextUtil.getBean(UkeyXpackService.class);
XpackUkeyDto userKey = ukeyXpackService.getUserKey(accessKey);
return userKey;
}
public static Long getUser(String accessKey, String signature) {
if (StringUtils.isBlank(accessKey) || StringUtils.isBlank(signature)) {
return null;
}
XpackUkeyDto userKey = ukey(accessKey);
if (userKey == null) {
throw new RuntimeException("invalid accessKey");
}
String signatureDecrypt;
try {
signatureDecrypt = CodingUtil.aesDecrypt(signature, userKey.getSecretKey(), accessKey);
} catch (Throwable t) {
throw new RuntimeException("invalid signature");
}
String[] signatureArray = StringUtils.split(StringUtils.trimToNull(signatureDecrypt), "|");
if (signatureArray.length < 2) {
throw new RuntimeException("invalid signature");
}
if (!StringUtils.equals(accessKey, signatureArray[0])) {
throw new RuntimeException("invalid signature");
}
long signatureTime = 0l;
try {
signatureTime = Long.valueOf(signatureArray[signatureArray.length - 1]).longValue();
} catch (Exception e) {
throw new RuntimeException(e);
}
if (Math.abs(System.currentTimeMillis() - signatureTime) > 1800000) {
//签名30分钟超时
throw new RuntimeException("expired signature");
}
return userKey.getUserId();
}
}

View File

@ -0,0 +1,21 @@
package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class UserKey implements Serializable {
private Long id;
private Long userId;
private String accessKey;
private String secretKey;
private Long createTime;
private String status;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,590 @@
package io.dataease.base.domain;
import java.util.ArrayList;
import java.util.List;
public class UserKeyExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public UserKeyExample() {
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(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andUserIdIsNull() {
addCriterion("user_id is null");
return (Criteria) this;
}
public Criteria andUserIdIsNotNull() {
addCriterion("user_id is not null");
return (Criteria) this;
}
public Criteria andUserIdEqualTo(Long value) {
addCriterion("user_id =", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotEqualTo(Long value) {
addCriterion("user_id <>", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThan(Long value) {
addCriterion("user_id >", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThanOrEqualTo(Long value) {
addCriterion("user_id >=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThan(Long value) {
addCriterion("user_id <", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThanOrEqualTo(Long value) {
addCriterion("user_id <=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdIn(List<Long> values) {
addCriterion("user_id in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotIn(List<Long> values) {
addCriterion("user_id not in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdBetween(Long value1, Long value2) {
addCriterion("user_id between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotBetween(Long value1, Long value2) {
addCriterion("user_id not between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andAccessKeyIsNull() {
addCriterion("access_key is null");
return (Criteria) this;
}
public Criteria andAccessKeyIsNotNull() {
addCriterion("access_key is not null");
return (Criteria) this;
}
public Criteria andAccessKeyEqualTo(String value) {
addCriterion("access_key =", value, "accessKey");
return (Criteria) this;
}
public Criteria andAccessKeyNotEqualTo(String value) {
addCriterion("access_key <>", value, "accessKey");
return (Criteria) this;
}
public Criteria andAccessKeyGreaterThan(String value) {
addCriterion("access_key >", value, "accessKey");
return (Criteria) this;
}
public Criteria andAccessKeyGreaterThanOrEqualTo(String value) {
addCriterion("access_key >=", value, "accessKey");
return (Criteria) this;
}
public Criteria andAccessKeyLessThan(String value) {
addCriterion("access_key <", value, "accessKey");
return (Criteria) this;
}
public Criteria andAccessKeyLessThanOrEqualTo(String value) {
addCriterion("access_key <=", value, "accessKey");
return (Criteria) this;
}
public Criteria andAccessKeyLike(String value) {
addCriterion("access_key like", value, "accessKey");
return (Criteria) this;
}
public Criteria andAccessKeyNotLike(String value) {
addCriterion("access_key not like", value, "accessKey");
return (Criteria) this;
}
public Criteria andAccessKeyIn(List<String> values) {
addCriterion("access_key in", values, "accessKey");
return (Criteria) this;
}
public Criteria andAccessKeyNotIn(List<String> values) {
addCriterion("access_key not in", values, "accessKey");
return (Criteria) this;
}
public Criteria andAccessKeyBetween(String value1, String value2) {
addCriterion("access_key between", value1, value2, "accessKey");
return (Criteria) this;
}
public Criteria andAccessKeyNotBetween(String value1, String value2) {
addCriterion("access_key not between", value1, value2, "accessKey");
return (Criteria) this;
}
public Criteria andSecretKeyIsNull() {
addCriterion("secret_key is null");
return (Criteria) this;
}
public Criteria andSecretKeyIsNotNull() {
addCriterion("secret_key is not null");
return (Criteria) this;
}
public Criteria andSecretKeyEqualTo(String value) {
addCriterion("secret_key =", value, "secretKey");
return (Criteria) this;
}
public Criteria andSecretKeyNotEqualTo(String value) {
addCriterion("secret_key <>", value, "secretKey");
return (Criteria) this;
}
public Criteria andSecretKeyGreaterThan(String value) {
addCriterion("secret_key >", value, "secretKey");
return (Criteria) this;
}
public Criteria andSecretKeyGreaterThanOrEqualTo(String value) {
addCriterion("secret_key >=", value, "secretKey");
return (Criteria) this;
}
public Criteria andSecretKeyLessThan(String value) {
addCriterion("secret_key <", value, "secretKey");
return (Criteria) this;
}
public Criteria andSecretKeyLessThanOrEqualTo(String value) {
addCriterion("secret_key <=", value, "secretKey");
return (Criteria) this;
}
public Criteria andSecretKeyLike(String value) {
addCriterion("secret_key like", value, "secretKey");
return (Criteria) this;
}
public Criteria andSecretKeyNotLike(String value) {
addCriterion("secret_key not like", value, "secretKey");
return (Criteria) this;
}
public Criteria andSecretKeyIn(List<String> values) {
addCriterion("secret_key in", values, "secretKey");
return (Criteria) this;
}
public Criteria andSecretKeyNotIn(List<String> values) {
addCriterion("secret_key not in", values, "secretKey");
return (Criteria) this;
}
public Criteria andSecretKeyBetween(String value1, String value2) {
addCriterion("secret_key between", value1, value2, "secretKey");
return (Criteria) this;
}
public Criteria andSecretKeyNotBetween(String value1, String value2) {
addCriterion("secret_key not between", value1, value2, "secretKey");
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 andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("`status` is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(String value) {
addCriterion("`status` =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(String value) {
addCriterion("`status` <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(String value) {
addCriterion("`status` >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(String value) {
addCriterion("`status` >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(String value) {
addCriterion("`status` <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(String value) {
addCriterion("`status` <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLike(String value) {
addCriterion("`status` like", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotLike(String value) {
addCriterion("`status` not like", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<String> values) {
addCriterion("`status` in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<String> values) {
addCriterion("`status` not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(String value1, String value2) {
addCriterion("`status` between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(String value1, String value2) {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

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

View File

@ -0,0 +1,228 @@
<?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.UserKeyMapper">
<resultMap id="BaseResultMap" type="io.dataease.base.domain.UserKey">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="access_key" jdbcType="VARCHAR" property="accessKey" />
<result column="secret_key" jdbcType="VARCHAR" property="secretKey" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="status" jdbcType="VARCHAR" property="status" />
</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, user_id, access_key, secret_key, create_time, `status`
</sql>
<select id="selectByExample" parameterType="io.dataease.base.domain.UserKeyExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from user_key
<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.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user_key
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from user_key
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="io.dataease.base.domain.UserKeyExample">
delete from user_key
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.dataease.base.domain.UserKey">
insert into user_key (id, user_id, access_key,
secret_key, create_time, `status`
)
values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{accessKey,jdbcType=VARCHAR},
#{secretKey,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.UserKey">
insert into user_key
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="accessKey != null">
access_key,
</if>
<if test="secretKey != null">
secret_key,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="status != null">
`status`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="accessKey != null">
#{accessKey,jdbcType=VARCHAR},
</if>
<if test="secretKey != null">
#{secretKey,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.dataease.base.domain.UserKeyExample" resultType="java.lang.Long">
select count(*) from user_key
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update user_key
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if test="record.accessKey != null">
access_key = #{record.accessKey,jdbcType=VARCHAR},
</if>
<if test="record.secretKey != null">
secret_key = #{record.secretKey,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update user_key
set id = #{record.id,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
access_key = #{record.accessKey,jdbcType=VARCHAR},
secret_key = #{record.secretKey,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
`status` = #{record.status,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.UserKey">
update user_key
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=BIGINT},
</if>
<if test="accessKey != null">
access_key = #{accessKey,jdbcType=VARCHAR},
</if>
<if test="secretKey != null">
secret_key = #{secretKey,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.UserKey">
update user_key
set user_id = #{userId,jdbcType=BIGINT},
access_key = #{accessKey,jdbcType=VARCHAR},
secret_key = #{secretKey,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
`status` = #{status,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -1,15 +1,19 @@
package io.dataease.base.mapper.ext;
import io.dataease.base.domain.DatasetTableField;
import io.dataease.dto.LinkageInfoDTO;
import io.dataease.dto.PanelViewLinkageDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface ExtPanelViewLinkageMapper {
List<PanelViewLinkageDTO> getViewLinkageGather(@Param("panelId") String panelId,@Param("sourceViewId") String sourceViewId,@Param("targetViewIds") List<String> targetViewIds);
List<LinkageInfoDTO> getPanelAllLinkageInfo(@Param("panelId") String panelId);
List<DatasetTableField> queryTableField(@Param("table_id") String tableId);
void deleteViewLinkage(@Param("panelId") String panelId,@Param("sourceViewId") String sourceViewId);

View File

@ -24,6 +24,14 @@
</collection>
</resultMap>
<resultMap id="AllLinkageMap" type="io.dataease.dto.LinkageInfoDTO">
<result column="sourceInfo" jdbcType="VARCHAR" property="sourceInfo"/>
<collection property="targetInfoList" ofType="String">
<result column="targetInfo" jdbcType="VARCHAR"/>
</collection>
</resultMap>
<select id="getViewLinkageGather" resultMap="LinkageGatherMap">
SELECT
chart_view.`name` as 'targetViewName',
@ -78,4 +86,16 @@
(#{menu.menuId},#{menu.title},#{menu.pid},#{menu.subCount},#{menu.permission},#{menu.hidden},ifnull(#{menu.hidden},0))
</foreach>
</insert>
<select id="getPanelAllLinkageInfo" resultMap="AllLinkageMap">
SELECT
distinct
CONCAT( panel_view_linkage.source_view_id, '#', panel_view_linkage_field.source_field ) AS 'sourceInfo',
CONCAT( panel_view_linkage.target_view_id, '#', panel_view_linkage_field.target_field ) AS 'targetInfo'
FROM
panel_view_linkage
LEFT JOIN panel_view_linkage_field ON panel_view_linkage.id = panel_view_linkage_field.linkage_id
WHERE
panel_view_linkage.panel_id = #{panelId}
</select>
</mapper>

View File

@ -7,6 +7,7 @@ import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.MessageDigest;
import java.util.UUID;
/**
* 加密解密工具
@ -153,6 +154,17 @@ public class CodingUtil {
}
}
/*public static String getSignature(String accessKey, String secretKey) throws Exception {
return aesEncrypt(accessKey + "|" + UUID.randomUUID().toString() + "|" + System.currentTimeMillis(), secretKey, accessKey);
}
public static void main(String[] args) throws Exception{
String accessKey = "gnPFmtAsdLhUEWPA";
String secretKey = "TfK5FGUle0KRfJJJ";
String signature = getSignature(accessKey, secretKey);
System.out.println(signature);
}*/
public static String secretKey() {
try {
KeyGenerator keyGen = KeyGenerator.getInstance("AES");

View File

@ -77,7 +77,9 @@ public class Knife4jConfiguration {
private Docket defaultApi(String groupName, String packageName) {
List<SecurityScheme> securitySchemes=new ArrayList<>();
securitySchemes.add(apiKey());
securitySchemes.add(accessKey());
securitySchemes.add(signature());
List<SecurityContext> securityContexts = new ArrayList<>();
securityContexts.add(securityContext());
@ -100,8 +102,12 @@ public class Knife4jConfiguration {
.build();
}
private ApiKey apiKey() {
return new ApiKey("Authorization", "Authorization", "header");
private ApiKey accessKey() {
return new ApiKey("accessKey", "accessKey", "header");
}
private ApiKey signature() {
return new ApiKey("signature", "signature", "header");
}
@ -109,7 +115,12 @@ public class Knife4jConfiguration {
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
authorizationScopes[0] = authorizationScope;
return CollectionUtil.newArrayList(new SecurityReference("Authorization", authorizationScopes));
List<SecurityReference> results = new ArrayList<>();
results.add(new SecurityReference("accessKey", authorizationScopes));
results.add(new SecurityReference("signature", authorizationScopes));
return results;
}
}

View File

@ -9,6 +9,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
@ -39,5 +40,10 @@ public class PanelViewLinkageController {
}
@ApiOperation("获取当前仪表板所有联动信息")
@GetMapping("/getPanelAllLinkageInfo/{panelId}")
public Map<String, List<String>> getPanelAllLinkageInfo(@PathVariable String panelId){
return panelViewLinkageService.getPanelAllLinkageInfo(panelId);
}
}

View File

@ -0,0 +1,15 @@
package io.dataease.controller.request.chart;
import io.dataease.dto.chart.ChartDimensionDTO;
import lombok.Data;
import java.util.List;
/**
* @Author gin
* @Date 2021/8/10 12:25 下午
*/
@Data
public class ChartDrillRequest {
private List<ChartDimensionDTO> dimensionList;
}

View File

@ -13,4 +13,8 @@ import java.util.List;
@Setter
public class ChartExtRequest {
private List<ChartExtFilterRequest> filter;
//联动过滤条件
private List<ChartExtFilterRequest> linkageFilters;
private List<ChartDrillRequest> drill;
}

View File

@ -0,0 +1,31 @@
package io.dataease.dto;
import java.util.List;
/**
* Author: wangjiahao
* Date: 8/10/21
* Description:
*/
public class LinkageInfoDTO {
private String sourceInfo;
private List<String> targetInfoList;
public String getSourceInfo() {
return sourceInfo;
}
public void setSourceInfo(String sourceInfo) {
this.sourceInfo = sourceInfo;
}
public List<String> getTargetInfoList() {
return targetInfoList;
}
public void setTargetInfoList(List<String> targetInfoList) {
this.targetInfoList = targetInfoList;
}
}

View File

@ -1,9 +1,11 @@
package io.dataease.dto.chart;
import io.dataease.base.domain.ChartViewWithBLOBs;
import io.dataease.controller.request.chart.ChartDrillRequest;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
/**
@ -20,4 +22,6 @@ public class ChartViewDTO extends ChartViewWithBLOBs {
private Boolean isLeaf;
private String pid;
private String sql;
private boolean drill;
}

View File

@ -0,0 +1,61 @@
package io.dataease.plugins.server;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.plugins.config.SpringContextUtil;
import io.dataease.plugins.xpack.ukey.dto.request.XpackUkeyDto;
import io.dataease.plugins.xpack.ukey.service.UkeyXpackService;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletRequest;
import java.util.List;
@RequestMapping("/plugin/ukey")
@RestController
public class XUserKeysServer {
@PostMapping("info")
public List<XpackUkeyDto> getUserKeysInfo() {
UkeyXpackService ukeyXpackService = SpringContextUtil.getBean(UkeyXpackService.class);
Long userId = AuthUtils.getUser().getUserId();
return ukeyXpackService.getUserKeysInfo(userId);
}
@PostMapping("validate")
public String validate(ServletRequest request) {
// return ApiKeyHandler.getUser(WebUtils.toHttp(request));
return null;
}
@PostMapping("generate")
public void generateUserKey() {
UkeyXpackService ukeyXpackService = SpringContextUtil.getBean(UkeyXpackService.class);
Long userId = AuthUtils.getUser().getUserId();
ukeyXpackService.generateUserKey(userId);
}
@PostMapping("delete/{id}")
public void deleteUserKey(@PathVariable Long id) {
UkeyXpackService ukeyXpackService = SpringContextUtil.getBean(UkeyXpackService.class);
ukeyXpackService.deleteUserKey(id);
}
@PostMapping("changeStatus/{id}")
public void changeStatus(@PathVariable Long id) {
UkeyXpackService ukeyXpackService = SpringContextUtil.getBean(UkeyXpackService.class);
ukeyXpackService.switchStatus(id);
}
/*@GetMapping("active/{id}")
public void activeUserKey(@PathVariable Long id) {
UkeyXpackService ukeyXpackService = SpringContextUtil.getBean(UkeyXpackService.class);
ukeyXpackService.activeUserKey(id);
}
@GetMapping("disable/{id}")
public void disabledUserKey(@PathVariable Long id) {
UkeyXpackService ukeyXpackService = SpringContextUtil.getBean(UkeyXpackService.class);
ukeyXpackService.disableUserKey(id);
}*/
}

View File

@ -632,10 +632,10 @@ public class OracleQueryProvider extends QueryProvider {
public String createRawQuerySQL(String table, List<DatasetTableField> fields) {
String[] array = fields.stream().map(f -> {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(" ").append(f.getOriginName());
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

View File

@ -11,19 +11,12 @@ import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.CommonBeanFactory;
import io.dataease.commons.utils.LogUtil;
import io.dataease.controller.request.chart.ChartExtFilterRequest;
import io.dataease.controller.request.chart.ChartExtRequest;
import io.dataease.controller.request.chart.ChartGroupRequest;
import io.dataease.controller.request.chart.ChartViewRequest;
import io.dataease.controller.request.dataset.DataSetGroupRequest;
import io.dataease.controller.request.dataset.DataSetTableRequest;
import io.dataease.controller.request.chart.*;
import io.dataease.datasource.provider.DatasourceProvider;
import io.dataease.datasource.provider.ProviderFactory;
import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.datasource.service.DatasourceService;
import io.dataease.dto.chart.*;
import io.dataease.dto.dataset.DataSetGroupDTO;
import io.dataease.dto.dataset.DataSetTableDTO;
import io.dataease.dto.dataset.DataSetTableUnionDTO;
import io.dataease.dto.dataset.DataTableInfoDTO;
import io.dataease.i18n.Translator;
@ -197,6 +190,8 @@ public class ChartViewService {
}.getType());
List<ChartFieldCustomFilterDTO> fieldCustomFilter = new Gson().fromJson(view.getCustomFilter(), new TypeToken<List<ChartFieldCustomFilterDTO>>() {
}.getType());
List<ChartViewFieldDTO> drill = new Gson().fromJson(view.getDrillFields(), new TypeToken<List<ChartViewFieldDTO>>() {
}.getType());
List<ChartCustomFilterDTO> customFilter = new ArrayList<>();
for (ChartFieldCustomFilterDTO ele : fieldCustomFilter) {
List<ChartCustomFilterDTO> collect = ele.getFilter().stream().map(f -> {
@ -225,6 +220,8 @@ public class ChartViewService {
// 过滤来自仪表板的条件
List<ChartExtFilterRequest> extFilterList = new ArrayList<>();
//组件过滤条件
if (ObjectUtils.isNotEmpty(requestList.getFilter())) {
for (ChartExtFilterRequest request : requestList.getFilter()) {
DatasetTableField datasetTableField = dataSetTableFieldsService.get(request.getFieldId());
@ -241,6 +238,55 @@ public class ChartViewService {
}
}
//联动过滤条件联动条件全部加上
if (ObjectUtils.isNotEmpty(requestList.getLinkageFilters())) {
for (ChartExtFilterRequest request : requestList.getLinkageFilters()) {
DatasetTableField datasetTableField = dataSetTableFieldsService.get(request.getFieldId());
request.setDatasetTableField(datasetTableField);
if (StringUtils.equalsIgnoreCase(datasetTableField.getTableId(), view.getTableId())) {
if (CollectionUtils.isNotEmpty(request.getViewIds())) {
if (request.getViewIds().contains(view.getId())) {
extFilterList.add(request);
}
} else {
extFilterList.add(request);
}
}
}
}
// 下钻
boolean isDrill = false;
List<ChartDrillRequest> drillRequest = requestList.getDrill();
if (CollectionUtils.isNotEmpty(drillRequest) && (drill.size() >= drillRequest.size())) {
for (int i = 0; i < drillRequest.size(); i++) {
ChartDrillRequest request = drillRequest.get(i);
for (ChartDimensionDTO dto : request.getDimensionList()) {
ChartViewFieldDTO chartViewFieldDTO = drill.get(i);
// 将钻取值作为条件传递将所有钻取字段作为xAxis并加上下一个钻取字段
if (StringUtils.equalsIgnoreCase(dto.getId(), chartViewFieldDTO.getId())) {
isDrill = true;
DatasetTableField datasetTableField = dataSetTableFieldsService.get(dto.getId());
ChartViewFieldDTO d = new ChartViewFieldDTO();
BeanUtils.copyBean(d, datasetTableField);
ChartExtFilterRequest drillFilter = new ChartExtFilterRequest();
drillFilter.setFieldId(dto.getId());
drillFilter.setValue(new ArrayList<String>() {{
add(dto.getValue());
}});
drillFilter.setOperator("in");
drillFilter.setDatasetTableField(datasetTableField);
extFilterList.add(drillFilter);
// xAxis.add(d);
// if (i == drillRequest.size() - 1) {
// xAxis.add(drill.get(i + 1));
// }
}
}
}
}
// 获取数据集,需校验权限
DatasetTable table = dataSetTableService.get(view.getTableId());
if (ObjectUtils.isEmpty(table)) {
@ -339,7 +385,9 @@ public class ChartViewService {
data = (List<String[]>) cache;
}*/
// 仪表板有参数不实用缓存
if (CollectionUtils.isNotEmpty(requestList.getFilter())) {
if (CollectionUtils.isNotEmpty(requestList.getFilter())
|| CollectionUtils.isNotEmpty(requestList.getLinkageFilters())
|| CollectionUtils.isNotEmpty(requestList.getDrill())) {
data = datasourceProvider.getData(datasourceRequest);
} else {
try {
@ -367,6 +415,9 @@ public class ChartViewService {
mapChart = transScatterData(xAxis, yAxis, view, data, extBubble);
} else if (StringUtils.containsIgnoreCase(view.getType(), "radar")) {
mapChart = transRadarChartData(xAxis, yAxis, view, data);
} else if (StringUtils.containsIgnoreCase(view.getType(), "text")
|| StringUtils.containsIgnoreCase(view.getType(), "gauge")) {
mapChart = transNormalChartData(xAxis, yAxis, view, data);
} else {
mapChart = transChartData(xAxis, yAxis, view, data);
}
@ -380,6 +431,8 @@ public class ChartViewService {
BeanUtils.copyBean(dto, view);
dto.setData(map);
dto.setSql(datasourceRequest.getQuery());
dto.setDrill(isDrill);
return dto;
}
@ -476,6 +529,44 @@ public class ChartViewService {
return map;
}
// 常规图形
private Map<String, Object> transNormalChartData(List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, ChartViewWithBLOBs view, List<String[]> data) {
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(view.getType());
series1.setData(new ArrayList<>());
series.add(series1);
}
for (String[] d : data) {
StringBuilder a = new StringBuilder();
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());
for (int i = xAxis.size(); i < xAxis.size() + yAxis.size(); i++) {
int j = i - xAxis.size();
try {
series.get(j).getData().add(new BigDecimal(StringUtils.isEmpty(d[i]) ? "0" : d[i]));
} catch (Exception e) {
series.get(j).getData().add(new BigDecimal(0));
}
}
}
map.put("x", x);
map.put("series", series);
return map;
}
// radar图
private Map<String, Object> transRadarChartData(List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, ChartViewWithBLOBs view, List<String[]> data) {
Map<String, Object> map = new HashMap<>();

View File

@ -8,6 +8,7 @@ import io.dataease.base.mapper.PanelViewLinkageMapper;
import io.dataease.base.mapper.ext.ExtPanelViewLinkageMapper;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.controller.request.panel.PanelLinkageRequest;
import io.dataease.dto.LinkageInfoDTO;
import io.dataease.dto.PanelViewLinkageDTO;
import io.dataease.dto.PanelViewLinkageFieldDTO;
import org.apache.commons.collections4.CollectionUtils;
@ -89,19 +90,12 @@ public class PanelViewLinkageService {
});
}
}
}
public Map<String, List<String>> getPanelAllLinkageInfo(String panelId) {
List<LinkageInfoDTO> info = extPanelViewLinkageMapper.getPanelAllLinkageInfo(panelId);
return Optional.ofNullable(info).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(LinkageInfoDTO::getSourceInfo,LinkageInfoDTO::getTargetInfoList));
}
}

View File

@ -28,7 +28,7 @@ knife4j.enable=true
knife4j.setting.enableFooter=false
knife4j.setting.enableFooterCustom=false
knife4j.setting.footerCustomContent=fit2cloud 1.0-b9
knife4j.setting.enableSwaggerModels=false
#knife4j.setting.enableSwaggerModels=false
knife4j.setting.enableDocumentManage=false
knife4j.setting.enableSearch=false
knife4j.setting.enableOpenApi=false

View File

@ -0,0 +1,15 @@
-- ----------------------------
-- Table structure for user_key
-- ----------------------------
DROP TABLE IF EXISTS `user_key`;
CREATE TABLE `user_key` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
`access_key` varchar(50) NOT NULL COMMENT 'access_key',
`secret_key` varchar(50) NOT NULL COMMENT 'secret key',
`create_time` bigint(13) NOT NULL COMMENT '创建时间',
`status` varchar(10) DEFAULT NULL COMMENT '状态',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `IDX_AK` (`access_key`),
KEY `IDX_USER_K_ID` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户KEY';

View File

@ -18,3 +18,9 @@ export function saveLinkage(requestInfo) {
})
}
export function getPanelAllLinkageInfo(panelId) {
return request({
url: '/linkage/getPanelAllLinkageInfo/' + panelId,
method: 'get'
})
}

View File

@ -102,7 +102,6 @@ export default {
})
},
elementMouseDown(e) {
debugger
// private
this.$store.commit('setClickComponentStatus', true)
if (this.config.component !== 'v-text' && this.config.component !== 'rect-shape' && this.config.component !== 'de-input-search' && this.config.component !== 'de-number-range') {

View File

@ -209,7 +209,6 @@ export default {
this.$refs['userViewDialog'].exportExcel()
},
deselectCurComponent(e) {
debugger
if (!this.isClickComponent) {
this.$store.commit('setCurComponent', { component: null, index: null })
}

View File

@ -84,6 +84,7 @@ export default {
filter() {
const filter = {}
filter.filter = this.element.filters
filter.linkageFilters = this.element.linkageFilters
return filter
},
filters() {
@ -91,6 +92,13 @@ export default {
if (!this.element.filters) return []
return JSON.parse(JSON.stringify(this.element.filters))
},
linkageFilters() {
// watch oldValuenewValue
if (!this.element.linkageFilters) return []
console.log('linkageFilters:' + JSON.stringify(this.element.linkageFilters))
return JSON.parse(JSON.stringify(this.element.linkageFilters))
},
...mapState([
'canvasStyleData'
])
@ -101,6 +109,13 @@ export default {
// this.getData(this.element.propValue.viewId)
isChange(val1, val2) && this.getData(this.element.propValue.viewId)
},
linkageFilters: {
handler(newVal, oldVal) {
debugger
isChange(newVal, oldVal) && this.getData(this.element.propValue.viewId)
},
deep: true
},
// deeppanel store
canvasStyleData: {
handler(newVal, oldVla) {

View File

@ -41,7 +41,6 @@ export default {
data.id = generateID()
// 如果是用户视图 测先进行底层复制
debugger
if (data.type === 'view') {
chartCopy(data.propValue.viewId).then(res => {
const newView = deepCopy(data)

View File

@ -0,0 +1 @@
<svg t="1628490858856" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2380" width="200" height="200"><path d="M64 128h512v448H64z m0 512h512v256H64z m576-192h320v448H640z m0-320h320v256H640z" p-id="2381"></path></svg>

After

Width:  |  Height:  |  Size: 263 B

View File

@ -337,7 +337,8 @@ export default {
confirm: 'Confirm',
ok: 'Confirm',
cancel: 'Cancel'
}
},
ukey_title: 'API Keys'
},
documentation: {
documentation: 'Documentation',
@ -831,7 +832,15 @@ export default {
axis_label_rotate: 'Label Rotate',
chart_scatter_bubble: 'Bubble',
chart_scatter: 'Scatter',
bubble_size: 'Bubble Size'
bubble_size: 'Bubble Size',
chart_treemap: 'Tree Map',
drill: 'Drill',
drag_block_treemap_label: 'Color Label',
drag_block_treemap_size: 'Color Size',
bubble_symbol: 'Shape',
gap_width: 'Gap Width',
width: 'Width',
height: 'Height'
},
dataset: {
sheet_warn: 'There are multiple sheet pages, and the first one is extracted by default',

View File

@ -337,7 +337,8 @@ export default {
confirm: '確認',
ok: '確認',
cancel: '取消'
}
},
ukey_title: 'API Keys'
},
documentation: {
documentation: '文檔',
@ -831,7 +832,15 @@ export default {
axis_label_rotate: '標簽角度',
chart_scatter_bubble: '氣泡圖',
chart_scatter: '散點圖',
bubble_size: '氣泡大小'
bubble_size: '氣泡大小',
chart_treemap: '矩形樹圖',
drill: '鉆取',
drag_block_treemap_label: '色塊標簽',
drag_block_treemap_size: '色塊大小',
bubble_symbol: '圖形',
gap_width: '間隔',
width: '寬度',
height: '高度'
},
dataset: {
sheet_warn: '有多個sheet頁面默認抽取第一個',

View File

@ -337,7 +337,8 @@ export default {
confirm: '确认',
ok: '确认',
cancel: '取消'
}
},
ukey_title: 'API Keys'
},
documentation: {
documentation: '文档',
@ -831,7 +832,15 @@ export default {
axis_label_rotate: '标签角度',
chart_scatter_bubble: '气泡图',
chart_scatter: '散点图',
bubble_size: '气泡大小'
bubble_size: '气泡大小',
chart_treemap: '矩形树图',
drill: '钻取',
drag_block_treemap_label: '色块标签',
drag_block_treemap_size: '色块大小',
bubble_symbol: '图形',
gap_width: '间隔',
width: '宽度',
height: '高度'
},
dataset: {
sheet_warn: '有多个 Sheet 页,默认抽取第一个',

View File

@ -53,6 +53,11 @@
<router-link to="/person-info/index">
<el-dropdown-item>{{ $t('commons.personal_info') }}</el-dropdown-item>
</router-link>
<router-link v-if="$store.getters.validate" to="/ukey/index">
<el-dropdown-item>{{ $t('commons.ukey_title') }}</el-dropdown-item>
</router-link>
<router-link to="/person-pwd/index">
<el-dropdown-item>{{ $t('user.change_password') }}</el-dropdown-item>
</router-link>

View File

@ -21,7 +21,9 @@ import event from '@/components/canvas/store/event'
import layer from '@/components/canvas/store/layer'
import snapshot from '@/components/canvas/store/snapshot'
import lock from '@/components/canvas/store/lock'
import { valueValid, formatCondition } from '@/utils/conditionUtil'
import { valueValid, formatCondition, formatLinkageCondition } from '@/utils/conditionUtil'
import { Condition } from '@/components/widget/bean/Condition'
import {
DEFAULT_COMMON_CANVAS_STYLE_STRING
} from '@/views/panel/panel'
@ -54,7 +56,9 @@ const data = {
// 当前设置联动的组件
curLinkageView: null,
// 和当前组件联动的目标组件
targetLinkageInfo: []
targetLinkageInfo: [],
// 当前仪表板联动 下钻 上卷等信息
nowPanelTrackInfo: {}
},
mutations: {
...animation.mutations,
@ -154,6 +158,47 @@ const data = {
state.componentData[index] = element
}
},
// 添加联动 下钻 等过滤组件
addViewTrackFilter(state, data) {
console.log('联动信息', JSON.stringify(data))
const viewId = data.viewId
const trackInfo = state.nowPanelTrackInfo
for (let index = 0; index < state.componentData.length; index++) {
const element = state.componentData[index]
if (!element.type || element.type !== 'view') continue
const currentFilters = element.linkageFilters || [] // 当前联动filter
data.dimensionList.forEach(dimension => {
const sourceInfo = viewId + '#' + dimension.id
// 获取所有目标联动信息
const targetInfoList = trackInfo[sourceInfo] || []
targetInfoList.forEach(targetInfo => {
const targetInfoArray = targetInfo.split('#')
const targetViewId = targetInfoArray[0] // 目标视图
if (element.propValue.viewId === targetViewId) { // 如果目标视图 和 当前循环组件id相等 则进行条件增减
const targetFieldId = targetInfoArray[1] // 目标视图列ID
const condition = new Condition('', targetFieldId, 'eq', [dimension.value], [targetViewId])
let j = currentFilters.length
while (j--) {
const filter = currentFilters[j]
// 兼容性准备 viewIds 只会存放一个值
if (targetFieldId === filter.fieldId && filter.viewIds.includes(targetViewId)) {
currentFilters.splice(j, 1)
}
}
// 不存在该条件 且 条件有效 直接保存该条件
// !filterExist && vValid && currentFilters.push(condition)
currentFilters.push(condition)
}
})
})
element.linkageFilters = currentFilters
state.componentData[index] = element
}
},
setComponentWithId(state, component) {
for (let index = 0; index < state.componentData.length; index++) {
const element = state.componentData[index]
@ -189,6 +234,9 @@ const data = {
state.linkageSettingStatus = false
state.curLinkageView = null
state.targetLinkageInfo = []
},
setNowPanelTrackInfo(state, trackInfo) {
state.nowPanelTrackInfo = trackInfo
}
},
modules: {

View File

@ -30,3 +30,9 @@ export const formatCondition = obj => {
const condition = new Condition(component.id, fieldId, operator, value, viewIds)
return condition
}
export const formatLinkageCondition = obj => {
const { viewIds, fieldId, value, operator } = obj
const condition = new Condition(null, fieldId, operator, value, viewIds)
return condition
}

View File

@ -39,7 +39,9 @@ export const DEFAULT_SIZE = {
dimensionShow: true,
quotaShow: true,
scatterSymbol: 'circle',
scatterSymbolSize: 20
scatterSymbolSize: 20,
treemapWidth: 80,
treemapHeight: 80
}
export const DEFAULT_LABEL = {
show: false,
@ -689,3 +691,39 @@ export const BASE_SCATTER = {
}
]
}
export const BASE_TREEMAP = {
title: {
text: '',
textStyle: {
fontWeight: 'normal'
}
},
grid: {
containLabel: true
},
tooltip: {},
legend: {
show: true,
type: 'scroll',
itemWidth: 10,
itemHeight: 10,
icon: 'rect'
},
series: [
{
// name: '',
type: 'treemap',
// radius: ['0%', '60%'],
// avoidLabelOverlap: false,
// emphasis: {
// itemStyle: {
// shadowBlur: 10,
// shadowOffsetX: 0,
// shadowColor: 'rgba(0, 0, 0, 0.5)'
// }
// },
data: []
}
]
}

View File

@ -31,8 +31,6 @@ export function baseFunnelOption(chart_option, chart) {
chart_option.series[0].label = customAttr.label
}
const valueArr = chart.data.series[0].data
// max value
chart_option.series[0].max = Math.max.apply(Math, valueArr)
for (let i = 0; i < valueArr.length; i++) {
// const y = {
// name: chart.data.x[i],
@ -44,7 +42,7 @@ export function baseFunnelOption(chart_option, chart) {
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
}
y.type = 'funnel'
// y.type = 'funnel'
chart_option.series[0].data.push(y)
}
}

View File

@ -0,0 +1,54 @@
import { hexColorToRGBA } from '@/views/chart/chart/util'
import { componentStyle } from '../common/common'
export function baseTreemapOption(chart_option, chart) {
// 处理shape attr
let customAttr = {}
if (chart.customAttr) {
customAttr = JSON.parse(chart.customAttr)
if (customAttr.color) {
chart_option.color = customAttr.color.colors
}
// tooltip
if (customAttr.tooltip) {
const tooltip = JSON.parse(JSON.stringify(customAttr.tooltip))
const reg = new RegExp('\n', 'g')
tooltip.formatter = tooltip.formatter.replace(reg, '<br/>')
chart_option.tooltip = tooltip
}
}
// 处理data
if (chart.data) {
chart_option.title.text = chart.title
if (chart.data.series.length > 0) {
// chart_option.series[0].name = chart.data.series[0].name
// size
if (customAttr.size) {
chart_option.series[0].width = (customAttr.size.treemapWidth ? customAttr.size.treemapWidth : 80) + '%'
chart_option.series[0].height = (customAttr.size.treemapHeight ? customAttr.size.treemapHeight : 80) + '%'
}
// label
// if (customAttr.label) {
// chart_option.series[0].label = customAttr.label
// }
const valueArr = chart.data.series[0].data
for (let i = 0; i < valueArr.length; i++) {
// const y = {
// name: chart.data.x[i],
// value: valueArr[i]
// }
const y = valueArr[i]
y.name = chart.data.x[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
}
// y.type = 'treemap'
chart_option.series[0].data.push(y)
}
}
}
// console.log(chart_option);
componentStyle(chart_option, chart)
return chart_option
}

View File

@ -5,7 +5,7 @@
</template>
<script>
import { BASE_BAR, BASE_LINE, HORIZONTAL_BAR, BASE_PIE, BASE_FUNNEL, BASE_RADAR, BASE_GAUGE, BASE_MAP, BASE_SCATTER } from '../chart/chart'
import { BASE_BAR, BASE_LINE, HORIZONTAL_BAR, BASE_PIE, BASE_FUNNEL, BASE_RADAR, BASE_GAUGE, BASE_MAP, BASE_SCATTER, BASE_TREEMAP } from '../chart/chart'
import { baseBarOption, stackBarOption, horizontalBarOption, horizontalStackBarOption } from '../chart/bar/bar'
import { baseLineOption, stackLineOption } from '../chart/line/line'
import { basePieOption, rosePieOption } from '../chart/pie/pie'
@ -14,6 +14,7 @@ import { baseFunnelOption } from '../chart/funnel/funnel'
import { baseRadarOption } from '../chart/radar/radar'
import { baseGaugeOption } from '../chart/gauge/gauge'
import { baseScatterOption } from '../chart/scatter/scatter'
import { baseTreemapOption } from '../chart/treemap/treemap'
// import eventBus from '@/components/canvas/utils/eventBus'
import { uuid } from 'vue-uuid'
import { geoJson } from '@/api/map/map'
@ -59,8 +60,11 @@ export default {
},
methods: {
preDraw() {
const viewId = this.chart.id
const _store = this.$store
// domecharts
// echartdom,idechart id
const that = this
new Promise((resolve) => { resolve() }).then(() => {
// domechartsdom
this.myChart = this.$echarts.getInstanceByDom(document.getElementById(this.chartId))
@ -68,6 +72,19 @@ export default {
this.myChart = this.$echarts.init(document.getElementById(this.chartId))
}
this.drawEcharts()
this.myChart.off('click')
this.myChart.on('click', function(param) {
console.log(JSON.stringify(param.data))
const trackFilter = {
viewId: viewId,
dimensionList: param.data.dimensionList,
quotaList: param.data.quotaList
}
_store.commit('addViewTrackFilter', trackFilter)
that.$emit('onChartClick', param)
})
})
},
drawEcharts() {
@ -98,6 +115,8 @@ export default {
chart_option = baseGaugeOption(JSON.parse(JSON.stringify(BASE_GAUGE)), chart)
} else if (chart.type === 'scatter') {
chart_option = baseScatterOption(JSON.parse(JSON.stringify(BASE_SCATTER)), chart)
} else if (chart.type === 'treemap') {
chart_option = baseTreemapOption(JSON.parse(JSON.stringify(BASE_TREEMAP)), chart)
}
if (chart.type === 'map') {

View File

@ -137,7 +137,7 @@
</el-form>
<el-form v-show="chart.type && chart.type.includes('scatter')" ref="sizeFormLine" :disabled="param && !hasDataPermission('manage',param.privileges)" :model="sizeForm" label-width="80px" size="mini">
<el-form-item :label="$t('chart.line_symbol')" class="form-item">
<el-form-item :label="$t('chart.bubble_symbol')" class="form-item">
<el-select v-model="sizeForm.scatterSymbol" :placeholder="$t('chart.line_symbol')" @change="changeBarSizeCase">
<el-option
v-for="item in lineSymbolOptions"
@ -147,8 +147,17 @@
/>
</el-select>
</el-form-item>
<el-form-item :label="$t('chart.line_symbol_size')" class="form-item form-item-slider">
<el-slider v-model="sizeForm.scatterSymbolSize" show-input :show-input-controls="false" input-size="mini" :min="0" :max="20" @change="changeBarSizeCase" />
<el-form-item :label="$t('chart.bubble_size')" class="form-item form-item-slider">
<el-slider v-model="sizeForm.scatterSymbolSize" show-input :show-input-controls="false" input-size="mini" :min="1" :max="20" @change="changeBarSizeCase" />
</el-form-item>
</el-form>
<el-form v-show="chart.type && chart.type === 'treemap'" ref="sizeFormLine" :disabled="param && !hasDataPermission('manage',param.privileges)" :model="sizeForm" label-width="80px" size="mini">
<el-form-item :label="$t('chart.width')" class="form-item form-item-slider">
<el-slider v-model="sizeForm.treemapWidth" show-input :show-input-controls="false" input-size="mini" :min="0" :max="100" @change="changeBarSizeCase" />
</el-form-item>
<el-form-item :label="$t('chart.height')" class="form-item form-item-slider">
<el-slider v-model="sizeForm.treemapHeight" show-input :show-input-controls="false" input-size="mini" :min="0" :max="100" @change="changeBarSizeCase" />
</el-form-item>
</el-form>
</el-col>
@ -353,6 +362,8 @@ export default {
}
if (customAttr.size) {
this.sizeForm = customAttr.size
this.sizeForm.treemapWidth = this.sizeForm.treemapWidth ? this.sizeForm.treemapWidth : 80
this.sizeForm.treemapHeight = this.sizeForm.treemapHeight ? this.sizeForm.treemapHeight : 80
}
}
},

View File

@ -163,23 +163,18 @@
<svg-icon icon-class="line-stack" class="chart-icon" />
</span>
</el-radio>
<el-radio value="pie" label="pie">
<span :title="$t('chart.chart_pie')">
<svg-icon icon-class="pie" class="chart-icon" />
<el-radio value="scatter" label="scatter">
<span :title="$t('chart.chart_scatter')">
<svg-icon icon-class="scatter" class="chart-icon" />
</span>
</el-radio>
<el-radio value="pie-rose" label="pie-rose">
<span :title="$t('chart.chart_pie_rose')">
<svg-icon icon-class="pie-rose" class="chart-icon" />
<el-radio value="map" label="map">
<span :title="$t('chart.chart_map')">
<svg-icon icon-class="map" class="chart-icon" />
</span>
</el-radio>
</div>
<div style="width: 100%;display: flex;display: -webkit-flex;justify-content: space-between;flex-direction: row;flex-wrap: wrap;">
<el-radio value="funnel" label="funnel">
<span :title="$t('chart.chart_funnel')">
<svg-icon icon-class="funnel" class="chart-icon" />
</span>
</el-radio>
<el-radio value="radar" label="radar">
<span :title="$t('chart.chart_radar')">
<svg-icon icon-class="radar" class="chart-icon" />
@ -190,19 +185,28 @@
<svg-icon icon-class="gauge" class="chart-icon" />
</span>
</el-radio>
<el-radio value="map" label="map">
<span :title="$t('chart.chart_map')">
<svg-icon icon-class="map" class="chart-icon" />
<el-radio value="pie" label="pie">
<span :title="$t('chart.chart_pie')">
<svg-icon icon-class="pie" class="chart-icon" />
</span>
</el-radio>
<el-radio value="scatter" label="scatter">
<span :title="$t('chart.chart_scatter')">
<svg-icon icon-class="scatter" class="chart-icon" />
<el-radio value="pie-rose" label="pie-rose">
<span :title="$t('chart.chart_pie_rose')">
<svg-icon icon-class="pie-rose" class="chart-icon" />
</span>
</el-radio>
<el-radio value="funnel" label="funnel">
<span :title="$t('chart.chart_funnel')">
<svg-icon icon-class="funnel" class="chart-icon" />
</span>
</el-radio>
</div>
<div style="width: 100%;display: flex;display: -webkit-flex;justify-content: space-between;flex-direction: row;flex-wrap: wrap;">
<el-radio value="" label="" disabled class="disabled-none-cursor"><svg-icon icon-class="" class="chart-icon" /></el-radio>
<el-radio value="treemap" label="treemap">
<span :title="$t('chart.chart_treemap')">
<svg-icon icon-class="treemap" class="chart-icon" />
</span>
</el-radio>
<el-radio value="" label="" disabled class="disabled-none-cursor"><svg-icon icon-class="" class="chart-icon" /></el-radio>
<el-radio value="" label="" disabled class="disabled-none-cursor"><svg-icon icon-class="" class="chart-icon" /></el-radio>
<el-radio value="" label="" disabled class="disabled-none-cursor"><svg-icon icon-class="" class="chart-icon" /></el-radio>
@ -213,7 +217,7 @@
</el-row>
<el-row style="color: #909399;">
<span>
<span v-show="chart.type && (chart.type.includes('pie') || chart.type.includes('funnel') || chart.type.includes('text') || chart.type.includes('gauge'))">
<span v-show="chart.type && (chart.type.includes('pie') || chart.type.includes('funnel') || chart.type.includes('text') || chart.type.includes('gauge') || chart.type.includes('treemap'))">
Tips: {{ $t('chart.only_one_quota') }}
</span>
<!-- <span v-show="chart.type && (chart.type.includes('text'))">-->
@ -245,7 +249,7 @@
</el-row>
<el-row class="padding-lr">
<span style="width: 80px;text-align: right;">
<span>钻取</span>
<span>{{ $t('chart.drill') }}</span>
/
<span>{{ $t('chart.dimension') }}</span>
</span>
@ -274,7 +278,8 @@
<span v-else-if="view.type && view.type.includes('pie')">{{ $t('chart.drag_block_pie_label') }}</span>
<span v-else-if="view.type && view.type.includes('funnel')">{{ $t('chart.drag_block_funnel_split') }}</span>
<span v-else-if="view.type && view.type.includes('radar')">{{ $t('chart.drag_block_radar_label') }}</span>
<span v-else-if="view.type && view.type.includes('map')">{{ $t('chart.area') }}</span>
<span v-else-if="view.type && view.type === 'map'">{{ $t('chart.area') }}</span>
<span v-else-if="view.type && view.type.includes('treemap')">{{ $t('chart.drag_block_treemap_label') }}</span>
/
<span>{{ $t('chart.dimension') }}</span>
</span>
@ -305,7 +310,8 @@
<span v-else-if="view.type && view.type.includes('radar')">{{ $t('chart.drag_block_radar_length') }}</span>
<span v-else-if="view.type && view.type.includes('gauge')">{{ $t('chart.drag_block_gauge_angel') }}</span>
<span v-else-if="view.type && view.type.includes('text')">{{ $t('chart.drag_block_label_value') }}</span>
<span v-else-if="view.type && view.type.includes('map')">{{ $t('chart.chart_data') }}</span>
<span v-else-if="view.type && view.type === 'map'">{{ $t('chart.chart_data') }}</span>
<span v-else-if="view.type && view.type.includes('tree')">{{ $t('chart.drag_block_treemap_size') }}</span>
/
<span>{{ $t('chart.quota') }}</span>
</span>
@ -424,7 +430,7 @@
<el-collapse-item v-show="chart.type !== 'map'" name="size" :title="$t('chart.size')">
<size-selector :param="param" class="attr-selector" :chart="chart" @onSizeChange="onSizeChange" />
</el-collapse-item>
<el-collapse-item v-show="!view.type.includes('table') && !view.type.includes('text')" name="label" :title="$t('chart.label')">
<el-collapse-item v-show="!view.type.includes('table') && !view.type.includes('text') && view.type !== 'treemap'" name="label" :title="$t('chart.label')">
<label-selector :param="param" class="attr-selector" :chart="chart" @onLabelChange="onLabelChange" />
</el-collapse-item>
<el-collapse-item v-show="!view.type.includes('table') && !view.type.includes('text')" name="tooltip" :title="$t('chart.tooltip')">
@ -453,7 +459,7 @@
<el-collapse-item name="title" :title="$t('chart.title')">
<title-selector :param="param" class="attr-selector" :chart="chart" @onTextChange="onTextChange" />
</el-collapse-item>
<el-collapse-item v-show="view.type && !view.type.includes('map') && !view.type.includes('table') && !view.type.includes('text')" name="legend" :title="$t('chart.legend')">
<el-collapse-item v-show="view.type && view.type !== 'map' && !view.type.includes('table') && !view.type.includes('text') && chart.type !== 'treemap'" name="legend" :title="$t('chart.legend')">
<legend-selector :param="param" class="attr-selector" :chart="chart" @onLegendChange="onLegendChange" />
</el-collapse-item>
<el-collapse-item name="background" :title="$t('chart.background')">
@ -477,7 +483,7 @@
<el-col style="height: 100%;min-width: 500px;border-top: 1px solid #E6E6E6;">
<el-row style="width: 100%;height: 100%;" class="padding-lr">
<div ref="imageWrapper" style="height: 100%">
<chart-component v-if="httpRequest.status && chart.type && !chart.type.includes('table') && !chart.type.includes('text')" :chart-id="chart.id" :chart="chart" class="chart-class" />
<chart-component v-if="httpRequest.status && chart.type && !chart.type.includes('table') && !chart.type.includes('text')" :chart-id="chart.id" :chart="chart" class="chart-class" @onChartClick="chartClick" />
<table-normal v-if="httpRequest.status && chart.type && chart.type.includes('table')" :chart="chart" class="table-class" />
<label-normal v-if="httpRequest.status && chart.type && chart.type.includes('text')" :chart="chart" class="table-class" />
<div v-if="!httpRequest.status" class="chart-error-class">
@ -732,7 +738,8 @@ export default {
filterItem: {},
places: [],
attrActiveNames: [],
styleActiveNames: []
styleActiveNames: [],
drillClickDimensionList: []
}
},
computed: {
@ -744,6 +751,7 @@ export default {
},
watch: {
'param': function() {
this.resetDrill()
if (this.param.optType === 'new') {
//
} else {
@ -853,7 +861,11 @@ export default {
}
}
})
if (view.type.startsWith('pie') || view.type.startsWith('funnel') || view.type.startsWith('text') || view.type.startsWith('gauge')) {
if (view.type.startsWith('pie') ||
view.type.startsWith('funnel') ||
view.type.startsWith('text') ||
view.type.startsWith('gauge') ||
view.type === 'treemap') {
if (view.yaxis.length > 1) {
view.yaxis.splice(1, view.yaxis.length)
}
@ -864,6 +876,9 @@ export default {
if (view.type === 'line-stack' && trigger === 'chart') {
view.customAttr.size.lineArea = true
}
if (view.type === 'treemap' && trigger === 'chart') {
view.customAttr.label.show = true
}
view.customFilter.forEach(function(ele) {
if (ele && !ele.filter) {
ele.filter = []
@ -881,6 +896,7 @@ export default {
// this.get(response.data.id);
// this.getData(response.data.id)
this.resetDrill()
if (getData) {
this.getData(response.data.id)
} else {
@ -970,7 +986,8 @@ export default {
getData(id) {
if (id) {
ajaxGetData(id, {
filter: []
filter: [],
drill: this.drillClickDimensionList
}).then(response => {
this.initTableData(response.data.tableId)
this.view = JSON.parse(JSON.stringify(response.data))
@ -990,8 +1007,12 @@ export default {
if (this.chart.privileges) {
this.param.privileges = this.chart.privileges
}
if (!response.data.drill) {
this.drillClickDimensionList.splice(this.drillClickDimensionList.length - 1, 1)
}
}).catch(err => {
this.resetView()
this.resetDrill()
this.httpRequest.status = err.response.data.success
this.httpRequest.msg = err.response.data.message
this.$nextTick(() => {
@ -1474,6 +1495,16 @@ export default {
bubbleItemRemove(item) {
this.view.extBubble.splice(item.index, 1)
this.save(true)
},
chartClick(param) {
console.log(param)
this.drillClickDimensionList.push({ dimensionList: param.data.dimensionList })
this.getData(this.param.id)
},
resetDrill() {
this.drillClickDimensionList = []
}
}
}

View File

@ -192,6 +192,7 @@ import { mapState } from 'vuex'
import { uuid } from 'vue-uuid'
import Toolbar from '@/components/canvas/components/Toolbar'
import { findOne } from '@/api/panel/panel'
import { getPanelAllLinkageInfo } from '@/api/panel/linkage'
import PreviewFullScreen from '@/components/canvas/components/Editor/PreviewFullScreen'
import Preview from '@/components/canvas/components/Editor/Preview'
import AttrList from '@/components/canvas/components/AttrList'
@ -363,6 +364,7 @@ export default {
const componentDatas = JSON.parse(componentDataTemp)
componentDatas.forEach(item => {
item.filters = (item.filters || [])
item.linkageFilters = (item.linkageFilters || [])
})
this.$store.commit('setComponentData', this.resetID(componentDatas))
// this.$store.commit('setComponentData', this.resetID(JSON.parse(componentDataTemp)))
@ -375,12 +377,17 @@ export default {
const componentDatas = JSON.parse(response.data.panelData)
componentDatas.forEach(item => {
item.filters = (item.filters || [])
item.linkageFilters = (item.linkageFilters || [])
})
this.$store.commit('setComponentData', this.resetID(componentDatas))
// this.$store.commit('setComponentData', this.resetID(JSON.parse(response.data.panelData)))
const panelStyle = JSON.parse(response.data.panelStyle)
this.$store.commit('setCanvasStyle', panelStyle)
this.$store.commit('recordSnapshot')//
//
getPanelAllLinkageInfo(panelId).then(rsp => {
this.$store.commit('setNowPanelTrackInfo', rsp.data)
})
})
}
},
@ -463,6 +470,7 @@ export default {
}
component.propValue = propValue
component.filters = []
component.linkageFilters = []
}
})
} else {
@ -660,6 +668,7 @@ export default {
}
component.propValue = propValue
component.filters = []
component.linkageFilters = []
}
})

View File

@ -134,7 +134,6 @@ export default {
return false
}
debugger
if (this.editPanel.panelInfo.name.length > 50) {
this.$warning(this.$t('commons.char_can_not_more_50'))
return false

View File

@ -177,6 +177,8 @@ import { uuid } from 'vue-uuid'
import bus from '@/utils/bus'
import EditPanel from './EditPanel'
import { addGroup, delGroup, groupTree, defaultTree, findOne } from '@/api/panel/panel'
import { getPanelAllLinkageInfo } from '@/api/panel/linkage'
import { mapState } from 'vuex'
import {
DEFAULT_COMMON_CANVAS_STYLE_STRING
} from '@/views/panel/panel'
@ -274,7 +276,10 @@ export default {
computed: {
panelDialogTitle() {
return this.editPanel.titlePre + this.editPanel.titleSuf
}
},
...mapState([
'nowPanelTrackInfo'
])
},
watch: {
//
@ -517,12 +522,18 @@ export default {
const componentDatas = JSON.parse(response.data.panelData)
componentDatas.forEach(item => {
item.filters = (item.filters || [])
item.linkageFilters = (item.linkageFilters || [])
})
this.$store.commit('setComponentData', this.resetID(componentDatas))
// this.$store.commit('setComponentData', sourceInfo.type === 'custom' ? sourceInfo : this.resetID(sourceInfo))
const temp = JSON.parse(response.data.panelStyle)
this.$store.commit('setCanvasStyle', temp)
this.$store.dispatch('panel/setPanelInfo', data)
//
getPanelAllLinkageInfo(data.id).then(rsp => {
this.$store.commit('setNowPanelTrackInfo', rsp.data)
})
})
}
if (node.expanded) {