Merge pull request #1861 from dataease/pr@v1.8@refactor_panel_share

refactor: 分享列表仪表板使用代理权限查看
This commit is contained in:
fit2cloud-chenyw 2022-03-01 21:01:01 +08:00 committed by GitHub
commit 9b28cf628a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 540 additions and 142 deletions

View File

@ -8,9 +8,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE, ElementType.METHOD})
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface DePermission {
public @interface DePermission {
DePermissionType type();

View File

@ -0,0 +1,16 @@
package io.dataease.auth.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface DePermissionProxy {
String value() default "";
int paramIndex() default 0;
}

View File

@ -1,6 +1,5 @@
package io.dataease.auth.aop;
import io.dataease.auth.annotation.DeCleaner;
import io.dataease.auth.api.dto.CurrentUserDto;
import io.dataease.commons.constants.AuthConstants;
@ -23,7 +22,6 @@ public class DeCleanerAnnotationHandler {
@Around(value = "@annotation(io.dataease.auth.annotation.DeCleaner)")
public Object CleanerAround(ProceedingJoinPoint point) {
try {
CurrentUserDto user = AuthUtils.getUser();
MethodSignature ms = (MethodSignature) point.getSignature();
Method method = ms.getMethod();
DeCleaner deCleaner = method.getAnnotation(DeCleaner.class);
@ -41,7 +39,7 @@ public class DeCleanerAnnotationHandler {
}
return point.proceed(point.getArgs());
}catch (Throwable e) {
} catch (Throwable e) {
LogUtil.error(e.getMessage(), e);
throw new RuntimeException(e);
}
@ -55,6 +53,7 @@ public class DeCleanerAnnotationHandler {
CacheUtils.remove(AuthConstants.ROLE_PANEL_NAME, "role" + role.getId());
});
}
public void cleanDataSet() {
CurrentUserDto user = AuthUtils.getUser();
CacheUtils.remove(AuthConstants.USER_DATASET_NAME, "user" + user.getUserId());
@ -63,6 +62,7 @@ public class DeCleanerAnnotationHandler {
CacheUtils.remove(AuthConstants.ROLE_DATASET_NAME, "role" + role.getId());
});
}
public void cleanDataSource() {
CurrentUserDto user = AuthUtils.getUser();
CacheUtils.remove(AuthConstants.USER_LINK_NAME, "user" + user.getUserId());

View File

@ -0,0 +1,155 @@
package io.dataease.auth.aop;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import io.dataease.auth.annotation.DePermissionProxy;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.LogUtil;
import io.dataease.dto.PermissionProxy;
@Aspect
@Component
@Order(0)
public class DePermissionProxyHandler {
@Around(value = "@annotation(io.dataease.auth.annotation.DePermissionProxy)")
public Object proxyAround(ProceedingJoinPoint point) {
try {
MethodSignature ms = (MethodSignature) point.getSignature();
Method method = ms.getMethod();
DePermissionProxy annotation = method.getAnnotation(DePermissionProxy.class);
Object[] args = point.getArgs();
if (null == args || args.length == 0) {
return point.proceed(args);
}
Object arg = point.getArgs()[annotation.paramIndex()];
/*
* if (arg instanceof PermissionProxy) {
* PermissionProxy proxy = (PermissionProxy) arg;
* AuthUtils.setProxyUser(proxy.getUserId());
* }
*/
PermissionProxy proxy = getProxy(arg, annotation, 0);
if (null != proxy && null != proxy.getUserId()) {
AuthUtils.setProxyUser(proxy.getUserId());
}
return point.proceed(args);
} catch (Throwable throwable) {
LogUtil.error(throwable.getMessage(), throwable);
throw new RuntimeException(throwable.getMessage());
} finally {
AuthUtils.cleanProxyUser();
}
}
private PermissionProxy getProxy(Object arg, DePermissionProxy annotation, int layer) throws Exception {
PermissionProxy result = null;
String value = annotation.value();
Class<?> parameterType = arg.getClass();
if (arg instanceof PermissionProxy) {
return (PermissionProxy) arg;
} else if (isArray(parameterType)) {
/*
* for (int i = 0; i < Array.getLength(arg); i++) {
* Object o = Array.get(arg, i);
* if ((result = getProxy(o, annotation, layer)) != null) {
* return result;
* }
* }
*/
return null;
} else if (isCollection(parameterType)) {
/*
* Object[] array = ((Collection) arg).toArray();
* for (int i = 0; i < array.length; i++) {
* Object o = array[i];
* if ((result = getProxy(o, annotation, layer)) != null) {
* return result;
* }
* }
*/
return null;
} else if (isMap(parameterType)) {
Map<String, Object> argMap = (Map) arg;
String[] values = value.split(".");
Object o = argMap.get(values[layer]);
return getProxy(o, annotation, ++layer);
} else {
// 当作自定义类处理
String[] values = value.split("\\.");
String fieldName = values[layer];
Object fieldValue = getFieldValue(arg, fieldName);
return getProxy(fieldValue, annotation, ++layer);
}
}
private Object getFieldValue(Object o, String fieldName) throws Exception {
Class<?> aClass = o.getClass();
while (null != aClass.getSuperclass()) {
Field[] declaredFields = aClass.getDeclaredFields();
for (int i = 0; i < declaredFields.length; i++) {
Field field = declaredFields[i];
String name = field.getName();
if (StringUtils.equals(name, fieldName)) {
field.setAccessible(true);
return field.get(o);
}
}
aClass = aClass.getSuperclass();
}
throw new NoSuchFieldException(fieldName);
}
private final static String[] wrapClasies = {
"java.lang.Boolean",
"java.lang.Character",
"java.lang.Integer",
"java.lang.Byte",
"java.lang.Short",
"java.lang.Long",
"java.lang.Float",
"java.lang.Double",
};
private Boolean isString(Class clz) {
return StringUtils.equals("java.lang.String", clz.getName());
}
private Boolean isArray(Class clz) {
return clz.isArray();
}
private Boolean isCollection(Class clz) {
return Collection.class.isAssignableFrom(clz);
}
private Boolean isMap(Class clz) {
return Map.class.isAssignableFrom(clz);
}
private Boolean isWrapClass(Class clz) {
return Arrays.stream(wrapClasies).anyMatch(item -> StringUtils.equals(item, clz.getName()));
}
}

View File

@ -21,40 +21,37 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Component
public class F2CRealm extends AuthorizingRealm {
@Autowired
@Lazy //shiro组件加载过早 让authUserService等一等再注入 否则 注入的可能不是代理对象
@Lazy // shiro组件加载过早 让authUserService等一等再注入 否则 注入的可能不是代理对象
private AuthUserService authUserService;
@Override
public boolean supports(AuthenticationToken token) {
return token instanceof JWTToken || token instanceof ASKToken;
}
//验证资源权限
// 验证资源权限
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
CurrentUserDto userDto = (CurrentUserDto)principals.getPrimaryPrincipal();
CurrentUserDto userDto = (CurrentUserDto) principals.getPrimaryPrincipal();
SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo();
Set<String> role = new HashSet<>(userDto.getRoles().stream().map(item -> ( item.getId() + "")).collect(Collectors.toSet()));
Set<String> role = new HashSet<>(
userDto.getRoles().stream().map(item -> (item.getId() + "")).collect(Collectors.toSet()));
simpleAuthorizationInfo.addRoles(role);
Set<String> permission = new HashSet<>(userDto.getPermissions());
simpleAuthorizationInfo.addStringPermissions(permission);
return simpleAuthorizationInfo;
}
//验证登录权限
// 验证登录权限
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
@ -73,11 +70,9 @@ public class F2CRealm extends AuthorizingRealm {
return new SimpleAuthenticationInfo(currentUserDto, signature, "f2cReam");
}
try {
CacheUtils.get("lic_info", "lic");
}catch (Exception e) {
} catch (Exception e) {
LogUtil.error(e);
throw new AuthenticationException("license error");
}
@ -88,7 +83,7 @@ public class F2CRealm extends AuthorizingRealm {
token = (String) auth.getCredentials();
// 解密获得username用于和数据库进行对比
tokenInfo = JWTUtils.tokenInfoByToken(token);
}catch (Exception e) {
} catch (Exception e) {
throw new AuthenticationException(e);
}
@ -105,7 +100,7 @@ public class F2CRealm extends AuthorizingRealm {
} catch (Exception e) {
e.printStackTrace();
}
if (! JWTUtils.verify(token, tokenInfo, pass)) {
if (!JWTUtils.verify(token, tokenInfo, pass)) {
throw new AuthenticationException("Username or password error");
}
@ -118,7 +113,7 @@ public class F2CRealm extends AuthorizingRealm {
if (user == null) {
throw new AuthenticationException("User didn't existed!");
}
if (user.getEnabled()==0) {
if (user.getEnabled() == 0) {
throw new AuthenticationException("User is valid!");
}
return user;

View File

@ -0,0 +1,41 @@
package io.dataease.auth.service;
import java.util.List;
import org.apache.shiro.authc.AuthenticationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import groovy.lang.Lazy;
import io.dataease.auth.api.dto.CurrentRoleDto;
import io.dataease.auth.api.dto.CurrentUserDto;
import io.dataease.auth.entity.SysUserEntity;
import io.dataease.commons.utils.BeanUtils;
@Service
public class ProxyAuthService {
@Autowired
@Lazy
private AuthUserService authUserService;
public CurrentUserDto queryCacheUserDto(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!");
}
// 使用缓存
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);
return currentUserDto;
}
}

View File

@ -1,8 +1,8 @@
package io.dataease.base.mapper.ext;
import io.dataease.base.domain.PanelShare;
import io.dataease.base.mapper.ext.query.GridExample;
import io.dataease.controller.request.panel.PanelShareRemoveRequest;
import io.dataease.controller.request.panel.PanelShareSearchRequest;
import io.dataease.dto.panel.PanelShareOutDTO;
import io.dataease.dto.panel.PanelSharePo;
import org.apache.ibatis.annotations.Param;
@ -20,9 +20,9 @@ public interface ExtPanelShareMapper {
List<PanelSharePo> queryOut(String userName);
List<PanelShare> queryWithResource(GridExample example);
List<PanelShare> queryWithResource(PanelShareSearchRequest request);
List<PanelShareOutDTO> queryTargets(String panelId);
List<PanelShareOutDTO> queryTargets(@Param("panelId") String panelId, @Param("userName") String userName);
void removeShares(@Param("request") PanelShareRemoveRequest request);

View File

@ -6,6 +6,7 @@
<id column="id" property="id" />
<result column="name" property="name" />
<result column="creator" property="creator" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
</resultMap>
<resultMap id="targetMap" type="io.dataease.dto.panel.PanelShareOutDTO">
@ -34,7 +35,7 @@
</delete>
<select id="query" resultMap="treeNodeMap">
select distinct s.panel_group_id as id, u.nick_name as creator, g.name
select distinct s.panel_group_id as id, u.nick_name as creator, g.name, u.user_id
from panel_share s
left join panel_group g on g.id = s.panel_group_id
left join sys_user u on u.username = IFNULL(s.granter,g.create_by)
@ -61,14 +62,17 @@
</select>
<select id="queryWithResource" parameterType="io.dataease.base.mapper.ext.query.GridExample" resultMap="io.dataease.base.mapper.PanelShareMapper.BaseResultMap">
select * from panel_share
<if test="_parameter != null">
<include refid="io.dataease.base.mapper.ext.query.GridSql.gridCondition" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
<select id="queryWithResource" parameterType="io.dataease.controller.request.panel.PanelShareSearchRequest" resultMap="io.dataease.base.mapper.PanelShareMapper.BaseResultMap">
select s.*
from panel_share s
left join panel_group g on g.id = s.panel_group_id
where
s.panel_group_id = #{resourceId}
<if test="type != null">
and s.type = #{type}
</if>
and (( s.granter is not null and s.granter = #{currentUserName} ) or ( s.granter is null and g.create_by = #{currentUserName} ))
order by s.create_time desc
</select>
@ -89,6 +93,7 @@
) as target_name
from panel_share s
where s.panel_group_id = #{panelId}
and s.granter = #{userName}
</select>

View File

@ -4,9 +4,12 @@ import io.dataease.auth.api.dto.CurrentRoleDto;
import io.dataease.auth.api.dto.CurrentUserDto;
import io.dataease.auth.entity.AuthItem;
import io.dataease.auth.service.ExtAuthService;
import io.dataease.auth.service.ProxyAuthService;
import io.dataease.commons.constants.DePermissionType;
import io.dataease.commons.constants.ResourceAuthLevel;
import io.dataease.commons.model.AuthURD;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,23 +22,43 @@ import java.util.stream.Collectors;
@Component
public class AuthUtils {
private static final String[] defaultPanelPermissions = {"panel_list"};
private static final String[] defaultDataSetPermissions = {"0"};
private static final String[] defaultLinkPermissions = {"0"};
private static final String[] defaultPanelPermissions = { "panel_list" };
private static final String[] defaultDataSetPermissions = { "0" };
private static final String[] defaultLinkPermissions = { "0" };
private static final ThreadLocal<CurrentUserDto> USER_INFO = new ThreadLocal<CurrentUserDto>();
private static ExtAuthService extAuthService;
private static ProxyAuthService proxyAuthService;
@Autowired
public void setExtAuthService(ExtAuthService extAuthService) {
AuthUtils.extAuthService = extAuthService;
}
@Autowired
public void setProxyAuthService(ProxyAuthService proxyAuthService) {
AuthUtils.proxyAuthService = proxyAuthService;
}
public static CurrentUserDto getUser() {
if (ObjectUtils.isNotEmpty(USER_INFO.get()))
return USER_INFO.get();
CurrentUserDto userDto = (CurrentUserDto) SecurityUtils.getSubject().getPrincipal();
return userDto;
}
//根据组织 角色 用户 获取下属用户ID
public static void setProxyUser(Long userId) {
CurrentUserDto currentUserDto = proxyAuthService.queryCacheUserDto(userId);
USER_INFO.set(currentUserDto);
}
public static void cleanProxyUser() {
USER_INFO.remove();
}
// 根据组织 角色 用户 获取下属用户ID
public static Set<Long> userIdsByURD(AuthURD request) {
Set<Long> userIds = extAuthService.userIdsByRD(request);
if (!CollectionUtils.isEmpty(request.getUserIds())) {
@ -49,8 +72,6 @@ public class AuthUtils {
return extAuthService.resourceTarget(resourceId);
}
public static Set<AuthItem> permissionByType(String type) {
CurrentUserDto user = getUser();
Long userId = user.getUserId();
@ -59,7 +80,8 @@ public class AuthUtils {
Set<AuthItem> result = new HashSet<>();
if (StringUtils.equals(DePermissionType.DATASOURCE.name().toLowerCase(), type)) {
Set<AuthItem> userSet = extAuthService.dataSourceIdByUser(userId).stream().collect(Collectors.toSet());
Set<AuthItem> roleSet = roles.stream().map(role -> extAuthService.dataSourceIdByRole(role.getId())).flatMap(Collection::stream).collect(Collectors.toSet());
Set<AuthItem> roleSet = roles.stream().map(role -> extAuthService.dataSourceIdByRole(role.getId()))
.flatMap(Collection::stream).collect(Collectors.toSet());
Set<AuthItem> deptSet = extAuthService.dataSourceIdByDept(deptId).stream().collect(Collectors.toSet());
result.addAll(userSet);
result.addAll(roleSet);
@ -72,7 +94,8 @@ public class AuthUtils {
else if (StringUtils.equals(DePermissionType.DATASET.name().toLowerCase(), type)) {
Set<AuthItem> userSet = extAuthService.dataSetIdByUser(userId).stream().collect(Collectors.toSet());
Set<AuthItem> roleSet = roles.stream().map(role -> extAuthService.dataSetIdByRole(role.getId())).flatMap(Collection::stream).collect(Collectors.toSet());
Set<AuthItem> roleSet = roles.stream().map(role -> extAuthService.dataSetIdByRole(role.getId()))
.flatMap(Collection::stream).collect(Collectors.toSet());
Set<AuthItem> deptSet = extAuthService.dataSetIdByDept(deptId).stream().collect(Collectors.toSet());
result.addAll(userSet);
result.addAll(roleSet);
@ -81,10 +104,10 @@ public class AuthUtils {
result.add(new AuthItem(item, ResourceAuthLevel.DATASET_LEVEL_MANAGE.getLevel()));
});
return result;
}
else if (StringUtils.equals(DePermissionType.PANEL.name().toLowerCase(), type)) {
} else if (StringUtils.equals(DePermissionType.PANEL.name().toLowerCase(), type)) {
Set<AuthItem> userSet = extAuthService.panelIdByUser(userId).stream().collect(Collectors.toSet());
Set<AuthItem> roleSet = roles.stream().map(role -> extAuthService.panelIdByRole(role.getId())).flatMap(Collection::stream).collect(Collectors.toSet());
Set<AuthItem> roleSet = roles.stream().map(role -> extAuthService.panelIdByRole(role.getId()))
.flatMap(Collection::stream).collect(Collectors.toSet());
Set<AuthItem> deptSet = extAuthService.panelIdByDept(deptId).stream().collect(Collectors.toSet());
result.addAll(userSet);
result.addAll(roleSet);

View File

@ -2,6 +2,7 @@ package io.dataease.controller.chart;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.auth.annotation.DePermission;
import io.dataease.auth.annotation.DePermissionProxy;
import io.dataease.base.domain.ChartViewWithBLOBs;
import io.dataease.commons.constants.DePermissionType;
import io.dataease.commons.constants.ResourceAuthLevel;
@ -66,10 +67,12 @@ public class ChartViewController {
chartViewService.delete(id);
}
@DePermissionProxy(value = "proxy", paramIndex = 2)
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_VIEW, paramIndex = 1)
@ApiOperation("数据")
@PostMapping("/getData/{id}/{panelId}")
public ChartViewDTO getData(@PathVariable String id, @PathVariable String panelId, @RequestBody ChartExtRequest requestList) throws Exception {
public ChartViewDTO getData(@PathVariable String id, @PathVariable String panelId,
@RequestBody ChartExtRequest requestList) throws Exception {
return chartViewService.getData(id, requestList);
}
@ -110,7 +113,8 @@ public class ChartViewController {
@ApiIgnore
@ApiOperation("验证视图是否使用相同数据集")
@GetMapping("/checkSameDataSet/{viewIdSource}/{viewIdTarget}")
public String checkSameDataSet(@PathVariable String viewIdSource, @PathVariable String viewIdTarget) throws Exception {
public String checkSameDataSet(@PathVariable String viewIdSource, @PathVariable String viewIdTarget)
throws Exception {
return chartViewService.checkSameDataSet(viewIdSource, viewIdTarget);
}
}

View File

@ -2,6 +2,7 @@ package io.dataease.controller.panel;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.auth.annotation.DePermission;
import io.dataease.auth.annotation.DePermissionProxy;
import io.dataease.auth.annotation.DePermissions;
import io.dataease.base.domain.PanelGroup;
import io.dataease.base.domain.PanelGroupWithBLOBs;
@ -9,13 +10,15 @@ import io.dataease.commons.constants.DePermissionType;
import io.dataease.commons.constants.ResourceAuthLevel;
import io.dataease.controller.handler.annotation.I18n;
import io.dataease.controller.request.panel.PanelGroupRequest;
import io.dataease.dto.PermissionProxy;
import io.dataease.dto.authModel.VAuthModelDTO;
import io.dataease.dto.panel.PanelGroupDTO;
import io.dataease.service.panel.PanelGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
import org.apache.shiro.authz.annotation.Logical;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -50,8 +53,8 @@ public class PanelGroupController {
@ApiOperation("保存")
@PostMapping("/save")
@DePermissions(value = {
@DePermission(type = DePermissionType.PANEL, value = "id"),
@DePermission(type = DePermissionType.PANEL, value = "pid", level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
@DePermission(type = DePermissionType.PANEL, value = "id"),
@DePermission(type = DePermissionType.PANEL, value = "pid", level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
}, logical = Logical.AND)
@I18n
public PanelGroup saveOrUpdate(@RequestBody PanelGroupRequest request) {
@ -72,10 +75,20 @@ public class PanelGroupController {
return panelGroupService.findOne(id);
}
@ApiIgnore
@ApiOperation("详细信息(分享人代理)")
@DePermissionProxy(paramIndex = 1)
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_VIEW)
@PostMapping("/proxy/findOne/{id}")
public PanelGroupWithBLOBs proxyFindOne(@PathVariable String id, @RequestBody PermissionProxy proxy)
throws Exception {
return panelGroupService.findOne(id);
}
@ApiOperation("仪表板视图信息")
@PostMapping("/queryPanelViewTree")
@I18n
public List<VAuthModelDTO> queryPanelViewTree(){
public List<VAuthModelDTO> queryPanelViewTree() {
return panelGroupService.queryPanelViewTree();
}

View File

@ -1,13 +1,18 @@
package io.dataease.controller.panel;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.auth.annotation.DePermissionProxy;
import io.dataease.base.domain.DatasetTableField;
import io.dataease.dto.PermissionProxy;
import io.dataease.dto.panel.linkJump.PanelLinkJumpBaseRequest;
import io.dataease.dto.panel.linkJump.PanelLinkJumpBaseResponse;
import io.dataease.dto.panel.linkJump.PanelLinkJumpDTO;
import io.dataease.service.panel.PanelLinkJumpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -33,7 +38,6 @@ public class PanelLinkJumpController {
return panelLinkJumpService.getViewFields(viewId);
}
@ApiOperation("根据仪表板ID和视图ID获取跳转信息")
@GetMapping("/queryWithViewId/{panelId}/{viewId}")
public PanelLinkJumpDTO queryWithViewId(@PathVariable String panelId, @PathVariable String viewId) {
@ -46,6 +50,15 @@ public class PanelLinkJumpController {
return panelLinkJumpService.queryPanelJumpInfo(panelId);
}
@ApiIgnore
@ApiOperation("根据仪表板ID获取跳转信息(分享人代理)")
@DePermissionProxy(paramIndex = 1)
@PostMapping("/proxy/queryPanelJumpInfo/{panelId}")
public PanelLinkJumpBaseResponse queryPanelJumpInfo(@PathVariable String panelId,
@RequestBody PermissionProxy proxy) {
return panelLinkJumpService.queryPanelJumpInfo(panelId);
}
@ApiOperation("更新跳转信息")
@PostMapping("/updateJumpSet")
public void updateJumpSet(@RequestBody PanelLinkJumpDTO jumpDTO) {

View File

@ -1,12 +1,17 @@
package io.dataease.controller.panel;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.auth.annotation.DePermissionProxy;
import io.dataease.commons.model.BaseRspModel;
import io.dataease.controller.request.panel.PanelLinkageRequest;
import io.dataease.dto.PanelViewLinkageDTO;
import io.dataease.dto.PermissionProxy;
import io.dataease.service.panel.PanelViewLinkageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -46,4 +51,13 @@ public class PanelViewLinkageController {
return panelViewLinkageService.getPanelAllLinkageInfo(panelId);
}
@ApiIgnore
@ApiOperation("获取当前仪表板所有联动信息(分享人代理)")
@DePermissionProxy(paramIndex = 1)
@PostMapping("/proxy/getPanelAllLinkageInfo/{panelId}")
public Map<String, List<String>> getPanelAllLinkageInfo(@PathVariable String panelId,
@RequestBody PermissionProxy proxy) {
return panelViewLinkageService.getPanelAllLinkageInfo(panelId);
}
}

View File

@ -6,6 +6,7 @@ import io.dataease.base.domain.PanelShare;
import io.dataease.commons.constants.DePermissionType;
import io.dataease.controller.request.panel.PanelShareFineDto;
import io.dataease.controller.request.panel.PanelShareRemoveRequest;
import io.dataease.controller.request.panel.PanelShareSearchRequest;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.dto.panel.PanelShareDto;
import io.dataease.dto.panel.PanelShareOutDTO;
@ -27,8 +28,6 @@ import java.util.List;
@RequestMapping("/api/share")
public interface ShareApi {
@ApiOperation("查询分享给我")
@PostMapping("/treeList")
List<PanelShareDto> treeList(BaseGridRequest request);
@ -37,25 +36,20 @@ public interface ShareApi {
@PostMapping("/shareOut")
List<PanelSharePo> shareOut();
@ApiOperation("根据资源查询分享")
@PostMapping("/queryWithResourceId")
List<PanelShare> queryWithResourceId(BaseGridRequest request);
List<PanelShare> queryWithResourceId(PanelShareSearchRequest request);
@ApiOperation("查询分享目标")
@PostMapping("/queryTargets/{panelId}")
@ApiImplicitParam(paramType = "path", value = "仪表板ID", name = "panelId", required = true, dataType = "String")
List<PanelShareOutDTO> queryTargets(@PathVariable("panelId") String panelId);
@DePermission(type = DePermissionType.PANEL, value = "resourceId")
@ApiOperation("创建分享")
@PostMapping("/fineSave")
void fineSave(PanelShareFineDto panelShareFineDto);
@ApiOperation("删除分享")
@PostMapping("/removeShares")
void removeShares(PanelShareRemoveRequest request);

View File

@ -4,7 +4,7 @@ import io.dataease.base.domain.PanelShare;
import io.dataease.controller.panel.api.ShareApi;
import io.dataease.controller.request.panel.PanelShareFineDto;
import io.dataease.controller.request.panel.PanelShareRemoveRequest;
import io.dataease.controller.request.panel.PanelShareRequest;
import io.dataease.controller.request.panel.PanelShareSearchRequest;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.dto.panel.PanelShareDto;
import io.dataease.dto.panel.PanelShareOutDTO;
@ -23,7 +23,6 @@ public class ShareServer implements ShareApi {
@Resource
private ShareService shareService;
@Override
public List<PanelShareDto> treeList(@RequestBody BaseGridRequest request) {
return shareService.queryTree(request);
@ -35,7 +34,7 @@ public class ShareServer implements ShareApi {
}
@Override
public List<PanelShare> queryWithResourceId(@RequestBody BaseGridRequest request) {
public List<PanelShare> queryWithResourceId(@RequestBody PanelShareSearchRequest request) {
return shareService.queryWithResource(request);
}
@ -54,5 +53,3 @@ public class ShareServer implements ShareApi {
shareService.removeShares(request);
}
}

View File

@ -1,8 +1,10 @@
package io.dataease.controller.request.chart;
import io.dataease.dto.PermissionProxy;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
@ -16,7 +18,7 @@ public class ChartExtRequest {
@ApiModelProperty("视图额外过滤条件集合")
private List<ChartExtFilterRequest> filter;
//联动过滤条件
// 联动过滤条件
@ApiModelProperty("联动过滤条件集合")
private List<ChartExtFilterRequest> linkageFilters;
@ -37,4 +39,7 @@ public class ChartExtRequest {
@ApiModelProperty("用户ID")
private Long user = null;
@ApiModelProperty(hidden = true)
private PermissionProxy proxy;
}

View File

@ -0,0 +1,20 @@
package io.dataease.controller.request.panel;
import java.io.Serializable;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PanelShareSearchRequest implements Serializable {
@ApiModelProperty(value = "分享目标类型", allowableValues = "0:user,1:role,2:dept")
private String type;
@ApiModelProperty("仪表板ID")
private String resourceId;
@ApiModelProperty("当前用户")
private String currentUserName;
}

View File

@ -0,0 +1,12 @@
package io.dataease.dto;
import java.io.Serializable;
import lombok.Data;
@Data
public class PermissionProxy implements Serializable {
private Long userId;
}

View File

@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class PanelSharePo {
@ -15,6 +14,7 @@ public class PanelSharePo {
private String name;
@ApiModelProperty("节点父ID")
private String creator;
@ApiModelProperty("分享人ID")
private Long userId;
}

View File

@ -9,7 +9,6 @@ import io.dataease.base.domain.PanelShareExample;
import io.dataease.base.mapper.PanelGroupMapper;
import io.dataease.base.mapper.PanelShareMapper;
import io.dataease.base.mapper.ext.ExtPanelShareMapper;
import io.dataease.base.mapper.ext.query.GridExample;
import io.dataease.commons.model.AuthURD;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.BeanUtils;
@ -17,6 +16,7 @@ import io.dataease.commons.utils.CommonBeanFactory;
import io.dataease.controller.request.panel.PanelShareFineDto;
import io.dataease.controller.request.panel.PanelShareRemoveRequest;
import io.dataease.controller.request.panel.PanelShareRequest;
import io.dataease.controller.request.panel.PanelShareSearchRequest;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.dto.panel.PanelShareDto;
import io.dataease.dto.panel.PanelShareOutDTO;
@ -32,7 +32,6 @@ import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class ShareService {
@ -46,50 +45,57 @@ public class ShareService {
private ExtPanelShareMapper extPanelShareMapper;
/**
* 1.查询当前节点已经分享给了哪些目标
* 2.过滤出新增的目标
* 3.过滤出减少的目标
* 4.批量删除
* 5.批量新增
* 6.发送取消分享消息
* 7.发送新增分享消息
* 1.查询当前节点已经分享给了哪些目标
* 2.过滤出新增的目标
* 3.过滤出减少的目标
* 4.批量删除
* 5.批量新增
* 6.发送取消分享消息
* 7.发送新增分享消息
*
* @param panelShareFineDto
*/
@Transactional
public void fineSave(PanelShareFineDto panelShareFineDto) {
List<PanelShare> addShares = new ArrayList<>();//新增的分享
List<Long> redShareIdLists = new ArrayList<>();//取消的分享
List<PanelShare> addShares = new ArrayList<>();// 新增的分享
List<Long> redShareIdLists = new ArrayList<>();// 取消的分享
String panelGroupId = panelShareFineDto.getResourceId();
AuthURD authURD = panelShareFineDto.getAuthURD();
AuthURD sharedAuthURD = new AuthURD();
AuthURD addAuthURD = new AuthURD();
Map<Integer, List<Long>> authURDMap = new HashMap<>();
authURDMap.put(0, authURD.getUserIds());
authURDMap.put(1, authURD.getRoleIds());
authURDMap.put(2, authURD.getDeptIds());
PanelShareExample example = new PanelShareExample();
example.createCriteria().andPanelGroupIdEqualTo(panelGroupId);
List<PanelShare> panelShares = mapper.selectByExample(example);
Map<Integer, List<TempShareNode>> typeSharedMap = panelShares.stream().map(this::convertNode).collect(Collectors.groupingBy(TempShareNode::getType));
/*
* PanelShareExample example = new PanelShareExample();
* example.createCriteria().andPanelGroupIdEqualTo(panelGroupId);
* List<PanelShare> panelShares = mapper.selectByExample(example);
*/
PanelShareSearchRequest request = new PanelShareSearchRequest();
request.setCurrentUserName(AuthUtils.getUser().getUsername());
request.setResourceId(panelGroupId);
// 当前用户已经分享出去的
List<PanelShare> panelShares = extPanelShareMapper.queryWithResource(request);
Map<Integer, List<TempShareNode>> typeSharedMap = panelShares.stream().map(this::convertNode)
.collect(Collectors.groupingBy(TempShareNode::getType));
for (Map.Entry<Integer, List<Long>> entry : authURDMap.entrySet()) {
Integer key = entry.getKey();
List<TempShareNode> shareNodes;
if (null == typeSharedMap || null == typeSharedMap.get(key)) {
shareNodes = new ArrayList<>();
}else{
} else {
shareNodes = typeSharedMap.get(key);
}
if (null != authURDMap.get(key)) {
Map<String, Object> dataMap = filterData(authURDMap.get(key), shareNodes);
List<Long> newIds = (List<Long>)dataMap.get("add");
List<Long> newIds = (List<Long>) dataMap.get("add");
for (int i = 0; i < newIds.size(); i++) {
Long id = newIds.get(i);
PanelShare share = new PanelShare();
@ -99,21 +105,24 @@ public class ShareService {
share.setType(key);
addShares.add(share);
}
List<TempShareNode> redNodes = (List<TempShareNode>)dataMap.get("red");
List<Long> redIds = redNodes.stream().map(TempShareNode::getShareId).distinct().collect(Collectors.toList());
List<TempShareNode> redNodes = (List<TempShareNode>) dataMap.get("red");
List<Long> redIds = redNodes.stream().map(TempShareNode::getShareId).distinct()
.collect(Collectors.toList());
redShareIdLists.addAll(redIds);
buildRedAuthURD(key, redNodes.stream().map(TempShareNode::getTargetId).distinct().collect(Collectors.toList()) , sharedAuthURD);
buildRedAuthURD(key,
redNodes.stream().map(TempShareNode::getTargetId).distinct().collect(Collectors.toList()),
sharedAuthURD);
buildRedAuthURD(key, newIds, addAuthURD);
}
}
if (CollectionUtils.isNotEmpty(redShareIdLists)){
if (CollectionUtils.isNotEmpty(redShareIdLists)) {
extPanelShareMapper.batchDelete(redShareIdLists);
}
if (CollectionUtils.isNotEmpty(addShares)){
if (CollectionUtils.isNotEmpty(addShares)) {
extPanelShareMapper.batchInsert(addShares, AuthUtils.getUser().getUsername());
}
@ -129,20 +138,21 @@ public class ShareService {
List<String> msgParam = new ArrayList<>();
msgParam.add(panelGroupId);
addUserIdSet.forEach(userId -> {
if (!redUserIdSet.contains(userId) && !user.getUserId().equals(userId)){
DeMsgutil.sendMsg(userId, 2L,user.getNickName()+" 分享了仪表板【"+msg+"】,请查收!", gson.toJson(msgParam));
if (!redUserIdSet.contains(userId) && !user.getUserId().equals(userId)) {
DeMsgutil.sendMsg(userId, 2L, user.getNickName() + " 分享了仪表板【" + msg + "】,请查收!", gson.toJson(msgParam));
}
});
redUserIdSet.forEach(userId -> {
if (!addUserIdSet.contains(userId) && !user.getUserId().equals(userId)){
DeMsgutil.sendMsg(userId, 3L, user.getNickName()+" 取消分享了仪表板【"+msg+"】,请查收!", gson.toJson(msgParam));
if (!addUserIdSet.contains(userId) && !user.getUserId().equals(userId)) {
DeMsgutil.sendMsg(userId, 3L, user.getNickName() + " 取消分享了仪表板【" + msg + "】,请查收!",
gson.toJson(msgParam));
}
});
}
private void buildRedAuthURD(Integer type, List<Long> redIds , AuthURD authURD) {
private void buildRedAuthURD(Integer type, List<Long> redIds, AuthURD authURD) {
if (type == 0) {
authURD.setUserIds(redIds);
}
@ -179,8 +189,9 @@ public class ShareService {
newUserIds.add(newTargetId);
}
}
//获取需要取消分享的
List<TempShareNode> missNodes = shareNodes.stream().filter(item -> !item.getMatched()).collect(Collectors.toList());
// 获取需要取消分享的
List<TempShareNode> missNodes = shareNodes.stream().filter(item -> !item.getMatched())
.collect(Collectors.toList());
result.put("add", newUserIds);
result.put("red", missNodes);
return result;
@ -202,33 +213,31 @@ public class ShareService {
return BeanUtils.copyBean(new TempShareNode(), panelShare);
}
@Transactional
public void save(PanelShareRequest request){
public void save(PanelShareRequest request) {
List<PanelGroup> panelGroups = queryGroup(request.getPanelIds());
//1.先根据仪表板删除所有已经分享的
// 1.先根据仪表板删除所有已经分享的
Integer type = request.getType();
List<String> panelIds = request.getPanelIds();
List<Long> targetIds = request.getTargetIds();
// 使用原生对象会导致事物失效 所以这里需要使用spring代理对象
if (CollectionUtils.isNotEmpty(panelIds)){
if (CollectionUtils.isNotEmpty(panelIds)) {
ShareService proxy = CommonBeanFactory.getBean(ShareService.class);
panelIds.forEach(panelId -> proxy.delete(panelId, type));
}
if (CollectionUtils.isEmpty(targetIds)) return;
if (CollectionUtils.isEmpty(targetIds))
return;
long now = System.currentTimeMillis();
List<PanelShare> shares = panelIds.stream().flatMap(panelId ->
targetIds.stream().map(targetId -> {
PanelShare share = new PanelShare();
share.setCreateTime(now);
share.setPanelGroupId(panelId);
share.setTargetId(targetId);
share.setType(type);
return share;
})
).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(shares)){
List<PanelShare> shares = panelIds.stream().flatMap(panelId -> targetIds.stream().map(targetId -> {
PanelShare share = new PanelShare();
share.setCreateTime(now);
share.setPanelGroupId(panelId);
share.setTargetId(targetId);
share.setType(type);
return share;
})).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(shares)) {
extPanelShareMapper.batchInsert(shares, AuthUtils.getUser().getUsername());
}
@ -241,15 +250,17 @@ public class ShareService {
if (type == 1) {
authURD.setRoleIds(targetIds);
}
if(type == 2) {
if (type == 2) {
authURD.setDeptIds(targetIds);
}
userIdSet = AuthUtils.userIdsByURD(authURD);
CurrentUserDto user = AuthUtils.getUser();
String msg = StringUtils.joinWith("", panelGroups.stream().map(PanelGroup::getName).collect(Collectors.toList()));
String msg = StringUtils.joinWith("",
panelGroups.stream().map(PanelGroup::getName).collect(Collectors.toList()));
Gson gson = new Gson();
userIdSet.forEach(userId -> DeMsgutil.sendMsg(userId, 2L, user.getNickName()+" 分享了仪表板【"+msg+"】给您,请查收!", gson.toJson(panelIds)));
userIdSet.forEach(userId -> DeMsgutil.sendMsg(userId, 2L, user.getNickName() + " 分享了仪表板【" + msg + "】给您,请查收!",
gson.toJson(panelIds)));
}
@ -259,14 +270,15 @@ public class ShareService {
/**
* panel_group_id建了索引 效率不会很差
*
* @param panel_group_id
*/
@Transactional
public void delete(String panel_group_id, Integer type){
public void delete(String panel_group_id, Integer type) {
PanelShareExample example = new PanelShareExample();
PanelShareExample.Criteria criteria = example.createCriteria();
criteria.andPanelGroupIdEqualTo(panel_group_id);
if(type != null){
if (type != null) {
criteria.andTypeEqualTo(type);
}
mapper.deleteByExample(example);
@ -281,7 +293,7 @@ public class ShareService {
return extPanelShareMapper.queryOut(username);
}
public List<PanelShareDto> queryTree(BaseGridRequest request){
public List<PanelShareDto> queryTree(BaseGridRequest request) {
CurrentUserDto user = AuthUtils.getUser();
Long userId = user.getUserId();
Long deptId = user.getDeptId();
@ -293,14 +305,18 @@ public class ShareService {
param.put("roleIds", roleIds);
List<PanelSharePo> datas = extPanelShareMapper.query(param);
List<PanelShareDto> dtoLists = datas.stream().map(po -> BeanUtils.copyBean(new PanelShareDto(), po)).collect(Collectors.toList());
List<PanelShareDto> dtoLists = datas.stream().map(po -> BeanUtils.copyBean(new PanelShareDto(), po))
.collect(Collectors.toList());
return convertTree(dtoLists);
}
//List构建Tree
private List<PanelShareDto> convertTree(List<PanelShareDto> datas){
// List构建Tree
private List<PanelShareDto> convertTree(List<PanelShareDto> datas) {
String username = AuthUtils.getUser().getUsername();
Map<String, List<PanelShareDto>> map = datas.stream().filter(panelShareDto -> StringUtils.isNotEmpty(panelShareDto.getCreator()) && !StringUtils.equals(username, panelShareDto.getCreator())).collect(Collectors.groupingBy(PanelShareDto::getCreator));
Map<String, List<PanelShareDto>> map = datas.stream()
.filter(panelShareDto -> StringUtils.isNotEmpty(panelShareDto.getCreator())
&& !StringUtils.equals(username, panelShareDto.getCreator()))
.collect(Collectors.groupingBy(PanelShareDto::getCreator));
return map.entrySet().stream().map(entry -> {
PanelShareDto panelShareDto = new PanelShareDto();
panelShareDto.setName(entry.getKey());
@ -309,15 +325,19 @@ public class ShareService {
}).collect(Collectors.toList());
}
public List<PanelShare> queryWithResource(BaseGridRequest request){
GridExample example = request.convertExample();
return extPanelShareMapper.queryWithResource(example);
public List<PanelShare> queryWithResource(PanelShareSearchRequest request) {
String username = AuthUtils.getUser().getUsername();
request.setCurrentUserName(username);
return extPanelShareMapper.queryWithResource(request);
}
public List<PanelShareOutDTO> queryTargets(String panelId) {
List<PanelShareOutDTO> targets = extPanelShareMapper.queryTargets(panelId);
if (CollectionUtils.isEmpty(targets)) return new ArrayList<>();
return targets.stream().filter(item -> StringUtils.isNotEmpty(item.getTargetName())).collect(Collectors.toList());
String username = AuthUtils.getUser().getUsername();
List<PanelShareOutDTO> targets = extPanelShareMapper.queryTargets(panelId, username);
if (CollectionUtils.isEmpty(targets))
return new ArrayList<>();
return targets.stream().filter(item -> StringUtils.isNotEmpty(item.getTargetName()))
.collect(Collectors.toList());
}
public void removeShares(PanelShareRemoveRequest removeRequest) {

View File

@ -0,0 +1,53 @@
import request from '@/utils/request'
import { panelInit } from '@/components/canvas/utils/utils'
import store from '@/store'
export function proxyInitPanelData(panelId, proxy, callback) {
// 加载视图数据
findOne(panelId, proxy).then(response => {
// 初始化视图data和style 数据
panelInit(JSON.parse(response.data.panelData), JSON.parse(response.data.panelStyle))
// 设置当前仪表板全局信息
store.dispatch('panel/setPanelInfo', {
id: response.data.id,
name: response.data.name,
privileges: response.data.privileges,
proxy: proxy.userId
})
// 刷新联动信息
getPanelAllLinkageInfo(panelId, proxy).then(rsp => {
store.commit('setNowPanelTrackInfo', rsp.data)
})
// 刷新跳转信息
queryPanelJumpInfo(panelId, proxy).then(rsp => {
store.commit('setNowPanelJumpInfo', rsp.data)
})
callback(response)
})
}
export function findOne(id, data) {
return request({
url: '/panel/group/proxy/findOne/' + id,
method: 'post',
loading: true,
data
})
}
export function getPanelAllLinkageInfo(panelId, data) {
return request({
url: '/linkage/proxy/getPanelAllLinkageInfo/' + panelId,
method: 'post',
data
})
}
export function queryPanelJumpInfo(panelId, data) {
return request({
url: '/linkJump/proxy/queryPanelJumpInfo/' + panelId,
method: 'post',
data
})
}

View File

@ -433,6 +433,10 @@ export default {
...this.filter,
cache: cache
}
if (this.panelInfo.proxy) {
// method = viewInfo
requestInfo.proxy = { userId: this.panelInfo.proxy }
}
method(id, this.panelInfo.id, requestInfo).then(response => {
// echart
if (response.success) {

View File

@ -73,6 +73,9 @@ export default {
},
manualModify() {
return !!this.element.options.manualModify
},
panelInfo() {
return this.$store.state.panel.panelInfo
}
},
@ -96,9 +99,13 @@ export default {
if (!token && linkToken) {
method = linkMultFieldValues
}
const param = { fieldIds: this.element.options.attrs.fieldId.split(',') }
if (this.panelInfo.proxy) {
param.userId = this.panelInfo.proxy
}
this.element.options.attrs.fieldId &&
this.element.options.attrs.fieldId.length > 0 &&
method({ fieldIds: this.element.options.attrs.fieldId.split(',') }).then(res => {
method(param).then(res => {
this.datas = this.optionDatas(res.data)
}) || (this.element.options.value = '')
},

View File

@ -93,6 +93,9 @@ export default {
},
manualModify() {
return !!this.element.options.manualModify
},
panelInfo() {
return this.$store.state.panel.panelInfo
}
},
watch: {
@ -119,9 +122,13 @@ export default {
if (!token && linkToken) {
method = linkMultFieldValues
}
const param = { fieldIds: this.element.options.attrs.fieldId.split(',') }
if (this.panelInfo.proxy) {
param.userId = this.panelInfo.proxy
}
this.element.options.attrs.fieldId &&
this.element.options.attrs.fieldId.length > 0 &&
method({ fieldIds: this.element.options.attrs.fieldId.split(',') }).then(res => {
method(param).then(res => {
this.datas = this.optionDatas(res.data)
}) || (this.element.options.value = '')
},

View File

@ -5,7 +5,8 @@ const getDefaultState = () => {
panelInfo: {
id: null,
name: '',
preStyle: null
preStyle: null,
proxy: null
},
canvasStyleDataTemp: null, // 页面全局临时存储数据
componentDataTemp: null, // 画布组件临时存储数据

View File

@ -208,9 +208,7 @@ export default {
},
queryShareNodeIds(callBack) {
const conditionResourceId = { field: 'panel_group_id', operator: 'eq', value: this.resourceId }
const conditionType = { field: 'type', operator: 'eq', value: this.type }
const param = { conditions: [conditionResourceId, conditionType] }
const param = { resourceId: this.resourceId, type: this.type }
loadShares(param).then(res => {
const shares = res.data
const nodeIds = shares.map(share => share.targetId)

View File

@ -93,9 +93,7 @@ export default {
},
queryShareNodeIds(callBack) {
const conditionResourceId = { field: 'panel_group_id', operator: 'eq', value: this.resourceId }
const conditionType = { field: 'type', operator: 'eq', value: this.type }
const param = { conditions: [conditionResourceId, conditionType] }
const param = { resourceId: this.resourceId, type: this.type }
loadShares(param).then(res => {
const shares = res.data
const nodeIds = shares.map(share => share.targetId)

View File

@ -50,7 +50,8 @@
<script>
import { loadTree, loadShareOutTree, removeShares } from '@/api/panel/share'
import { uuid } from 'vue-uuid'
import { get, initPanelData } from '@/api/panel/panel'
import { initPanelData } from '@/api/panel/panel'
import { proxyInitPanelData } from '@/api/panel/shareProxy'
import bus from '@/utils/bus'
export default {
name: 'ShareTree',
@ -103,7 +104,11 @@ export default {
return loadShareOutTree()
},
handleNodeClick(data) {
initPanelData(data.id, function() {
if (!data || !data.userId || !data.id) {
return
}
const param = { userId: data.userId }
proxyInitPanelData(data.id, param, function() {
bus.$emit('set-panel-show-type', 1)
})
this.$refs['botTree'].setCurrentKey(null)

View File

@ -100,9 +100,7 @@ export default {
},
queryShareNodeIds(callBack) {
const conditionResourceId = { field: 'panel_group_id', operator: 'eq', value: this.resourceId }
const conditionType = { field: 'type', operator: 'eq', value: this.type }
const param = { conditions: [conditionResourceId, conditionType] }
const param = { resourceId: this.resourceId, type: this.type }
loadShares(param).then(res => {
const shares = res.data
const nodeIds = shares.map(share => share.targetId)