diff --git a/backend/src/main/java/io/dataease/commons/constants/PanelConstants.java b/backend/src/main/java/io/dataease/commons/constants/PanelConstants.java index a412b9bddf..22b00b9587 100644 --- a/backend/src/main/java/io/dataease/commons/constants/PanelConstants.java +++ b/backend/src/main/java/io/dataease/commons/constants/PanelConstants.java @@ -41,6 +41,9 @@ public class PanelConstants { // 外部模板新建 public static final String NEW_OUTER_TEMPLATE = "new_outer_template"; + // 模板市场新建 + public static final String NEW_MARKET_TEMPLATE = "new_market_template"; + } //仪表板类型 diff --git a/backend/src/main/java/io/dataease/commons/constants/ParamConstants.java b/backend/src/main/java/io/dataease/commons/constants/ParamConstants.java index e1dc4b9285..9c309442ed 100644 --- a/backend/src/main/java/io/dataease/commons/constants/ParamConstants.java +++ b/backend/src/main/java/io/dataease/commons/constants/ParamConstants.java @@ -111,7 +111,9 @@ public interface ParamConstants { FRONT_TIME_OUT("basic.frontTimeOut"), MSG_TIME_OUT("basic.msgTimeOut"), DEFAULT_LOGIN_TYPE("basic.loginType"), - OPEN_HOME_PAGE("ui.openHomePage"); + OPEN_HOME_PAGE("ui.openHomePage"), + TEMPLATE_MARKET_ULR("basic.templateMarketUlr"), + TEMPLATE_ACCESS_KEY("basic.templateAccessKey"); private String value; diff --git a/backend/src/main/java/io/dataease/commons/utils/HttpClientUtil.java b/backend/src/main/java/io/dataease/commons/utils/HttpClientUtil.java index 70565fed75..d0faaf8d2a 100755 --- a/backend/src/main/java/io/dataease/commons/utils/HttpClientUtil.java +++ b/backend/src/main/java/io/dataease/commons/utils/HttpClientUtil.java @@ -64,7 +64,6 @@ public class HttpClientUtil { throw new RuntimeException("HttpClient构建失败", e); } } - /** * Get http请求 * diff --git a/backend/src/main/java/io/dataease/controller/request/panel/PanelGroupRequest.java b/backend/src/main/java/io/dataease/controller/request/panel/PanelGroupRequest.java index 433dfe8706..a9da1cb542 100644 --- a/backend/src/main/java/io/dataease/controller/request/panel/PanelGroupRequest.java +++ b/backend/src/main/java/io/dataease/controller/request/panel/PanelGroupRequest.java @@ -27,6 +27,8 @@ public class PanelGroupRequest extends PanelGroupDTO { private String templateId; @ApiModelProperty("静态文件") private String staticResource; + @ApiModelProperty("模板链接") + private String templateUrl; public PanelGroupRequest() { } diff --git a/backend/src/main/java/io/dataease/controller/request/templateMarket/TemplateMarketSearchRequest.java b/backend/src/main/java/io/dataease/controller/request/templateMarket/TemplateMarketSearchRequest.java new file mode 100644 index 0000000000..d2a89a130a --- /dev/null +++ b/backend/src/main/java/io/dataease/controller/request/templateMarket/TemplateMarketSearchRequest.java @@ -0,0 +1,12 @@ +package io.dataease.controller.request.templateMarket; + +import io.dataease.dto.templateMarket.TemplateMarketDTO; + +/** + * Author: wangjiahao + * Date: 2022/7/15 + * Description: + */ +public class TemplateMarketSearchRequest extends TemplateMarketDTO { + +} diff --git a/backend/src/main/java/io/dataease/controller/sys/SysUserController.java b/backend/src/main/java/io/dataease/controller/sys/SysUserController.java index 05eeeb75ee..b161131bcb 100644 --- a/backend/src/main/java/io/dataease/controller/sys/SysUserController.java +++ b/backend/src/main/java/io/dataease/controller/sys/SysUserController.java @@ -6,6 +6,8 @@ import com.github.xiaoymin.knife4j.annotations.ApiSupport; import io.dataease.auth.annotation.DeLog; import io.dataease.auth.api.dto.CurrentUserDto; import io.dataease.commons.constants.SysLogConstants; +import io.dataease.commons.utils.BeanUtils; +import io.dataease.controller.sys.request.UserGridRequest; import io.dataease.exception.DataEaseException; import io.dataease.i18n.Translator; import io.dataease.plugins.common.base.domain.SysRole; @@ -58,7 +60,7 @@ public class SysUserController { @ApiImplicitParam(name = "request", value = "查询条件", required = true) }) public Pager> userGrid(@PathVariable int goPage, @PathVariable int pageSize, - @RequestBody BaseGridRequest request) { + @RequestBody UserGridRequest request) { Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, sysUserService.query(request)); } @@ -66,7 +68,8 @@ public class SysUserController { @ApiIgnore @PostMapping("/userLists") public List userLists(@RequestBody BaseGridRequest request) { - return sysUserService.query(request); + UserGridRequest userGridRequest = BeanUtils.copyBean(new UserGridRequest(), request); + return sysUserService.query(userGridRequest); } @ApiOperation("创建用户") diff --git a/backend/src/main/java/io/dataease/controller/sys/request/UserGridRequest.java b/backend/src/main/java/io/dataease/controller/sys/request/UserGridRequest.java index 55da77bea9..029b889972 100644 --- a/backend/src/main/java/io/dataease/controller/sys/request/UserGridRequest.java +++ b/backend/src/main/java/io/dataease/controller/sys/request/UserGridRequest.java @@ -1,18 +1,13 @@ package io.dataease.controller.sys.request; +import io.dataease.controller.sys.base.BaseGridRequest; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; @Data -public class UserGridRequest implements Serializable { - @ApiModelProperty("快速检索") - private String quick; - @ApiModelProperty("名称") - private String name; - @ApiModelProperty("组织") - private String deptId; - @ApiModelProperty("状态") - private String enabled; +public class UserGridRequest extends BaseGridRequest implements Serializable { + @ApiModelProperty("关键字") + private String keyWord; } diff --git a/backend/src/main/java/io/dataease/controller/sys/response/BasicInfo.java b/backend/src/main/java/io/dataease/controller/sys/response/BasicInfo.java index 91ced9becc..c2ce08e501 100644 --- a/backend/src/main/java/io/dataease/controller/sys/response/BasicInfo.java +++ b/backend/src/main/java/io/dataease/controller/sys/response/BasicInfo.java @@ -16,5 +16,9 @@ public class BasicInfo implements Serializable { private String openHomePage; @ApiModelProperty("默认登录方式") private Integer loginType = 0; + @ApiModelProperty("模板市场链接") + private String templateMarketUlr; + @ApiModelProperty("模板市场AccessKey") + private String templateAccessKey; } diff --git a/backend/src/main/java/io/dataease/controller/templateMarket/TemplateMarketController.java b/backend/src/main/java/io/dataease/controller/templateMarket/TemplateMarketController.java new file mode 100644 index 0000000000..274a9da8ab --- /dev/null +++ b/backend/src/main/java/io/dataease/controller/templateMarket/TemplateMarketController.java @@ -0,0 +1,44 @@ +package io.dataease.controller.templateMarket; + +import com.github.xiaoymin.knife4j.annotations.ApiSupport; +import io.dataease.controller.request.templateMarket.TemplateMarketSearchRequest; +import io.dataease.dto.templateMarket.MarketBaseResponse; +import io.dataease.dto.templateMarket.TemplateMarketDTO; +import io.dataease.service.templateMarket.TemplateMarketService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * Author: wangjiahao + * Date: 2022/7/15 + * Description: + */ +@RestController +@Api(tags = "系统:模板市场") +@ApiSupport(order = 220) +@RequestMapping("/template/market") +public class TemplateMarketController { + + @Resource + private TemplateMarketService marketService; + + + @ApiOperation("查询模板") + @PostMapping("/search") + private MarketBaseResponse searchTemplate(@RequestBody TemplateMarketSearchRequest request){ + return marketService.searchTemplate(request); + } + + @ApiOperation("查询分类") + @GetMapping("/categories") + private List categories(){ + return marketService.getCategories(); + } + + +} diff --git a/backend/src/main/java/io/dataease/dto/panel/PanelTemplateFileDTO.java b/backend/src/main/java/io/dataease/dto/panel/PanelTemplateFileDTO.java new file mode 100644 index 0000000000..bee2d2cf96 --- /dev/null +++ b/backend/src/main/java/io/dataease/dto/panel/PanelTemplateFileDTO.java @@ -0,0 +1,20 @@ +package io.dataease.dto.panel; + +import io.dataease.plugins.common.base.domain.PanelTemplateWithBLOBs; +import lombok.Data; + +/** + * Author: wangjiahao + * Date: 2022/7/14 + * Description: + */ +@Data +public class PanelTemplateFileDTO extends PanelTemplateWithBLOBs { + + private String panelStyle; + + private String panelData; + + private String staticResource; + +} diff --git a/backend/src/main/java/io/dataease/dto/templateMarket/MarketBaseResponse.java b/backend/src/main/java/io/dataease/dto/templateMarket/MarketBaseResponse.java new file mode 100644 index 0000000000..3fd26687b9 --- /dev/null +++ b/backend/src/main/java/io/dataease/dto/templateMarket/MarketBaseResponse.java @@ -0,0 +1,25 @@ +package io.dataease.dto.templateMarket; + +import lombok.Data; + +import java.util.List; + +/** + * Author: wangjiahao + * Date: 2022/7/15 + * Description: + */ +@Data +public class MarketBaseResponse { + private String baseUrl; + + private List contents; + + public MarketBaseResponse() { + } + + public MarketBaseResponse(String baseUrl, List contents) { + this.baseUrl = baseUrl; + this.contents = contents; + } +} diff --git a/backend/src/main/java/io/dataease/dto/templateMarket/MarketCategory.java b/backend/src/main/java/io/dataease/dto/templateMarket/MarketCategory.java new file mode 100644 index 0000000000..17be643e1d --- /dev/null +++ b/backend/src/main/java/io/dataease/dto/templateMarket/MarketCategory.java @@ -0,0 +1,15 @@ +package io.dataease.dto.templateMarket; + +import lombok.Data; + +/** + * Author: wangjiahao + * Date: 2022/7/15 + * Description: + */ +@Data +public class MarketCategory { + private String id; + private String name; + private String slug; +} diff --git a/backend/src/main/java/io/dataease/dto/templateMarket/MarketMetas.java b/backend/src/main/java/io/dataease/dto/templateMarket/MarketMetas.java new file mode 100644 index 0000000000..f60ea8354a --- /dev/null +++ b/backend/src/main/java/io/dataease/dto/templateMarket/MarketMetas.java @@ -0,0 +1,13 @@ +package io.dataease.dto.templateMarket; + +import lombok.Data; + +/** + * Author: wangjiahao + * Date: 2022/7/15 + * Description: + */ +@Data +public class MarketMetas { + private String theme_repo; +} diff --git a/backend/src/main/java/io/dataease/dto/templateMarket/TemplateCategory.java b/backend/src/main/java/io/dataease/dto/templateMarket/TemplateCategory.java new file mode 100644 index 0000000000..dd78b81ec4 --- /dev/null +++ b/backend/src/main/java/io/dataease/dto/templateMarket/TemplateCategory.java @@ -0,0 +1,17 @@ +package io.dataease.dto.templateMarket; + +import lombok.Data; + +/** + * Author: wangjiahao + * Date: 2022/7/18 + * Description: + */ +@Data +public class TemplateCategory { + private Integer id; + + private String name; + + private String slug; +} diff --git a/backend/src/main/java/io/dataease/dto/templateMarket/TemplateMarketDTO.java b/backend/src/main/java/io/dataease/dto/templateMarket/TemplateMarketDTO.java new file mode 100644 index 0000000000..9614dc3dc0 --- /dev/null +++ b/backend/src/main/java/io/dataease/dto/templateMarket/TemplateMarketDTO.java @@ -0,0 +1,24 @@ +package io.dataease.dto.templateMarket; + +import lombok.Data; + +import java.util.List; + +/** + * Author: wangjiahao + * Date: 2022/7/15 + * Description: + */ +@Data +public class TemplateMarketDTO { + private String id; + private String title; + private String status; + private String slug; + private String editorType; + private String summary; + private String thumbnail; + private Boolean showFlag = true; + private List categories; + private MarketMetas metas; +} diff --git a/backend/src/main/java/io/dataease/ext/ExtSysUserMapper.xml b/backend/src/main/java/io/dataease/ext/ExtSysUserMapper.xml index 1f713a8c2b..7a8066ec89 100644 --- a/backend/src/main/java/io/dataease/ext/ExtSysUserMapper.xml +++ b/backend/src/main/java/io/dataease/ext/ExtSysUserMapper.xml @@ -40,7 +40,15 @@ d.pid, d.NAME AS dept_name FROM - sys_user u + ( + select * from sys_user + + where + nick_name like concat('%', #{extendCondition} , '%') + or + email like concat('%', #{extendCondition} , '%') + + ) u LEFT JOIN sys_dept d ON d.dept_id = u.dept_id LEFT JOIN sys_users_roles sur ON sur.user_id = u.user_id LEFT JOIN sys_role r ON r.role_id = sur.role_id diff --git a/backend/src/main/java/io/dataease/listener/RowPermissionMergeListener.java b/backend/src/main/java/io/dataease/listener/RowPermissionMergeListener.java new file mode 100644 index 0000000000..204708fc47 --- /dev/null +++ b/backend/src/main/java/io/dataease/listener/RowPermissionMergeListener.java @@ -0,0 +1,51 @@ +package io.dataease.listener; + +import io.dataease.plugins.common.base.domain.SysStartupJob; +import io.dataease.plugins.common.base.mapper.SysStartupJobMapper; +import io.dataease.plugins.config.SpringContextUtil; +import io.dataease.plugins.loader.ClassloaderResponsity; +import io.dataease.plugins.xpack.auth.service.RowPermissionTreeService; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * @Author gin + * @Date 2022/07/10 10:01 上午 + */ +@Component +public class RowPermissionMergeListener implements ApplicationListener { + private final Logger logger = LoggerFactory.getLogger(ClassloaderResponsity.class); + public static final String JOB_ID = "rowPermissionsMerge"; + @Resource + private SysStartupJobMapper sysStartupJobMapper; + + @Override + public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { + Map beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((RowPermissionTreeService.class)); + if (beansOfType.keySet().size() > 0) { + System.out.println("====row permissions merge [start]===="); + logger.info("====row permissions merge [start]===="); + + SysStartupJob sysStartupJob = sysStartupJobMapper.selectByPrimaryKey(JOB_ID); + if (ObjectUtils.isNotEmpty(sysStartupJob) && StringUtils.equalsIgnoreCase(sysStartupJob.getStatus(), "ready")) { + System.out.println("====row permissions merge [doing]===="); + logger.info("====row permissions merge [doing]===="); + + RowPermissionTreeService rowPermissionTreeService = SpringContextUtil.getBean(RowPermissionTreeService.class); + rowPermissionTreeService.mergeOldPermissions(); + sysStartupJob.setStatus("done"); + sysStartupJobMapper.updateByPrimaryKey(sysStartupJob); + } + System.out.println("====row permissions merge [end]===="); + logger.info("====row permissions merge [end]===="); + } + } +} diff --git a/backend/src/main/java/io/dataease/map/api/MapApi.java b/backend/src/main/java/io/dataease/map/api/MapApi.java index 88e179ddbf..58a839443f 100644 --- a/backend/src/main/java/io/dataease/map/api/MapApi.java +++ b/backend/src/main/java/io/dataease/map/api/MapApi.java @@ -10,21 +10,13 @@ import java.util.List; @RequestMapping("/api/map") public interface MapApi { - @GetMapping("/resourceFull/{areaCode}") - String resourceFull(@PathVariable String areaCode); - @GetMapping("/asyncGeometry") - String asyncGeometry(); @GetMapping("/areaEntitys/{pcode}") List areaEntitys(@PathVariable String pcode); - /** - * 由于api有限流机制 - * 请求失败后 调用重试方法 - * @param areaCode - */ - @GetMapping("/retry/{areaCode}") - void retry(@PathVariable String areaCode); + @GetMapping("/globalEntitys/{pcode}") + List globalEntitys(@PathVariable String pcode); + } diff --git a/backend/src/main/java/io/dataease/map/dto/entity/Constants.java b/backend/src/main/java/io/dataease/map/dto/entity/Constants.java index 5cd4bbcee8..e70c6e2b10 100644 --- a/backend/src/main/java/io/dataease/map/dto/entity/Constants.java +++ b/backend/src/main/java/io/dataease/map/dto/entity/Constants.java @@ -2,6 +2,9 @@ package io.dataease.map.dto.entity; public class Constants { + public static final String COUNTRY_CODE = "国gb"; + public static final String COUNTRY_NAME = "国name"; + public static final String PROVINCE_CODE = "省gb"; public static final String PROVINCE_NAME = "省name"; diff --git a/backend/src/main/java/io/dataease/map/server/MapServer.java b/backend/src/main/java/io/dataease/map/server/MapServer.java index d3cdc5af3e..82e54caca8 100644 --- a/backend/src/main/java/io/dataease/map/server/MapServer.java +++ b/backend/src/main/java/io/dataease/map/server/MapServer.java @@ -15,28 +15,9 @@ import java.util.List; @RestController public class MapServer implements MapApi { - - @Resource private MapService mapService; - @Override - public String resourceFull(@PathVariable String areaCode) { - return mapService.geometry(areaCode); - } - - @Override - public String asyncGeometry() { - try { - List areaEntities = mapService.areaEntities(); - MapUtils.recursionWriteFull(areaEntities); - }catch (Exception e) { - LogUtil.error(e); - return e.getMessage(); - } - return "async success"; - } - @Override public List areaEntitys(@PathVariable String pcode) { List areaEntities = mapService.areaEntities(); @@ -47,11 +28,11 @@ public class MapServer implements MapApi { } @Override - public void retry(@PathVariable String areaCode) { - List areaEntities = mapService.areaEntities(); - AreaEntity areaEntity = MapUtils.nodeByCode(areaEntities, areaCode); - List targets = new ArrayList<>(); - targets.add(areaEntity); - MapUtils.recursionWriteFull(targets); + public List globalEntitys(String pcode) { + List areaEntities = mapService.globalEntities(); + if (StringUtils.equals(pcode, "0")) { + return areaEntities; + } + return mapService.entitysByPid(areaEntities, pcode); } } diff --git a/backend/src/main/java/io/dataease/map/service/MapService.java b/backend/src/main/java/io/dataease/map/service/MapService.java index d159cac3cb..ac21dc9052 100644 --- a/backend/src/main/java/io/dataease/map/service/MapService.java +++ b/backend/src/main/java/io/dataease/map/service/MapService.java @@ -1,6 +1,5 @@ package io.dataease.map.service; - import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.io.file.FileReader; import io.dataease.map.dto.entity.AreaEntity; @@ -14,22 +13,20 @@ import java.util.List; @Service public class MapService { - private static final String dirPath = "/opt/dataease/data/feature/"; - // 要不要加缓存呢? - public String geometry(String areaCode) { - String path = dirPath + "full/" + areaCode + "_full.json"; - FileReader fileReader = new FileReader(path); - return fileReader.readString(); - } - @Cacheable("sys_map_areas") public List areaEntities() { List areaEntities = MapUtils.readAreaEntity(); return areaEntities; } + @Cacheable("sys_map_areas") + public List globalEntities() { + List areaEntities = MapUtils.readGlobalAreaEntity(); + return areaEntities; + } + public List entitysByPid(List entities, String pid) { for (int i = 0; i < entities.size(); i++) { AreaEntity areaEntity = entities.get(i); @@ -39,7 +36,7 @@ public class MapService { if (CollectionUtil.isNotEmpty(areaEntity.getChildren())) { List areaEntities = entitysByPid(areaEntity.getChildren(), pid); - if (null != areaEntities){ + if (null != areaEntities) { return areaEntities; } } @@ -48,6 +45,4 @@ public class MapService { } - - } diff --git a/backend/src/main/java/io/dataease/map/utils/MapUtils.java b/backend/src/main/java/io/dataease/map/utils/MapUtils.java index a016cecd48..7a35805a96 100644 --- a/backend/src/main/java/io/dataease/map/utils/MapUtils.java +++ b/backend/src/main/java/io/dataease/map/utils/MapUtils.java @@ -1,17 +1,16 @@ package io.dataease.map.utils; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.io.file.FileWriter; import cn.hutool.core.util.StrUtil; -import cn.hutool.json.JSONUtil; +import io.dataease.map.dto.entity.AreaEntity; +import io.dataease.map.dto.entity.Constants; import io.dataease.plugins.common.base.domain.AreaMapping; import io.dataease.plugins.common.base.domain.AreaMappingExample; +import io.dataease.plugins.common.base.domain.AreaMappingGlobal; +import io.dataease.plugins.common.base.domain.AreaMappingGlobalExample; +import io.dataease.plugins.common.base.mapper.AreaMappingGlobalMapper; import io.dataease.plugins.common.base.mapper.AreaMappingMapper; -import io.dataease.commons.utils.LogUtil; -import io.dataease.map.dto.entity.*; -import io.dataease.map.dto.entity.Properties; -import io.dataease.map.dto.response.MapResponse; -import io.dataease.map.dto.response.MapResultDto; + +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.*; @@ -21,24 +20,33 @@ import java.util.stream.Collectors; @Component public class MapUtils { - private static AreaMappingMapper areaMappingMapper; + private static AreaMappingGlobalMapper areaMappingGlobalMapper; + @Autowired public void setAreaMappingMapper(AreaMappingMapper areaMappingMapper) { MapUtils.areaMappingMapper = areaMappingMapper; } - private static final String path = "/opt/dataease/data/行政区划列表2020-03.xlsx"; - private static final String featureDir = "/opt/dataease/data/feature/"; + @Autowired + public void setAreaMappingGlobalMapper(AreaMappingGlobalMapper areaMappingGlobalMapper) { + MapUtils.areaMappingGlobalMapper = areaMappingGlobalMapper; + } + private static final String featureDir = "/opt/dataease/data/feature/"; public static String formatCode(String code) { return code; } + public static List readGlobalCodes() { + AreaMappingGlobalExample example = new AreaMappingGlobalExample(); + List mappingGlobals = areaMappingGlobalMapper.selectByExample(example); + return mappingGlobals; + } - public static List> readCodeList( ) { + public static List> readCodeList() { AreaMappingExample example = new AreaMappingExample(); List areaMappings = areaMappingMapper.selectByExample(example); return areaMappings.stream().map(mapping -> { @@ -54,6 +62,74 @@ public class MapUtils { }).collect(Collectors.toList()); } + public static List readGlobalAreaEntity() { + List maps = readGlobalCodes(); + Map countryMap = new ConcurrentHashMap<>(); + Map provinceMap = new ConcurrentHashMap<>(); + Map cityMap = new ConcurrentHashMap<>(); + Map countyMap = new ConcurrentHashMap<>(); + AreaEntity globalRoot = globalRoot(); + maps.stream().forEach(map -> { + String country_code = map.getCountryCode(); + String province_code = map.getProvinceCode(); + String city_code = map.getCityCode(); + String county_code = map.getCountyCode(); + // 是否是跨级直辖 + Boolean isCrossLevel = StrUtil.equals(province_code, city_code) + && !StrUtil.equals(province_code, "156710000"); + + if (!countryMap.containsKey(country_code)) { + String country_name = map.getCountryName(); + AreaEntity child = AreaEntity.builder().code(country_code).name(country_name) + .pcode(globalRoot.getCode()).build(); + + countryMap.put(country_code, child); + globalRoot.addChild(child); + } + + AreaEntity currentCountry = countryMap.get(country_code); + + String province_name = map.getProvinceName(); + if (!provinceMap.containsKey(province_code)) { + AreaEntity child = AreaEntity.builder().code(province_code).name(province_name) + .pcode(currentCountry.getCode()).build(); + provinceMap.put(province_code, child); + currentCountry.addChild(child); + } + + // 当前省 + AreaEntity currentProvince = provinceMap.get(province_code); + + String city_name = map.getCityName(); + if (isCrossLevel) { + city_code = county_code; + city_name = map.getCountyName(); + } + if (StringUtils.isNotBlank(city_code) && !cityMap.containsKey(city_code)) { + AreaEntity child = AreaEntity.builder().code(city_code).name(city_name).pcode(currentProvince.getCode()) + .build(); + cityMap.put(city_code, child); + currentProvince.addChild(child); + } + if (StringUtils.isNotBlank(county_code) && !isCrossLevel) { + // 当前市 + AreaEntity currentCity = cityMap.get(city_code); + if (!countyMap.containsKey(county_code)) { + String county_name = map.getCountyName(); + AreaEntity child = AreaEntity.builder().code(county_code).name(county_name) + .pcode(currentCity.getCode()) + .build(); + countyMap.put(county_code, child); + currentCity.addChild(child); + } + } + }); + + List result = new ArrayList<>(); + result.add(globalRoot); + return result; + } + public static List readAreaEntity() { List> maps = readCodeList(); @@ -75,15 +151,15 @@ public class MapUtils { // 是否是跨级直辖 Boolean isCrossLevel = StrUtil.equals(province_code, city_code) && !StrUtil.equals(province_code, "710000"); - if (!provinceMap.containsKey(province_code)) { String province_name = map.get(Constants.PROVINCE_NAME).toString(); - AreaEntity child = AreaEntity.builder().code(province_code).name(province_name).pcode(china.getCode()).build(); + AreaEntity child = AreaEntity.builder().code(province_code).name(province_name).pcode(china.getCode()) + .build(); provinceMap.put(province_code, child); china.addChild(child); } - //当前省 + // 当前省 AreaEntity currentProvince = provinceMap.get(province_code); String city_name = map.get(Constants.CITY_NAME).toString(); @@ -92,16 +168,19 @@ public class MapUtils { city_name = map.get(Constants.COUNTY_NAME).toString(); } if (!cityMap.containsKey(city_code)) { - AreaEntity child = AreaEntity.builder().code(city_code).name(city_name).pcode(currentProvince.getCode()).build(); + AreaEntity child = AreaEntity.builder().code(city_code).name(city_name).pcode(currentProvince.getCode()) + .build(); cityMap.put(city_code, child); currentProvince.addChild(child); } if (!isCrossLevel) { - //当前市 + // 当前市 AreaEntity currentCity = cityMap.get(city_code); if (!countyMap.containsKey(county_code)) { String county_name = map.get(Constants.COUNTY_NAME).toString(); - AreaEntity child = AreaEntity.builder().code(county_code).name(county_name).pcode(currentCity.getCode()).build(); + AreaEntity child = AreaEntity.builder().code(county_code).name(county_name) + .pcode(currentCity.getCode()) + .build(); countyMap.put(county_code, child); currentCity.addChild(child); } @@ -116,148 +195,8 @@ public class MapUtils { return AreaEntity.builder().code("100000").name("中华人民共和国").build(); } - public static void recursionWrite(List areaEntityList) { - areaEntityList.forEach(areaEntity -> { - String code = areaEntity.getCode(); - MapResponse mapResponse = HttpUtils.get(code); - if (StrUtil.equals("1", mapResponse.getStatus()) && StrUtil.equalsAnyIgnoreCase("ok", mapResponse.getInfo()) && StrUtil.equalsAnyIgnoreCase("10000", mapResponse.getInfocode())) { - List districts = mapResponse.getDistricts(); - if (CollectionUtil.isNotEmpty(districts)) { - List kidFeatures = districts.stream().map(district -> buildFeature(district, areaEntity)).collect(Collectors.toList()); - MapResultDto mapResultDto = buildGeometry(kidFeatures); - writeFeatureFile(mapResultDto, areaEntity.getCode()); - } - - } - - if (CollectionUtil.isNotEmpty(areaEntity.getChildren())) { - recursionWrite(areaEntity.getChildren()); - } - }); - + private static AreaEntity globalRoot() { + return AreaEntity.builder().code("000000000").name("地球村").build(); } - public static void recursionWriteFull(List areaEntityList) { - areaEntityList.forEach(areaEntity -> { - - List childrens = areaEntity.getChildren(); - if (CollectionUtil.isEmpty(childrens)) { - childrens = new ArrayList<>(); - childrens.add(areaEntity); - } - - List features = new ArrayList<>(); - - childrens.stream().forEach(child -> { - MapResponse mapResponse = HttpUtils.get(child.getCode()); - if (StrUtil.equals("1", mapResponse.getStatus()) && StrUtil.equalsAnyIgnoreCase("ok", mapResponse.getInfo()) && StrUtil.equalsAnyIgnoreCase("10000", mapResponse.getInfocode())) { - List districts = mapResponse.getDistricts(); - if (CollectionUtil.isNotEmpty(districts)) { - List kidFeatures = districts.stream().map(district -> buildFeature(district, child)).collect(Collectors.toList()); - features.addAll(kidFeatures); - } - }else { - LogUtil.error("请求节点错误 请手动补偿: " + areaEntity.getName() +" -> "+child.getName()); - } - }); - - if (CollectionUtil.isNotEmpty(features)) { - MapResultDto mapResultDto = buildGeometry(features); - writeFeatureFileFull(mapResultDto, areaEntity.getCode() + "_full"); - } - - if (CollectionUtil.isNotEmpty(areaEntity.getChildren())) { - recursionWriteFull(areaEntity.getChildren()); - } - - - }); - - } - - public static Feature buildFeature(District district, AreaEntity areaEntity) { - String type = "Feature"; - Properties properties = new Properties(); - properties.setAdcode(district.getAdcode()); - properties.setName(district.getName()); - properties.setCenter(Arrays.stream(district.getCenter().split(",")).map(Double::parseDouble).collect(Collectors.toList())); - properties.setCentroid(properties.getCenter()); - properties.setChildrenNum(CollectionUtil.isNotEmpty(areaEntity.getChildren()) ? areaEntity.getChildren().size() : 0); - properties.setLevel(district.getLevel()); - Parent parent = new Parent(); - parent.setAdcode(areaEntity.getPcode()); - properties.setParent(parent); - - String polylineStr = district.getPolyline(); - String[] polylines = polylineStr.split("[|]"); - List>>> multiPolygon = Arrays.stream(polylines).map(polyline -> { - String[] strings = polyline.split(";"); - List> line = Arrays.stream(strings).map(str -> { - String[] pointstr = str.split(","); - List strPoint = Arrays.asList(pointstr); - List point = strPoint.stream().map(Double::parseDouble).collect(Collectors.toList()); - return point; - }).collect(Collectors.toList()); - List firstPoint = line.get(0); - List lastPoint = line.get(line.size() - 1); - // 线的起始点和终点没有重合 说明没有闭合 需要手动闭合 - if (firstPoint.get(0) != lastPoint.get(0) || firstPoint.get(1) != lastPoint.get(1)) { - line.add(firstPoint); - } - List>> polygon = new ArrayList<>(); - polygon.add(line); - return polygon; - }).collect(Collectors.toList()); - - Geometry geometry = new Geometry(); - geometry.setType("MultiPolygon"); - geometry.setCoordinates(multiPolygon); - - Feature feature = new Feature(); - feature.setType(type); - feature.setProperties(properties); - feature.setGeometry(geometry); - return feature; - } - - - - - - public static MapResultDto buildGeometry(List features) { - MapResultDto mapResultDto = new MapResultDto(); - mapResultDto.setType("FeatureCollection"); - mapResultDto.setFeatures(features); - return mapResultDto; - } - - public static void writeFeatureFile(MapResultDto mapResultDto, String fileName) { - String path = featureDir + fileName + ".json"; - FileWriter fileWriter = new FileWriter(path); - String content = JSONUtil.toJsonStr(mapResultDto); - fileWriter.write(content); - } - - public static void writeFeatureFileFull(MapResultDto mapResultDto, String fileName) { - String path = featureDir + "full/" + fileName + ".json"; - FileWriter fileWriter = new FileWriter(path); - String content = JSONUtil.toJsonStr(mapResultDto); - fileWriter.write(content); - } - - public static AreaEntity nodeByCode(List areaEntities, String code) { - for (int i = 0; i < areaEntities.size(); i++) { - AreaEntity areaEntity = areaEntities.get(i); - if (StrUtil.equals(areaEntity.getCode(), code)) { - return areaEntity; - } - if (CollectionUtil.isNotEmpty(areaEntity.getChildren())) { - AreaEntity temp = nodeByCode(areaEntity.getChildren(), code); - if (null != temp){ - return temp; - } - } - } - return null; - } } diff --git a/backend/src/main/java/io/dataease/plugins/server/RowPermissionsTreeController.java b/backend/src/main/java/io/dataease/plugins/server/RowPermissionsTreeController.java index 0c60d051cd..251d3563a8 100644 --- a/backend/src/main/java/io/dataease/plugins/server/RowPermissionsTreeController.java +++ b/backend/src/main/java/io/dataease/plugins/server/RowPermissionsTreeController.java @@ -1,17 +1,19 @@ package io.dataease.plugins.server; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import io.dataease.auth.annotation.DePermission; import io.dataease.commons.constants.DePermissionType; import io.dataease.commons.constants.ResourceAuthLevel; +import io.dataease.commons.utils.PageUtils; +import io.dataease.commons.utils.Pager; import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO; +import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeRequest; import io.dataease.plugins.config.SpringContextUtil; import io.dataease.plugins.xpack.auth.service.RowPermissionTreeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -56,8 +58,19 @@ public class RowPermissionsTreeController { @DePermission(type = DePermissionType.DATASET, value = "datasetId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE) @ApiOperation("根据数据集查找行权限") @PostMapping("getByDs") - public List getByDs(@RequestBody DataSetRowPermissionsTreeDTO request) { + public List getByDs(@RequestBody DatasetRowPermissionsTreeRequest request) { RowPermissionTreeService rowPermissionTreeService = SpringContextUtil.getBean(RowPermissionTreeService.class); return rowPermissionTreeService.list(request); } + + @DePermission(type = DePermissionType.DATASET, value = "datasetId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE) + @ApiOperation("根据数据集分页查找行权限") + @PostMapping("getByDsPage/{goPage}/{pageSize}") + public Pager> getByDs(@RequestBody DatasetRowPermissionsTreeRequest request, @PathVariable int goPage, @PathVariable int pageSize) { + RowPermissionTreeService rowPermissionTreeService = SpringContextUtil.getBean(RowPermissionTreeService.class); + Page page = PageHelper.startPage(goPage, pageSize, true); + List list = rowPermissionTreeService.list(request); + Pager> setPageInfo = PageUtils.setPageInfo(page, list); + return setPageInfo; + } } diff --git a/backend/src/main/java/io/dataease/plugins/server/XDeptServer.java b/backend/src/main/java/io/dataease/plugins/server/XDeptServer.java index eed3a3d7b2..5fcb242b89 100644 --- a/backend/src/main/java/io/dataease/plugins/server/XDeptServer.java +++ b/backend/src/main/java/io/dataease/plugins/server/XDeptServer.java @@ -153,22 +153,24 @@ public class XDeptServer { public Pager> userGrid(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody XpackDeptUserRequest request) { DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class); Page page = PageHelper.startPage(goPage, pageSize, true); - List userItems = deptService.queryBinded(request); + List userItems = deptService.queryBinded(request, true); Pager> setPageInfo = PageUtils.setPageInfo(page, userItems); return setPageInfo; } @RequiresPermissions({"dept:edit", "user:edit"}) - @CacheEvict(value = AuthConstants.USER_CACHE_NAME, key = "'user' + #request.userId") @PostMapping("/bindUser") public void bindUser(@RequestBody XpackDeptBindRequest request) { DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class); + request.getUserIds().forEach(userId -> { + CacheUtils.remove( AuthConstants.USER_CACHE_NAME, "user" + userId); + }); deptService.bindUser(request); } @RequiresPermissions({"dept:edit", "user:edit"}) @PostMapping("/unBindUser") - public void unBindUser(@RequestBody XpackDeptUnBindRequest request) { + public void unBindUser(@RequestBody XpackDeptBindRequest request) { DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class); if (CollectionUtil.isEmpty(request.getUserIds())) { DEException.throwException("userIds can not be empty"); diff --git a/backend/src/main/java/io/dataease/plugins/server/XRoleServer.java b/backend/src/main/java/io/dataease/plugins/server/XRoleServer.java index 57aa1fc02f..4cf3741a96 100644 --- a/backend/src/main/java/io/dataease/plugins/server/XRoleServer.java +++ b/backend/src/main/java/io/dataease/plugins/server/XRoleServer.java @@ -12,7 +12,6 @@ import io.dataease.commons.utils.Pager; import io.dataease.listener.util.CacheUtils; import io.dataease.plugins.common.entity.XpackGridRequest; import io.dataease.plugins.config.SpringContextUtil; -import io.dataease.plugins.xpack.role.dto.request.RoleUserMappingDelRequest; import io.dataease.plugins.xpack.role.dto.request.RoleUserMappingRequest; import io.dataease.plugins.xpack.role.dto.request.RoleUserRequest; import io.dataease.plugins.xpack.role.dto.response.RoleUserItem; @@ -120,17 +119,21 @@ public class XRoleServer { @RequiresPermissions({"role:edit", "user:edit"}) @ApiOperation("绑定用户") - @CacheEvict(value = AuthConstants.USER_CACHE_NAME, key = "'user' + #request.userId") @PostMapping("/bindUser") public void bindUser(@RequestBody RoleUserMappingRequest request) { RoleXpackService roleXpackService = SpringContextUtil.getBean(RoleXpackService.class); + if (CollectionUtils.isNotEmpty(request.getUserIds())) { + request.getUserIds().forEach(userId -> { + CacheUtils.remove( AuthConstants.USER_CACHE_NAME, "user" + userId); + }); + } roleXpackService.addUser(request); } @RequiresPermissions({"role:edit", "user:edit"}) @ApiOperation("解绑用户") @PostMapping("/unBindUsers") - public void unBindUsers(@RequestBody RoleUserMappingDelRequest request) { + public void unBindUsers(@RequestBody RoleUserMappingRequest request) { RoleXpackService roleXpackService = SpringContextUtil.getBean(RoleXpackService.class); if (CollectionUtils.isNotEmpty(request.getUserIds())) { request.getUserIds().forEach(userId -> { diff --git a/backend/src/main/java/io/dataease/provider/engine/doris/DorisQueryProvider.java b/backend/src/main/java/io/dataease/provider/engine/doris/DorisQueryProvider.java index 6ca7e49439..ad15ab3251 100644 --- a/backend/src/main/java/io/dataease/provider/engine/doris/DorisQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/engine/doris/DorisQueryProvider.java @@ -154,8 +154,11 @@ public class DorisQueryProvider extends QueryProvider { if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); + if (whereTrees != null) wheres.add(whereTrees); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); if (CollectionUtils.isNotEmpty(sortFields)) { @@ -316,6 +319,8 @@ public class DorisQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -323,6 +328,7 @@ public class DorisQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -393,12 +399,15 @@ public class DorisQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -505,6 +514,8 @@ public class DorisQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -512,6 +523,7 @@ public class DorisQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -616,6 +628,8 @@ public class DorisQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -623,6 +637,7 @@ public class DorisQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -702,12 +717,15 @@ public class DorisQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(yFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); // 外层再次套sql List orders = new ArrayList<>(); @@ -1206,7 +1224,7 @@ public class DorisQueryProvider extends QueryProvider { String cast = String.format(DorisConstants.CAST, originField, y.getDeType() == 2 ? DorisConstants.DEFAULT_INT_FORMAT : DorisConstants.DEFAULT_FLOAT_FORMAT); String agg = String.format(DorisConstants.AGG_FIELD, y.getSummary(), cast); String cast1 = String.format(DorisConstants.CAST, agg, DorisConstants.DEFAULT_FLOAT_FORMAT); - fieldName = String.format(DorisConstants.ROUND, cast1, "2"); + fieldName = String.format(DorisConstants.ROUND, cast1, "8"); } else { String cast = String.format(DorisConstants.CAST, originField, y.getDeType() == 2 ? DorisConstants.DEFAULT_INT_FORMAT : DorisConstants.DEFAULT_FLOAT_FORMAT); if (StringUtils.equalsIgnoreCase(y.getSummary(), "count_distinct")) { diff --git a/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java b/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java index 9693bc5af2..4c85369efc 100644 --- a/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java @@ -155,8 +155,10 @@ public class MysqlQueryProvider extends QueryProvider { if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); + if (whereTrees != null) wheres.add(whereTrees); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); if (CollectionUtils.isNotEmpty(sortFields)) { @@ -317,6 +319,8 @@ public class MysqlQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -324,6 +328,7 @@ public class MysqlQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -394,12 +399,15 @@ public class MysqlQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -506,6 +514,8 @@ public class MysqlQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -513,6 +523,7 @@ public class MysqlQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -617,6 +628,8 @@ public class MysqlQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -624,6 +637,7 @@ public class MysqlQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -703,12 +717,15 @@ public class MysqlQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(yFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); // 外层再次套sql List orders = new ArrayList<>(); @@ -1212,7 +1229,7 @@ public class MysqlQueryProvider extends QueryProvider { String cast = String.format(MysqlConstants.CAST, originField, y.getDeType() == 2 ? MysqlConstants.DEFAULT_INT_FORMAT : MysqlConstants.DEFAULT_FLOAT_FORMAT); String agg = String.format(MysqlConstants.AGG_FIELD, y.getSummary(), cast); String cast1 = String.format(MysqlConstants.CAST, agg, MysqlConstants.DEFAULT_FLOAT_FORMAT); - fieldName = String.format(MysqlConstants.ROUND, cast1, "2"); + fieldName = String.format(MysqlConstants.ROUND, cast1, "8"); } else { String cast = String.format(MysqlConstants.CAST, originField, y.getDeType() == 2 ? MysqlConstants.DEFAULT_INT_FORMAT : MysqlConstants.DEFAULT_FLOAT_FORMAT); if (StringUtils.equalsIgnoreCase(y.getSummary(), "count_distinct")) { diff --git a/backend/src/main/java/io/dataease/provider/query/ck/CKQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/ck/CKQueryProvider.java index 8cd8f47f7e..87a6701f01 100644 --- a/backend/src/main/java/io/dataease/provider/query/ck/CKQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/ck/CKQueryProvider.java @@ -183,8 +183,11 @@ public class CKQueryProvider extends QueryProvider { if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); + if (whereTrees != null) wheres.add(whereTrees); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); List xOrders = new ArrayList<>(); @@ -348,6 +351,8 @@ public class CKQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -355,6 +360,7 @@ public class CKQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -425,12 +431,15 @@ public class CKQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -538,6 +547,8 @@ public class CKQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -545,6 +556,7 @@ public class CKQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -649,6 +661,8 @@ public class CKQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -656,6 +670,7 @@ public class CKQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -735,12 +750,15 @@ public class CKQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(yFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); // 外层再次套sql List orders = new ArrayList<>(); diff --git a/backend/src/main/java/io/dataease/provider/query/db2/Db2QueryProvider.java b/backend/src/main/java/io/dataease/provider/query/db2/Db2QueryProvider.java index 897d40da3d..1b6a7b116f 100644 --- a/backend/src/main/java/io/dataease/provider/query/db2/Db2QueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/db2/Db2QueryProvider.java @@ -158,8 +158,11 @@ public class Db2QueryProvider extends QueryProvider { if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); + if (whereTrees != null) wheres.add(whereTrees); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); List xOrders = new ArrayList<>(); @@ -328,6 +331,8 @@ public class Db2QueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -335,6 +340,7 @@ public class Db2QueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -407,12 +413,15 @@ public class Db2QueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -521,6 +530,8 @@ public class Db2QueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -528,6 +539,7 @@ public class Db2QueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -633,6 +645,8 @@ public class Db2QueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -640,6 +654,7 @@ public class Db2QueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -720,12 +735,15 @@ public class Db2QueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(yFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); // 外层再次套sql List orders = new ArrayList<>(); diff --git a/backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java index 0c8692dfd5..939fbf3bd4 100644 --- a/backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java @@ -183,8 +183,11 @@ public class EsQueryProvider extends QueryProvider { if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); + if (whereTrees != null) wheres.add(whereTrees); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); @@ -353,6 +356,8 @@ public class EsQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -360,6 +365,7 @@ public class EsQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -435,12 +441,15 @@ public class EsQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -550,6 +559,8 @@ public class EsQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -557,6 +568,7 @@ public class EsQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -669,6 +681,8 @@ public class EsQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -676,6 +690,7 @@ public class EsQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -759,12 +774,15 @@ public class EsQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(yFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); // 外层再次套sql List orders = new ArrayList<>(); @@ -1213,7 +1231,7 @@ public class EsQueryProvider extends QueryProvider { if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) { String cast = String.format(EsSqlLConstants.CAST, originField, y.getDeType() == DeTypeConstants.DE_INT ? "bigint" : "double"); String agg = String.format(EsSqlLConstants.AGG_FIELD, y.getSummary(), cast); - fieldName = String.format(EsSqlLConstants.ROUND, agg, "2"); + fieldName = String.format(EsSqlLConstants.ROUND, agg, "8"); } else { String cast = String.format(EsSqlLConstants.CAST, originField, y.getDeType() == DeTypeConstants.DE_INT ? "bigint" : "double"); if (StringUtils.equalsIgnoreCase(y.getSummary(), "count_distinct")) { diff --git a/backend/src/main/java/io/dataease/provider/query/hive/HiveQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/hive/HiveQueryProvider.java index afd9cd10be..78b289fac3 100644 --- a/backend/src/main/java/io/dataease/provider/query/hive/HiveQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/hive/HiveQueryProvider.java @@ -143,8 +143,11 @@ public class HiveQueryProvider extends QueryProvider { if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); + if (whereTrees != null) wheres.add(whereTrees); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); List xOrders = new ArrayList<>(); @@ -304,6 +307,8 @@ public class HiveQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -311,6 +316,7 @@ public class HiveQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -381,12 +387,15 @@ public class HiveQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -494,6 +503,8 @@ public class HiveQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -501,6 +512,7 @@ public class HiveQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -605,6 +617,8 @@ public class HiveQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -612,6 +626,7 @@ public class HiveQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -691,12 +706,15 @@ public class HiveQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(yFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); // 外层再次套sql List orders = new ArrayList<>(); diff --git a/backend/src/main/java/io/dataease/provider/query/impala/ImpalaQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/impala/ImpalaQueryProvider.java index 0c3b2918c3..8671402112 100644 --- a/backend/src/main/java/io/dataease/provider/query/impala/ImpalaQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/impala/ImpalaQueryProvider.java @@ -140,8 +140,11 @@ public class ImpalaQueryProvider extends QueryProvider { if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); + if (whereTrees != null) wheres.add(whereTrees); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); List xOrders = new ArrayList<>(); @@ -301,6 +304,8 @@ public class ImpalaQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -308,6 +313,7 @@ public class ImpalaQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -378,12 +384,15 @@ public class ImpalaQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -491,6 +500,8 @@ public class ImpalaQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -498,6 +509,7 @@ public class ImpalaQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -602,6 +614,8 @@ public class ImpalaQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -609,6 +623,7 @@ public class ImpalaQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -688,12 +703,15 @@ public class ImpalaQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(yFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); // 外层再次套sql List orders = new ArrayList<>(); diff --git a/backend/src/main/java/io/dataease/provider/query/mongodb/MongoQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/mongodb/MongoQueryProvider.java index 7dd4f06496..1ea026b22a 100644 --- a/backend/src/main/java/io/dataease/provider/query/mongodb/MongoQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/mongodb/MongoQueryProvider.java @@ -130,8 +130,11 @@ public class MongoQueryProvider extends QueryProvider { } if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); + if (whereTrees != null) wheres.add(whereTrees); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); List xOrders = new ArrayList<>(); @@ -264,6 +267,8 @@ public class MongoQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -271,6 +276,7 @@ public class MongoQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -346,12 +352,15 @@ public class MongoQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -461,6 +470,8 @@ public class MongoQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -468,6 +479,7 @@ public class MongoQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -577,6 +589,8 @@ public class MongoQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -584,6 +598,7 @@ public class MongoQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -669,12 +684,15 @@ public class MongoQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(yFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); // 外层再次套sql List orders = new ArrayList<>(); diff --git a/backend/src/main/java/io/dataease/provider/query/oracle/OracleQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/oracle/OracleQueryProvider.java index 26cb9d88b5..1f0f3e9f17 100644 --- a/backend/src/main/java/io/dataease/provider/query/oracle/OracleQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/oracle/OracleQueryProvider.java @@ -117,8 +117,11 @@ public class OracleQueryProvider extends QueryProvider { if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); + if (whereTrees != null) wheres.add(whereTrees); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); List xOrders = new ArrayList<>(); @@ -360,6 +363,8 @@ public class OracleQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -367,6 +372,7 @@ public class OracleQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -437,12 +443,15 @@ public class OracleQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -549,6 +558,8 @@ public class OracleQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -556,6 +567,7 @@ public class OracleQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -660,6 +672,8 @@ public class OracleQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -667,6 +681,7 @@ public class OracleQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -747,12 +762,15 @@ public class OracleQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(yFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); // 外层再次套sql List orders = new ArrayList<>(); orders.addAll(yOrders); diff --git a/backend/src/main/java/io/dataease/provider/query/pg/PgQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/pg/PgQueryProvider.java index 97424cc9ce..2c30997e58 100644 --- a/backend/src/main/java/io/dataease/provider/query/pg/PgQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/pg/PgQueryProvider.java @@ -171,8 +171,11 @@ public class PgQueryProvider extends QueryProvider { if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); + if (whereTrees != null) wheres.add(whereTrees); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); List xOrders = new ArrayList<>(); @@ -331,6 +334,8 @@ public class PgQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -338,6 +343,7 @@ public class PgQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -408,12 +414,15 @@ public class PgQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -521,6 +530,8 @@ public class PgQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -528,6 +539,7 @@ public class PgQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -632,6 +644,8 @@ public class PgQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -639,6 +653,7 @@ public class PgQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -719,12 +734,15 @@ public class PgQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(yFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); // 外层再次套sql List orders = new ArrayList<>(); diff --git a/backend/src/main/java/io/dataease/provider/query/redshift/RedshiftQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/redshift/RedshiftQueryProvider.java index 0dd9aa6cde..b2d8fd468c 100644 --- a/backend/src/main/java/io/dataease/provider/query/redshift/RedshiftQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/redshift/RedshiftQueryProvider.java @@ -180,8 +180,11 @@ public class RedshiftQueryProvider extends QueryProvider { if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); + if (whereTrees != null) wheres.add(whereTrees); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); @@ -341,6 +344,8 @@ public class RedshiftQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -348,6 +353,7 @@ public class RedshiftQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -463,6 +469,8 @@ public class RedshiftQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -470,6 +478,7 @@ public class RedshiftQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -574,6 +583,8 @@ public class RedshiftQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -581,6 +592,7 @@ public class RedshiftQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -661,12 +673,15 @@ public class RedshiftQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(yFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); // 外层再次套sql List orders = new ArrayList<>(); diff --git a/backend/src/main/java/io/dataease/provider/query/sqlserver/SqlserverQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/sqlserver/SqlserverQueryProvider.java index a45e390de4..545540850d 100644 --- a/backend/src/main/java/io/dataease/provider/query/sqlserver/SqlserverQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/sqlserver/SqlserverQueryProvider.java @@ -170,8 +170,11 @@ public class SqlserverQueryProvider extends QueryProvider { if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); + if (whereTrees != null) wheres.add(whereTrees); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); List xOrders = new ArrayList<>(); if (CollectionUtils.isNotEmpty(sortFields)) { @@ -323,6 +326,8 @@ public class SqlserverQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -330,6 +335,7 @@ public class SqlserverQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -404,12 +410,15 @@ public class SqlserverQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -540,6 +549,8 @@ public class SqlserverQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -547,6 +558,7 @@ public class SqlserverQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -655,6 +667,8 @@ public class SqlserverQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(xFields); @@ -662,6 +676,7 @@ public class SqlserverQueryProvider extends QueryProvider { List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); groups.addAll(xFields); // 外层再次套sql @@ -746,12 +761,15 @@ public class SqlserverQueryProvider extends QueryProvider { String customWheres = transCustomFilterList(tableObj, fieldCustomFilter); // 处理仪表板字段过滤 String extWheres = transExtFilterList(tableObj, extFilterRequestList); + // row permissions tree + String whereTrees = transFilterTrees(tableObj, rowPermissionsTree); // 构建sql所有参数 List fields = new ArrayList<>(); fields.addAll(yFields); List wheres = new ArrayList<>(); if (customWheres != null) wheres.add(customWheres); if (extWheres != null) wheres.add(extWheres); + if (whereTrees != null) wheres.add(whereTrees); List groups = new ArrayList<>(); // 外层再次套sql List orders = new ArrayList<>(); diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index 740da7834a..f0a33fc4f8 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -997,9 +997,9 @@ public class ChartViewService { item[dataIndex] = null; } else { item[dataIndex] = new BigDecimal(cValue) - .divide(new BigDecimal(lastValue), 2, RoundingMode.HALF_UP) + .divide(new BigDecimal(lastValue), 8, RoundingMode.HALF_UP) .subtract(new BigDecimal(1)) - .setScale(2, RoundingMode.HALF_UP) + .setScale(8, RoundingMode.HALF_UP) .toString(); } } diff --git a/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java b/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java index bff4282568..a58c9b0d27 100644 --- a/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java +++ b/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java @@ -902,7 +902,7 @@ public class ChartDataBuild { if (chartViewFieldDTO.getDeType() == 0 || chartViewFieldDTO.getDeType() == 1 || chartViewFieldDTO.getDeType() == 5) { d.put(fields.get(i).getDataeaseName(), StringUtils.isEmpty(ele[i]) ? "" : ele[i]); } else if (chartViewFieldDTO.getDeType() == 2 || chartViewFieldDTO.getDeType() == 3) { - d.put(fields.get(i).getDataeaseName(), StringUtils.isEmpty(ele[i]) ? null : new BigDecimal(ele[i]).setScale(2, RoundingMode.HALF_UP)); + d.put(fields.get(i).getDataeaseName(), StringUtils.isEmpty(ele[i]) ? null : new BigDecimal(ele[i]).setScale(8, RoundingMode.HALF_UP)); } } tableRow.add(d); diff --git a/backend/src/main/java/io/dataease/service/dataset/PermissionsTreeService.java b/backend/src/main/java/io/dataease/service/dataset/PermissionsTreeService.java index 678657776f..eefb995999 100644 --- a/backend/src/main/java/io/dataease/service/dataset/PermissionsTreeService.java +++ b/backend/src/main/java/io/dataease/service/dataset/PermissionsTreeService.java @@ -11,6 +11,7 @@ import io.dataease.plugins.common.base.domain.DatasetTableField; import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO; import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem; import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeObj; +import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeRequest; import io.dataease.plugins.config.SpringContextUtil; import io.dataease.plugins.xpack.auth.service.RowPermissionTreeService; import org.apache.commons.lang3.ObjectUtils; @@ -18,7 +19,10 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; @Service @@ -60,7 +64,7 @@ public class PermissionsTreeService { List currentRoleDtos = authUserService.roleInfos(userId); roleIds = currentRoleDtos.stream().map(CurrentRoleDto::getId).collect(Collectors.toList()); - DataSetRowPermissionsTreeDTO dataSetRowPermissionsDTO = new DataSetRowPermissionsTreeDTO(); + DatasetRowPermissionsTreeRequest dataSetRowPermissionsDTO = new DatasetRowPermissionsTreeRequest(); dataSetRowPermissionsDTO.setDatasetId(datasetId); dataSetRowPermissionsDTO.setEnable(true); diff --git a/backend/src/main/java/io/dataease/service/panel/PanelGroupService.java b/backend/src/main/java/io/dataease/service/panel/PanelGroupService.java index 8f4119f477..35eb934abb 100644 --- a/backend/src/main/java/io/dataease/service/panel/PanelGroupService.java +++ b/backend/src/main/java/io/dataease/service/panel/PanelGroupService.java @@ -3,14 +3,12 @@ package io.dataease.service.panel; import com.google.gson.Gson; import io.dataease.auth.annotation.DeCleaner; import io.dataease.commons.constants.*; -import io.dataease.commons.utils.AuthUtils; -import io.dataease.commons.utils.DeLogUtils; -import io.dataease.commons.utils.LogUtil; -import io.dataease.commons.utils.TreeUtils; +import io.dataease.commons.utils.*; import io.dataease.controller.request.authModel.VAuthModelRequest; import io.dataease.controller.request.dataset.DataSetTableRequest; import io.dataease.controller.request.panel.PanelGroupBaseInfoRequest; import io.dataease.controller.request.panel.PanelGroupRequest; +import io.dataease.controller.request.panel.PanelTemplateRequest; import io.dataease.controller.request.panel.PanelViewDetailsRequest; import io.dataease.dto.PanelGroupExtendDataDTO; import io.dataease.dto.SysLogDTO; @@ -18,6 +16,7 @@ import io.dataease.dto.authModel.VAuthModelDTO; import io.dataease.dto.chart.ChartViewDTO; import io.dataease.dto.dataset.DataSetTableDTO; import io.dataease.dto.panel.PanelGroupDTO; +import io.dataease.dto.panel.PanelTemplateFileDTO; import io.dataease.dto.panel.po.PanelViewInsertDTO; import io.dataease.exception.DataEaseException; import io.dataease.ext.*; @@ -389,6 +388,16 @@ public class PanelGroupService { dynamicData = request.getDynamicData(); staticResource = request.getStaticResource(); mobileLayout = panelViewService.havaMobileLayout(templateData); + } else if (PanelConstants.NEW_PANEL_FROM.NEW_MARKET_TEMPLATE.equals(newFrom)){ + PanelTemplateFileDTO templateFileInfo = getTemplateFromMarket(request.getTemplateUrl()); + if(templateFileInfo == null){ + DataEaseException.throwException("Can't find the template's info from market,please check"); + } + templateStyle = templateFileInfo.getPanelStyle(); + templateData = templateFileInfo.getPanelData(); + dynamicData = templateFileInfo.getDynamicData(); + staticResource = templateFileInfo.getStaticResource(); + mobileLayout = panelViewService.havaMobileLayout(templateData); } Map dynamicDataMap = gson.fromJson(dynamicData, Map.class); List panelViews = new ArrayList<>(); @@ -583,4 +592,15 @@ public class PanelGroupService { panelGroup.setStatus(request.getStatus()); panelGroupMapper.updateByPrimaryKeySelective(panelGroup); } + + + public PanelTemplateFileDTO getTemplateFromMarket(String templateUrl){ + if(StringUtils.isNotEmpty(templateUrl)){ + Gson gson = new Gson(); + String templateInfo = HttpClientUtil.get(templateUrl,null); + return gson.fromJson(templateInfo, PanelTemplateFileDTO.class); + }else{ + return null; + } + } } diff --git a/backend/src/main/java/io/dataease/service/sys/SysUserService.java b/backend/src/main/java/io/dataease/service/sys/SysUserService.java index 6b0d6fe100..3b0eaf57b2 100644 --- a/backend/src/main/java/io/dataease/service/sys/SysUserService.java +++ b/backend/src/main/java/io/dataease/service/sys/SysUserService.java @@ -2,6 +2,8 @@ package io.dataease.service.sys; import io.dataease.auth.api.dto.CurrentUserDto; import io.dataease.auth.service.ExtAuthService; +import io.dataease.controller.sys.base.ConditionEntity; +import io.dataease.controller.sys.request.*; import io.dataease.ext.ExtSysUserAssistMapper; import io.dataease.ext.ExtSysUserMapper; import io.dataease.ext.query.GridExample; @@ -10,10 +12,6 @@ import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.CodingUtil; import io.dataease.controller.sys.base.BaseGridRequest; -import io.dataease.controller.sys.request.LdapAddRequest; -import io.dataease.controller.sys.request.SysUserCreateRequest; -import io.dataease.controller.sys.request.SysUserPwdRequest; -import io.dataease.controller.sys.request.SysUserStateRequest; import io.dataease.controller.sys.response.SysUserGridResponse; import io.dataease.controller.sys.response.SysUserRole; import io.dataease.i18n.Translator; @@ -60,12 +58,12 @@ public class SysUserService { private ExtSysUserAssistMapper extSysUserAssistMapper; - public List query(BaseGridRequest request) { - + public List query(UserGridRequest request) { + String keyWord = request.getKeyWord(); GridExample gridExample = request.convertExample(); + gridExample.setExtendCondition(keyWord); List lists = extSysUserMapper.query(gridExample); lists.forEach(item -> { - List roles = item.getRoles(); List roleIds = roles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList()); item.setRoleIds(roleIds); diff --git a/backend/src/main/java/io/dataease/service/system/SystemParameterService.java b/backend/src/main/java/io/dataease/service/system/SystemParameterService.java index 1a85f3046b..594389b4ee 100644 --- a/backend/src/main/java/io/dataease/service/system/SystemParameterService.java +++ b/backend/src/main/java/io/dataease/service/system/SystemParameterService.java @@ -6,6 +6,7 @@ import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.EncryptUtils; import io.dataease.controller.sys.response.BasicInfo; import io.dataease.dto.SystemParameterDTO; +import io.dataease.exception.DataEaseException; import io.dataease.plugins.common.base.domain.FileMetadata; import io.dataease.plugins.common.base.domain.SystemParameter; import io.dataease.plugins.common.base.domain.SystemParameterExample; @@ -69,6 +70,13 @@ public class SystemParameterService { boolean open = StringUtils.equals("true", param.getParamValue()); result.setOpenHomePage(open ? "true" : "false"); } + if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.TEMPLATE_MARKET_ULR.getValue())) { + result.setTemplateMarketUlr(param.getParamValue()); + } + if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.TEMPLATE_ACCESS_KEY.getValue())) { + result.setTemplateAccessKey(param.getParamValue()); + } + } } return result; @@ -270,5 +278,23 @@ public class SystemParameterService { } } + public BasicInfo templateMarketInfo(){ + BasicInfo basicInfo = new BasicInfo(); + List result = this.getParamList("basic.template"); + if(CollectionUtils.isNotEmpty(result)){ + result.stream().forEach(param -> { + if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.TEMPLATE_MARKET_ULR.getValue())) { + basicInfo.setTemplateMarketUlr(param.getParamValue()); + } + if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.TEMPLATE_ACCESS_KEY.getValue())) { + basicInfo.setTemplateAccessKey(param.getParamValue()); + } + }); + } + if(StringUtils.isEmpty(basicInfo.getTemplateMarketUlr())|| StringUtils.isEmpty(basicInfo.getTemplateAccessKey())){ + DataEaseException.throwException("Please check market setting info"); + } + return basicInfo; + } } diff --git a/backend/src/main/java/io/dataease/service/templateMarket/TemplateMarketService.java b/backend/src/main/java/io/dataease/service/templateMarket/TemplateMarketService.java new file mode 100644 index 0000000000..427d111358 --- /dev/null +++ b/backend/src/main/java/io/dataease/service/templateMarket/TemplateMarketService.java @@ -0,0 +1,85 @@ +package io.dataease.service.templateMarket; + +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; +import io.dataease.commons.utils.HttpClientConfig; +import io.dataease.commons.utils.HttpClientUtil; +import io.dataease.controller.request.templateMarket.TemplateMarketSearchRequest; +import io.dataease.controller.sys.response.BasicInfo; +import io.dataease.dto.panel.PanelTemplateFileDTO; +import io.dataease.dto.templateMarket.MarketBaseResponse; +import io.dataease.dto.templateMarket.TemplateCategory; +import io.dataease.dto.templateMarket.TemplateMarketDTO; +import io.dataease.exception.DataEaseException; +import io.dataease.service.system.SystemParameterService; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Author: wangjiahao + * Date: 2022/7/14 + * Description: ${userName} + */ +@Service +public class TemplateMarketService { + + private final static String POSTS_API="/api/content/posts?page=0&size=2000"; + private final static String CATEGORIES_API="/api/content/categories"; + + @Resource + private SystemParameterService systemParameterService; + + /** + * @Description Get template file from template market + * @param templateUrl template url + */ + public PanelTemplateFileDTO getTemplateFromMarket(String templateUrl){ + if(StringUtils.isNotEmpty(templateUrl)){ + String sufUrl = systemParameterService.templateMarketInfo().getTemplateMarketUlr(); + Gson gson = new Gson(); + String templateInfo = HttpClientUtil.get(sufUrl+templateUrl,null); + return gson.fromJson(templateInfo, PanelTemplateFileDTO.class); + }else{ + return null; + } + } + + /** + * @Description Get info from template market content api + * @param url content api url + */ + public String marketGet(String url,String accessKey){ + HttpClientConfig config = new HttpClientConfig(); + config.addHeader("API-Authorization",accessKey); + return HttpClientUtil.get(url,config); + } + + public MarketBaseResponse searchTemplate(TemplateMarketSearchRequest request){ + try{ + BasicInfo basicInfo = systemParameterService.templateMarketInfo(); + String result = marketGet(basicInfo.getTemplateMarketUlr()+POSTS_API,basicInfo.getTemplateAccessKey()); + List postsResult = JSONObject.parseObject(result).getJSONObject("data").getJSONArray("content").toJavaList(TemplateMarketDTO.class); + return new MarketBaseResponse(basicInfo.getTemplateMarketUlr(),postsResult); + }catch (Exception e){ + DataEaseException.throwException(e); + } + return null; + } + + public List getCategories(){ + BasicInfo basicInfo = systemParameterService.templateMarketInfo(); + String resultStr = marketGet(basicInfo.getTemplateMarketUlr()+CATEGORIES_API,basicInfo.getTemplateAccessKey()); + List categories = JSONObject.parseObject(resultStr).getJSONArray("data").toJavaList(TemplateCategory.class); + if(CollectionUtils.isNotEmpty(categories)){ + return categories.stream().map(TemplateCategory :: getName).collect(Collectors.toList()); + }else{ + return null; + } + + } +} diff --git a/backend/src/main/resources/db/migration/V38__1.13.sql b/backend/src/main/resources/db/migration/V38__1.13.sql index 44c035b200..ba5dc6f822 100644 --- a/backend/src/main/resources/db/migration/V38__1.13.sql +++ b/backend/src/main/resources/db/migration/V38__1.13.sql @@ -36,4 +36,8 @@ ADD COLUMN `phone_prefix` varchar(255) NULL COMMENT '手机号前缀' AFTER `sub INSERT INTO `my_plugin` (`name`, `store`, `free`, `cost`, `category`, `descript`, `version`, `creator`, `load_mybatis`, `install_time`, `module_name`, `ds_type`) VALUES ('Mongo 数据源插件', 'default', '0', '0', 'datasource', 'Mongo 数据源插件', '1.0-SNAPSHOT', 'DATAEASE', '0', - '1650765903630', 'mongo-backend', 'mongobi'); \ No newline at end of file + '1650765903630', 'mongo-backend', 'mongobi'); + + +INSERT INTO `system_parameter` (`param_key`, `param_value`, `type`, `sort`) VALUES ('basic.templateAccessKey', 'dataease', 'text', NULL); +INSERT INTO `system_parameter` (`param_key`, `param_value`, `type`, `sort`) VALUES ('basic.templateMarketUlr', 'https://dataease.io/templates', 'text', 4); diff --git a/frontend/src/api/map/map.js b/frontend/src/api/map/map.js index 19257ef9cf..be82bdc9a6 100644 --- a/frontend/src/api/map/map.js +++ b/frontend/src/api/map/map.js @@ -8,6 +8,14 @@ export const areaMapping = () => { }) } +export const globalMapping = () => { + return request({ + url: '/api/map/globalEntitys/0', + method: 'get', + loading: true + }) +} + export function geoJson(areaCode) { return request({ url: '/geo/' + areaCode + '_full.json', diff --git a/frontend/src/api/templateMarket/index.js b/frontend/src/api/templateMarket/index.js new file mode 100644 index 0000000000..74534221d3 --- /dev/null +++ b/frontend/src/api/templateMarket/index.js @@ -0,0 +1,20 @@ +import request from '@/utils/request' + +export function searchMarket(data) { + return request({ + url: '/template/market/search', + method: 'post', + loading: true, + hideMsg: true, + data + }) +} + +export function getCategories() { + return request({ + url: '/template/market/categories', + method: 'get', + hideMsg: true, + loading: false + }) +} diff --git a/frontend/src/components/canvas/components/Toolbar.vue b/frontend/src/components/canvas/components/Toolbar.vue index 391a18d0f2..aad29b1a67 100644 --- a/frontend/src/components/canvas/components/Toolbar.vue +++ b/frontend/src/components/canvas/components/Toolbar.vue @@ -26,6 +26,7 @@
+ + + + + diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index 66399ddf4a..57e117e905 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -1121,7 +1121,15 @@ export default { open: 'Open', row: 'Row', interval: 'Interval', - max_more_than_mix: 'Max must more than Min' + max_more_than_mix: 'Max must more than Min', + field: 'Field', + textColor: 'Text Color', + backgroundColor: 'Background Color', + field_can_not_empty: 'Field can not empty', + conditions_can_not_empty: 'Conditions can not be empty,if unnecessary,please delete the field', + remark: 'Remark', + remark_edit: 'Edit Remark', + remark_bg_color: 'Background Fill' }, dataset: { field_rename: 'Rename Field', @@ -1491,6 +1499,11 @@ export default { sure_bt: 'Confirm' }, panel: { + market_network_tips: 'View template Market template requires server and template Market( https://dataease.io/templates ), please check the network... ', + enter_name_tips: 'Please enter the name of the panel', + name: 'Name', + apply_template: 'Apply Template', + enter_template_name_tips: 'Please enter the template name...', pic_adaptation: 'Adaptation', pic_equiratio: 'Equiratio', pic_original: 'Original', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 8ebeed339f..3b89e96aa5 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -1121,7 +1121,15 @@ export default { open: '開啟', row: '行數', interval: '間隔', - max_more_than_mix: '最大值必須大於最小值' + max_more_than_mix: '最大值必須大於最小值', + field: '字段', + textColor: '文字顏色', + backgroundColor: '背景顏色', + field_can_not_empty: '字段不能為空', + conditions_can_not_empty: '字段的條件不能為空,若無條件,請直接刪除該字段', + remark: '備註', + remark_edit: '編輯備註', + remark_bg_color: '背景填充' }, dataset: { field_rename: '字段重命名', @@ -1492,6 +1500,11 @@ export default { sure_bt: '確定' }, panel: { + market_network_tips: '查看模板市场模板需要服务器与模板市场(https://dataease.io/templates)联通,请检查网络...', + enter_name_tips: '请输入仪表板名称', + name: '名称', + apply_template: '应用模板', + enter_template_name_tips: '请输入模板名称...', pic_adaptation: '适应组件', pic_equiratio: '等比适应', pic_original: '原始尺寸', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 2ddfca37ab..901aec82c8 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -1123,7 +1123,15 @@ export default { open: '开启', row: '行数', interval: '间隔', - max_more_than_mix: '最大值必须大于最小值' + max_more_than_mix: '最大值必须大于最小值', + field: '字段', + textColor: '文字颜色', + backgroundColor: '背景颜色', + field_can_not_empty: '字段不能为空', + conditions_can_not_empty: '字段的条件不能为空,若无条件,请直接删除该字段', + remark: '备注', + remark_edit: '编辑备注', + remark_bg_color: '背景填充' }, dataset: { field_rename: '字段重命名', @@ -1500,6 +1508,11 @@ export default { sure_bt: '确定' }, panel: { + market_network_tips: '查看模板市场模板需要服务器与模板市场(https://dataease.io/templates)联通,请检查网络...', + enter_name_tips: '请输入仪表板名称', + name: '名称', + apply_template: '应用模板', + enter_template_name_tips: '请输入模板名称...', pic_adaptation: '适应组件', pic_equiratio: '等比适应', pic_original: '原始尺寸', diff --git a/frontend/src/layout/components/Topbar.vue b/frontend/src/layout/components/Topbar.vue index 932850a3a5..825f2a279b 100644 --- a/frontend/src/layout/components/Topbar.vue +++ b/frontend/src/layout/components/Topbar.vue @@ -22,7 +22,7 @@
@@ -95,9 +104,11 @@ import { import { initTheme } from '@/utils/ThemeUtil' +import TemplateMarket from '@/views/panel/templateMarket' export default { name: 'Topbar', components: { + TemplateMarket, AppLink, Notification, LangSelect @@ -114,7 +125,8 @@ export default { uiInfo: null, logoUrl: null, axiosFinished: false, - isPluginLoaded: false + isPluginLoaded: false, + templateMarketShow: false } }, @@ -357,6 +369,9 @@ export default { }, setTopTextActiveInfo(val) { this.loadUiInfo() + }, + changeTemplateMarketShow(isShow) { + this.templateMarketShow = isShow } } @@ -387,5 +402,15 @@ export default { background-color: var(--MainBG); } + .template-market-item{ + display: flex; + color: var(--MenuActiveBG, #409EFF); + font-size: 14px!important; + line-height: 38px!important; + } + + .dialog-css ::v-deep .el-dialog__header{ + display: none; + } diff --git a/frontend/src/views/chart/chart/chart.js b/frontend/src/views/chart/chart/chart.js index dc8e119a52..afc9abf262 100644 --- a/frontend/src/views/chart/chart/chart.js +++ b/frontend/src/views/chart/chart/chart.js @@ -144,7 +144,10 @@ export const DEFAULT_TITLE_STYLE = { hPosition: 'left', vPosition: 'top', isItalic: false, - isBolder: true + isBolder: true, + remarkShow: false, + remark: '', + remarkBackgroundColor: '#ffffffff' } export const DEFAULT_TITLE_STYLE_DARK = { @@ -337,7 +340,8 @@ export const DEFAULT_FUNCTION_CFG = { } export const DEFAULT_THRESHOLD = { gaugeThreshold: '', - labelThreshold: [] + labelThreshold: [], + tableThreshold: [] } export const DEFAULT_SCROLL = { open: false, diff --git a/frontend/src/views/chart/chart/table/table-info.js b/frontend/src/views/chart/chart/table/table-info.js index 8751c8eea9..cdd4392bb4 100644 --- a/frontend/src/views/chart/chart/table/table-info.js +++ b/frontend/src/views/chart/chart/table/table-info.js @@ -1,7 +1,8 @@ import { TableSheet, S2Event, PivotSheet } from '@antv/s2' import { getCustomTheme, getSize } from '@/views/chart/chart/common/common_table' -import { DEFAULT_TOTAL } from '@/views/chart/chart/chart' +import { DEFAULT_COLOR_CASE, DEFAULT_TOTAL } from '@/views/chart/chart/chart' import { formatterItem, valueFormatter } from '@/views/chart/chart/formatter' +import { hexColorToRGBA } from '@/views/chart/chart/util' export function baseTableInfo(s2, container, chart, action, tableData) { const containerDom = document.getElementById(container) @@ -59,6 +60,9 @@ export function baseTableInfo(s2, container, chart, action, tableData) { if (!f) { return value } + if (value === null || value === undefined) { + return value + } if (f.groupType === 'd') { return value } else { @@ -86,6 +90,9 @@ export function baseTableInfo(s2, container, chart, action, tableData) { if (!f) { return value } + if (value === null || value === undefined) { + return value + } if (f.groupType === 'd') { return value } else { @@ -116,7 +123,8 @@ export function baseTableInfo(s2, container, chart, action, tableData) { width: containerDom.offsetWidth, height: containerDom.offsetHeight, // showSeriesNumber: true - style: getSize(chart) + style: getSize(chart), + conditions: getConditions(chart) } // 开始渲染 @@ -190,6 +198,9 @@ export function baseTableNormal(s2, container, chart, action, tableData) { if (!f) { return value } + if (value === null || value === undefined) { + return value + } if (f.formatterCfg) { return valueFormatter(value, f.formatterCfg) } else { @@ -211,6 +222,9 @@ export function baseTableNormal(s2, container, chart, action, tableData) { if (!f) { return value } + if (value === null || value === undefined) { + return value + } if (f.formatterCfg) { return valueFormatter(value, f.formatterCfg) } else { @@ -235,7 +249,8 @@ export function baseTableNormal(s2, container, chart, action, tableData) { width: containerDom.offsetWidth, height: containerDom.offsetHeight, // showSeriesNumber: true - style: getSize(chart) + style: getSize(chart), + conditions: getConditions(chart) } // 开始渲染 @@ -319,6 +334,9 @@ export function baseTablePivot(s2, container, chart, action, tableData) { if (!f) { return value } + if (value === null || value === undefined) { + return value + } if (f.formatterCfg) { return valueFormatter(value, f.formatterCfg) } else { @@ -340,6 +358,9 @@ export function baseTablePivot(s2, container, chart, action, tableData) { if (!f) { return value } + if (value === null || value === undefined) { + return value + } if (f.formatterCfg) { return valueFormatter(value, f.formatterCfg) } else { @@ -385,7 +406,8 @@ export function baseTablePivot(s2, container, chart, action, tableData) { width: containerDom.offsetWidth, height: containerDom.offsetHeight, style: getSize(chart), - totals: totalCfg + totals: totalCfg, + conditions: getConditions(chart) } // 开始渲染 @@ -424,3 +446,190 @@ function getCurrentField(valueFieldList, field) { return res } + +function getConditions(chart) { + const res = { + text: [], + background: [] + } + let conditions + try { + const senior = JSON.parse(chart.senior) + conditions = senior.threshold ? senior.threshold.tableThreshold : null + } catch (err) { + const senior = JSON.parse(JSON.stringify(chart.senior)) + conditions = senior.threshold ? senior.threshold.tableThreshold : null + } + + if (conditions && conditions.length > 0) { + // table item color + let valueColor = DEFAULT_COLOR_CASE.tableFontColor + let valueBgColor = DEFAULT_COLOR_CASE.tableItemBgColor + if (chart.customAttr) { + const customAttr = JSON.parse(chart.customAttr) + // color + if (customAttr.color) { + const c = JSON.parse(JSON.stringify(customAttr.color)) + valueColor = c.tableFontColor + valueBgColor = hexColorToRGBA(c.tableItemBgColor, c.alpha) + } + } + + for (let i = 0; i < conditions.length; i++) { + const field = conditions[i] + res.text.push({ + field: field.field.dataeaseName, + mapping(value) { + return { + fill: mappingColor(value, valueColor, field, 'color') + } + } + }) + res.background.push({ + field: field.field.dataeaseName, + mapping(value) { + return { + fill: mappingColor(value, valueBgColor, field, 'backgroundColor') + } + } + }) + } + } + return res +} + +function mappingColor(value, defaultColor, field, type) { + let color + for (let i = 0; i < field.conditions.length; i++) { + let flag = false + const t = field.conditions[i] + if (field.field.deType === 2 || field.field.deType === 3 || field.field.deType === 4) { + const tv = parseFloat(t.value) + if (t.term === 'eq') { + if (value === tv) { + color = t[type] + flag = true + } + } else if (t.term === 'not_eq') { + if (value !== tv) { + color = t[type] + flag = true + } + } else if (t.term === 'lt') { + if (value < tv) { + color = t[type] + flag = true + } + } else if (t.term === 'gt') { + if (value > tv) { + color = t[type] + flag = true + } + } else if (t.term === 'le') { + if (value <= tv) { + color = t[type] + flag = true + } + } else if (t.term === 'ge') { + if (value >= tv) { + color = t[type] + flag = true + } + } + if (flag) { + break + } else if (i === field.conditions.length - 1) { + color = defaultColor + } + } else if (field.field.deType === 0) { + const tv = t.value + if (t.term === 'eq') { + if (value === tv) { + color = t[type] + flag = true + } + } else if (t.term === 'not_eq') { + if (value !== tv) { + color = t[type] + flag = true + } + } else if (t.term === 'like') { + if (value.includes(tv)) { + color = t[type] + flag = true + } + } else if (t.term === 'not like') { + if (!value.includes(tv)) { + color = t[type] + flag = true + } + } else if (t.term === 'null') { + if (value === null || value === undefined) { + color = t[type] + flag = true + } + } else if (t.term === 'not_null') { + if (value !== null && value !== undefined) { + color = t[type] + flag = true + } + } else if (t.term === 'empty') { + if (value === '') { + color = t[type] + flag = true + } + } else if (t.term === 'not_empty') { + if (value !== '') { + color = t[type] + flag = true + } + } + if (flag) { + break + } else if (i === field.conditions.length - 1) { + color = defaultColor + } + } else { + // time + const tv = new Date(t.value + ' GMT+8').getTime() + const v = new Date(value + ' GMT+8').getTime() + if (t.term === 'eq') { + if (v === tv) { + color = t[type] + flag = true + } + } else if (t.term === 'not_eq') { + if (v !== tv) { + color = t[type] + flag = true + } + } else if (t.term === 'lt') { + if (v < tv) { + color = t[type] + flag = true + } + } else if (t.term === 'gt') { + if (v > tv) { + color = t[type] + flag = true + } + } else if (t.term === 'le') { + if (v <= tv) { + color = t[type] + flag = true + } + } else if (t.term === 'ge') { + if (v >= tv) { + color = t[type] + flag = true + } + } + if (flag) { + break + } else if (i === field.conditions.length - 1) { + color = defaultColor + } + } + } + return color +} diff --git a/frontend/src/views/chart/components/senior/Threshold.vue b/frontend/src/views/chart/components/senior/Threshold.vue index 6b433b70fe..6440f8069a 100644 --- a/frontend/src/views/chart/components/senior/Threshold.vue +++ b/frontend/src/views/chart/components/senior/Threshold.vue @@ -44,14 +44,67 @@ {{ item.value }} - + - + + + + + + + + + + + + + + {{ fieldItem.field.name }} + + + + {{ $t('chart.filter_eq') }} + {{ $t('chart.filter_not_eq') }} + {{ $t('chart.filter_lt') }} + {{ $t('chart.filter_gt') }} + {{ $t('chart.filter_le') }} + {{ $t('chart.filter_ge') }} + {{ $t('chart.filter_like') }} + {{ $t('chart.filter_not_like') }} + {{ $t('chart.filter_null') }} + {{ $t('chart.filter_not_null') }} + {{ $t('chart.filter_empty') }} + {{ $t('chart.filter_not_empty') }} + + + {{ item.value }} +   + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index dea7115270..d55a280f8a 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -207,7 +207,7 @@ class="render-select" style="width: 100px" size="mini" - @change="changeChartType()" + @change="changeChartRender()" >
{{ $t('chart.senior_cfg') }} @@ -714,7 +714,7 @@ @onFunctionCfgChange="onFunctionCfgChange" /> - + {{ $t('chart.analyse_cfg') }} @@ -742,7 +742,7 @@ /> @@ -1469,7 +1469,7 @@ export default { }) }) }, - buildParam(getData, trigger, needRefreshGroup = false, switchType = false) { + buildParam(getData, trigger, needRefreshGroup = false, switchType = false, switchRender = false) { if (!this.view.resultCount || this.view.resultCount === '' || isNaN(Number(this.view.resultCount)) || @@ -1477,6 +1477,9 @@ export default { parseInt(this.view.resultCount) < 1) { this.view.resultCount = '1000' } + if (switchType) { + this.view.senior.threshold.tableThreshold = [] + } if (switchType && (this.view.type === 'table-info' || this.chart.type === 'table-info') && this.view.xaxis.length > 0) { this.$message({ showClose: true, @@ -1663,9 +1666,9 @@ export default { delete view.data return view }, - calcData(getData, trigger, needRefreshGroup = false, switchType = false) { + calcData(getData, trigger, needRefreshGroup = false, switchType = false, switchRender = false) { this.changeEditStatus(true) - const view = this.buildParam(true, 'chart', false, switchType) + const view = this.buildParam(true, 'chart', false, switchType, switchRender) if (!view) return viewEditSave(this.panelInfo.id, view).then(() => { // this.getData(this.param.id) @@ -2490,6 +2493,10 @@ export default { this.hasEdit = status this.$store.commit('recordViewEdit', { viewId: this.param.id, hasEdit: status }) }, + changeChartRender() { + this.setChartDefaultOptions() + this.calcData(true, 'chart', true, false, true) + }, changeChartType() { this.setChartDefaultOptions() this.calcData(true, 'chart', true, true) diff --git a/frontend/src/views/panel/list/PanelList.vue b/frontend/src/views/panel/list/PanelList.vue index 965a98994d..12e0731d6f 100644 --- a/frontend/src/views/panel/list/PanelList.vue +++ b/frontend/src/views/panel/list/PanelList.vue @@ -354,7 +354,7 @@ export default { watch: { // 切换展示页面后 重新点击一下当前节点 '$store.state.panel.mainActiveName': function(newVal, oldVal) { - if (newVal === 'PanelMain' && this.lastActiveNode && this.lastActiveNodeData) { + if (newVal === 'PanelMain' && this.lastActiveNodeData) { this.activeNodeAndClickOnly(this.lastActiveNodeData) } }, @@ -369,14 +369,25 @@ export default { this.$refs.panel_list_tree.filter(this.filterText) } }, + beforeDestroy() { + bus.$off('newPanelFromMarket', this.newPanelFromMarket) + }, mounted() { this.$store.commit('setComponentData', []) this.$store.commit('setCanvasStyle', DEFAULT_COMMON_CANVAS_STYLE_STRING) this.defaultTree(true) this.tree(true) this.initCache() + bus.$on('newPanelFromMarket', this.newPanelFromMarket) }, methods: { + newPanelFromMarket(panelInfo) { + if (panelInfo) { + this.defaultTree() + this.tree() + this.edit(panelInfo, null) + } + }, initCache() { // 初始化时提前加载视图和数据集的缓存 this.initLocalStorage.forEach(item => { diff --git a/frontend/src/views/panel/templateMarket/component/TemplateMarketItem.vue b/frontend/src/views/panel/templateMarket/component/TemplateMarketItem.vue new file mode 100644 index 0000000000..022822d587 --- /dev/null +++ b/frontend/src/views/panel/templateMarket/component/TemplateMarketItem.vue @@ -0,0 +1,116 @@ + + + + + diff --git a/frontend/src/views/panel/templateMarket/index.vue b/frontend/src/views/panel/templateMarket/index.vue new file mode 100644 index 0000000000..97621f9675 --- /dev/null +++ b/frontend/src/views/panel/templateMarket/index.vue @@ -0,0 +1,260 @@ + + + + +