mirror of
https://github.com/dataease/dataease.git
synced 2026-06-18 05:18:07 +08:00
feat: 设置 Excel 字段长度
This commit is contained in:
@@ -31,7 +31,4 @@ public interface AuthApi {
|
||||
@PostMapping("/validateName")
|
||||
Boolean validateName(Map<String, String> nameDto);
|
||||
|
||||
|
||||
@GetMapping("/test")
|
||||
String test();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ public class DynamicMenuDto implements Serializable {
|
||||
|
||||
private Integer type;
|
||||
|
||||
private Integer menuSort;
|
||||
|
||||
private Boolean isPlugin;
|
||||
|
||||
private Boolean noLayout;
|
||||
|
||||
@@ -19,7 +19,6 @@ import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -13,8 +13,6 @@ public class TokenInfo implements Serializable {
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long lastLoginTime;
|
||||
|
||||
public String format(){
|
||||
return username + "," +userId;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.i18n.Translator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
@@ -28,9 +29,6 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
|
||||
|
||||
public final static String expireMessage = "Login token is expire.";
|
||||
|
||||
/*@Autowired
|
||||
private AuthUserService authUserService;*/
|
||||
|
||||
|
||||
/**
|
||||
* 判断用户是否想要登入。
|
||||
@@ -52,22 +50,15 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
|
||||
String authorization = httpServletRequest.getHeader("Authorization");
|
||||
// 当没有出现登录超时 且需要刷新token 则执行刷新token
|
||||
if (JWTUtils.loginExpire(authorization)){
|
||||
throw new AuthenticationException(expireMessage);
|
||||
throw new AuthenticationException(expireMessage);
|
||||
}
|
||||
if (JWTUtils.needRefresh(authorization)){
|
||||
String oldAuthorization = authorization;
|
||||
authorization = refreshToken(request, response);
|
||||
JWTUtils.removeTokenExpire(oldAuthorization);
|
||||
}
|
||||
// 删除老的操作时间
|
||||
JWTUtils.removeTokenExpire(authorization);
|
||||
// 设置新的操作时间
|
||||
JWTUtils.addTokenExpire(authorization);
|
||||
JWTToken token = new JWTToken(authorization);
|
||||
Subject subject = getSubject(request, response);
|
||||
// 提交给realm进行登入,如果错误他会抛出异常并被捕获
|
||||
subject.login(token);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -82,10 +73,11 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
|
||||
boolean loginSuccess = executeLogin(request, response);
|
||||
return loginSuccess;
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
if (e instanceof AuthenticationException && StringUtils.equals(e.getMessage(), expireMessage)){
|
||||
responseExpire(request, response);
|
||||
responseExpire(request, response, e);
|
||||
}else {
|
||||
response401(request, response);
|
||||
tokenError(request, response, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,14 +99,8 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
|
||||
}
|
||||
String password = user.getPassword();
|
||||
|
||||
// 删除老token操作时间
|
||||
// JWTUtils.removeTokenExpire(token);
|
||||
String newToken = JWTUtils.sign(tokenInfo, password);
|
||||
// 记录新token操作时间
|
||||
JWTUtils.addTokenExpire(newToken);
|
||||
|
||||
JWTToken jwtToken = new JWTToken(newToken);
|
||||
this.getSubject(request, response).login(jwtToken);
|
||||
// 设置响应的Header头新Token
|
||||
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
|
||||
httpServletResponse.addHeader("Access-Control-Expose-Headers", "RefreshAuthorization");
|
||||
@@ -141,29 +127,17 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
|
||||
return super.preHandle(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将非法请求跳转到 /401
|
||||
*/
|
||||
private void response401(ServletRequest req, ServletResponse resp) {
|
||||
try {
|
||||
HttpServletResponse httpServletResponse = (HttpServletResponse) resp;
|
||||
httpServletResponse.addHeader("Access-Control-Expose-Headers", "authentication-status");
|
||||
httpServletResponse.setHeader("authentication-status", "invalid");
|
||||
httpServletResponse.setStatus(401);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(e.getMessage());
|
||||
}
|
||||
|
||||
private void tokenError(ServletRequest req, ServletResponse resp, Exception e1) {
|
||||
HttpServletResponse httpServletResponse = (HttpServletResponse) resp;
|
||||
httpServletResponse.addHeader("Access-Control-Expose-Headers", "authentication-status");
|
||||
httpServletResponse.setHeader("authentication-status", "invalid");
|
||||
}
|
||||
|
||||
private void responseExpire(ServletRequest req, ServletResponse resp) {
|
||||
try {
|
||||
HttpServletResponse httpServletResponse = (HttpServletResponse) resp;
|
||||
httpServletResponse.addHeader("Access-Control-Expose-Headers", "authentication-status");
|
||||
httpServletResponse.setHeader("authentication-status", "login_expire");
|
||||
httpServletResponse.setStatus(401);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(e.getMessage());
|
||||
}
|
||||
private void responseExpire(ServletRequest req, ServletResponse resp, Exception e1) {
|
||||
HttpServletResponse httpServletResponse = (HttpServletResponse) resp;
|
||||
httpServletResponse.addHeader("Access-Control-Expose-Headers", "authentication-status");
|
||||
httpServletResponse.setHeader("authentication-status", "login_expire");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,16 +14,14 @@ import io.dataease.commons.utils.BeanUtils;
|
||||
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.display.service.DisPlayXpackService;*/
|
||||
import io.dataease.i18n.Translator;
|
||||
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;
|
||||
@@ -41,11 +39,11 @@ public class AuthServer implements AuthApi {
|
||||
String password = loginDto.getPassword();
|
||||
SysUserEntity user = authUserService.getUserByName(username);
|
||||
|
||||
if (ObjectUtils.isEmpty(user)){
|
||||
throw new RuntimeException("没有该用户!");
|
||||
if (ObjectUtils.isEmpty(user)) {
|
||||
throw new RuntimeException(Translator.get("i18n_id_or_pwd_error"));
|
||||
}
|
||||
if (user.getEnabled()==0){
|
||||
throw new RuntimeException("用户已经失效!");
|
||||
if (user.getEnabled() == 0) {
|
||||
throw new RuntimeException(Translator.get("i18n_id_or_pwd_error"));
|
||||
}
|
||||
String realPwd = user.getPassword();
|
||||
//私钥解密
|
||||
@@ -53,14 +51,13 @@ public class AuthServer implements AuthApi {
|
||||
//md5加密
|
||||
pwd = CodingUtil.md5(pwd);
|
||||
|
||||
if (!StringUtils.equals(pwd, realPwd)){
|
||||
throw new RuntimeException("密码错误!");
|
||||
if (!StringUtils.equals(pwd, realPwd)) {
|
||||
throw new RuntimeException(Translator.get("i18n_id_or_pwd_error"));
|
||||
}
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(username).lastLoginTime(System.currentTimeMillis()).build();
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(username).build();
|
||||
String token = JWTUtils.sign(tokenInfo, realPwd);
|
||||
// 记录token操作时间
|
||||
JWTUtils.addTokenExpire(token);
|
||||
result.put("token", token);
|
||||
ServletUtils.setToken(token);
|
||||
return result;
|
||||
@@ -68,7 +65,7 @@ public class AuthServer implements AuthApi {
|
||||
|
||||
@Override
|
||||
public CurrentUserDto userInfo() {
|
||||
CurrentUserDto userDto = (CurrentUserDto)SecurityUtils.getSubject().getPrincipal();
|
||||
CurrentUserDto userDto = (CurrentUserDto) SecurityUtils.getSubject().getPrincipal();
|
||||
if (ObjectUtils.isEmpty(userDto)) {
|
||||
String token = ServletUtils.getToken();
|
||||
Long userId = JWTUtils.tokenInfoByToken(token).getUserId();
|
||||
@@ -84,7 +81,7 @@ public class AuthServer implements AuthApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String logout(){
|
||||
public String logout() {
|
||||
String token = ServletUtils.getToken();
|
||||
Long userId = JWTUtils.tokenInfoByToken(token).getUserId();
|
||||
authUserService.clearCache(userId);
|
||||
@@ -105,20 +102,5 @@ public class AuthServer implements AuthApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String test() {
|
||||
SysUserEntity userById = authUserService.getUserById(4L);
|
||||
String nickName = userById.getNickName();
|
||||
// System.out.println(nickName);
|
||||
/* Map<String, DisPlayXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType(DisPlayXpackService.class);
|
||||
for (Map.Entry entry : beansOfType.entrySet()) {
|
||||
Object key = entry.getKey();
|
||||
DisPlayXpackService value = (DisPlayXpackService)entry.getValue();
|
||||
List<SysSettingDto> sysSettingDtos = value.systemSettings();
|
||||
|
||||
String name = entry.getValue().getClass().getName();
|
||||
System.out.println("key: "+ key + ", value: "+ name);
|
||||
}*/
|
||||
return "apple";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.dataease.base.mapper.ext.AuthMapper;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.base.mapper.ext.ExtPluginSysMenuMapper;
|
||||
import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.plugins.common.dto.PluginSysMenu;
|
||||
import io.dataease.plugins.util.PluginUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -17,7 +18,6 @@ import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -99,7 +99,7 @@ public class AuthUserServiceImpl implements AuthUserService {
|
||||
})
|
||||
@Override
|
||||
public void clearCache(Long userId) {
|
||||
|
||||
LogUtil.info("正在清除用户缓存【{}】",userId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
public class DynamicMenuServiceImpl implements DynamicMenuService {
|
||||
@@ -35,6 +36,12 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
|
||||
List<DynamicMenuDto> pluginDtos = pluginSysMenus.stream().map(this::convert).collect(Collectors.toList());
|
||||
dynamicMenuDtos.addAll(pluginDtos);
|
||||
}
|
||||
dynamicMenuDtos = dynamicMenuDtos.stream().sorted((s1, s2) -> {
|
||||
int sortIndex1 = null == s1.getMenuSort() ? 999: s1.getMenuSort();
|
||||
int sortIndex2 = null == s2.getMenuSort() ? 999: s2.getMenuSort();
|
||||
return sortIndex1 - sortIndex2;
|
||||
}).collect(Collectors.toList());
|
||||
dynamicMenuDtos.sort((s1, s2) -> s1.getHidden().compareTo(s2.getHidden()));
|
||||
List<DynamicMenuDto> result = buildTree(dynamicMenuDtos);
|
||||
return result;
|
||||
}
|
||||
@@ -53,6 +60,7 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
|
||||
menuMeta.setIcon(sysMenu.getIcon());
|
||||
dynamicMenuDto.setMeta(menuMeta);
|
||||
dynamicMenuDto.setPermission(sysMenu.getPermission());
|
||||
dynamicMenuDto.setMenuSort(sysMenu.getMenuSort());
|
||||
dynamicMenuDto.setHidden(sysMenu.getHidden());
|
||||
dynamicMenuDto.setIsPlugin(false);
|
||||
return dynamicMenuDto;
|
||||
@@ -71,6 +79,7 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
|
||||
menuMeta.setIcon(sysMenu.getIcon());
|
||||
dynamicMenuDto.setMeta(menuMeta);
|
||||
dynamicMenuDto.setPermission(sysMenu.getPermission());
|
||||
dynamicMenuDto.setMenuSort(sysMenu.getMenuSort());
|
||||
dynamicMenuDto.setHidden(sysMenu.getHidden());
|
||||
dynamicMenuDto.setIsPlugin(true);
|
||||
dynamicMenuDto.setNoLayout(!!sysMenu.isNoLayout());
|
||||
|
||||
@@ -11,8 +11,7 @@ import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -24,7 +23,7 @@ public class JWTUtils {
|
||||
// token过期时间1min (过期会自动刷新续命 目的是避免一直都是同一个token )
|
||||
private static final long EXPIRE_TIME = 1*60*1000;
|
||||
// 登录间隔时间10min 超过这个时间强制重新登录
|
||||
private static long Login_Interval;
|
||||
private static long Login_Interval;
|
||||
|
||||
|
||||
|
||||
@@ -38,17 +37,10 @@ public class JWTUtils {
|
||||
public static boolean verify(String token, TokenInfo tokenInfo, String secret) {
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
JWTVerifier verifier = JWT.require(algorithm)
|
||||
.withClaim("lastLoginTime", tokenInfo.getLastLoginTime())
|
||||
.withClaim("username", tokenInfo.getUsername())
|
||||
.withClaim("userId", tokenInfo.getUserId())
|
||||
.build();
|
||||
verifier.verify(token);
|
||||
if (loginExpire(token)){
|
||||
// 登录超时
|
||||
throw new AuthenticationException(JWTFilter.expireMessage);
|
||||
// 前端拦截 登录超时状态 直接logout
|
||||
//return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -60,11 +52,10 @@ public class JWTUtils {
|
||||
DecodedJWT jwt = JWT.decode(token);
|
||||
String username = jwt.getClaim("username").asString();
|
||||
Long userId = jwt.getClaim("userId").asLong();
|
||||
Long lastLoginTime = jwt.getClaim("lastLoginTime").asLong();
|
||||
if (StringUtils.isEmpty(username) || ObjectUtils.isEmpty(userId) || ObjectUtils.isEmpty(lastLoginTime)){
|
||||
if (StringUtils.isEmpty(username) || ObjectUtils.isEmpty(userId) ){
|
||||
throw new RuntimeException("token格式错误!");
|
||||
}
|
||||
TokenInfo tokenInfo = TokenInfo.builder().username(username).userId(userId).lastLoginTime(lastLoginTime).build();
|
||||
TokenInfo tokenInfo = TokenInfo.builder().username(username).userId(userId).build();
|
||||
return tokenInfo;
|
||||
}
|
||||
|
||||
@@ -84,15 +75,15 @@ public class JWTUtils {
|
||||
*/
|
||||
public static boolean loginExpire(String token){
|
||||
if (Login_Interval==0) {
|
||||
// 默认超时时间是8h
|
||||
int minute = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout", Integer.class, 8*60);
|
||||
// 分钟换算成毫秒
|
||||
Login_Interval = minute * 1000 * 60;
|
||||
}
|
||||
Long now = System.currentTimeMillis();
|
||||
Long lastOperateTime = tokenLastOperateTime(token);
|
||||
if (ObjectUtils.isEmpty(lastOperateTime)) return true;
|
||||
boolean isExpire = false;
|
||||
boolean isExpire = true;
|
||||
if (lastOperateTime != null) {
|
||||
Long now = System.currentTimeMillis();
|
||||
isExpire = now - lastOperateTime > Login_Interval;
|
||||
}
|
||||
return isExpire;
|
||||
@@ -109,7 +100,7 @@ public class JWTUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成签名,1min后过期
|
||||
* 生成签名,5min后过期
|
||||
* @param tokenInfo 用户信息
|
||||
* @param secret 用户的密码
|
||||
* @return 加密的token
|
||||
@@ -120,10 +111,8 @@ public class JWTUtils {
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
// 附带username信息
|
||||
return JWT.create()
|
||||
.withClaim("lastLoginTime", tokenInfo.getLastLoginTime())
|
||||
.withClaim("username", tokenInfo.getUsername())
|
||||
.withClaim("userId", tokenInfo.getUserId())
|
||||
.withClaim("exp", date)
|
||||
.withExpiresAt(date)
|
||||
.sign(algorithm);
|
||||
} catch (Exception e) {
|
||||
@@ -155,26 +144,9 @@ public class JWTUtils {
|
||||
* @return
|
||||
*/
|
||||
public static Long tokenLastOperateTime(String token){
|
||||
CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class);
|
||||
Cache tokens_expire = cacheManager.getCache("tokens_expire");
|
||||
Long expTime = tokens_expire.get(token, Long.class);
|
||||
// System.out.println("get-------"+token+" :"+expTime);
|
||||
return expTime;
|
||||
}
|
||||
|
||||
public static void removeTokenExpire(String token){
|
||||
// System.out.println("remove----"+token);
|
||||
CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class);
|
||||
Cache tokens_expire = cacheManager.getCache("tokens_expire");
|
||||
tokens_expire.evict(token);
|
||||
}
|
||||
|
||||
public static void addTokenExpire(String token){
|
||||
CacheManager cacheManager = CommonBeanFactory.getBean(CacheManager.class);
|
||||
Cache tokens_expire = cacheManager.getCache("tokens_expire");
|
||||
long now = System.currentTimeMillis();
|
||||
// System.out.println("add-------"+token+" :"+now);
|
||||
tokens_expire.put(token, now);
|
||||
DecodedJWT jwt = JWT.decode(token);
|
||||
Date expiresAt = jwt.getExpiresAt();
|
||||
return expiresAt.getTime();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,6 +64,9 @@
|
||||
<if test="sort != null">
|
||||
order by ${sort}
|
||||
</if>
|
||||
<if test="sort == null">
|
||||
order by panel_group.create_time desc
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<delete id="deleteCircle">
|
||||
|
||||
@@ -83,6 +83,9 @@
|
||||
<if test="sort != null">
|
||||
order by ${sort}
|
||||
</if>
|
||||
<if test="sort == null">
|
||||
order by panel_template.create_time desc
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<delete id="deleteCircle">
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package io.dataease.base.mapper.ext;
|
||||
|
||||
import io.dataease.dto.panel.PanelViewDto;
|
||||
import io.dataease.dto.panel.po.PanelViewPo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtPanelViewMapper {
|
||||
|
||||
List<PanelViewPo> groups(String userId);
|
||||
List<PanelViewDto> groups(String userId);
|
||||
|
||||
List<PanelViewPo> views(String userId);
|
||||
List<PanelViewDto> views(String userId);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="io.dataease.base.mapper.ext.ExtPanelViewMapper">
|
||||
|
||||
<resultMap id="treeNodeMap" type="io.dataease.dto.panel.po.PanelViewPo">
|
||||
<resultMap id="treeNodeMap" type="io.dataease.dto.panel.PanelViewDto">
|
||||
<id column="id" property="id" />
|
||||
<result column="name" property="name" />
|
||||
<result column="pid" property="pid" />
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
<select id="groups" resultMap="treeNodeMap">
|
||||
select id, pid, name, `type`
|
||||
select id, ifnull(pid,0) as pid, name, `type`
|
||||
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'chart') cids) t,chart_group
|
||||
<where>
|
||||
FIND_IN_SET(chart_group.id,cids)
|
||||
|
||||
@@ -8,18 +8,30 @@
|
||||
<result column="leaf" property="leaf"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 函数嵌套会导致循环调用函数 导致查询速度变慢 所有预先经需要嵌套查询的函数分解查询-->
|
||||
<select id="searchTree" resultMap="BaseResultMapDTO">
|
||||
SELECT
|
||||
auth.*,
|
||||
authCount.children_count AS children_count,
|
||||
IF
|
||||
(( authCount.children_count > 0 ), 0, 1 ) AS leaf
|
||||
FROM (select get_grant_auths (#{modelType},#{createBy}) cids1) t1,
|
||||
( SELECT * FROM (select get_grant_auths (#{modelType},#{createBy}) cids2) t2 ,v_auth_model
|
||||
FROM (select get_grant_auths (#{modelType},#{createBy}) c_auth_ids) t1,
|
||||
( SELECT * FROM (select GET_V_AUTH_MODEL_WITH_PARENT(get_grant_auths (#{modelType},#{createBy}),#{modelType}) c_auth_parent_ids) t2,
|
||||
<if test="withExtend == 'parent' and id != null">
|
||||
(select GET_V_AUTH_MODEL_WITH_PARENT(#{id},#{modelType}) c_model_parent_ids) tmp,
|
||||
</if>
|
||||
<if test="withExtend == 'children' and id != null">
|
||||
(select GET_V_AUTH_MODEL_WITH_CHILDREN(#{id},#{modelType}) c_model_children_ids) tmc,
|
||||
</if>
|
||||
<if test="name != null and name !='' and withExtend == 'parent'">
|
||||
(select GET_V_AUTH_MODEL_WITH_PARENT ( (select GROUP_CONCAT(id) from
|
||||
v_auth_model where model_type = #{modelType} and `name` like CONCAT('%', #{name},'%')) ,#{modelType}) c_model_parent_seartch_ids) tmsc,
|
||||
</if>
|
||||
v_auth_model
|
||||
<where>
|
||||
model_type = #{modelType}
|
||||
<if test="1== withAuth">
|
||||
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT ( cids2 ,#{modelType}))
|
||||
and FIND_IN_SET(v_auth_model.id,c_auth_parent_ids)
|
||||
</if>
|
||||
<if test="pid !=null">
|
||||
and v_auth_model.pid = #{pid}
|
||||
@@ -29,15 +41,14 @@
|
||||
and v_auth_model.id = #{id}
|
||||
</if>
|
||||
<if test="withExtend == 'parent' and id != null">
|
||||
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT(#{id},#{modelType}))
|
||||
and FIND_IN_SET(v_auth_model.id,c_model_parent_ids)
|
||||
</if>
|
||||
<if test="withExtend == 'children' and id != null">
|
||||
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_CHILDREN(#{id},#{modelType}))
|
||||
and FIND_IN_SET(v_auth_model.id,c_model_children_ids)
|
||||
</if>
|
||||
|
||||
<if test="name != null and name !='' and withExtend == 'parent'">
|
||||
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT ( (select GROUP_CONCAT(id) from
|
||||
v_auth_model where model_type = #{modelType} and `name` like CONCAT('%', #{name},'%')) ,#{modelType}))
|
||||
and FIND_IN_SET(v_auth_model.id,c_model_parent_seartch_ids)
|
||||
</if>
|
||||
|
||||
<if test="name != null and name =='' and withExtend == 'parent'">
|
||||
@@ -51,11 +62,11 @@
|
||||
count( 1 ) AS `children_count`,
|
||||
`authTemp`.`pid` AS `pid`
|
||||
FROM
|
||||
( SELECT * FROM (select get_grant_auths (#{modelType},#{createBy}) cids3) t3,v_auth_model
|
||||
( SELECT * FROM (select GET_V_AUTH_MODEL_WITH_PARENT(get_grant_auths (#{modelType},#{createBy}),#{modelType}) cids3) t3,v_auth_model
|
||||
<where>
|
||||
model_type = #{modelType}
|
||||
<if test="1== withAuth">
|
||||
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT ( cids3 ,#{modelType}))
|
||||
and FIND_IN_SET(v_auth_model.id,cids3)
|
||||
</if>
|
||||
</where>
|
||||
) authTemp
|
||||
@@ -65,7 +76,7 @@
|
||||
auth.id = authCount.pid
|
||||
<where>
|
||||
<if test="1== withAuth">
|
||||
(authCount.children_count>0 or FIND_IN_SET(auth.id,cids1) )
|
||||
(authCount.children_count>0 or FIND_IN_SET(auth.id,c_auth_ids) )
|
||||
</if>
|
||||
</where>
|
||||
|
||||
|
||||
@@ -26,12 +26,7 @@ public class StoreServer implements StoreApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String storeId) {
|
||||
try {
|
||||
Long id = Long.parseLong(storeId);
|
||||
storeService.remove(id);
|
||||
} catch (Exception e) {
|
||||
storeService.removeByPanelId(storeId);
|
||||
}
|
||||
public void remove(String panelId) {
|
||||
storeService.removeByPanelId(panelId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.dataease.controller.panel.server;
|
||||
import io.dataease.base.domain.ChartView;
|
||||
import io.dataease.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.TreeUtils;
|
||||
import io.dataease.controller.panel.api.ViewApi;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.base.ConditionEntity;
|
||||
@@ -10,6 +11,7 @@ import io.dataease.dto.panel.PanelViewDto;
|
||||
import io.dataease.dto.panel.po.PanelViewPo;
|
||||
import io.dataease.service.chart.ChartViewService;
|
||||
import io.dataease.service.panel.PanelViewService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -35,10 +37,13 @@ public class ViewServer implements ViewApi {
|
||||
*/
|
||||
@Override
|
||||
public List<PanelViewDto> treeWithAuth() {
|
||||
List<PanelViewPo> groups = panelViewService.groups();
|
||||
List<PanelViewPo> views = panelViewService.views();
|
||||
List<PanelViewDto> panelViewDtos = panelViewService.buildTree(groups, views);
|
||||
return panelViewDtos;
|
||||
List<PanelViewDto> groups = panelViewService.groups();
|
||||
List<PanelViewDto> views = panelViewService.views();
|
||||
if(CollectionUtils.isNotEmpty(groups)&&CollectionUtils.isNotEmpty(views)){
|
||||
groups.addAll(views);
|
||||
}
|
||||
// List<PanelViewDto> panelViewDtos = panelViewService.buildTree(groups, views);
|
||||
return TreeUtils.mergeTree(groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import io.dataease.dto.dataset.DataTableInfoDTO;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.service.dataset.DataSetGroupService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -124,7 +125,11 @@ public class DatasourceService {
|
||||
dbTableDTO.setEnableCheck(false);
|
||||
List<DatasetGroup> parents = dataSetGroupService.getParents(datasetTable.getSceneId());
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
parents.forEach(ele -> stringBuilder.append(ele.getName()).append("/"));
|
||||
parents.forEach(ele -> {
|
||||
if (ObjectUtils.isNotEmpty(ele)) {
|
||||
stringBuilder.append(ele.getName()).append("/");
|
||||
}
|
||||
});
|
||||
stringBuilder.append(datasetTable.getName());
|
||||
dbTableDTO.setDatasetPath(stringBuilder.toString());
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.dataease.dto.panel;
|
||||
|
||||
import io.dataease.commons.model.ITreeBase;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -7,7 +8,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Data
|
||||
public class PanelViewDto {
|
||||
public class PanelViewDto implements ITreeBase<PanelViewDto> {
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package io.dataease.dto.panel.po;
|
||||
|
||||
import io.dataease.commons.model.ITreeBase;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PanelViewPo {
|
||||
public class PanelViewPo{
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package io.dataease.plugins.config;
|
||||
|
||||
import io.dataease.base.domain.MyPlugin;
|
||||
import io.dataease.commons.utils.DeFileUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.service.sys.PluginService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
@@ -26,7 +24,7 @@ public class PluginRunner implements ApplicationRunner {
|
||||
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
public void run(ApplicationArguments args) {
|
||||
// 执行加载插件逻辑
|
||||
BaseGridRequest request = new BaseGridRequest();
|
||||
List<MyPlugin> plugins = pluginService.query(request);
|
||||
@@ -45,17 +43,14 @@ public class PluginRunner implements ApplicationRunner {
|
||||
if (jarFile.exists()) {
|
||||
pluginService.loadJar(jarPath, plugin);
|
||||
}else {
|
||||
LogUtil.error("插件错误");
|
||||
LogUtil.error("插件路径不存在 {} ", jarPath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtil.error(e);
|
||||
//e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private boolean isPluginJar(File file) {
|
||||
String name = file.getName();
|
||||
return StringUtils.equals(DeFileUtils.getExtensionName(name), "jar");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,14 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
} else {
|
||||
stringBuilder.append(f.getDataeaseName());
|
||||
}
|
||||
} else if (f.getDeExtractType() == 0) {
|
||||
if (f.getDeType() == 2) {
|
||||
stringBuilder.append("cast(").append(f.getDataeaseName()).append(" as decimal(20,0)) as ").append(f.getDataeaseName());
|
||||
} else if (f.getDeType() == 3) {
|
||||
stringBuilder.append("cast(").append(f.getDataeaseName()).append(" as decimal(20,2)) as ").append(f.getDataeaseName());
|
||||
} else {
|
||||
stringBuilder.append(f.getDataeaseName());
|
||||
}
|
||||
} else {
|
||||
if (f.getDeType() == 1) {
|
||||
stringBuilder.append("FROM_UNIXTIME(cast(").append(f.getDataeaseName()).append(" as decimal(20,0))/1000,'%Y-%m-%d %H:%i:%S') as ").append(f.getDataeaseName());
|
||||
|
||||
@@ -82,6 +82,14 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
} else {
|
||||
stringBuilder.append(f.getOriginName());
|
||||
}
|
||||
} else if (f.getDeExtractType() == 0) {
|
||||
if (f.getDeType() == 2) {
|
||||
stringBuilder.append("cast(").append(f.getOriginName()).append(" as decimal(20,0)) as ").append(f.getOriginName());
|
||||
} else if (f.getDeType() == 3) {
|
||||
stringBuilder.append("cast(").append(f.getOriginName()).append(" as decimal(20,2)) as ").append(f.getOriginName());
|
||||
} else {
|
||||
stringBuilder.append(f.getOriginName());
|
||||
}
|
||||
} else {
|
||||
if (f.getDeType() == 1) {
|
||||
stringBuilder.append("FROM_UNIXTIME(cast(").append(f.getOriginName()).append(" as decimal(20,0))/1000,'%Y-%m-%d %H:%i:%S') as ").append(f.getOriginName());
|
||||
|
||||
@@ -813,6 +813,7 @@ public class DataSetTableService {
|
||||
if (cellTypeEnum.equals(CellType.STRING)) {
|
||||
if (cellType) {
|
||||
tableFiled.setFieldType("TEXT");
|
||||
tableFiled.setFieldSize(65533);
|
||||
}
|
||||
return cell.getStringCellValue();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package io.dataease.service.dataset;
|
||||
|
||||
import io.dataease.base.domain.DatasetTableTask;
|
||||
import io.dataease.base.domain.DatasetTableTaskExample;
|
||||
import io.dataease.base.domain.DatasetTableTaskLog;
|
||||
import io.dataease.base.domain.*;
|
||||
import io.dataease.base.mapper.DatasetTableTaskMapper;
|
||||
import io.dataease.commons.constants.JobStatus;
|
||||
import io.dataease.commons.constants.ScheduleType;
|
||||
@@ -38,7 +36,9 @@ public class DataSetTableTaskService {
|
||||
private DataSetTableService dataSetTableService;
|
||||
@Resource
|
||||
private ExtractDataService extractDataService;
|
||||
|
||||
public DatasetTableTask save(DataSetTaskRequest dataSetTaskRequest) throws Exception {
|
||||
checkName(dataSetTaskRequest);
|
||||
DatasetTableTask datasetTableTask = dataSetTaskRequest.getDatasetTableTask();
|
||||
dataSetTableService.saveIncrementalConfig(dataSetTaskRequest.getDatasetTableIncrementalConfig());
|
||||
|
||||
@@ -60,8 +60,8 @@ public class DataSetTableTaskService {
|
||||
datasetTableTask.setId(UUID.randomUUID().toString());
|
||||
datasetTableTask.setCreateTime(System.currentTimeMillis());
|
||||
// SIMPLE 类型,提前占位
|
||||
if(datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())){
|
||||
if(extractDataService.updateSyncStatus(dataSetTableService.get(datasetTableTask.getTableId()))){
|
||||
if (datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())) {
|
||||
if (extractDataService.updateSyncStatus(dataSetTableService.get(datasetTableTask.getTableId()))) {
|
||||
throw new Exception(Translator.get("i18n_sync_job_exists"));
|
||||
}else {
|
||||
//write log
|
||||
@@ -119,4 +119,22 @@ public class DataSetTableTaskService {
|
||||
datasetTableTaskExample.setOrderByClause("create_time desc,name asc");
|
||||
return datasetTableTaskMapper.selectByExample(datasetTableTaskExample);
|
||||
}
|
||||
|
||||
private void checkName(DataSetTaskRequest dataSetTaskRequest) {
|
||||
DatasetTableTaskExample datasetTableTaskExample = new DatasetTableTaskExample();
|
||||
DatasetTableTaskExample.Criteria criteria = datasetTableTaskExample.createCriteria();
|
||||
if (StringUtils.isNotEmpty(dataSetTaskRequest.getDatasetTableTask().getId())) {
|
||||
criteria.andIdNotEqualTo(dataSetTaskRequest.getDatasetTableTask().getId());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dataSetTaskRequest.getDatasetTableTask().getTableId())) {
|
||||
criteria.andTableIdEqualTo(dataSetTaskRequest.getDatasetTableTask().getTableId());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dataSetTaskRequest.getDatasetTableTask().getName())) {
|
||||
criteria.andNameEqualTo(dataSetTaskRequest.getDatasetTableTask().getName());
|
||||
}
|
||||
List<DatasetTableTask> list = datasetTableTaskMapper.selectByExample(datasetTableTaskExample);
|
||||
if (list.size() > 0) {
|
||||
throw new RuntimeException(Translator.get("i18n_task_name_repeat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,6 +689,7 @@ public class ExtractDataService {
|
||||
String tmp_code = code.replace("alterColumnTypeCode", needToChangeColumnType).replace("Column_Fields", String.join(",", datasetTableFields.stream().map(DatasetTableField::getOriginName).collect(Collectors.toList())));
|
||||
if(isExcel){
|
||||
tmp_code = tmp_code.replace("handleExcelIntColumn", handleExcelIntColumn);
|
||||
tmp_code = tmp_code.replace("handleExcelWraps", handleExcelWraps);
|
||||
}else {
|
||||
tmp_code = tmp_code.replace("handleExcelIntColumn", "");
|
||||
}
|
||||
@@ -746,6 +747,14 @@ public class ExtractDataService {
|
||||
" }catch (Exception e){}\n" +
|
||||
" }";
|
||||
|
||||
private static String handleExcelWraps = " \n" +
|
||||
" if(tmp != null ){\n" +
|
||||
" tmp = tmp.trim();\n" +
|
||||
" tmp = tmp.replaceAll(\"\\r\",\" \");\n" +
|
||||
" tmp = tmp.replaceAll(\"\\n\",\" \");\n" +
|
||||
" get(Fields.Out, filed).setValue(r, tmp);\n" +
|
||||
" }";
|
||||
|
||||
private static String code = "import org.pentaho.di.core.row.ValueMetaInterface;\n" +
|
||||
"import java.util.List;\n" +
|
||||
"import java.io.File;\n" +
|
||||
@@ -775,6 +784,7 @@ public class ExtractDataService {
|
||||
" List<String> fileds = Arrays.asList(\"Column_Fields\".split(\",\"));\n" +
|
||||
" for (String filed : fileds) {\n" +
|
||||
" String tmp = get(Fields.In, filed).getString(r);\n" +
|
||||
"handleExcelWraps \n" +
|
||||
"alterColumnTypeCode \n" +
|
||||
"handleExcelIntColumn \n" +
|
||||
" str = str + tmp;\n" +
|
||||
|
||||
@@ -26,11 +26,11 @@ public class PanelViewService {
|
||||
|
||||
private final static String SCENE_TYPE = "scene";
|
||||
|
||||
public List<PanelViewPo> groups(){
|
||||
public List<PanelViewDto> groups(){
|
||||
return extPanelViewMapper.groups(String.valueOf(AuthUtils.getUser().getUserId()));
|
||||
}
|
||||
|
||||
public List<PanelViewPo> views(){
|
||||
public List<PanelViewDto> views(){
|
||||
return extPanelViewMapper.views(String.valueOf(AuthUtils.getUser().getUserId()));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,14 +34,15 @@ public class StoreService {
|
||||
}
|
||||
|
||||
public void removeByPanelId(String panelId) {
|
||||
Long userId = AuthUtils.getUser().getUserId();
|
||||
PanelStoreExample panelStoreExample = new PanelStoreExample();
|
||||
panelStoreExample.createCriteria().andPanelGroupIdEqualTo(panelId);
|
||||
panelStoreExample.createCriteria().andPanelGroupIdEqualTo(panelId).andUserIdEqualTo(userId);
|
||||
panelStoreMapper.deleteByExample(panelStoreExample);
|
||||
}
|
||||
|
||||
public void remove(Long storeId) {
|
||||
/*public void remove(Long storeId) {
|
||||
panelStoreMapper.deleteByPrimaryKey(storeId);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 按照当前用户ID查询收藏仪表板
|
||||
|
||||
Reference in New Issue
Block a user