🎨 Improving structure / format of the code. 格式化大屏模块代码格式
This commit is contained in:
commit
5fdbdf4998
142 files changed
+7480
-7476
No files matched your search
+23
-22
@@ -16,28 +16,29 @@ import java.io.IOException;
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class CorsFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletResponse res = (HttpServletResponse) response;
|
||||
// 设置允许Cookie
|
||||
res.addHeader("Access-Control-Allow-Credentials", "true");
|
||||
// 允许http://www.xxx.com域(自行设置,这里只做示例)发起跨域请求
|
||||
res.addHeader("Access-Control-Allow-Origin", req.getHeader("Origin"));
|
||||
// 设置允许跨域请求的方法
|
||||
res.addHeader("Access-Control-Allow-Methods", "*");
|
||||
// 允许跨域请求包含content-type
|
||||
res.addHeader("Access-Control-Allow-Headers", "*");
|
||||
res.addHeader("Access-Control-Expose-Headers", "*");
|
||||
chain.doFilter(req, res);
|
||||
}
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletResponse res = (HttpServletResponse) response;
|
||||
// 设置允许Cookie
|
||||
res.addHeader("Access-Control-Allow-Credentials", "true");
|
||||
// 允许http://www.xxx.com域(自行设置,这里只做示例)发起跨域请求
|
||||
res.addHeader("Access-Control-Allow-Origin", req.getHeader("Origin"));
|
||||
// 设置允许跨域请求的方法
|
||||
res.addHeader("Access-Control-Allow-Methods", "*");
|
||||
// 允许跨域请求包含content-type
|
||||
res.addHeader("Access-Control-Allow-Headers", "*");
|
||||
res.addHeader("Access-Control-Expose-Headers", "*");
|
||||
chain.doFilter(req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
}
|
||||
}
|
||||
+39
-42
@@ -2,66 +2,63 @@
|
||||
package com.anjiplus.template.gaea.business.modules.accessauthority.controller;
|
||||
|
||||
import com.anji.plus.gaea.annotation.Permission;
|
||||
import com.anji.plus.gaea.annotation.AccessKey;
|
||||
import com.anji.plus.gaea.bean.KeyValue;
|
||||
import com.anji.plus.gaea.bean.ResponseBean;
|
||||
import com.anji.plus.gaea.bean.TreeNode;
|
||||
import com.anji.plus.gaea.curd.controller.GaeaBaseController;
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
import com.anji.plus.gaea.holder.UserContentHolder;
|
||||
import com.anji.plus.gaea.utils.GaeaBeanUtils;
|
||||
import com.anji.plus.gaea.utils.GaeaUtils;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.dao.entity.AccessAuthority;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.service.AccessAuthorityService;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.controller.dto.AccessAuthorityDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.controller.param.AccessAuthorityParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.dao.entity.AccessAuthority;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.service.AccessAuthorityService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @desc 权限管理 controller
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
* @desc 权限管理 controller
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "权限管理管理")
|
||||
@RequestMapping("/accessAuthority")
|
||||
@Permission(code = "authorityManage", name = "权限管理")
|
||||
public class AccessAuthorityController extends GaeaBaseController<AccessAuthorityParam, AccessAuthority, AccessAuthorityDto> {
|
||||
public class AccessAuthorityController
|
||||
extends GaeaBaseController<AccessAuthorityParam, AccessAuthority, AccessAuthorityDto> {
|
||||
|
||||
@Autowired
|
||||
private AccessAuthorityService accessAuthorityService;
|
||||
@Autowired
|
||||
private AccessAuthorityService accessAuthorityService;
|
||||
|
||||
@Override
|
||||
public GaeaBaseService<AccessAuthorityParam, AccessAuthority> getService() {
|
||||
return accessAuthorityService;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseService<AccessAuthorityParam, AccessAuthority> getService() {
|
||||
return accessAuthorityService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessAuthority getEntity() {
|
||||
return new AccessAuthority();
|
||||
}
|
||||
@Override
|
||||
public AccessAuthority getEntity() {
|
||||
return new AccessAuthority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessAuthorityDto getDTO() {
|
||||
return new AccessAuthorityDto();
|
||||
}
|
||||
@Override
|
||||
public AccessAuthorityDto getDTO() {
|
||||
return new AccessAuthorityDto();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一二级菜单
|
||||
* @return
|
||||
*/
|
||||
@Permission( code = "query", name = "查询")
|
||||
@GetMapping("/menuTree")
|
||||
public ResponseBean menuTree(){
|
||||
String username = UserContentHolder.getContext().getUsername();
|
||||
List<TreeNode> parentTreeList = accessAuthorityService.getAuthorityTree(username, false);
|
||||
return responseSuccessWithData(parentTreeList);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取一二级菜单
|
||||
* @return
|
||||
*/
|
||||
@Permission(code = "query", name = "查询")
|
||||
@GetMapping("/menuTree")
|
||||
public ResponseBean menuTree() {
|
||||
String username = UserContentHolder.getContext().getUsername();
|
||||
List<TreeNode> parentTreeList = accessAuthorityService.getAuthorityTree(username, false);
|
||||
return responseSuccessWithData(parentTreeList);
|
||||
}
|
||||
|
||||
}
|
||||
+39
-41
@@ -1,58 +1,56 @@
|
||||
|
||||
package com.anjiplus.template.gaea.business.modules.accessauthority.controller.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.anji.plus.gaea.annotation.Query;
|
||||
import com.anji.plus.gaea.constant.QueryEnum;
|
||||
import com.anji.plus.gaea.curd.dto.GaeaBaseDTO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.anji.plus.gaea.annotation.Formatter;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 权限管理 dto
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
* @description 权限管理 dto
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
@Data
|
||||
public class AccessAuthorityDto extends GaeaBaseDTO implements Serializable {
|
||||
/** 父菜单代码 */
|
||||
@ApiModelProperty(value = "父菜单代码")
|
||||
private String parentTarget;
|
||||
|
||||
/** 目标菜单 */
|
||||
@ApiModelProperty(value = "菜单代码")
|
||||
@NotEmpty(message = "6002")
|
||||
private String target;
|
||||
/** 父菜单代码 */
|
||||
@ApiModelProperty(value = "父菜单代码")
|
||||
private String parentTarget;
|
||||
|
||||
/** 目标菜单名称 */
|
||||
@ApiModelProperty(value = "菜单名称")
|
||||
@NotEmpty(message = "6002")
|
||||
private String targetName;
|
||||
/** 目标菜单 */
|
||||
@ApiModelProperty(value = "菜单代码")
|
||||
@NotEmpty(message = "6002")
|
||||
private String target;
|
||||
|
||||
/** 目标按钮 */
|
||||
@ApiModelProperty(value = "按钮代码")
|
||||
@NotEmpty(message = "6002")
|
||||
private String action;
|
||||
/** 目标菜单名称 */
|
||||
@ApiModelProperty(value = "菜单名称")
|
||||
@NotEmpty(message = "6002")
|
||||
private String targetName;
|
||||
|
||||
/** 目标按钮名称 */
|
||||
@ApiModelProperty(value = "按钮名称")
|
||||
@NotEmpty(message = "6002")
|
||||
private String actionName;
|
||||
/** 目标按钮 */
|
||||
@ApiModelProperty(value = "按钮代码")
|
||||
@NotEmpty(message = "6002")
|
||||
private String action;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
@ApiModelProperty(value = " 0--未删除 1--已删除 DIC_NAME=DEL_FLAG")
|
||||
private Integer deleteFlag;
|
||||
/** 目标按钮名称 */
|
||||
@ApiModelProperty(value = "按钮名称")
|
||||
@NotEmpty(message = "6002")
|
||||
private String actionName;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
@NotNull(message = "6002")
|
||||
private Integer enableFlag;
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
@ApiModelProperty(value = " 0--未删除 1--已删除 DIC_NAME=DEL_FLAG")
|
||||
private Integer deleteFlag;
|
||||
|
||||
@ApiModelProperty(value = "sort")
|
||||
private Integer sort;
|
||||
}
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
@NotNull(message = "6002")
|
||||
private Integer enableFlag;
|
||||
|
||||
@ApiModelProperty(value = "sort")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
+27
-28
@@ -1,44 +1,43 @@
|
||||
/**/
|
||||
package com.anjiplus.template.gaea.business.modules.accessauthority.controller.param;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import com.anji.plus.gaea.annotation.Query;
|
||||
import com.anji.plus.gaea.constant.QueryEnum;
|
||||
import com.anji.plus.gaea.curd.params.PageParam;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @desc AccessAuthority 权限管理查询输入类
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
* @desc AccessAuthority 权限管理查询输入类
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
@Data
|
||||
public class AccessAuthorityParam extends PageParam implements Serializable{
|
||||
public class AccessAuthorityParam extends PageParam implements Serializable {
|
||||
|
||||
/** 父菜单代码 */
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String parentTarget;
|
||||
/** 父菜单代码 */
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String parentTarget;
|
||||
|
||||
/** 菜单代码 */
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String target;
|
||||
/** 菜单代码 */
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String target;
|
||||
|
||||
/** 菜单名称 */
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String targetName;
|
||||
/** 菜单名称 */
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String targetName;
|
||||
|
||||
/** 按钮代码 */
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String action;
|
||||
/** 按钮代码 */
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String action;
|
||||
|
||||
/** 按钮名称 */
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String actionName;
|
||||
/** 按钮名称 */
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String actionName;
|
||||
|
||||
// 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG
|
||||
@Query
|
||||
private Integer enableFlag;
|
||||
}
|
||||
// 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG
|
||||
@Query
|
||||
private Integer enableFlag;
|
||||
|
||||
}
|
||||
+7
-8
@@ -1,17 +1,16 @@
|
||||
package com.anjiplus.template.gaea.business.modules.accessauthority.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.dao.entity.AccessAuthority;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* AccessAuthority Mapper
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
* AccessAuthority Mapper
|
||||
*
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
@Mapper
|
||||
public interface AccessAuthorityMapper extends GaeaBaseMapper<AccessAuthority> {
|
||||
|
||||
}
|
||||
}
|
||||
+22
-25
@@ -1,43 +1,40 @@
|
||||
|
||||
package com.anjiplus.template.gaea.business.modules.accessauthority.dao.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import com.anji.plus.gaea.curd.entity.GaeaBaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description 权限管理 entity
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
@TableName(keepGlobalPrefix=true, value="access_authority")
|
||||
* @description 权限管理 entity
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
@TableName(keepGlobalPrefix = true, value = "access_authority")
|
||||
@Data
|
||||
public class AccessAuthority extends GaeaBaseEntity {
|
||||
/** 父菜单代码 */
|
||||
private String parentTarget;
|
||||
|
||||
/** 菜单代码 */
|
||||
private String target;
|
||||
/** 父菜单代码 */
|
||||
private String parentTarget;
|
||||
|
||||
/** 菜单名称 */
|
||||
private String targetName;
|
||||
/** 菜单代码 */
|
||||
private String target;
|
||||
|
||||
/** 按钮代码 */
|
||||
private String action;
|
||||
/** 菜单名称 */
|
||||
private String targetName;
|
||||
|
||||
/** 按钮名称 */
|
||||
private String actionName;
|
||||
/** 按钮代码 */
|
||||
private String action;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
private Integer deleteFlag;
|
||||
/** 按钮名称 */
|
||||
private String actionName;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
|
||||
private Integer sort;
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
private Integer deleteFlag;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
+18
-17
@@ -2,28 +2,29 @@
|
||||
package com.anjiplus.template.gaea.business.modules.accessauthority.service;
|
||||
|
||||
import com.anji.plus.gaea.bean.TreeNode;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.dao.entity.AccessAuthority;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.controller.param.AccessAuthorityParam;
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.controller.param.AccessAuthorityParam;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.dao.entity.AccessAuthority;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @desc AccessAuthority 权限管理服务接口
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
* @desc AccessAuthority 权限管理服务接口
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
public interface AccessAuthorityService extends GaeaBaseService<AccessAuthorityParam, AccessAuthority> {
|
||||
|
||||
/**
|
||||
* @param loginName 当前登录的用户名
|
||||
* @param withActionNode 带第三层的按钮节点
|
||||
* @return
|
||||
*/
|
||||
List<TreeNode> getAuthorityTree(String loginName, boolean withActionNode);
|
||||
/**
|
||||
* @param loginName 当前登录的用户名
|
||||
* @param withActionNode 带第三层的按钮节点
|
||||
* @return
|
||||
*/
|
||||
List<TreeNode> getAuthorityTree(String loginName, boolean withActionNode);
|
||||
|
||||
/**
|
||||
* 扫描所有mvc url的需要权限码,建立拦截体系
|
||||
*/
|
||||
void scanGaeaSecurityAuthorities();
|
||||
}
|
||||
/**
|
||||
* 扫描所有mvc url的需要权限码,建立拦截体系
|
||||
*/
|
||||
void scanGaeaSecurityAuthorities();
|
||||
|
||||
}
|
||||
+95
-97
@@ -1,16 +1,15 @@
|
||||
|
||||
package com.anjiplus.template.gaea.business.modules.accessauthority.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.anji.plus.gaea.bean.TreeNode;
|
||||
import com.anji.plus.gaea.cache.CacheHelper;
|
||||
import com.anji.plus.gaea.constant.Enabled;
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anji.plus.gaea.init.InitRequestUrlMappings;
|
||||
import com.anjiplus.template.gaea.business.constant.BusinessConstant;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.dao.AccessAuthorityMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.dao.entity.AccessAuthority;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.service.AccessAuthorityService;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.dao.AccessAuthorityMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -24,117 +23,116 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @desc AccessAuthority 权限管理服务实现
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
* @desc AccessAuthority 权限管理服务实现
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:10.009
|
||||
**/
|
||||
@Service
|
||||
public class AccessAuthorityServiceImpl implements AccessAuthorityService {
|
||||
|
||||
@Autowired
|
||||
private InitRequestUrlMappings initRequestUrlMappings;
|
||||
@Autowired
|
||||
private InitRequestUrlMappings initRequestUrlMappings;
|
||||
|
||||
@Autowired
|
||||
private CacheHelper cacheHelper;
|
||||
@Autowired
|
||||
private CacheHelper cacheHelper;
|
||||
|
||||
@Autowired
|
||||
private AccessAuthorityMapper accessAuthorityMapper;
|
||||
@Autowired
|
||||
private AccessAuthorityMapper accessAuthorityMapper;
|
||||
|
||||
@Override
|
||||
public GaeaBaseMapper<AccessAuthority> getMapper() {
|
||||
return accessAuthorityMapper;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseMapper<AccessAuthority> getMapper() {
|
||||
return accessAuthorityMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeNode> getAuthorityTree(String loginName, boolean withActionNode) {
|
||||
// 查询出所有的菜单记录
|
||||
LambdaQueryWrapper<AccessAuthority> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.select(AccessAuthority::getParentTarget, AccessAuthority::getTarget, AccessAuthority::getTargetName, AccessAuthority::getAction, AccessAuthority::getActionName)
|
||||
.eq(AccessAuthority::getEnableFlag, 1)
|
||||
.eq(AccessAuthority::getDeleteFlag, 0)
|
||||
.orderByAsc(AccessAuthority::getSort);
|
||||
// 按operator去筛选 后面再加where
|
||||
List<AccessAuthority> accessAuthorityList = getMapper().selectList(wrapper);
|
||||
@Override
|
||||
public List<TreeNode> getAuthorityTree(String loginName, boolean withActionNode) {
|
||||
// 查询出所有的菜单记录
|
||||
LambdaQueryWrapper<AccessAuthority> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.select(AccessAuthority::getParentTarget, AccessAuthority::getTarget, AccessAuthority::getTargetName,
|
||||
AccessAuthority::getAction, AccessAuthority::getActionName).eq(AccessAuthority::getEnableFlag, 1)
|
||||
.eq(AccessAuthority::getDeleteFlag, 0).orderByAsc(AccessAuthority::getSort);
|
||||
// 按operator去筛选 后面再加where
|
||||
List<AccessAuthority> accessAuthorityList = getMapper().selectList(wrapper);
|
||||
|
||||
// 筛选出一级菜单
|
||||
List<TreeNode> parentNodes = accessAuthorityList.stream().filter(accessAuthority -> StringUtils.isBlank(accessAuthority.getParentTarget()))
|
||||
.map(item -> {
|
||||
TreeNode treeNode = new TreeNode();
|
||||
treeNode.setId(item.getTarget());
|
||||
treeNode.setLabel(item.getTargetName());
|
||||
return treeNode;
|
||||
}).collect(Collectors.toList());
|
||||
// 筛选出一级菜单
|
||||
List<TreeNode> parentNodes = accessAuthorityList.stream()
|
||||
.filter(accessAuthority -> StringUtils.isBlank(accessAuthority.getParentTarget())).map(item -> {
|
||||
TreeNode treeNode = new TreeNode();
|
||||
treeNode.setId(item.getTarget());
|
||||
treeNode.setLabel(item.getTargetName());
|
||||
return treeNode;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 菜单-按钮的map
|
||||
Map<String, List<AccessAuthority>> targetActionsMap = accessAuthorityList.stream()
|
||||
.filter(accessAuthority -> StringUtils.isNoneBlank(accessAuthority.getParentTarget()))
|
||||
.collect(Collectors.groupingBy(AccessAuthority::getTarget));
|
||||
// 菜单-按钮的map
|
||||
Map<String, List<AccessAuthority>> targetActionsMap = accessAuthorityList.stream()
|
||||
.filter(accessAuthority -> StringUtils.isNoneBlank(accessAuthority.getParentTarget()))
|
||||
.collect(Collectors.groupingBy(AccessAuthority::getTarget));
|
||||
|
||||
// 设置每个一级菜单的二菜单
|
||||
parentNodes.stream().forEach(parentNode -> {
|
||||
List<String> alreadyTargets = new ArrayList<>();
|
||||
// 设置每个一级菜单的二菜单
|
||||
parentNodes.stream().forEach(parentNode -> {
|
||||
List<String> alreadyTargets = new ArrayList<>();
|
||||
|
||||
accessAuthorityList.stream().forEach(authority -> {
|
||||
if(!StringUtils.equals(parentNode.getId(), authority.getParentTarget()) || alreadyTargets.contains(authority.getTarget())){
|
||||
return;
|
||||
}
|
||||
// 找到一级菜单对应的二级菜单
|
||||
accessAuthorityList.stream().forEach(authority -> {
|
||||
if (!StringUtils.equals(parentNode.getId(), authority.getParentTarget())
|
||||
|| alreadyTargets.contains(authority.getTarget())) {
|
||||
return;
|
||||
}
|
||||
// 找到一级菜单对应的二级菜单
|
||||
|
||||
// 初始化二级菜单节点
|
||||
TreeNode levelTwoMenuNode = new TreeNode();
|
||||
levelTwoMenuNode.setId(authority.getTarget());
|
||||
levelTwoMenuNode.setLabel(authority.getTargetName());
|
||||
levelTwoMenuNode.setChildren(new ArrayList<TreeNode>());
|
||||
// 初始化二级菜单节点
|
||||
TreeNode levelTwoMenuNode = new TreeNode();
|
||||
levelTwoMenuNode.setId(authority.getTarget());
|
||||
levelTwoMenuNode.setLabel(authority.getTargetName());
|
||||
levelTwoMenuNode.setChildren(new ArrayList<TreeNode>());
|
||||
|
||||
// 初始化二级菜单的按钮
|
||||
if(withActionNode){
|
||||
List<AccessAuthority> actionList = targetActionsMap.get(authority.getTarget());
|
||||
if(actionList != null && !actionList.isEmpty()){
|
||||
actionList.stream().forEach(action ->{
|
||||
TreeNode buttonNode = new TreeNode();
|
||||
buttonNode.setId(String.format("%s_%s", action.getTarget(), action.getAction()));
|
||||
buttonNode.setLabel(action.getActionName());
|
||||
levelTwoMenuNode.getChildren().add(buttonNode);
|
||||
});
|
||||
}
|
||||
}
|
||||
// 初始化二级菜单的按钮
|
||||
if (withActionNode) {
|
||||
List<AccessAuthority> actionList = targetActionsMap.get(authority.getTarget());
|
||||
if (actionList != null && !actionList.isEmpty()) {
|
||||
actionList.stream().forEach(action -> {
|
||||
TreeNode buttonNode = new TreeNode();
|
||||
buttonNode.setId(String.format("%s_%s", action.getTarget(), action.getAction()));
|
||||
buttonNode.setLabel(action.getActionName());
|
||||
levelTwoMenuNode.getChildren().add(buttonNode);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 将上面找到的二级菜单加入到一菜单的子树中去
|
||||
List<TreeNode> children = parentNode.getChildren();
|
||||
if(children == null){
|
||||
children = new ArrayList<TreeNode>();
|
||||
}
|
||||
children.add(levelTwoMenuNode);
|
||||
parentNode.setChildren(children);
|
||||
// 将上面找到的二级菜单加入到一菜单的子树中去
|
||||
List<TreeNode> children = parentNode.getChildren();
|
||||
if (children == null) {
|
||||
children = new ArrayList<TreeNode>();
|
||||
}
|
||||
children.add(levelTwoMenuNode);
|
||||
parentNode.setChildren(children);
|
||||
|
||||
// 已经找过的二级菜单,后面不在重复添加
|
||||
alreadyTargets.add(authority.getTarget());
|
||||
});
|
||||
});
|
||||
// 已经找过的二级菜单,后面不在重复添加
|
||||
alreadyTargets.add(authority.getTarget());
|
||||
});
|
||||
});
|
||||
|
||||
return parentNodes;
|
||||
}
|
||||
return parentNodes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scanGaeaSecurityAuthorities() {
|
||||
/* 获取当前应用中所有的请求信息
|
||||
{
|
||||
"applicationName": "aj-report",
|
||||
"authCode": "authorityManage:query",
|
||||
"authName": "权限管理查询",
|
||||
"beanName": "accessAuthorityController",
|
||||
"menuCode": "authorityManage",
|
||||
"path": "GET#/accessAuthority/menuTree"
|
||||
}*/
|
||||
List<InitRequestUrlMappings.RequestInfo> requestInfos = initRequestUrlMappings.getRequestInfos(Enabled.YES.getValue());
|
||||
@Override
|
||||
public void scanGaeaSecurityAuthorities() {
|
||||
/*
|
||||
* 获取当前应用中所有的请求信息 { "applicationName": "aj-report", "authCode":
|
||||
* "authorityManage:query", "authName": "权限管理查询", "beanName":
|
||||
* "accessAuthorityController", "menuCode": "authorityManage", "path":
|
||||
* "GET#/accessAuthority/menuTree" }
|
||||
*/
|
||||
List<InitRequestUrlMappings.RequestInfo> requestInfos = initRequestUrlMappings
|
||||
.getRequestInfos(Enabled.YES.getValue());
|
||||
|
||||
// key="GET#/accessAuthority/menuTree" value="authorityManage:query"
|
||||
Map<String, String> securityAuthorityMap = new HashMap<String, String>();
|
||||
requestInfos.stream().forEach(requestInfo -> {
|
||||
securityAuthorityMap.put(requestInfo.getPath(), requestInfo.getAuthCode());
|
||||
});
|
||||
// key="GET#/accessAuthority/menuTree" value="authorityManage:query"
|
||||
Map<String, String> securityAuthorityMap = new HashMap<String, String>();
|
||||
requestInfos.stream().forEach(requestInfo -> {
|
||||
securityAuthorityMap.put(requestInfo.getPath(), requestInfo.getAuthCode());
|
||||
});
|
||||
|
||||
// 将key存入到缓存中
|
||||
cacheHelper.hashSet(BusinessConstant.GAEA_SECURITY_AUTHORITIES, securityAuthorityMap);
|
||||
}
|
||||
}
|
||||
// 将key存入到缓存中
|
||||
cacheHelper.hashSet(BusinessConstant.GAEA_SECURITY_AUTHORITIES, securityAuthorityMap);
|
||||
}
|
||||
|
||||
}
|
||||
+44
-48
@@ -2,74 +2,70 @@
|
||||
package com.anjiplus.template.gaea.business.modules.accessrole.controller;
|
||||
|
||||
import com.anji.plus.gaea.annotation.Permission;
|
||||
import com.anji.plus.gaea.annotation.AccessKey;
|
||||
import com.anji.plus.gaea.bean.ResponseBean;
|
||||
import com.anji.plus.gaea.bean.TreeNode;
|
||||
import com.anji.plus.gaea.curd.controller.GaeaBaseController;
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
import com.anji.plus.gaea.holder.UserContentHolder;
|
||||
import com.anji.plus.gaea.utils.GaeaBeanUtils;
|
||||
import com.anji.plus.gaea.utils.GaeaUtils;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.service.AccessRoleService;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.controller.dto.AccessRoleDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.controller.param.AccessRoleParam;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.service.AccessRoleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.Api;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @desc 角色管理 controller
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
* @desc 角色管理 controller
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "角色管理管理")
|
||||
@RequestMapping("/accessRole")
|
||||
@Permission(code = "roleManage", name = "角色管理")
|
||||
public class AccessRoleController extends GaeaBaseController<AccessRoleParam, AccessRole, AccessRoleDto> {
|
||||
|
||||
@Autowired
|
||||
private AccessRoleService accessRoleService;
|
||||
@Autowired
|
||||
private AccessRoleService accessRoleService;
|
||||
|
||||
@Override
|
||||
public GaeaBaseService<AccessRoleParam, AccessRole> getService() {
|
||||
return accessRoleService;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseService<AccessRoleParam, AccessRole> getService() {
|
||||
return accessRoleService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRole getEntity() {
|
||||
return new AccessRole();
|
||||
}
|
||||
@Override
|
||||
public AccessRole getEntity() {
|
||||
return new AccessRole();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRoleDto getDTO() {
|
||||
return new AccessRoleDto();
|
||||
}
|
||||
@Override
|
||||
public AccessRoleDto getDTO() {
|
||||
return new AccessRoleDto();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色的 菜单按钮树 一级菜单 二级菜单 三级按钮
|
||||
* @return
|
||||
*/
|
||||
@Permission( code = "grantAuthority", name = "分配权限")
|
||||
@GetMapping("/authorityTree/{roleCode}")
|
||||
public ResponseBean authorityTree(@PathVariable("roleCode")String roleCode){
|
||||
String operator = UserContentHolder.getContext().getUsername();
|
||||
Map map = accessRoleService.getAuthorityTree(roleCode, operator);
|
||||
return responseSuccessWithData(map);
|
||||
}
|
||||
/**
|
||||
* 获取角色的 菜单按钮树 一级菜单 二级菜单 三级按钮
|
||||
* @return
|
||||
*/
|
||||
@Permission(code = "grantAuthority", name = "分配权限")
|
||||
@GetMapping("/authorityTree/{roleCode}")
|
||||
public ResponseBean authorityTree(@PathVariable("roleCode") String roleCode) {
|
||||
String operator = UserContentHolder.getContext().getUsername();
|
||||
Map map = accessRoleService.getAuthorityTree(roleCode, operator);
|
||||
return responseSuccessWithData(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存角色的权限
|
||||
* @return
|
||||
*/
|
||||
@Permission( code = "grantAuthority", name = "分配权限")
|
||||
@PostMapping("/saveAuthorityTree")
|
||||
public ResponseBean saveAuthorityTree(@RequestBody AccessRoleDto dto){
|
||||
Boolean data = accessRoleService.saveAuthorityTree(dto);
|
||||
return responseSuccessWithData(data);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 保存角色的权限
|
||||
* @return
|
||||
*/
|
||||
@Permission(code = "grantAuthority", name = "分配权限")
|
||||
@PostMapping("/saveAuthorityTree")
|
||||
public ResponseBean saveAuthorityTree(@RequestBody AccessRoleDto dto) {
|
||||
Boolean data = accessRoleService.saveAuthorityTree(dto);
|
||||
return responseSuccessWithData(data);
|
||||
}
|
||||
|
||||
}
|
||||
+28
-31
@@ -1,46 +1,43 @@
|
||||
|
||||
package com.anjiplus.template.gaea.business.modules.accessrole.controller.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.anji.plus.gaea.annotation.Query;
|
||||
import com.anji.plus.gaea.constant.QueryEnum;
|
||||
import com.anji.plus.gaea.curd.dto.GaeaBaseDTO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.anji.plus.gaea.annotation.Formatter;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 角色管理 dto
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
* @description 角色管理 dto
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
@Data
|
||||
public class AccessRoleDto extends GaeaBaseDTO implements Serializable {
|
||||
|
||||
/** 角色编码 */
|
||||
@ApiModelProperty(value = "角色编码")
|
||||
@NotEmpty(message = "6002")
|
||||
private String roleCode;
|
||||
/** 角色编码 */
|
||||
@ApiModelProperty(value = "角色编码")
|
||||
@NotEmpty(message = "6002")
|
||||
private String roleCode;
|
||||
|
||||
/** 角色名称 */
|
||||
@ApiModelProperty(value = "角色名称")
|
||||
@NotEmpty(message = "6002")
|
||||
private String roleName;
|
||||
/** 角色名称 */
|
||||
@ApiModelProperty(value = "角色名称")
|
||||
@NotEmpty(message = "6002")
|
||||
private String roleName;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
@ApiModelProperty(value = " 0--未删除 1--已删除 DIC_NAME=DEL_FLAG")
|
||||
private Integer deleteFlag;
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
@ApiModelProperty(value = " 0--未删除 1--已删除 DIC_NAME=DEL_FLAG")
|
||||
private Integer deleteFlag;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
@NotNull(message = "6002")
|
||||
private Integer enableFlag;
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
@NotNull(message = "6002")
|
||||
private Integer enableFlag;
|
||||
|
||||
/** 角色保存的权限 */
|
||||
private List<String> authorityList;
|
||||
}
|
||||
/** 角色保存的权限 */
|
||||
private List<String> authorityList;
|
||||
|
||||
}
|
||||
+17
-19
@@ -1,33 +1,31 @@
|
||||
/**/
|
||||
package com.anjiplus.template.gaea.business.modules.accessrole.controller.param;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import com.anji.plus.gaea.annotation.Query;
|
||||
import com.anji.plus.gaea.constant.QueryEnum;
|
||||
import com.anji.plus.gaea.curd.params.PageParam;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @desc AccessRole 角色管理查询输入类
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
* @desc AccessRole 角色管理查询输入类
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
@Data
|
||||
public class AccessRoleParam extends PageParam implements Serializable{
|
||||
public class AccessRoleParam extends PageParam implements Serializable {
|
||||
|
||||
/** 角色编码 */
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String roleCode;
|
||||
/** 角色编码 */
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String roleCode;
|
||||
|
||||
// 角色名称
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String roleName;
|
||||
// 角色名称
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String roleName;
|
||||
|
||||
// 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG
|
||||
@Query
|
||||
private Integer enableFlag;
|
||||
// 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG
|
||||
@Query
|
||||
private Integer enableFlag;
|
||||
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -5,10 +5,11 @@ import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessR
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* AccessRoleAuthority Mapper
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
* AccessRoleAuthority Mapper
|
||||
*
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
@Mapper
|
||||
public interface AccessRoleAuthorityMapper extends GaeaBaseMapper<AccessRoleAuthority> {
|
||||
|
||||
|
||||
+9
-10
@@ -1,22 +1,21 @@
|
||||
package com.anjiplus.template.gaea.business.modules.accessrole.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AccessRole Mapper
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
* AccessRole Mapper
|
||||
*
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
@Mapper
|
||||
public interface AccessRoleMapper extends GaeaBaseMapper<AccessRole> {
|
||||
|
||||
List<String> checkedAuthoritys(@Param("roleCode")String roleCode);
|
||||
}
|
||||
List<String> checkedAuthoritys(@Param("roleCode") String roleCode);
|
||||
|
||||
}
|
||||
+15
-16
@@ -1,30 +1,29 @@
|
||||
|
||||
package com.anjiplus.template.gaea.business.modules.accessrole.dao.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import com.anji.plus.gaea.curd.entity.GaeaBaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description 角色管理 entity
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
@TableName(keepGlobalPrefix=true, value="access_role")
|
||||
* @description 角色管理 entity
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
@TableName(keepGlobalPrefix = true, value = "access_role")
|
||||
@Data
|
||||
public class AccessRole extends GaeaBaseEntity {
|
||||
|
||||
/** 角色编码 */
|
||||
private String roleCode;
|
||||
/** 角色编码 */
|
||||
private String roleCode;
|
||||
|
||||
/** 角色名称 */
|
||||
private String roleName;
|
||||
/** 角色名称 */
|
||||
private String roleName;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
private Integer deleteFlag;
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
private Integer deleteFlag;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
|
||||
}
|
||||
+18
-19
@@ -1,10 +1,8 @@
|
||||
package com.anjiplus.template.gaea.business.modules.accessrole.dao.entity;
|
||||
|
||||
import com.anji.plus.gaea.curd.entity.GaeaBaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.Version;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -14,31 +12,32 @@ import java.util.Date;
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
@TableName(keepGlobalPrefix=true, value="access_role_authority")
|
||||
@TableName(keepGlobalPrefix = true, value = "access_role_authority")
|
||||
@Data
|
||||
public class AccessRoleAuthority extends GaeaBaseEntity {
|
||||
|
||||
/** 角色编码 */
|
||||
private String roleCode;
|
||||
/** 角色编码 */
|
||||
private String roleCode;
|
||||
|
||||
/** 菜单代码 */
|
||||
private String target;
|
||||
/** 菜单代码 */
|
||||
private String target;
|
||||
|
||||
/** 按钮代码 */
|
||||
private String action;
|
||||
/** 按钮代码 */
|
||||
private String action;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String createBy;
|
||||
@TableField(exist = false)
|
||||
private String createBy;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Date createTime;
|
||||
@TableField(exist = false)
|
||||
private Date createTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String updateBy;
|
||||
@TableField(exist = false)
|
||||
private String updateBy;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Date updateTime;
|
||||
@TableField(exist = false)
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer version;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer version;
|
||||
}
|
||||
+21
-22
@@ -1,34 +1,33 @@
|
||||
|
||||
package com.anjiplus.template.gaea.business.modules.accessrole.service;
|
||||
|
||||
import com.anji.plus.gaea.bean.ResponseBean;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.controller.dto.AccessRoleDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.controller.param.AccessRoleParam;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.controller.dto.AccessRoleDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.controller.param.AccessRoleParam;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @desc AccessRole 角色管理服务接口
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
* @desc AccessRole 角色管理服务接口
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
public interface AccessRoleService extends GaeaBaseService<AccessRoleParam, AccessRole> {
|
||||
|
||||
/** 查询某角色的权限树
|
||||
* @param roleCode 被操作的对象
|
||||
* @param operator 当前登录者
|
||||
* @return
|
||||
*/
|
||||
Map getAuthorityTree(String roleCode, String operator);
|
||||
/**
|
||||
* 查询某角色的权限树
|
||||
* @param roleCode 被操作的对象
|
||||
* @param operator 当前登录者
|
||||
* @return
|
||||
*/
|
||||
Map getAuthorityTree(String roleCode, String operator);
|
||||
|
||||
/**
|
||||
* 保存角色的权限
|
||||
* @param accessRoleDto
|
||||
* @return
|
||||
*/
|
||||
Boolean saveAuthorityTree(AccessRoleDto accessRoleDto);
|
||||
|
||||
/** 保存角色的权限
|
||||
* @param accessRoleDto
|
||||
* @return
|
||||
*/
|
||||
Boolean saveAuthorityTree(AccessRoleDto accessRoleDto);
|
||||
}
|
||||
}
|
||||
+64
-61
@@ -8,10 +8,10 @@ import com.anjiplus.template.gaea.business.code.ResponseCode;
|
||||
import com.anjiplus.template.gaea.business.modules.accessauthority.service.AccessAuthorityService;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.controller.dto.AccessRoleDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.dao.AccessRoleAuthorityMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.dao.AccessRoleMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRoleAuthority;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.service.AccessRoleService;
|
||||
import com.anjiplus.template.gaea.business.modules.accessrole.dao.AccessRoleMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -24,78 +24,81 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @desc AccessRole 角色管理服务实现
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
* @desc AccessRole 角色管理服务实现
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:14.136
|
||||
**/
|
||||
@Service
|
||||
public class AccessRoleServiceImpl implements AccessRoleService {
|
||||
|
||||
@Autowired
|
||||
private AccessRoleMapper accessRoleMapper;
|
||||
@Autowired
|
||||
private AccessRoleMapper accessRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private AccessRoleAuthorityMapper accessRoleAuthorityMapper;
|
||||
@Autowired
|
||||
private AccessRoleAuthorityMapper accessRoleAuthorityMapper;
|
||||
|
||||
@Autowired
|
||||
private AccessAuthorityService accessAuthorityService;
|
||||
@Autowired
|
||||
private AccessAuthorityService accessAuthorityService;
|
||||
|
||||
@Override
|
||||
public GaeaBaseMapper<AccessRole> getMapper() {
|
||||
return accessRoleMapper;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseMapper<AccessRole> getMapper() {
|
||||
return accessRoleMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getAuthorityTree(String roleCode, String operator) {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
@Override
|
||||
public Map getAuthorityTree(String roleCode, String operator) {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
|
||||
// 菜单按钮树
|
||||
List<TreeNode> treeData = accessAuthorityService.getAuthorityTree(operator, true);
|
||||
// 菜单按钮树
|
||||
List<TreeNode> treeData = accessAuthorityService.getAuthorityTree(operator, true);
|
||||
|
||||
// 该角色已选中的菜单及按钮
|
||||
// List<String> checkedKeys = accessRoleMapper.checkedAuthoritys(roleCode);
|
||||
// 该角色已选中的菜单及按钮
|
||||
// List<String> checkedKeys = accessRoleMapper.checkedAuthoritys(roleCode);
|
||||
|
||||
LambdaQueryWrapper<AccessRoleAuthority> accessRoleAuthorityWrapper = Wrappers.lambdaQuery();
|
||||
accessRoleAuthorityWrapper.select(AccessRoleAuthority::getTarget, AccessRoleAuthority::getAction);
|
||||
accessRoleAuthorityWrapper.eq(AccessRoleAuthority::getRoleCode, roleCode);
|
||||
List<AccessRoleAuthority> accessRoleAuthorities = accessRoleAuthorityMapper.selectList(accessRoleAuthorityWrapper);
|
||||
List<String> checkedKeys = accessRoleAuthorities.stream()
|
||||
.map(accessRoleAuthority -> accessRoleAuthority.getTarget().concat("_").concat(accessRoleAuthority.getAction())).distinct().collect(Collectors.toList());
|
||||
LambdaQueryWrapper<AccessRoleAuthority> accessRoleAuthorityWrapper = Wrappers.lambdaQuery();
|
||||
accessRoleAuthorityWrapper.select(AccessRoleAuthority::getTarget, AccessRoleAuthority::getAction);
|
||||
accessRoleAuthorityWrapper.eq(AccessRoleAuthority::getRoleCode, roleCode);
|
||||
List<AccessRoleAuthority> accessRoleAuthorities = accessRoleAuthorityMapper
|
||||
.selectList(accessRoleAuthorityWrapper);
|
||||
List<String> checkedKeys = accessRoleAuthorities.stream().map(accessRoleAuthority -> accessRoleAuthority
|
||||
.getTarget().concat("_").concat(accessRoleAuthority.getAction())).distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
result.put("treeData", treeData);
|
||||
result.put("checkedKeys", checkedKeys);
|
||||
return result;
|
||||
}
|
||||
result.put("treeData", treeData);
|
||||
result.put("checkedKeys", checkedKeys);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean saveAuthorityTree(AccessRoleDto accessRoleDto) {
|
||||
// 校验
|
||||
String roleCode = accessRoleDto.getRoleCode();
|
||||
List<String> authorityList = accessRoleDto.getAuthorityList();
|
||||
if(StringUtils.isBlank(roleCode)){
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, roleCode);
|
||||
}
|
||||
if(authorityList == null || authorityList.isEmpty()){
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, authorityList);
|
||||
}
|
||||
@Override
|
||||
public Boolean saveAuthorityTree(AccessRoleDto accessRoleDto) {
|
||||
// 校验
|
||||
String roleCode = accessRoleDto.getRoleCode();
|
||||
List<String> authorityList = accessRoleDto.getAuthorityList();
|
||||
if (StringUtils.isBlank(roleCode)) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, roleCode);
|
||||
}
|
||||
if (authorityList == null || authorityList.isEmpty()) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, authorityList);
|
||||
}
|
||||
|
||||
// 先清除该角色已保存的权限
|
||||
LambdaQueryWrapper<AccessRoleAuthority> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(AccessRoleAuthority::getRoleCode, roleCode);
|
||||
accessRoleAuthorityMapper.delete(wrapper);
|
||||
// 先清除该角色已保存的权限
|
||||
LambdaQueryWrapper<AccessRoleAuthority> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(AccessRoleAuthority::getRoleCode, roleCode);
|
||||
accessRoleAuthorityMapper.delete(wrapper);
|
||||
|
||||
// 保存勾选的权限(菜单和按钮)
|
||||
authorityList.stream().forEach(authorityStr -> {
|
||||
if (!authorityStr.contains("_")) {
|
||||
return;
|
||||
}
|
||||
String[] array = authorityStr.split("_");
|
||||
AccessRoleAuthority accessRoleAuthority = new AccessRoleAuthority();
|
||||
accessRoleAuthority.setRoleCode(roleCode);
|
||||
accessRoleAuthority.setTarget(array[0].trim());
|
||||
accessRoleAuthority.setAction(array[1].trim());
|
||||
accessRoleAuthorityMapper.insert(accessRoleAuthority);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
// 保存勾选的权限(菜单和按钮)
|
||||
authorityList.stream().forEach(authorityStr -> {
|
||||
if(!authorityStr.contains("_")){
|
||||
return;
|
||||
}
|
||||
String[] array = authorityStr.split("_");
|
||||
AccessRoleAuthority accessRoleAuthority = new AccessRoleAuthority();
|
||||
accessRoleAuthority.setRoleCode(roleCode);
|
||||
accessRoleAuthority.setTarget(array[0].trim());
|
||||
accessRoleAuthority.setAction(array[1].trim());
|
||||
accessRoleAuthorityMapper.insert(accessRoleAuthority);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+72
-79
@@ -6,108 +6,101 @@ import com.anji.plus.gaea.bean.ResponseBean;
|
||||
import com.anji.plus.gaea.curd.controller.GaeaBaseController;
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
import com.anji.plus.gaea.holder.UserContentHolder;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.AccessUserDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.GaeaUserDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.UpdatePasswordDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.param.AccessUserParam;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.dao.entity.AccessUser;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.service.AccessUserService;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.AccessUserDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.param.AccessUserParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
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.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @desc 用户管理 controller
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
* @desc 用户管理 controller
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "用户管理管理")
|
||||
@RequestMapping("/accessUser")
|
||||
@Permission(code = "userManage", name = "用户管理")
|
||||
public class AccessUserController extends GaeaBaseController<AccessUserParam, AccessUser, AccessUserDto> {
|
||||
|
||||
@Autowired
|
||||
private AccessUserService accessUserService;
|
||||
@Autowired
|
||||
private AccessUserService accessUserService;
|
||||
|
||||
@Override
|
||||
public GaeaBaseService<AccessUserParam, AccessUser> getService() {
|
||||
return accessUserService;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseService<AccessUserParam, AccessUser> getService() {
|
||||
return accessUserService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessUser getEntity() {
|
||||
return new AccessUser();
|
||||
}
|
||||
@Override
|
||||
public AccessUser getEntity() {
|
||||
return new AccessUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessUserDto getDTO() {
|
||||
return new AccessUserDto();
|
||||
}
|
||||
@Override
|
||||
public AccessUserDto getDTO() {
|
||||
return new AccessUserDto();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户的角色树
|
||||
* @return
|
||||
*/
|
||||
@Permission(code = "grantRole", name = "分配角色")
|
||||
@GetMapping("/roleTree/{loginName}")
|
||||
public ResponseBean getRoleTree(@PathVariable("loginName") String loginName) {
|
||||
String operator = UserContentHolder.getContext().getUsername();
|
||||
Map map = accessUserService.getRoleTree(loginName, operator);
|
||||
return responseSuccessWithData(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户的角色树
|
||||
* @return
|
||||
*/
|
||||
@Permission( code = "grantRole", name = "分配角色")
|
||||
@GetMapping("/roleTree/{loginName}")
|
||||
public ResponseBean getRoleTree(@PathVariable("loginName")String loginName){
|
||||
String operator = UserContentHolder.getContext().getUsername();
|
||||
Map map = accessUserService.getRoleTree(loginName, operator);
|
||||
return responseSuccessWithData(map);
|
||||
}
|
||||
/**
|
||||
* 保存用户的角色树
|
||||
* @return
|
||||
*/
|
||||
@Permission(code = "grantRole", name = "分配角色")
|
||||
@PostMapping("/saveRoleTree")
|
||||
public ResponseBean saveRoleTree(@RequestBody AccessUserDto dto) {
|
||||
Boolean data = accessUserService.saveRoleTree(dto);
|
||||
return responseSuccessWithData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户的角色树
|
||||
* @return
|
||||
*/
|
||||
@Permission( code = "grantRole", name = "分配角色")
|
||||
@PostMapping("/saveRoleTree")
|
||||
public ResponseBean saveRoleTree(@RequestBody AccessUserDto dto){
|
||||
Boolean data = accessUserService.saveRoleTree(dto);
|
||||
return responseSuccessWithData(data);
|
||||
}
|
||||
/**
|
||||
* 重置密码
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Permission(code = "resetPassword", name = "重置密码")
|
||||
@PostMapping({ "/resetPassword" })
|
||||
public ResponseBean resetPassword(@RequestBody @Validated GaeaUserDto dto) {
|
||||
Boolean data = accessUserService.resetPassword(dto);
|
||||
return responseSuccessWithData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单实现登录
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping({ "/login" })
|
||||
public ResponseBean login(@RequestBody @Validated GaeaUserDto dto) {
|
||||
return responseSuccessWithData(accessUserService.login(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Permission( code = "resetPassword", name = "重置密码")
|
||||
@PostMapping({"/resetPassword"})
|
||||
public ResponseBean resetPassword(@RequestBody @Validated GaeaUserDto dto) {
|
||||
Boolean data = accessUserService.resetPassword(dto);
|
||||
return responseSuccessWithData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单实现登录
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping({"/login"})
|
||||
public ResponseBean login(@RequestBody @Validated GaeaUserDto dto) {
|
||||
return responseSuccessWithData(accessUserService.login(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改自己的密码
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updatePassword")
|
||||
public ResponseBean updatePassword(@RequestBody UpdatePasswordDto dto) {
|
||||
return responseSuccessWithData(accessUserService.updatePassword(dto));
|
||||
}
|
||||
/**
|
||||
* 修改自己的密码
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updatePassword")
|
||||
public ResponseBean updatePassword(@RequestBody UpdatePasswordDto dto) {
|
||||
return responseSuccessWithData(accessUserService.updatePassword(dto));
|
||||
}
|
||||
|
||||
}
|
||||
+42
-44
@@ -1,66 +1,64 @@
|
||||
|
||||
package com.anjiplus.template.gaea.business.modules.accessuser.controller.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import com.anji.plus.gaea.curd.dto.GaeaBaseDTO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.anji.plus.gaea.curd.dto.GaeaBaseDTO;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.dao.entity.AccessUser;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.anji.plus.gaea.annotation.Formatter;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 用户管理 dto
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
* @description 用户管理 dto
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
@Data
|
||||
public class AccessUserDto extends GaeaBaseDTO implements Serializable {
|
||||
|
||||
/** 登录名 */
|
||||
@ApiModelProperty(value = " 登录名")
|
||||
@NotEmpty(message = "6002")
|
||||
private String loginName;
|
||||
/** 登录名 */
|
||||
@ApiModelProperty(value = " 登录名")
|
||||
@NotEmpty(message = "6002")
|
||||
private String loginName;
|
||||
|
||||
/** 真实用户 */
|
||||
@ApiModelProperty(value = "真实用户")
|
||||
@NotEmpty(message = "6002")
|
||||
private String realName;
|
||||
/** 真实用户 */
|
||||
@ApiModelProperty(value = "真实用户")
|
||||
@NotEmpty(message = "6002")
|
||||
private String realName;
|
||||
|
||||
/** 手机号码 */
|
||||
@ApiModelProperty(value = "手机号码")
|
||||
private String phone;
|
||||
/** 手机号码 */
|
||||
@ApiModelProperty(value = "手机号码")
|
||||
private String phone;
|
||||
|
||||
/** 用户邮箱 */
|
||||
@ApiModelProperty(value = "用户邮箱")
|
||||
private String email;
|
||||
/** 用户邮箱 */
|
||||
@ApiModelProperty(value = "用户邮箱")
|
||||
private String email;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
@NotNull(message = "6002")
|
||||
private Integer enableFlag;
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
@NotNull(message = "6002")
|
||||
private Integer enableFlag;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
@ApiModelProperty(value = " 0--未删除 1--已删除 DIC_NAME=DEL_FLAG")
|
||||
private Integer deleteFlag;
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
@ApiModelProperty(value = " 0--未删除 1--已删除 DIC_NAME=DEL_FLAG")
|
||||
private Integer deleteFlag;
|
||||
|
||||
/** 最后一次登录IP */
|
||||
@ApiModelProperty(value = "最后一次登录IP")
|
||||
private String lastLoginIp;
|
||||
/** 最后一次登录IP */
|
||||
@ApiModelProperty(value = "最后一次登录IP")
|
||||
private String lastLoginIp;
|
||||
|
||||
/** 最后一次登陆时间 */
|
||||
@ApiModelProperty(value = "最后一次登陆时间")
|
||||
private Date lastLoginTime;
|
||||
/** 最后一次登陆时间 */
|
||||
@ApiModelProperty(value = "最后一次登陆时间")
|
||||
private Date lastLoginTime;
|
||||
|
||||
/** 备注 */
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
/** 备注 */
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/** 用户勾选的角色 */
|
||||
private List<String> roleCodeList;
|
||||
|
||||
/** 用户勾选的角色 */
|
||||
private List<String> roleCodeList;
|
||||
}
|
||||
+13
-12
@@ -11,20 +11,21 @@ import java.util.List;
|
||||
@Data
|
||||
public class GaeaUserDto {
|
||||
|
||||
@ApiModelProperty(value = "登录名")
|
||||
@NotBlank
|
||||
private String loginName;
|
||||
@ApiModelProperty(value = "登录名")
|
||||
@NotBlank
|
||||
private String loginName;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
@NotBlank
|
||||
private String password;
|
||||
@ApiModelProperty(value = "密码")
|
||||
@NotBlank
|
||||
private String password;
|
||||
|
||||
/** 真实用户 */
|
||||
private String realName;
|
||||
/** 真实用户 */
|
||||
private String realName;
|
||||
|
||||
/** 登录成功后的 */
|
||||
private String token;
|
||||
/** 登录成功后的 */
|
||||
private String token;
|
||||
|
||||
/** 用户所拥有的权限合集 */
|
||||
private List<String> authorities;
|
||||
|
||||
/** 用户所拥有的权限合集 */
|
||||
private List<String> authorities;
|
||||
}
|
||||
+10
-10
@@ -5,21 +5,21 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "修改密码")
|
||||
@Data
|
||||
public class UpdatePasswordDto {
|
||||
|
||||
@ApiModelProperty(value = "旧密码密码")
|
||||
@NotBlank
|
||||
private String oldPassword;
|
||||
@ApiModelProperty(value = "旧密码密码")
|
||||
@NotBlank
|
||||
private String oldPassword;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
@NotBlank
|
||||
private String password;
|
||||
@ApiModelProperty(value = "密码")
|
||||
@NotBlank
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
@NotBlank
|
||||
private String confirmPassword;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
@NotBlank
|
||||
private String confirmPassword;
|
||||
}
|
||||
+20
-22
@@ -1,37 +1,35 @@
|
||||
/**/
|
||||
package com.anjiplus.template.gaea.business.modules.accessuser.controller.param;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import com.anji.plus.gaea.annotation.Query;
|
||||
import com.anji.plus.gaea.constant.QueryEnum;
|
||||
import com.anji.plus.gaea.curd.params.PageParam;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @desc AccessUser 用户管理查询输入类
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
* @desc AccessUser 用户管理查询输入类
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
@Data
|
||||
public class AccessUserParam extends PageParam implements Serializable{
|
||||
public class AccessUserParam extends PageParam implements Serializable {
|
||||
|
||||
// 登录名
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String loginName;
|
||||
// 登录名
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String loginName;
|
||||
|
||||
// 真实用户
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String realName;
|
||||
// 真实用户
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String realName;
|
||||
|
||||
// 手机号码
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String phone;
|
||||
// 手机号码
|
||||
@Query(value = QueryEnum.LIKE)
|
||||
private String phone;
|
||||
|
||||
// 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG
|
||||
@Query
|
||||
private Integer enableFlag;
|
||||
// 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG
|
||||
@Query
|
||||
private Integer enableFlag;
|
||||
|
||||
}
|
||||
}
|
||||
+14
-14
@@ -1,26 +1,26 @@
|
||||
package com.anjiplus.template.gaea.business.modules.accessuser.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.dao.entity.AccessUser;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AccessUser Mapper
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
* AccessUser Mapper
|
||||
*
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
@Mapper
|
||||
public interface AccessUserMapper extends GaeaBaseMapper<AccessUser> {
|
||||
|
||||
/** 查询用户所拥有的所有角色下的权限
|
||||
* @param loginName
|
||||
* @return
|
||||
*/
|
||||
List<String> queryAuthoritiesByLoginName(@Param("loginName")String loginName);
|
||||
}
|
||||
/**
|
||||
* 查询用户所拥有的所有角色下的权限
|
||||
* @param loginName
|
||||
* @return
|
||||
*/
|
||||
List<String> queryAuthoritiesByLoginName(@Param("loginName") String loginName);
|
||||
|
||||
}
|
||||
+5
-4
@@ -5,10 +5,11 @@ import com.anjiplus.template.gaea.business.modules.accessuser.dao.entity.AccessU
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* AccessUser Mapper
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
* AccessUser Mapper
|
||||
*
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
@Mapper
|
||||
public interface AccessUserRoleMapper extends GaeaBaseMapper<AccessUserRole> {
|
||||
|
||||
|
||||
+28
-27
@@ -1,48 +1,49 @@
|
||||
|
||||
package com.anjiplus.template.gaea.business.modules.accessuser.dao.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import com.anji.plus.gaea.curd.entity.GaeaBaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import javax.validation.constraints.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @description 用户管理 entity
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
@TableName(keepGlobalPrefix=true, value="access_user")
|
||||
* @description 用户管理 entity
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
@TableName(keepGlobalPrefix = true, value = "access_user")
|
||||
@Data
|
||||
public class AccessUser extends GaeaBaseEntity {
|
||||
|
||||
/** 登录名 */
|
||||
private String loginName;
|
||||
/** 登录名 */
|
||||
private String loginName;
|
||||
|
||||
/** 密码 */
|
||||
private String password;
|
||||
/** 密码 */
|
||||
private String password;
|
||||
|
||||
/** 真实用户 */
|
||||
private String realName;
|
||||
/** 真实用户 */
|
||||
private String realName;
|
||||
|
||||
/** 手机号码 */
|
||||
private String phone;
|
||||
/** 手机号码 */
|
||||
private String phone;
|
||||
|
||||
/** 用户邮箱 */
|
||||
private String email;
|
||||
/** 用户邮箱 */
|
||||
private String email;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
private Integer deleteFlag;
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
private Integer deleteFlag;
|
||||
|
||||
/** 最后一次登录IP */
|
||||
private String lastLoginIp;
|
||||
/** 最后一次登录IP */
|
||||
private String lastLoginIp;
|
||||
|
||||
/** 最后一次登陆时间 */
|
||||
private Date lastLoginTime;
|
||||
/** 最后一次登陆时间 */
|
||||
private Date lastLoginTime;
|
||||
|
||||
}
|
||||
+20
-19
@@ -9,32 +9,33 @@ import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @description 用户--角色关联关系 entity
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
@TableName(keepGlobalPrefix=true, value="access_user_role")
|
||||
* @description 用户--角色关联关系 entity
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
@TableName(keepGlobalPrefix = true, value = "access_user_role")
|
||||
@Data
|
||||
public class AccessUserRole extends GaeaBaseEntity {
|
||||
|
||||
/** 登录名 */
|
||||
private String loginName;
|
||||
/** 登录名 */
|
||||
private String loginName;
|
||||
|
||||
/** 角色编码 */
|
||||
private String roleCode;
|
||||
/** 角色编码 */
|
||||
private String roleCode;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String createBy;
|
||||
@TableField(exist = false)
|
||||
private String createBy;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Date createTime;
|
||||
@TableField(exist = false)
|
||||
private Date createTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String updateBy;
|
||||
@TableField(exist = false)
|
||||
private String updateBy;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Date updateTime;
|
||||
@TableField(exist = false)
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer version;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer version;
|
||||
}
|
||||
+37
-33
@@ -1,52 +1,56 @@
|
||||
|
||||
package com.anjiplus.template.gaea.business.modules.accessuser.service;
|
||||
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.AccessUserDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.GaeaUserDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.UpdatePasswordDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.dao.entity.AccessUser;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.param.AccessUserParam;
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.dao.entity.AccessUser;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @desc AccessUser 用户管理服务接口
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
* @desc AccessUser 用户管理服务接口
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
public interface AccessUserService extends GaeaBaseService<AccessUserParam, AccessUser> {
|
||||
|
||||
/** 获取用户的角色树
|
||||
* @param loginName 被操作的对象
|
||||
* @param operator 当前登录者
|
||||
* @return
|
||||
*/
|
||||
Map getRoleTree(String loginName, String operator);
|
||||
/**
|
||||
* 获取用户的角色树
|
||||
* @param loginName 被操作的对象
|
||||
* @param operator 当前登录者
|
||||
* @return
|
||||
*/
|
||||
Map getRoleTree(String loginName, String operator);
|
||||
|
||||
/**
|
||||
* 保存用户的角色树
|
||||
* @param accessUserDto
|
||||
* @return
|
||||
*/
|
||||
Boolean saveRoleTree(AccessUserDto accessUserDto);
|
||||
|
||||
/** 保存用户的角色树
|
||||
* @param accessUserDto
|
||||
* @return
|
||||
*/
|
||||
Boolean saveRoleTree(AccessUserDto accessUserDto);
|
||||
/**
|
||||
* 重置密码
|
||||
* @param gaeaUserDto
|
||||
* @return
|
||||
*/
|
||||
Boolean resetPassword(GaeaUserDto gaeaUserDto);
|
||||
|
||||
/** 重置密码
|
||||
* @param gaeaUserDto
|
||||
* @return
|
||||
*/
|
||||
Boolean resetPassword(GaeaUserDto gaeaUserDto);
|
||||
/**
|
||||
* 用户登录
|
||||
* @param gaeaUserDto
|
||||
* @return
|
||||
*/
|
||||
GaeaUserDto login(GaeaUserDto gaeaUserDto);
|
||||
|
||||
/** 用户登录
|
||||
* @param gaeaUserDto
|
||||
* @return
|
||||
*/
|
||||
GaeaUserDto login(GaeaUserDto gaeaUserDto);
|
||||
/**
|
||||
* 修改密码
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Boolean updatePassword(UpdatePasswordDto dto);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Boolean updatePassword(UpdatePasswordDto dto);
|
||||
}
|
||||
+190
-188
@@ -5,9 +5,9 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.anji.plus.gaea.bean.TreeNode;
|
||||
import com.anji.plus.gaea.cache.CacheHelper;
|
||||
import com.anji.plus.gaea.constant.BaseOperationEnum;
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anji.plus.gaea.exception.BusinessException;
|
||||
import com.anji.plus.gaea.exception.BusinessExceptionBuilder;
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anji.plus.gaea.holder.UserContentHolder;
|
||||
import com.anji.plus.gaea.utils.GaeaUtils;
|
||||
import com.anji.plus.gaea.utils.JwtBean;
|
||||
@@ -20,11 +20,11 @@ import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessR
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.AccessUserDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.GaeaUserDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.UpdatePasswordDto;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.dao.AccessUserMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.dao.AccessUserRoleMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.dao.entity.AccessUser;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.dao.entity.AccessUserRole;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.service.AccessUserService;
|
||||
import com.anjiplus.template.gaea.business.modules.accessuser.dao.AccessUserMapper;
|
||||
import com.anjiplus.template.gaea.business.util.MD5Util;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -37,226 +37,228 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @desc AccessUser 用户管理服务实现
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
* @desc AccessUser 用户管理服务实现
|
||||
* @author 木子李·De <lide1202@hotmail.com>
|
||||
* @date 2019-02-17 08:50:11.902
|
||||
**/
|
||||
@Service
|
||||
public class AccessUserServiceImpl implements AccessUserService {
|
||||
|
||||
@Autowired
|
||||
private AccessRoleMapper accessRoleMapper;
|
||||
@Autowired
|
||||
private AccessRoleMapper accessRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private AccessUserMapper accessUserMapper;
|
||||
@Autowired
|
||||
private AccessUserMapper accessUserMapper;
|
||||
|
||||
@Autowired
|
||||
private AccessUserRoleMapper accessUserRoleMapper;
|
||||
@Autowired
|
||||
private AccessUserRoleMapper accessUserRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private AccessRoleAuthorityMapper accessRoleAuthorityMapper;
|
||||
@Autowired
|
||||
private AccessRoleAuthorityMapper accessRoleAuthorityMapper;
|
||||
|
||||
@Value("${customer.user.default.password:'123456'}")
|
||||
private String defaultPassword;
|
||||
@Value("${customer.user.default.password:'123456'}")
|
||||
private String defaultPassword;
|
||||
|
||||
@Override
|
||||
public GaeaBaseMapper<AccessUser> getMapper() {
|
||||
return accessUserMapper;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseMapper<AccessUser> getMapper() {
|
||||
return accessUserMapper;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private JwtBean jwtBean;
|
||||
@Autowired
|
||||
private JwtBean jwtBean;
|
||||
|
||||
@Autowired
|
||||
private CacheHelper cacheHelper;
|
||||
@Autowired
|
||||
private CacheHelper cacheHelper;
|
||||
|
||||
@Override
|
||||
public Map getRoleTree(String loginName, String operator) {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
List<TreeNode> treeData = new ArrayList<>();
|
||||
List checkedKeys = new ArrayList();
|
||||
@Override
|
||||
public Map getRoleTree(String loginName, String operator) {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
List<TreeNode> treeData = new ArrayList<>();
|
||||
List checkedKeys = new ArrayList();
|
||||
|
||||
// 角色树
|
||||
LambdaQueryWrapper<AccessRole> roleQuery = Wrappers.lambdaQuery();
|
||||
roleQuery.select(AccessRole::getRoleCode, AccessRole::getRoleName);
|
||||
// 按operator去筛选role 后面再加where
|
||||
List<AccessRole> roleList = accessRoleMapper.selectList(roleQuery);
|
||||
if(roleList == null || roleList.isEmpty()){
|
||||
result.put("treeData", treeData);
|
||||
result.put("checkedKeys", checkedKeys);
|
||||
return result;
|
||||
}
|
||||
treeData = roleList.stream().map(role -> {
|
||||
TreeNode treeNode = new TreeNode();
|
||||
treeNode.setId(role.getRoleCode());
|
||||
treeNode.setLabel(role.getRoleName());
|
||||
return treeNode;
|
||||
}).collect(Collectors.toList());
|
||||
// 角色树
|
||||
LambdaQueryWrapper<AccessRole> roleQuery = Wrappers.lambdaQuery();
|
||||
roleQuery.select(AccessRole::getRoleCode, AccessRole::getRoleName);
|
||||
// 按operator去筛选role 后面再加where
|
||||
List<AccessRole> roleList = accessRoleMapper.selectList(roleQuery);
|
||||
if (roleList == null || roleList.isEmpty()) {
|
||||
result.put("treeData", treeData);
|
||||
result.put("checkedKeys", checkedKeys);
|
||||
return result;
|
||||
}
|
||||
treeData = roleList.stream().map(role -> {
|
||||
TreeNode treeNode = new TreeNode();
|
||||
treeNode.setId(role.getRoleCode());
|
||||
treeNode.setLabel(role.getRoleName());
|
||||
return treeNode;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 该用户已保存的角色
|
||||
LambdaQueryWrapper<AccessUserRole> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.select(AccessUserRole::getRoleCode)
|
||||
.eq(AccessUserRole::getLoginName, loginName);
|
||||
checkedKeys = accessUserRoleMapper.selectObjs(queryWrapper);
|
||||
// 该用户已保存的角色
|
||||
LambdaQueryWrapper<AccessUserRole> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.select(AccessUserRole::getRoleCode).eq(AccessUserRole::getLoginName, loginName);
|
||||
checkedKeys = accessUserRoleMapper.selectObjs(queryWrapper);
|
||||
|
||||
result.put("treeData", treeData);
|
||||
result.put("checkedKeys", checkedKeys);
|
||||
return result;
|
||||
}
|
||||
result.put("treeData", treeData);
|
||||
result.put("checkedKeys", checkedKeys);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean saveRoleTree(AccessUserDto accessUserDto) {
|
||||
// 校验
|
||||
String loginName = accessUserDto.getLoginName();
|
||||
List<String> roleCodeList = accessUserDto.getRoleCodeList();
|
||||
if(StringUtils.isBlank(loginName)){
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, loginName);
|
||||
}
|
||||
if(roleCodeList == null || roleCodeList.isEmpty()){
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, roleCodeList);
|
||||
}
|
||||
@Override
|
||||
public Boolean saveRoleTree(AccessUserDto accessUserDto) {
|
||||
// 校验
|
||||
String loginName = accessUserDto.getLoginName();
|
||||
List<String> roleCodeList = accessUserDto.getRoleCodeList();
|
||||
if (StringUtils.isBlank(loginName)) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, loginName);
|
||||
}
|
||||
if (roleCodeList == null || roleCodeList.isEmpty()) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, roleCodeList);
|
||||
}
|
||||
|
||||
// 先清除该用户已保存的角色
|
||||
LambdaQueryWrapper<AccessUserRole> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(AccessUserRole::getLoginName, loginName);
|
||||
accessUserRoleMapper.delete(wrapper);
|
||||
// 先清除该用户已保存的角色
|
||||
LambdaQueryWrapper<AccessUserRole> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(AccessUserRole::getLoginName, loginName);
|
||||
accessUserRoleMapper.delete(wrapper);
|
||||
|
||||
// 保存勾选的角色
|
||||
roleCodeList.stream().forEach(roleCode -> {
|
||||
AccessUserRole accessUserRole = new AccessUserRole();
|
||||
accessUserRole.setLoginName(loginName);
|
||||
accessUserRole.setRoleCode(roleCode);
|
||||
accessUserRoleMapper.insert(accessUserRole);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
// 保存勾选的角色
|
||||
roleCodeList.stream().forEach(roleCode -> {
|
||||
AccessUserRole accessUserRole = new AccessUserRole();
|
||||
accessUserRole.setLoginName(loginName);
|
||||
accessUserRole.setRoleCode(roleCode);
|
||||
accessUserRoleMapper.insert(accessUserRole);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean resetPassword(GaeaUserDto gaeaUserDto) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public Boolean resetPassword(GaeaUserDto gaeaUserDto) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GaeaUserDto login(GaeaUserDto gaeaUserDto) {
|
||||
@Override
|
||||
public GaeaUserDto login(GaeaUserDto gaeaUserDto) {
|
||||
|
||||
String loginName = gaeaUserDto.getLoginName();
|
||||
String password = gaeaUserDto.getPassword();
|
||||
String loginName = gaeaUserDto.getLoginName();
|
||||
String password = gaeaUserDto.getPassword();
|
||||
|
||||
// 1.判断用户是否存在
|
||||
LambdaQueryWrapper<AccessUser> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(AccessUser::getLoginName, loginName);
|
||||
AccessUser accessUser = accessUserMapper.selectOne(wrapper);
|
||||
if (null == accessUser) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.LOGIN_ERROR);
|
||||
}
|
||||
// 2.密码错误
|
||||
if (!accessUser.getPassword().equals(MD5Util.encrypt(password))) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.USER_PASSWORD_ERROR);
|
||||
}
|
||||
// 1.判断用户是否存在
|
||||
LambdaQueryWrapper<AccessUser> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(AccessUser::getLoginName, loginName);
|
||||
AccessUser accessUser = accessUserMapper.selectOne(wrapper);
|
||||
if (null == accessUser) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.LOGIN_ERROR);
|
||||
}
|
||||
// 2.密码错误
|
||||
if (!accessUser.getPassword().equals(MD5Util.encrypt(password))) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.USER_PASSWORD_ERROR);
|
||||
}
|
||||
|
||||
// 3.如果该用户登录未过期,这里允许一个用户在多个终端登录
|
||||
String tokenKey = String.format(BusinessConstant.GAEA_SECURITY_LOGIN_TOKEN, loginName);
|
||||
String token = "";
|
||||
GaeaUserDto gaeaUser = new GaeaUserDto();
|
||||
if (cacheHelper.exist(tokenKey)) {
|
||||
token = cacheHelper.stringGet(tokenKey);
|
||||
} else {
|
||||
// 生成用户token
|
||||
String uuid = GaeaUtils.UUID();
|
||||
token = jwtBean.createToken(loginName, uuid);
|
||||
cacheHelper.stringSetExpire(tokenKey, token, 3600);
|
||||
}
|
||||
// 3.如果该用户登录未过期,这里允许一个用户在多个终端登录
|
||||
String tokenKey = String.format(BusinessConstant.GAEA_SECURITY_LOGIN_TOKEN, loginName);
|
||||
String token = "";
|
||||
GaeaUserDto gaeaUser = new GaeaUserDto();
|
||||
if (cacheHelper.exist(tokenKey)) {
|
||||
token = cacheHelper.stringGet(tokenKey);
|
||||
}
|
||||
else {
|
||||
// 生成用户token
|
||||
String uuid = GaeaUtils.UUID();
|
||||
token = jwtBean.createToken(loginName, uuid);
|
||||
cacheHelper.stringSetExpire(tokenKey, token, 3600);
|
||||
}
|
||||
|
||||
// 4.读取用户最新人权限主信息
|
||||
String userKey = String.format(BusinessConstant.GAEA_SECURITY_LOGIN_USER, loginName);
|
||||
// 4.读取用户最新人权限主信息
|
||||
String userKey = String.format(BusinessConstant.GAEA_SECURITY_LOGIN_USER, loginName);
|
||||
|
||||
//为了兼容底层其他数据库,不再写自定义sql
|
||||
// List<String> authorities = accessUserMapper.queryAuthoritiesByLoginName(loginName);
|
||||
// 为了兼容底层其他数据库,不再写自定义sql
|
||||
// List<String> authorities =
|
||||
// accessUserMapper.queryAuthoritiesByLoginName(loginName);
|
||||
|
||||
//当前用户的roleCode集合
|
||||
LambdaQueryWrapper<AccessUserRole> accessUserWrapper = Wrappers.lambdaQuery();
|
||||
accessUserWrapper.select(AccessUserRole::getRoleCode);
|
||||
accessUserWrapper.eq(AccessUserRole::getLoginName, loginName);
|
||||
List<AccessUserRole> accessUserRoles = accessUserRoleMapper.selectList(accessUserWrapper);
|
||||
Set<String> roleCodeSet = accessUserRoles.stream().map(AccessUserRole::getRoleCode).collect(Collectors.toSet());
|
||||
if (roleCodeSet.size() < 1) {
|
||||
gaeaUser.setAuthorities(new ArrayList<>());
|
||||
}else {
|
||||
LambdaQueryWrapper<AccessRoleAuthority> accessRoleAuthorityWrapper = Wrappers.lambdaQuery();
|
||||
accessRoleAuthorityWrapper.select(AccessRoleAuthority::getTarget, AccessRoleAuthority::getAction);
|
||||
accessRoleAuthorityWrapper.in(AccessRoleAuthority::getRoleCode, roleCodeSet);
|
||||
List<AccessRoleAuthority> accessRoleAuthorities = accessRoleAuthorityMapper.selectList(accessRoleAuthorityWrapper);
|
||||
List<String> authorities = accessRoleAuthorities.stream()
|
||||
.map(accessRoleAuthority -> accessRoleAuthority.getTarget().concat(":").concat(accessRoleAuthority.getAction())).distinct().collect(Collectors.toList());
|
||||
gaeaUser.setAuthorities(authorities);
|
||||
}
|
||||
// 当前用户的roleCode集合
|
||||
LambdaQueryWrapper<AccessUserRole> accessUserWrapper = Wrappers.lambdaQuery();
|
||||
accessUserWrapper.select(AccessUserRole::getRoleCode);
|
||||
accessUserWrapper.eq(AccessUserRole::getLoginName, loginName);
|
||||
List<AccessUserRole> accessUserRoles = accessUserRoleMapper.selectList(accessUserWrapper);
|
||||
Set<String> roleCodeSet = accessUserRoles.stream().map(AccessUserRole::getRoleCode).collect(Collectors.toSet());
|
||||
if (roleCodeSet.size() < 1) {
|
||||
gaeaUser.setAuthorities(new ArrayList<>());
|
||||
}
|
||||
else {
|
||||
LambdaQueryWrapper<AccessRoleAuthority> accessRoleAuthorityWrapper = Wrappers.lambdaQuery();
|
||||
accessRoleAuthorityWrapper.select(AccessRoleAuthority::getTarget, AccessRoleAuthority::getAction);
|
||||
accessRoleAuthorityWrapper.in(AccessRoleAuthority::getRoleCode, roleCodeSet);
|
||||
List<AccessRoleAuthority> accessRoleAuthorities = accessRoleAuthorityMapper
|
||||
.selectList(accessRoleAuthorityWrapper);
|
||||
List<String> authorities = accessRoleAuthorities.stream().map(accessRoleAuthority -> accessRoleAuthority
|
||||
.getTarget().concat(":").concat(accessRoleAuthority.getAction())).distinct()
|
||||
.collect(Collectors.toList());
|
||||
gaeaUser.setAuthorities(authorities);
|
||||
}
|
||||
|
||||
gaeaUser.setLoginName(loginName);
|
||||
gaeaUser.setRealName(accessUser.getRealName());
|
||||
gaeaUser.setToken(token);
|
||||
gaeaUser.setLoginName(loginName);
|
||||
gaeaUser.setRealName(accessUser.getRealName());
|
||||
gaeaUser.setToken(token);
|
||||
|
||||
String gaeaUserStr = JSONObject.toJSONString(gaeaUser);
|
||||
cacheHelper.stringSetExpire(userKey, gaeaUserStr, 3600);
|
||||
String gaeaUserStr = JSONObject.toJSONString(gaeaUser);
|
||||
cacheHelper.stringSetExpire(userKey, gaeaUserStr, 3600);
|
||||
|
||||
return gaeaUser;
|
||||
}
|
||||
return gaeaUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updatePassword(UpdatePasswordDto dto) {
|
||||
if (!dto.getConfirmPassword().equals(dto.getPassword())) {
|
||||
//密码和确认密码不一致
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.USER_INCONSISTENT_PASSWORD_ERROR);
|
||||
}
|
||||
//新密码不能与老密码一样
|
||||
if(StringUtils.equals(dto.getOldPassword(), dto.getPassword())){
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.USER_PASSWORD_CONFIG_PASSWORD_CANOT_EQUAL);
|
||||
}
|
||||
/**
|
||||
* 修改密码
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updatePassword(UpdatePasswordDto dto) {
|
||||
if (!dto.getConfirmPassword().equals(dto.getPassword())) {
|
||||
// 密码和确认密码不一致
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.USER_INCONSISTENT_PASSWORD_ERROR);
|
||||
}
|
||||
// 新密码不能与老密码一样
|
||||
if (StringUtils.equals(dto.getOldPassword(), dto.getPassword())) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.USER_PASSWORD_CONFIG_PASSWORD_CANOT_EQUAL);
|
||||
}
|
||||
|
||||
String username = UserContentHolder.getUsername();
|
||||
String username = UserContentHolder.getUsername();
|
||||
|
||||
LambdaQueryWrapper<AccessUser> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(AccessUser::getLoginName, username);
|
||||
AccessUser accessUser = selectOne(wrapper);
|
||||
String password = accessUser.getPassword();
|
||||
if (!MD5Util.encrypt(dto.getOldPassword()).equals(password)) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.USER_OLD_PASSWORD_ERROR);
|
||||
}
|
||||
accessUser.setPassword(MD5Util.encrypt(dto.getPassword()));
|
||||
|
||||
LambdaQueryWrapper<AccessUser> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(AccessUser::getLoginName, username);
|
||||
AccessUser accessUser = selectOne(wrapper);
|
||||
String password = accessUser.getPassword();
|
||||
if (!MD5Util.encrypt(dto.getOldPassword()).equals(password)) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.USER_OLD_PASSWORD_ERROR);
|
||||
}
|
||||
accessUser.setPassword(MD5Util.encrypt(dto.getPassword()));
|
||||
accessUserMapper.updateById(accessUser);
|
||||
return true;
|
||||
}
|
||||
|
||||
accessUserMapper.updateById(accessUser);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 操作前处理
|
||||
* @param entity 前端传递的对象
|
||||
* @param operationEnum 操作类型
|
||||
* @throws BusinessException 阻止程序继续执行或回滚事务
|
||||
*/
|
||||
@Override
|
||||
public void processBeforeOperation(AccessUser entity, BaseOperationEnum operationEnum) throws BusinessException {
|
||||
// 过滤密码
|
||||
switch (operationEnum) {
|
||||
case INSERT:
|
||||
// gaea是为了和前端加密保持一致
|
||||
entity.setPassword(MD5Util.encrypt(MD5Util.encrypt(defaultPassword.concat("gaea"))));
|
||||
break;
|
||||
case UPDATE:
|
||||
// 更新用户不允许修改密码
|
||||
entity.setPassword(null);
|
||||
break;
|
||||
default:
|
||||
|
||||
/**
|
||||
* 操作前处理
|
||||
*
|
||||
* @param entity 前端传递的对象
|
||||
* @param operationEnum 操作类型
|
||||
* @throws BusinessException 阻止程序继续执行或回滚事务
|
||||
*/
|
||||
@Override
|
||||
public void processBeforeOperation(AccessUser entity, BaseOperationEnum operationEnum) throws BusinessException {
|
||||
//过滤密码
|
||||
switch (operationEnum) {
|
||||
case INSERT:
|
||||
//gaea是为了和前端加密保持一致
|
||||
entity.setPassword(MD5Util.encrypt(MD5Util.encrypt(defaultPassword.concat("gaea"))));
|
||||
break;
|
||||
case UPDATE:
|
||||
//更新用户不允许修改密码
|
||||
entity.setPassword(null);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+72
-72
@@ -4,9 +4,9 @@ package com.anjiplus.template.gaea.business.modules.dashboard.controller;
|
||||
import com.anji.plus.gaea.annotation.Permission;
|
||||
import com.anji.plus.gaea.annotation.log.GaeaAuditLog;
|
||||
import com.anji.plus.gaea.bean.ResponseBean;
|
||||
import com.anjiplus.template.gaea.business.modules.dashboard.service.ReportDashboardService;
|
||||
import com.anjiplus.template.gaea.business.modules.dashboard.controller.dto.ChartDto;
|
||||
import com.anjiplus.template.gaea.business.modules.dashboard.controller.dto.ReportDashboardObjectDto;
|
||||
import com.anjiplus.template.gaea.business.modules.dashboard.service.ReportDashboardService;
|
||||
import com.anjiplus.template.gaea.business.modules.reportshare.controller.dto.ReportShareDto;
|
||||
import com.anjiplus.template.gaea.business.modules.reportshare.service.ReportShareService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -20,89 +20,89 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @desc 大屏设计 controller
|
||||
* @website https://gitee.com/anji-plus/gaea
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
* @desc 大屏设计 controller
|
||||
* @website https://gitee.com/anji-plus/gaea
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "大屏设计管理")
|
||||
@Permission(code = "bigScreenManage", name = "大屏报表")
|
||||
@RequestMapping("/reportDashboard")
|
||||
public class ReportDashboardController {
|
||||
|
||||
@Autowired
|
||||
private ReportDashboardService reportDashboardService;
|
||||
@Autowired
|
||||
private ReportDashboardService reportDashboardService;
|
||||
|
||||
@Autowired
|
||||
private ReportShareService reportShareService;
|
||||
@Autowired
|
||||
private ReportShareService reportShareService;
|
||||
|
||||
/**
|
||||
* 预览、查询大屏详情
|
||||
* @param reportCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping({"/{reportCode}"})
|
||||
@Permission(code = "view", name = "查看大屏")
|
||||
public ResponseBean detail(@PathVariable("reportCode") String reportCode) {
|
||||
return ResponseBean.builder().data(reportDashboardService.getDetail(reportCode)).build();
|
||||
}
|
||||
/**
|
||||
* 预览、查询大屏详情
|
||||
* @param reportCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping({ "/{reportCode}" })
|
||||
@Permission(code = "view", name = "查看大屏")
|
||||
public ResponseBean detail(@PathVariable("reportCode") String reportCode) {
|
||||
return ResponseBean.builder().data(reportDashboardService.getDetail(reportCode)).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存大屏设计
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Permission(code = "design", name = "设计大屏")
|
||||
@GaeaAuditLog(pageTitle = "新增")
|
||||
public ResponseBean insert(@RequestBody ReportDashboardObjectDto dto) {
|
||||
reportDashboardService.insertDashboard(dto);
|
||||
return ResponseBean.builder().build();
|
||||
}
|
||||
/**
|
||||
* 保存大屏设计
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Permission(code = "design", name = "设计大屏")
|
||||
@GaeaAuditLog(pageTitle = "新增")
|
||||
public ResponseBean insert(@RequestBody ReportDashboardObjectDto dto) {
|
||||
reportDashboardService.insertDashboard(dto);
|
||||
return ResponseBean.builder().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取去单个图层数据
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getData")
|
||||
@Permission(code = "view", name = "查看大屏")
|
||||
public ResponseBean getData(@RequestBody ChartDto dto) {
|
||||
return ResponseBean.builder().data(reportDashboardService.getChartData(dto)).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取去单个图层数据
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getData")
|
||||
@Permission(code = "view", name = "查看大屏")
|
||||
public ResponseBean getData(@RequestBody ChartDto dto) {
|
||||
return ResponseBean.builder().data(reportDashboardService.getChartData(dto)).build();
|
||||
}
|
||||
/**
|
||||
* 导出大屏
|
||||
* @param reportCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
@Permission(code = "export", name = "导出大屏")
|
||||
public ResponseEntity<byte[]> exportDashboard(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestParam("reportCode") String reportCode,
|
||||
@RequestParam(value = "showDataSet", required = false, defaultValue = "1") Integer showDataSet) {
|
||||
return reportDashboardService.exportDashboard(request, response, reportCode, showDataSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入大屏
|
||||
* @param file 导入的zip文件
|
||||
* @param reportCode
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/import/{reportCode}")
|
||||
@Permission(code = "import", name = "导入大屏")
|
||||
public ResponseBean importDashboard(@RequestParam("file") MultipartFile file,
|
||||
@PathVariable("reportCode") String reportCode) {
|
||||
reportDashboardService.importDashboard(file, reportCode);
|
||||
return ResponseBean.builder().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出大屏
|
||||
* @param reportCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
@Permission(code = "export", name = "导出大屏")
|
||||
public ResponseEntity<byte[]> exportDashboard(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestParam("reportCode") String reportCode, @RequestParam(value = "showDataSet",required = false, defaultValue = "1") Integer showDataSet) {
|
||||
return reportDashboardService.exportDashboard(request, response, reportCode, showDataSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入大屏
|
||||
* @param file 导入的zip文件
|
||||
* @param reportCode
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/import/{reportCode}")
|
||||
@Permission(code = "import", name = "导入大屏")
|
||||
public ResponseBean importDashboard(@RequestParam("file") MultipartFile file, @PathVariable("reportCode") String reportCode) {
|
||||
reportDashboardService.importDashboard(file, reportCode);
|
||||
return ResponseBean.builder().build();
|
||||
}
|
||||
|
||||
@PostMapping("/share")
|
||||
@GaeaAuditLog(pageTitle = "分享")
|
||||
public ResponseBean share(@Validated @RequestBody ReportShareDto dto) {
|
||||
return ResponseBean.builder().data(reportShareService.insertShare(dto)).build();
|
||||
}
|
||||
@PostMapping("/share")
|
||||
@GaeaAuditLog(pageTitle = "分享")
|
||||
public ResponseBean share(@Validated @RequestBody ReportShareDto dto) {
|
||||
return ResponseBean.builder().data(reportShareService.insertShare(dto)).build();
|
||||
}
|
||||
|
||||
}
|
||||
+24
-27
@@ -6,46 +6,43 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 大屏设计 dto
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
* @description 大屏设计 dto
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
@Data
|
||||
public class ChartDto implements Serializable {
|
||||
|
||||
private String chartType;
|
||||
private String chartType;
|
||||
|
||||
/**数据集编码*/
|
||||
private String setCode;
|
||||
/** 数据集编码 */
|
||||
private String setCode;
|
||||
|
||||
/** 传入的自定义参数*/
|
||||
private Map<String, Object> contextData;
|
||||
/** 传入的自定义参数 */
|
||||
private Map<String, Object> contextData;
|
||||
|
||||
/**图表属性*/
|
||||
private Map<String, String> chartProperties;
|
||||
/** 图表属性 */
|
||||
private Map<String, String> chartProperties;
|
||||
|
||||
/**时间字段*/
|
||||
private String timeLineFiled;
|
||||
/** 时间字段 */
|
||||
private String timeLineFiled;
|
||||
|
||||
/**时间颗粒度*/
|
||||
private String particles;
|
||||
/** 时间颗粒度 */
|
||||
private String particles;
|
||||
|
||||
/**时间格式化*/
|
||||
private String dataTimeFormat;
|
||||
/** 时间格式化 */
|
||||
private String dataTimeFormat;
|
||||
|
||||
/**时间展示层*/
|
||||
private String timeLineFormat;
|
||||
/** 时间展示层 */
|
||||
private String timeLineFormat;
|
||||
|
||||
private int timeUnit;
|
||||
private int timeUnit;
|
||||
|
||||
/**时间区间*/
|
||||
private String startTime;
|
||||
|
||||
/**时间区间*/
|
||||
private String endTime;
|
||||
/** 时间区间 */
|
||||
private String startTime;
|
||||
|
||||
/** 时间区间 */
|
||||
private String endTime;
|
||||
|
||||
}
|
||||
+28
-29
@@ -8,48 +8,47 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 大屏设计 dto
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
* @description 大屏设计 dto
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
@Data
|
||||
public class ReportDashboardDto extends GaeaBaseDTO implements Serializable {
|
||||
/** 报表编码 */
|
||||
private String reportCode;
|
||||
|
||||
/** 看板标题 */
|
||||
private String title;
|
||||
/** 报表编码 */
|
||||
private String reportCode;
|
||||
|
||||
/** 宽度px */
|
||||
private Long width;
|
||||
/** 看板标题 */
|
||||
private String title;
|
||||
|
||||
/** 高度px */
|
||||
private Long height;
|
||||
/** 宽度px */
|
||||
private Long width;
|
||||
|
||||
/** 背景色 */
|
||||
private String backgroundColor;
|
||||
/** 高度px */
|
||||
private Long height;
|
||||
|
||||
/** 背景图片 */
|
||||
private String backgroundImage;
|
||||
/** 背景色 */
|
||||
private String backgroundColor;
|
||||
|
||||
/** 工作台中的辅助线 */
|
||||
private String presetLine;
|
||||
/** 背景图片 */
|
||||
private String backgroundImage;
|
||||
|
||||
/** 自动刷新间隔秒,数据字典REFRESH_TYPE */
|
||||
private Integer refreshSeconds;
|
||||
/** 工作台中的辅助线 */
|
||||
private String presetLine;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
/** 自动刷新间隔秒,数据字典REFRESH_TYPE */
|
||||
private Integer refreshSeconds;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
private Integer deleteFlag;
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
|
||||
/** 排序,降序 */
|
||||
private Integer sort;
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
private Integer deleteFlag;
|
||||
|
||||
private List<ReportDashboardWidgetDto> widgets;
|
||||
/** 排序,降序 */
|
||||
private Integer sort;
|
||||
|
||||
private List<ReportDashboardWidgetDto> widgets;
|
||||
|
||||
}
|
||||
+15
-16
@@ -7,26 +7,25 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 大屏设计 dto
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
* @description 大屏设计 dto
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
@Data
|
||||
public class ReportDashboardObjectDto implements Serializable {
|
||||
|
||||
/** 报表编码 */
|
||||
private String reportCode;
|
||||
/**
|
||||
* 报表编码
|
||||
*/
|
||||
private ReportDashboardDto dashboard;
|
||||
/** 报表编码 */
|
||||
private String reportCode;
|
||||
|
||||
/**
|
||||
* 大屏画布中的组件
|
||||
*/
|
||||
private List<ReportDashboardWidgetDto> widgets;
|
||||
/**
|
||||
* 报表编码
|
||||
*/
|
||||
private ReportDashboardDto dashboard;
|
||||
|
||||
/**
|
||||
* 大屏画布中的组件
|
||||
*/
|
||||
private List<ReportDashboardWidgetDto> widgets;
|
||||
|
||||
}
|
||||
+8
-11
@@ -1,20 +1,17 @@
|
||||
/**/
|
||||
package com.anjiplus.template.gaea.business.modules.dashboard.controller.param;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import com.anji.plus.gaea.annotation.Query;
|
||||
import com.anji.plus.gaea.constant.QueryEnum;
|
||||
import com.anji.plus.gaea.curd.params.PageParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @desc ReportDashboard 大屏设计查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
* @desc ReportDashboard 大屏设计查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
@Data
|
||||
public class ReportDashboardParam extends PageParam implements Serializable{
|
||||
public class ReportDashboardParam extends PageParam implements Serializable {
|
||||
|
||||
}
|
||||
+6
-6
@@ -1,15 +1,15 @@
|
||||
package com.anjiplus.template.gaea.business.modules.dashboard.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.dashboard.dao.entity.ReportDashboard;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* ReportDashboard Mapper
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
* ReportDashboard Mapper
|
||||
*
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
@Mapper
|
||||
public interface ReportDashboardMapper extends GaeaBaseMapper<ReportDashboard> {
|
||||
|
||||
|
||||
+28
-28
@@ -9,46 +9,46 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description 大屏设计 entity
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
@TableName(keepGlobalPrefix=true, value="gaea_report_dashboard")
|
||||
* @description 大屏设计 entity
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
@TableName(keepGlobalPrefix = true, value = "gaea_report_dashboard")
|
||||
@Data
|
||||
public class ReportDashboard extends GaeaBaseEntity {
|
||||
@ApiModelProperty(value = "报表编码")
|
||||
@Unique(code = ResponseCode.REPORT_CODE_ISEXIST)
|
||||
private String reportCode;
|
||||
|
||||
@ApiModelProperty(value = "看板标题")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "报表编码")
|
||||
@Unique(code = ResponseCode.REPORT_CODE_ISEXIST)
|
||||
private String reportCode;
|
||||
|
||||
@ApiModelProperty(value = "宽度px")
|
||||
private Long width;
|
||||
@ApiModelProperty(value = "看板标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "高度px")
|
||||
private Long height;
|
||||
@ApiModelProperty(value = "宽度px")
|
||||
private Long width;
|
||||
|
||||
@ApiModelProperty(value = "背景色")
|
||||
private String backgroundColor;
|
||||
@ApiModelProperty(value = "高度px")
|
||||
private Long height;
|
||||
|
||||
@ApiModelProperty(value = "背景图片")
|
||||
private String backgroundImage;
|
||||
@ApiModelProperty(value = "背景色")
|
||||
private String backgroundColor;
|
||||
|
||||
@ApiModelProperty(value = "工作台中的辅助线")
|
||||
private String presetLine;
|
||||
@ApiModelProperty(value = "背景图片")
|
||||
private String backgroundImage;
|
||||
|
||||
@ApiModelProperty(value = "自动刷新间隔秒,数据字典REFRESH_TYPE")
|
||||
private Integer refreshSeconds;
|
||||
@ApiModelProperty(value = "工作台中的辅助线")
|
||||
private String presetLine;
|
||||
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
private Integer enableFlag;
|
||||
@ApiModelProperty(value = "自动刷新间隔秒,数据字典REFRESH_TYPE")
|
||||
private Integer refreshSeconds;
|
||||
|
||||
@ApiModelProperty(value = " 0--未删除 1--已删除 DIC_NAME=DEL_FLAG")
|
||||
private Integer deleteFlag;
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
private Integer enableFlag;
|
||||
|
||||
@ApiModelProperty(value = "排序,降序")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = " 0--未删除 1--已删除 DIC_NAME=DEL_FLAG")
|
||||
private Integer deleteFlag;
|
||||
|
||||
@ApiModelProperty(value = "排序,降序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
+12
-12
@@ -10,17 +10,17 @@ import java.util.List;
|
||||
*/
|
||||
public interface ChartStrategy {
|
||||
|
||||
/**
|
||||
* 图表类型
|
||||
* @return
|
||||
*/
|
||||
String type();
|
||||
/**
|
||||
* 图表类型
|
||||
* @return
|
||||
*/
|
||||
String type();
|
||||
|
||||
/**
|
||||
* 针对每种图表类型做单独的数据转换解析
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Object transform(ChartDto dto, List<JSONObject> data);
|
||||
|
||||
/**
|
||||
* 针对每种图表类型做单独的数据转换解析
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Object transform(ChartDto dto, List<JSONObject> data);
|
||||
}
|
||||
+36
-38
@@ -13,49 +13,47 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @desc ReportDashboard 大屏设计服务接口
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
* @desc ReportDashboard 大屏设计服务接口
|
||||
* @author Raod
|
||||
* @date 2021-04-12 14:52:21.761
|
||||
**/
|
||||
public interface ReportDashboardService extends GaeaBaseService<ReportDashboardParam, ReportDashboard> {
|
||||
|
||||
/***
|
||||
* 查询详情
|
||||
*
|
||||
* @param reportCode
|
||||
*/
|
||||
ReportDashboardObjectDto getDetail(String reportCode);
|
||||
/***
|
||||
* 查询详情
|
||||
* @param reportCode
|
||||
*/
|
||||
ReportDashboardObjectDto getDetail(String reportCode);
|
||||
|
||||
/***
|
||||
* 保存大屏设计
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
void insertDashboard(ReportDashboardObjectDto dto);
|
||||
/***
|
||||
* 保存大屏设计
|
||||
* @param dto
|
||||
*/
|
||||
void insertDashboard(ReportDashboardObjectDto dto);
|
||||
|
||||
/**
|
||||
* 获取单个图表数据
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Object getChartData(ChartDto dto);
|
||||
|
||||
/**
|
||||
* 获取单个图表数据
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Object getChartData(ChartDto dto);
|
||||
/**
|
||||
* 导出大屏,zip文件
|
||||
* @param request
|
||||
* @param response
|
||||
* @param reportCode
|
||||
* @return
|
||||
*/
|
||||
ResponseEntity<byte[]> exportDashboard(HttpServletRequest request, HttpServletResponse response, String reportCode,
|
||||
Integer showDataSet);
|
||||
|
||||
/**
|
||||
* 导入大屏zip
|
||||
* @param file
|
||||
* @param reportCode
|
||||
* @return
|
||||
*/
|
||||
void importDashboard(MultipartFile file, String reportCode);
|
||||
|
||||
/**
|
||||
* 导出大屏,zip文件
|
||||
* @param request
|
||||
* @param response
|
||||
* @param reportCode
|
||||
* @return
|
||||
*/
|
||||
ResponseEntity<byte[]> exportDashboard(HttpServletRequest request, HttpServletResponse response, String reportCode, Integer showDataSet);
|
||||
|
||||
/**
|
||||
* 导入大屏zip
|
||||
* @param file
|
||||
* @param reportCode
|
||||
* @return
|
||||
*/
|
||||
void importDashboard(MultipartFile file, String reportCode);
|
||||
}
|
||||
+44
-62
@@ -8,72 +8,54 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 柱状体或者折线图
|
||||
* Created by raodeming on 2021/4/26.
|
||||
* 柱状体或者折线图 Created by raodeming on 2021/4/26.
|
||||
*/
|
||||
@Component
|
||||
public class BarChartServiceImpl implements ChartStrategy {
|
||||
/**
|
||||
* 图表类型
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return "widget-barchart|widget-linechart";
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对每种图表类型做单独的数据转换解析
|
||||
*
|
||||
* @param dto
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object transform(ChartDto dto, List<JSONObject> data) {
|
||||
// JSONObject json = new JSONObject();
|
||||
// List<Object> xAxis = new ArrayList<>();
|
||||
// List<Object> series = new ArrayList<>();
|
||||
// data.forEach(jsonObject -> {
|
||||
// jsonObject.forEach((s, o) -> {
|
||||
// if ("xAxis".equals(s)) {
|
||||
// xAxis.add(o);
|
||||
// } else {
|
||||
// series.add(o);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// json.put("xAxis", xAxis);
|
||||
// JSONArray objects = new JSONArray();
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("data", series);
|
||||
// objects.add(jsonObject);
|
||||
// json.put("series", objects);
|
||||
// return json.toJSONString();
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* 图表类型
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return "widget-barchart|widget-linechart";
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对每种图表类型做单独的数据转换解析
|
||||
* @param dto
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object transform(ChartDto dto, List<JSONObject> data) {
|
||||
// JSONObject json = new JSONObject();
|
||||
// List<Object> xAxis = new ArrayList<>();
|
||||
// List<Object> series = new ArrayList<>();
|
||||
// data.forEach(jsonObject -> {
|
||||
// jsonObject.forEach((s, o) -> {
|
||||
// if ("xAxis".equals(s)) {
|
||||
// xAxis.add(o);
|
||||
// } else {
|
||||
// series.add(o);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// json.put("xAxis", xAxis);
|
||||
// JSONArray objects = new JSONArray();
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("data", series);
|
||||
// objects.add(jsonObject);
|
||||
// json.put("series", objects);
|
||||
// return json.toJSONString();
|
||||
return data;
|
||||
}
|
||||
|
||||
/*
|
||||
* { "xAxis": [ "哈哈", "洗洗", "来了", "问问", "天天" ], "series": [ { "data": [ 1, 2, 3, 4, 5
|
||||
* ] } ] }
|
||||
*/
|
||||
|
||||
/* {
|
||||
"xAxis": [
|
||||
"哈哈",
|
||||
"洗洗",
|
||||
"来了",
|
||||
"问问",
|
||||
"天天"
|
||||
],
|
||||
"series": [
|
||||
{
|
||||
"data": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
]
|
||||
}
|
||||
]
|
||||
}*/
|
||||
}
|
||||
+61
-87
@@ -8,98 +8,72 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 折柱图
|
||||
* Created by raodeming on 2021/4/26.
|
||||
* 折柱图 Created by raodeming on 2021/4/26.
|
||||
*/
|
||||
@Component
|
||||
public class BarLineChartServiceImpl implements ChartStrategy {
|
||||
/**
|
||||
* 图表类型
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return "widget-barlinechart";
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对每种图表类型做单独的数据转换解析
|
||||
*
|
||||
* @param dto
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object transform(ChartDto dto, List<JSONObject> data) {
|
||||
// JSONObject json = new JSONObject();
|
||||
// List<Object> xAxis = new ArrayList<>();
|
||||
// Map<String, List<Object>> series = new HashMap<>();
|
||||
// data.forEach(jsonObject -> {
|
||||
// jsonObject.forEach((s, o) -> {
|
||||
// if ("xAxis".equals(s)) {
|
||||
// xAxis.add(o);
|
||||
// } else {
|
||||
// List<Object> objects;
|
||||
// if (series.containsKey(s)) {
|
||||
// objects = series.get(s);
|
||||
// } else {
|
||||
// objects = new ArrayList<>();
|
||||
//
|
||||
// }
|
||||
// objects.add(o);
|
||||
// series.put(s, objects);
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// json.put("xAxis", xAxis);
|
||||
// List<JSONObject> result = new ArrayList<>();
|
||||
// series.forEach((s, objects) -> {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("name", s);
|
||||
// if (s.endsWith("bar")) {
|
||||
// jsonObject.put("type", "bar");
|
||||
// } else {
|
||||
// jsonObject.put("type", "line");
|
||||
// }
|
||||
// jsonObject.put("data", objects);
|
||||
// result.add(jsonObject);
|
||||
// });
|
||||
// json.put("series", result);
|
||||
// return json.toJSONString();
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* 图表类型
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return "widget-barlinechart";
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对每种图表类型做单独的数据转换解析
|
||||
* @param dto
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object transform(ChartDto dto, List<JSONObject> data) {
|
||||
// JSONObject json = new JSONObject();
|
||||
// List<Object> xAxis = new ArrayList<>();
|
||||
// Map<String, List<Object>> series = new HashMap<>();
|
||||
// data.forEach(jsonObject -> {
|
||||
// jsonObject.forEach((s, o) -> {
|
||||
// if ("xAxis".equals(s)) {
|
||||
// xAxis.add(o);
|
||||
// } else {
|
||||
// List<Object> objects;
|
||||
// if (series.containsKey(s)) {
|
||||
// objects = series.get(s);
|
||||
// } else {
|
||||
// objects = new ArrayList<>();
|
||||
//
|
||||
// }
|
||||
// objects.add(o);
|
||||
// series.put(s, objects);
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// json.put("xAxis", xAxis);
|
||||
// List<JSONObject> result = new ArrayList<>();
|
||||
// series.forEach((s, objects) -> {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("name", s);
|
||||
// if (s.endsWith("bar")) {
|
||||
// jsonObject.put("type", "bar");
|
||||
// } else {
|
||||
// jsonObject.put("type", "line");
|
||||
// }
|
||||
// jsonObject.put("data", objects);
|
||||
// result.add(jsonObject);
|
||||
// });
|
||||
// json.put("series", result);
|
||||
// return json.toJSONString();
|
||||
return data;
|
||||
}
|
||||
|
||||
/*{
|
||||
"xAxis": [
|
||||
"1月",
|
||||
"2月",
|
||||
"3月"
|
||||
],
|
||||
"series": [
|
||||
{
|
||||
"name": "指标1", //暂时用不上
|
||||
"type": "bar", //需要处理
|
||||
"data": [
|
||||
2,
|
||||
49,
|
||||
2
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "指标2",
|
||||
"type": "line",
|
||||
"yAxisIndex": 1,
|
||||
"data": [
|
||||
2,
|
||||
32,
|
||||
4
|
||||
]
|
||||
}
|
||||
]
|
||||
}*/
|
||||
/*
|
||||
* { "xAxis": [ "1月", "2月", "3月" ], "series": [ { "name": "指标1", //暂时用不上 "type":
|
||||
* "bar", //需要处理 "data": [ 2, 49, 2 ] }, { "name": "指标2", "type": "line",
|
||||
* "yAxisIndex": 1, "data": [ 2, 32, 4 ] } ] }
|
||||
*/
|
||||
|
||||
}
|
||||
+20
-25
@@ -8,36 +8,31 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 饼图或者空心饼图或者漏斗图
|
||||
* Created by raodeming on 2021/4/26.
|
||||
* 饼图或者空心饼图或者漏斗图 Created by raodeming on 2021/4/26.
|
||||
*/
|
||||
@Component
|
||||
public class GaugeChartServiceImpl implements ChartStrategy {
|
||||
/**
|
||||
* 图表类型
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return "widget-gauge";
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对每种图表类型做单独的数据转换解析
|
||||
*
|
||||
* @param dto
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object transform(ChartDto dto, List<JSONObject> data) {
|
||||
|
||||
// return "{\"value\": 50, \"name\": \"名称1\", \"unit\": \"%\"}";
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 图表类型
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return "widget-gauge";
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对每种图表类型做单独的数据转换解析
|
||||
* @param dto
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object transform(ChartDto dto, List<JSONObject> data) {
|
||||
|
||||
// return "{\"value\": 50, \"name\": \"名称1\", \"unit\": \"%\"}";
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
+22
-33
@@ -8,45 +8,34 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 饼图或者空心饼图或者漏斗图
|
||||
* Created by raodeming on 2021/4/26.
|
||||
* 饼图或者空心饼图或者漏斗图 Created by raodeming on 2021/4/26.
|
||||
*/
|
||||
@Component
|
||||
public class PieChartServiceImpl implements ChartStrategy {
|
||||
/**
|
||||
* 图表类型
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return "widget-piechart|widget-hollow-piechart|widget-funnel";
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对每种图表类型做单独的数据转换解析
|
||||
*
|
||||
* @param dto
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object transform(ChartDto dto, List<JSONObject> data) {
|
||||
/**
|
||||
* 图表类型
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return "widget-piechart|widget-hollow-piechart|widget-funnel";
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/* [
|
||||
{
|
||||
"value": 11,
|
||||
"name": "指标1"
|
||||
},
|
||||
{
|
||||
"value": 10,
|
||||
"name": "指标2"
|
||||
}
|
||||
]*/
|
||||
/**
|
||||
* 针对每种图表类型做单独的数据转换解析
|
||||
* @param dto
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object transform(ChartDto dto, List<JSONObject> data) {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/*
|
||||
* [ { "value": 11, "name": "指标1" }, { "value": 10, "name": "指标2" } ]
|
||||
*/
|
||||
|
||||
}
|
||||
+501
-498
File diff suppressed because it is too large.
Load diff
+16
-18
@@ -6,29 +6,27 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 大屏看板数据渲染 dto
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
* @description 大屏看板数据渲染 dto
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
@Data
|
||||
public class ReportDashboardWidgetDto implements Serializable {
|
||||
|
||||
/**
|
||||
* 组件类型参考字典DASHBOARD_PANEL_TYPE
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 组件类型参考字典DASHBOARD_PANEL_TYPE
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* value
|
||||
*/
|
||||
private ReportDashboardWidgetValueDto value;
|
||||
/**
|
||||
* value
|
||||
*/
|
||||
private ReportDashboardWidgetValueDto value;
|
||||
|
||||
/**
|
||||
* options
|
||||
*/
|
||||
private JSONObject options;
|
||||
/**
|
||||
* options
|
||||
*/
|
||||
private JSONObject options;
|
||||
|
||||
}
|
||||
+24
-25
@@ -6,42 +6,41 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 大屏看板数据渲染 dto,已弃用
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
* @description 大屏看板数据渲染 dto,已弃用
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
@Data
|
||||
public class ReportDashboardWidgetValueDto implements Serializable {
|
||||
/** 报表编码 */
|
||||
private String reportCode;
|
||||
|
||||
/** 组件的渲染属性json */
|
||||
private JSONObject setup;
|
||||
/** 报表编码 */
|
||||
private String reportCode;
|
||||
|
||||
/** 组件的数据属性json */
|
||||
private JSONObject data;
|
||||
/** 组件的渲染属性json */
|
||||
private JSONObject setup;
|
||||
|
||||
/** 组件的配置属性json */
|
||||
private JSONObject collapse;
|
||||
/** 组件的数据属性json */
|
||||
private JSONObject data;
|
||||
|
||||
/** 组件的大小位置属性json */
|
||||
private JSONObject position;
|
||||
/** 组件的配置属性json */
|
||||
private JSONObject collapse;
|
||||
|
||||
private String options;
|
||||
/** 组件的大小位置属性json */
|
||||
private JSONObject position;
|
||||
|
||||
/** 自动刷新间隔秒 */
|
||||
private Integer refreshSeconds;
|
||||
private String options;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
/** 自动刷新间隔秒 */
|
||||
private Integer refreshSeconds;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
private Integer deleteFlag;
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
|
||||
/** 排序,图层的概念 */
|
||||
private Long sort;
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DEL_FLAG */
|
||||
private Integer deleteFlag;
|
||||
|
||||
/** 排序,图层的概念 */
|
||||
private Long sort;
|
||||
|
||||
}
|
||||
+8
-11
@@ -1,20 +1,17 @@
|
||||
/**/
|
||||
package com.anjiplus.template.gaea.business.modules.dashboardwidget.controller.param;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import com.anji.plus.gaea.annotation.Query;
|
||||
import com.anji.plus.gaea.constant.QueryEnum;
|
||||
import com.anji.plus.gaea.curd.params.PageParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @desc ReportDashboardWidget 大屏看板数据渲染查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
* @desc ReportDashboardWidget 大屏看板数据渲染查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
@Data
|
||||
public class ReportDashboardWidgetParam extends PageParam implements Serializable{
|
||||
public class ReportDashboardWidgetParam extends PageParam implements Serializable {
|
||||
|
||||
}
|
||||
+6
-6
@@ -1,15 +1,15 @@
|
||||
package com.anjiplus.template.gaea.business.modules.dashboardwidget.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.dashboardwidget.dao.entity.ReportDashboardWidget;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* ReportDashboardWidget Mapper
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
* ReportDashboardWidget Mapper
|
||||
*
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
@Mapper
|
||||
public interface ReportDashboardWidgetMapper extends GaeaBaseMapper<ReportDashboardWidget> {
|
||||
|
||||
|
||||
+26
-26
@@ -7,44 +7,44 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description 大屏看板数据渲染 entity
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
@TableName(keepGlobalPrefix=true, value="gaea_report_dashboard_widget")
|
||||
* @description 大屏看板数据渲染 entity
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
@TableName(keepGlobalPrefix = true, value = "gaea_report_dashboard_widget")
|
||||
@Data
|
||||
public class ReportDashboardWidget extends GaeaBaseEntity {
|
||||
@ApiModelProperty(value = "报表编码")
|
||||
private String reportCode;
|
||||
|
||||
@ApiModelProperty(value = "组件类型参考字典DASHBOARD_PANEL_TYPE")
|
||||
private String type;
|
||||
@ApiModelProperty(value = "报表编码")
|
||||
private String reportCode;
|
||||
|
||||
@ApiModelProperty(value = "组件的渲染属性json")
|
||||
private String setup;
|
||||
@ApiModelProperty(value = "组件类型参考字典DASHBOARD_PANEL_TYPE")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "组件的数据属性json")
|
||||
private String data;
|
||||
@ApiModelProperty(value = "组件的渲染属性json")
|
||||
private String setup;
|
||||
|
||||
@ApiModelProperty(value = "组件的配置属性json")
|
||||
private String collapse;
|
||||
@ApiModelProperty(value = "组件的数据属性json")
|
||||
private String data;
|
||||
|
||||
@ApiModelProperty(value = "组件的大小位置属性json")
|
||||
private String position;
|
||||
@ApiModelProperty(value = "组件的配置属性json")
|
||||
private String collapse;
|
||||
|
||||
private String options;
|
||||
@ApiModelProperty(value = "组件的大小位置属性json")
|
||||
private String position;
|
||||
|
||||
@ApiModelProperty(value = "自动刷新间隔秒")
|
||||
private Integer refreshSeconds;
|
||||
private String options;
|
||||
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
private Integer enableFlag;
|
||||
@ApiModelProperty(value = "自动刷新间隔秒")
|
||||
private Integer refreshSeconds;
|
||||
|
||||
@ApiModelProperty(value = " 0--未删除 1--已删除 DIC_NAME=DEL_FLAG")
|
||||
private Integer deleteFlag;
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
private Integer enableFlag;
|
||||
|
||||
@ApiModelProperty(value = "排序,图层的概念")
|
||||
private Long sort;
|
||||
@ApiModelProperty(value = " 0--未删除 1--已删除 DIC_NAME=DEL_FLAG")
|
||||
private Integer deleteFlag;
|
||||
|
||||
@ApiModelProperty(value = "排序,图层的概念")
|
||||
private Long sort;
|
||||
|
||||
}
|
||||
+13
-12
@@ -1,21 +1,22 @@
|
||||
|
||||
package com.anjiplus.template.gaea.business.modules.dashboardwidget.service;
|
||||
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
import com.anjiplus.template.gaea.business.modules.dashboardwidget.controller.param.ReportDashboardWidgetParam;
|
||||
import com.anjiplus.template.gaea.business.modules.dashboardwidget.dao.entity.ReportDashboardWidget;
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
|
||||
/**
|
||||
* @desc ReportDashboardWidget 大屏看板数据渲染服务接口
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
public interface ReportDashboardWidgetService extends GaeaBaseService<ReportDashboardWidgetParam, ReportDashboardWidget> {
|
||||
* @desc ReportDashboardWidget 大屏看板数据渲染服务接口
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
public interface ReportDashboardWidgetService
|
||||
extends GaeaBaseService<ReportDashboardWidgetParam, ReportDashboardWidget> {
|
||||
|
||||
/***
|
||||
* 查询详情
|
||||
* @param id
|
||||
*/
|
||||
ReportDashboardWidget getDetail(Long id);
|
||||
|
||||
/***
|
||||
* 查询详情
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
ReportDashboardWidget getDetail(Long id);
|
||||
}
|
||||
+20
-20
@@ -2,33 +2,33 @@
|
||||
package com.anjiplus.template.gaea.business.modules.dashboardwidget.service.impl;
|
||||
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
|
||||
import com.anjiplus.template.gaea.business.modules.dashboardwidget.dao.ReportDashboardWidgetMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.dashboardwidget.dao.entity.ReportDashboardWidget;
|
||||
import com.anjiplus.template.gaea.business.modules.dashboardwidget.service.ReportDashboardWidgetService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.anjiplus.template.gaea.business.modules.dashboardwidget.dao.entity.ReportDashboardWidget;
|
||||
import com.anjiplus.template.gaea.business.modules.dashboardwidget.service.ReportDashboardWidgetService;
|
||||
import com.anjiplus.template.gaea.business.modules.dashboardwidget.dao.ReportDashboardWidgetMapper;
|
||||
/**
|
||||
* @desc ReportDashboardWidget 大屏看板数据渲染服务实现
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
* @desc ReportDashboardWidget 大屏看板数据渲染服务实现
|
||||
* @author Raod
|
||||
* @date 2021-04-12 15:12:43.724
|
||||
**/
|
||||
@Service
|
||||
//@RequiredArgsConstructor
|
||||
// @RequiredArgsConstructor
|
||||
public class ReportDashboardWidgetServiceImpl implements ReportDashboardWidgetService {
|
||||
|
||||
@Autowired
|
||||
private ReportDashboardWidgetMapper reportDashboardWidgetMapper;
|
||||
@Autowired
|
||||
private ReportDashboardWidgetMapper reportDashboardWidgetMapper;
|
||||
|
||||
@Override
|
||||
public GaeaBaseMapper<ReportDashboardWidget> getMapper() {
|
||||
return reportDashboardWidgetMapper;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseMapper<ReportDashboardWidget> getMapper() {
|
||||
return reportDashboardWidgetMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportDashboardWidget getDetail(Long id) {
|
||||
ReportDashboardWidget reportDashboardWidget = this.selectOne(id);
|
||||
return reportDashboardWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportDashboardWidget getDetail(Long id) {
|
||||
ReportDashboardWidget reportDashboardWidget = this.selectOne(id);
|
||||
return reportDashboardWidget;
|
||||
}
|
||||
}
|
||||
+90
-104
@@ -21,125 +21,111 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @desc 数据集 controller
|
||||
* @website https://gitee.com/anji-plus/gaea
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
* @desc 数据集 controller
|
||||
* @website https://gitee.com/anji-plus/gaea
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "数据集管理")
|
||||
@Permission(code = "resultsetManage", name = "数据集管理")
|
||||
@RequestMapping("/dataSet")
|
||||
public class DataSetController extends GaeaBaseController<DataSetParam, DataSet, DataSetDto> {
|
||||
|
||||
@Autowired
|
||||
private DataSetService dataSetService;
|
||||
@Autowired
|
||||
private DataSetService dataSetService;
|
||||
|
||||
@Override
|
||||
public GaeaBaseService<DataSetParam, DataSet> getService() {
|
||||
return dataSetService;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseService<DataSetParam, DataSet> getService() {
|
||||
return dataSetService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSet getEntity() {
|
||||
return new DataSet();
|
||||
}
|
||||
@Override
|
||||
public DataSet getEntity() {
|
||||
return new DataSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSetDto getDTO() {
|
||||
return new DataSetDto();
|
||||
}
|
||||
@Override
|
||||
public DataSetDto getDTO() {
|
||||
return new DataSetDto();
|
||||
}
|
||||
|
||||
@GetMapping("/detailBysetId/{id}")
|
||||
@Permission( code = "query", name = "明细" )
|
||||
public ResponseBean detailBysetId(@PathVariable("id") Long id) {
|
||||
this.logger.info("{}根据ID查询服务开始,id为:{}", this.getClass().getSimpleName(), id);
|
||||
ResponseBean responseBean = this.responseSuccessWithData(dataSetService.detailSet(id));
|
||||
this.logger.info("{}根据ID查询结束,结果:{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(responseBean));
|
||||
return responseBean;
|
||||
}
|
||||
@GetMapping("/detailBysetId/{id}")
|
||||
@Permission(code = "query", name = "明细")
|
||||
public ResponseBean detailBysetId(@PathVariable("id") Long id) {
|
||||
this.logger.info("{}根据ID查询服务开始,id为:{}", this.getClass().getSimpleName(), id);
|
||||
ResponseBean responseBean = this.responseSuccessWithData(dataSetService.detailSet(id));
|
||||
this.logger.info("{}根据ID查询结束,结果:{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(responseBean));
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
@GetMapping({"/detailBysetCode/{setCode}"})
|
||||
@Permission( code = "query", name = "明细" )
|
||||
@AccessKey
|
||||
public ResponseBean detailBysetCode(@PathVariable("setCode") String setCode) {
|
||||
this.logger.info("{}根据setCode查询服务开始,setCode为:{}", this.getClass().getSimpleName(), setCode);
|
||||
ResponseBean responseBean = this.responseSuccessWithData(dataSetService.detailSet(setCode));
|
||||
this.logger.info("{}根据setCode查询结束,结果:{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(responseBean));
|
||||
return responseBean;
|
||||
}
|
||||
@GetMapping({ "/detailBysetCode/{setCode}" })
|
||||
@Permission(code = "query", name = "明细")
|
||||
@AccessKey
|
||||
public ResponseBean detailBysetCode(@PathVariable("setCode") String setCode) {
|
||||
this.logger.info("{}根据setCode查询服务开始,setCode为:{}", this.getClass().getSimpleName(), setCode);
|
||||
ResponseBean responseBean = this.responseSuccessWithData(dataSetService.detailSet(setCode));
|
||||
this.logger.info("{}根据setCode查询结束,结果:{}", this.getClass().getSimpleName(),
|
||||
GaeaUtils.toJSONString(responseBean));
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Permission(
|
||||
code = "insert",
|
||||
name = "新增"
|
||||
)
|
||||
@GaeaAuditLog(
|
||||
pageTitle = "新增"
|
||||
)
|
||||
@Override
|
||||
public ResponseBean insert(@RequestBody DataSetDto dto) {
|
||||
this.logger.info("{}新增服务开始,参数:{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(dto));
|
||||
DataSetDto dataSetDto = dataSetService.insertSet(dto);
|
||||
this.logger.info("{}新增服务结束,结果:{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(dataSetDto));
|
||||
return ResponseBean.builder().data(dataSetDto).build();
|
||||
}
|
||||
@PostMapping
|
||||
@Permission(code = "insert", name = "新增")
|
||||
@GaeaAuditLog(pageTitle = "新增")
|
||||
@Override
|
||||
public ResponseBean insert(@RequestBody DataSetDto dto) {
|
||||
this.logger.info("{}新增服务开始,参数:{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(dto));
|
||||
DataSetDto dataSetDto = dataSetService.insertSet(dto);
|
||||
this.logger.info("{}新增服务结束,结果:{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(dataSetDto));
|
||||
return ResponseBean.builder().data(dataSetDto).build();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Permission(
|
||||
code = "update",
|
||||
name = "更新"
|
||||
)
|
||||
@GaeaAuditLog(
|
||||
pageTitle = "修改"
|
||||
)
|
||||
@Override
|
||||
public ResponseBean update(@RequestBody DataSetDto dto) {
|
||||
String username = UserContentHolder.getContext().getUsername();
|
||||
this.logger.info("{}更新服务开始,更新人:{},参数:{}", this.getClass().getSimpleName(), username, GaeaUtils.toJSONString(dto));
|
||||
ResponseBean responseBean = this.responseSuccess();
|
||||
dataSetService.updateSet(dto);
|
||||
this.logger.info("{}更新服务结束,结果:{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(responseBean));
|
||||
return this.responseSuccess();
|
||||
}
|
||||
@PutMapping
|
||||
@Permission(code = "update", name = "更新")
|
||||
@GaeaAuditLog(pageTitle = "修改")
|
||||
@Override
|
||||
public ResponseBean update(@RequestBody DataSetDto dto) {
|
||||
String username = UserContentHolder.getContext().getUsername();
|
||||
this.logger.info("{}更新服务开始,更新人:{},参数:{}", this.getClass().getSimpleName(), username,
|
||||
GaeaUtils.toJSONString(dto));
|
||||
ResponseBean responseBean = this.responseSuccess();
|
||||
dataSetService.updateSet(dto);
|
||||
this.logger.info("{}更新服务结束,结果:{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(responseBean));
|
||||
return this.responseSuccess();
|
||||
}
|
||||
|
||||
@DeleteMapping({"/{id}"})
|
||||
@Permission(
|
||||
code = "delete",
|
||||
name = "删除"
|
||||
)
|
||||
@GaeaAuditLog(
|
||||
pageTitle = "删除"
|
||||
)
|
||||
@Override
|
||||
public ResponseBean deleteById(@PathVariable("id") Long id) {
|
||||
this.logger.info("{}删除服务开始,参数ID:{}", this.getClass().getSimpleName(), id);
|
||||
dataSetService.deleteSet(id);
|
||||
this.logger.info("{}删除服务结束", this.getClass().getSimpleName());
|
||||
return this.responseSuccess();
|
||||
}
|
||||
@DeleteMapping({ "/{id}" })
|
||||
@Permission(code = "delete", name = "删除")
|
||||
@GaeaAuditLog(pageTitle = "删除")
|
||||
@Override
|
||||
public ResponseBean deleteById(@PathVariable("id") Long id) {
|
||||
this.logger.info("{}删除服务开始,参数ID:{}", this.getClass().getSimpleName(), id);
|
||||
dataSetService.deleteSet(id);
|
||||
this.logger.info("{}删除服务结束", this.getClass().getSimpleName());
|
||||
return this.responseSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 数据转换是否正确
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/testTransform")
|
||||
@Permission( code = "query", name = "明细" )
|
||||
public ResponseBean testTransform(@Validated @RequestBody DataSetTestTransformParam param) {
|
||||
DataSetDto dto = new DataSetDto();
|
||||
BeanUtils.copyProperties(param, dto);
|
||||
return responseSuccessWithData(dataSetService.testTransform(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有数据集
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryAllDataSet")
|
||||
public ResponseBean queryAllDataSet() {
|
||||
return responseSuccessWithData(dataSetService.queryAllDataSet());
|
||||
}
|
||||
/**
|
||||
* 测试 数据转换是否正确
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/testTransform")
|
||||
@Permission(code = "query", name = "明细")
|
||||
public ResponseBean testTransform(@Validated @RequestBody DataSetTestTransformParam param) {
|
||||
DataSetDto dto = new DataSetDto();
|
||||
BeanUtils.copyProperties(param, dto);
|
||||
return responseSuccessWithData(dataSetService.testTransform(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有数据集
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryAllDataSet")
|
||||
public ResponseBean queryAllDataSet() {
|
||||
return responseSuccessWithData(dataSetService.queryAllDataSet());
|
||||
}
|
||||
|
||||
}
|
||||
+31
-33
@@ -11,55 +11,53 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 数据集 dto
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
* @description 数据集 dto
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
@Data
|
||||
public class DataSetDto extends GaeaBaseDTO implements Serializable {
|
||||
/** 数据集编码 */
|
||||
private String setCode;
|
||||
|
||||
/** 数据集名称 */
|
||||
private String setName;
|
||||
/** 数据集编码 */
|
||||
private String setCode;
|
||||
|
||||
/** 数据集描述 */
|
||||
private String setDesc;
|
||||
/** 数据集名称 */
|
||||
private String setName;
|
||||
|
||||
/** 数据集类型 */
|
||||
private String setType;
|
||||
/** 数据集描述 */
|
||||
private String setDesc;
|
||||
|
||||
/** 数据集类型 */
|
||||
private String setType;
|
||||
|
||||
/** 数据源编码 */
|
||||
private String sourceCode;
|
||||
/** 数据源编码 */
|
||||
private String sourceCode;
|
||||
|
||||
/** 动态查询sql或者接口中的请求体 */
|
||||
private String dynSentence;
|
||||
/** 动态查询sql或者接口中的请求体 */
|
||||
private String dynSentence;
|
||||
|
||||
/** 结果案例 */
|
||||
private String caseResult;
|
||||
/** 结果案例 */
|
||||
private String caseResult;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */
|
||||
private Integer deleteFlag;
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */
|
||||
private Integer deleteFlag;
|
||||
|
||||
/** 请求参数集合 */
|
||||
private List<DataSetParamDto> dataSetParamDtoList;
|
||||
/** 请求参数集合 */
|
||||
private List<DataSetParamDto> dataSetParamDtoList;
|
||||
|
||||
/** 数据转换集合 */
|
||||
private List<DataSetTransformDto> dataSetTransformDtoList;
|
||||
/** 数据转换集合 */
|
||||
private List<DataSetTransformDto> dataSetTransformDtoList;
|
||||
|
||||
/** 传入的自定义参数*/
|
||||
private Map<String, Object> contextData;
|
||||
/** 传入的自定义参数 */
|
||||
private Map<String, Object> contextData;
|
||||
|
||||
private Set<String> setParamList;
|
||||
private Set<String> setParamList;
|
||||
|
||||
/**指定字段*/
|
||||
private String fieldLabel;
|
||||
/** 指定字段 */
|
||||
private String fieldLabel;
|
||||
|
||||
}
|
||||
+14
-13
@@ -12,21 +12,22 @@ import java.util.List;
|
||||
@Data
|
||||
public class OriginalDataDto implements Serializable {
|
||||
|
||||
/**总数*/
|
||||
private long total;
|
||||
/** 总数 */
|
||||
private long total;
|
||||
|
||||
/**获取的数据详情*/
|
||||
private List<JSONObject> data;
|
||||
/** 获取的数据详情 */
|
||||
private List<JSONObject> data;
|
||||
|
||||
public OriginalDataDto(List<JSONObject> data) {
|
||||
this.data = data;
|
||||
}
|
||||
public OriginalDataDto(List<JSONObject> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public OriginalDataDto(long total, List<JSONObject> data) {
|
||||
this.total = total;
|
||||
this.data = data;
|
||||
}
|
||||
public OriginalDataDto(long total, List<JSONObject> data) {
|
||||
this.total = total;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public OriginalDataDto() {
|
||||
}
|
||||
|
||||
public OriginalDataDto() {
|
||||
}
|
||||
}
|
||||
+19
-18
@@ -8,27 +8,28 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* @desc DataSet 数据集查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
* @desc DataSet 数据集查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
@Data
|
||||
public class DataSetParam extends PageParam implements Serializable{
|
||||
/** 数据集编码 */
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String setCode;
|
||||
public class DataSetParam extends PageParam implements Serializable {
|
||||
|
||||
/** 数据集名称 */
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String setName;
|
||||
/** 数据集编码 */
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String setCode;
|
||||
|
||||
/** 数据源编码 */
|
||||
@Query(QueryEnum.EQ)
|
||||
private String sourceCode;
|
||||
/** 数据集名称 */
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String setName;
|
||||
|
||||
/** 数据源编码 */
|
||||
@Query(QueryEnum.EQ)
|
||||
private String sourceCode;
|
||||
|
||||
/** 数据集类型 */
|
||||
@Query(QueryEnum.EQ)
|
||||
private String setType;
|
||||
|
||||
/** 数据集类型 */
|
||||
@Query(QueryEnum.EQ)
|
||||
private String setType;
|
||||
}
|
||||
+15
-16
@@ -8,28 +8,27 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @desc DataSet 数据集查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
* @desc DataSet 数据集查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
@Data
|
||||
public class DataSetTestTransformParam implements Serializable{
|
||||
public class DataSetTestTransformParam implements Serializable {
|
||||
|
||||
/** 数据源编码 */
|
||||
private String sourceCode;
|
||||
/** 数据源编码 */
|
||||
private String sourceCode;
|
||||
|
||||
/** 动态查询sql或者接口中的请求体 */
|
||||
private String dynSentence;
|
||||
/** 动态查询sql或者接口中的请求体 */
|
||||
private String dynSentence;
|
||||
|
||||
/** 数据集类型 */
|
||||
private String setType;
|
||||
/** 数据集类型 */
|
||||
private String setType;
|
||||
|
||||
/** 请求参数集合 */
|
||||
private List<DataSetParamDto> dataSetParamDtoList;
|
||||
/** 请求参数集合 */
|
||||
private List<DataSetParamDto> dataSetParamDtoList;
|
||||
|
||||
/** 数据转换集合 */
|
||||
private List<DataSetTransformDto> dataSetTransformDtoList;
|
||||
/** 数据转换集合 */
|
||||
private List<DataSetTransformDto> dataSetTransformDtoList;
|
||||
|
||||
}
|
||||
+6
-6
@@ -1,15 +1,15 @@
|
||||
package com.anjiplus.template.gaea.business.modules.dataset.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.dataset.dao.entity.DataSet;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* DataSet Mapper
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
* DataSet Mapper
|
||||
*
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
@Mapper
|
||||
public interface DataSetMapper extends GaeaBaseMapper<DataSet> {
|
||||
|
||||
|
||||
+24
-24
@@ -9,40 +9,40 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description 数据集 entity
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
@TableName(keepGlobalPrefix=true, value="gaea_report_data_set")
|
||||
* @description 数据集 entity
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
@TableName(keepGlobalPrefix = true, value = "gaea_report_data_set")
|
||||
@Data
|
||||
public class DataSet extends GaeaBaseEntity {
|
||||
@ApiModelProperty(value = "数据集编码")
|
||||
@Unique(code = ResponseCode.SET_CODE_ISEXIST)
|
||||
private String setCode;
|
||||
|
||||
@ApiModelProperty(value = "数据集名称")
|
||||
private String setName;
|
||||
@ApiModelProperty(value = "数据集编码")
|
||||
@Unique(code = ResponseCode.SET_CODE_ISEXIST)
|
||||
private String setCode;
|
||||
|
||||
@ApiModelProperty(value = "数据集描述")
|
||||
private String setDesc;
|
||||
@ApiModelProperty(value = "数据集名称")
|
||||
private String setName;
|
||||
|
||||
@ApiModelProperty(value = "数据集类型")
|
||||
private String setType;
|
||||
@ApiModelProperty(value = "数据集描述")
|
||||
private String setDesc;
|
||||
|
||||
@ApiModelProperty(value = "数据源编码")
|
||||
private String sourceCode;
|
||||
@ApiModelProperty(value = "数据集类型")
|
||||
private String setType;
|
||||
|
||||
@ApiModelProperty(value = "动态查询sql或者接口中的请求体")
|
||||
private String dynSentence;
|
||||
@ApiModelProperty(value = "数据源编码")
|
||||
private String sourceCode;
|
||||
|
||||
@ApiModelProperty(value = "结果案例")
|
||||
private String caseResult;
|
||||
@ApiModelProperty(value = "动态查询sql或者接口中的请求体")
|
||||
private String dynSentence;
|
||||
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
private Integer enableFlag;
|
||||
@ApiModelProperty(value = "结果案例")
|
||||
private String caseResult;
|
||||
|
||||
@ApiModelProperty(value = "0--未删除 1--已删除 DIC_NAME=DELETE_FLAG")
|
||||
private Integer deleteFlag;
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
private Integer enableFlag;
|
||||
|
||||
@ApiModelProperty(value = "0--未删除 1--已删除 DIC_NAME=DELETE_FLAG")
|
||||
private Integer deleteFlag;
|
||||
|
||||
}
|
||||
+48
-48
@@ -10,61 +10,61 @@ import com.anjiplus.template.gaea.business.modules.dataset.dao.entity.DataSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @desc DataSet 数据集服务接口
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
* @desc DataSet 数据集服务接口
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
public interface DataSetService extends GaeaBaseService<DataSetParam, DataSet> {
|
||||
|
||||
/**
|
||||
* 单条详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
DataSetDto detailSet(Long id);
|
||||
/**
|
||||
* 单条详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
DataSetDto detailSet(Long id);
|
||||
|
||||
/**
|
||||
* 单条详情
|
||||
* @param setCode
|
||||
* @return
|
||||
*/
|
||||
DataSetDto detailSet(String setCode);
|
||||
/**
|
||||
* 单条详情
|
||||
* @param setCode
|
||||
* @return
|
||||
*/
|
||||
DataSetDto detailSet(String setCode);
|
||||
|
||||
/**
|
||||
* 新增数据集、添加查询参数、数据转换
|
||||
* @param dto
|
||||
*/
|
||||
DataSetDto insertSet(DataSetDto dto);
|
||||
/**
|
||||
* 新增数据集、添加查询参数、数据转换
|
||||
* @param dto
|
||||
*/
|
||||
DataSetDto insertSet(DataSetDto dto);
|
||||
|
||||
/**
|
||||
* 更新数据集、添加查询参数、数据转换
|
||||
* @param dto
|
||||
*/
|
||||
void updateSet(DataSetDto dto);
|
||||
/**
|
||||
* 更新数据集、添加查询参数、数据转换
|
||||
* @param dto
|
||||
*/
|
||||
void updateSet(DataSetDto dto);
|
||||
|
||||
/**
|
||||
* 删除数据集、添加查询参数、数据转换
|
||||
* @param id
|
||||
*/
|
||||
void deleteSet(Long id);
|
||||
/**
|
||||
* 删除数据集、添加查询参数、数据转换
|
||||
* @param id
|
||||
*/
|
||||
void deleteSet(Long id);
|
||||
|
||||
/**
|
||||
* 获取数据
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
OriginalDataDto getData(DataSetDto dto);
|
||||
/**
|
||||
* 获取数据
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
OriginalDataDto getData(DataSetDto dto);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
OriginalDataDto testTransform(DataSetDto dto);
|
||||
/**
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
OriginalDataDto testTransform(DataSetDto dto);
|
||||
|
||||
/**
|
||||
* 获取所有数据集
|
||||
* @return
|
||||
*/
|
||||
List<DataSet> queryAllDataSet();
|
||||
|
||||
/**
|
||||
* 获取所有数据集
|
||||
* @return
|
||||
*/
|
||||
List<DataSet> queryAllDataSet();
|
||||
}
|
||||
+299
-323
@@ -9,8 +9,8 @@ import com.anji.plus.gaea.exception.BusinessExceptionBuilder;
|
||||
import com.anji.plus.gaea.utils.GaeaBeanUtils;
|
||||
import com.anjiplus.template.gaea.business.code.ResponseCode;
|
||||
import com.anjiplus.template.gaea.business.enums.SetTypeEnum;
|
||||
import com.anjiplus.template.gaea.business.modules.dataset.controller.dto.OriginalDataDto;
|
||||
import com.anjiplus.template.gaea.business.modules.dataset.controller.dto.DataSetDto;
|
||||
import com.anjiplus.template.gaea.business.modules.dataset.controller.dto.OriginalDataDto;
|
||||
import com.anjiplus.template.gaea.business.modules.dataset.dao.DataSetMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.dataset.dao.entity.DataSet;
|
||||
import com.anjiplus.template.gaea.business.modules.dataset.service.DataSetService;
|
||||
@@ -41,366 +41,342 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @desc DataSet 数据集服务实现
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
* @desc DataSet 数据集服务实现
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:11:31.150755900
|
||||
**/
|
||||
@Service
|
||||
//@RequiredArgsConstructor
|
||||
// @RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DataSetServiceImpl implements DataSetService {
|
||||
|
||||
@Autowired
|
||||
private DataSetMapper dataSetMapper;
|
||||
@Autowired
|
||||
private DataSetMapper dataSetMapper;
|
||||
|
||||
@Autowired
|
||||
private DataSetParamService dataSetParamService;
|
||||
@Autowired
|
||||
private DataSetParamService dataSetParamService;
|
||||
|
||||
@Autowired
|
||||
private DataSetTransformService dataSetTransformService;
|
||||
@Autowired
|
||||
private DataSetTransformService dataSetTransformService;
|
||||
|
||||
@Autowired
|
||||
private DataSourceService dataSourceService;
|
||||
@Autowired
|
||||
private DataSourceService dataSourceService;
|
||||
|
||||
@Override
|
||||
public GaeaBaseMapper<DataSet> getMapper() {
|
||||
return dataSetMapper;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseMapper<DataSet> getMapper() {
|
||||
return dataSetMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单条详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DataSetDto detailSet(Long id) {
|
||||
DataSetDto dto = new DataSetDto();
|
||||
DataSet result = selectOne(id);
|
||||
String setCode = result.getSetCode();
|
||||
GaeaBeanUtils.copyAndFormatter(result, dto);
|
||||
return getDetailSet(dto, setCode);
|
||||
}
|
||||
/**
|
||||
* 单条详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DataSetDto detailSet(Long id) {
|
||||
DataSetDto dto = new DataSetDto();
|
||||
DataSet result = selectOne(id);
|
||||
String setCode = result.getSetCode();
|
||||
GaeaBeanUtils.copyAndFormatter(result, dto);
|
||||
return getDetailSet(dto, setCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单条详情
|
||||
*
|
||||
* @param setCode
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DataSetDto detailSet(String setCode) {
|
||||
DataSetDto dto = new DataSetDto();
|
||||
DataSet result = selectOne("set_code", setCode);
|
||||
GaeaBeanUtils.copyAndFormatter(result, dto);
|
||||
return getDetailSet(dto, setCode);
|
||||
}
|
||||
/**
|
||||
* 单条详情
|
||||
* @param setCode
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DataSetDto detailSet(String setCode) {
|
||||
DataSetDto dto = new DataSetDto();
|
||||
DataSet result = selectOne("set_code", setCode);
|
||||
GaeaBeanUtils.copyAndFormatter(result, dto);
|
||||
return getDetailSet(dto, setCode);
|
||||
}
|
||||
|
||||
public DataSetDto getDetailSet(DataSetDto dto, String setCode) {
|
||||
//查询参数
|
||||
List<DataSetParam> dataSetParamList = dataSetParamService.list(
|
||||
new QueryWrapper<DataSetParam>()
|
||||
.lambda()
|
||||
.eq(DataSetParam::getSetCode, setCode)
|
||||
);
|
||||
List<DataSetParamDto> dataSetParamDtoList = new ArrayList<>();
|
||||
dataSetParamList.forEach(dataSetParam -> {
|
||||
DataSetParamDto dataSetParamDto = new DataSetParamDto();
|
||||
GaeaBeanUtils.copyAndFormatter(dataSetParam, dataSetParamDto);
|
||||
dataSetParamDtoList.add(dataSetParamDto);
|
||||
});
|
||||
dto.setDataSetParamDtoList(dataSetParamDtoList);
|
||||
public DataSetDto getDetailSet(DataSetDto dto, String setCode) {
|
||||
// 查询参数
|
||||
List<DataSetParam> dataSetParamList = dataSetParamService
|
||||
.list(new QueryWrapper<DataSetParam>().lambda().eq(DataSetParam::getSetCode, setCode));
|
||||
List<DataSetParamDto> dataSetParamDtoList = new ArrayList<>();
|
||||
dataSetParamList.forEach(dataSetParam -> {
|
||||
DataSetParamDto dataSetParamDto = new DataSetParamDto();
|
||||
GaeaBeanUtils.copyAndFormatter(dataSetParam, dataSetParamDto);
|
||||
dataSetParamDtoList.add(dataSetParamDto);
|
||||
});
|
||||
dto.setDataSetParamDtoList(dataSetParamDtoList);
|
||||
|
||||
//数据转换
|
||||
// 数据转换
|
||||
|
||||
List<DataSetTransform> dataSetTransformList = dataSetTransformService.list(
|
||||
new QueryWrapper<DataSetTransform>()
|
||||
.lambda()
|
||||
.eq(DataSetTransform::getSetCode, setCode)
|
||||
.orderByAsc(DataSetTransform::getOrderNum)
|
||||
);
|
||||
List<DataSetTransformDto> dataSetTransformDtoList = new ArrayList<>();
|
||||
dataSetTransformList.forEach(dataSetTransform -> {
|
||||
DataSetTransformDto dataSetTransformDto = new DataSetTransformDto();
|
||||
GaeaBeanUtils.copyAndFormatter(dataSetTransform, dataSetTransformDto);
|
||||
dataSetTransformDtoList.add(dataSetTransformDto);
|
||||
});
|
||||
dto.setDataSetTransformDtoList(dataSetTransformDtoList);
|
||||
List<DataSetTransform> dataSetTransformList = dataSetTransformService.list(new QueryWrapper<DataSetTransform>()
|
||||
.lambda().eq(DataSetTransform::getSetCode, setCode).orderByAsc(DataSetTransform::getOrderNum));
|
||||
List<DataSetTransformDto> dataSetTransformDtoList = new ArrayList<>();
|
||||
dataSetTransformList.forEach(dataSetTransform -> {
|
||||
DataSetTransformDto dataSetTransformDto = new DataSetTransformDto();
|
||||
GaeaBeanUtils.copyAndFormatter(dataSetTransform, dataSetTransformDto);
|
||||
dataSetTransformDtoList.add(dataSetTransformDto);
|
||||
});
|
||||
dto.setDataSetTransformDtoList(dataSetTransformDtoList);
|
||||
|
||||
if (StringUtils.isNotBlank(dto.getCaseResult())) {
|
||||
try {
|
||||
JSONArray jsonArray = JSONArray.parseArray(dto.getCaseResult());
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(0);
|
||||
dto.setSetParamList(jsonObject.keySet());
|
||||
} catch (Exception e) {
|
||||
log.error("error",e);
|
||||
}
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
if (StringUtils.isNotBlank(dto.getCaseResult())) {
|
||||
try {
|
||||
JSONArray jsonArray = JSONArray.parseArray(dto.getCaseResult());
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(0);
|
||||
dto.setSetParamList(jsonObject.keySet());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("error", e);
|
||||
}
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据集、添加查询参数、数据转换
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public DataSetDto insertSet(DataSetDto dto) {
|
||||
List<DataSetParamDto> dataSetParamDtoList = dto.getDataSetParamDtoList();
|
||||
List<DataSetTransformDto> dataSetTransformDtoList = dto.getDataSetTransformDtoList();
|
||||
|
||||
/**
|
||||
* 新增数据集、添加查询参数、数据转换
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public DataSetDto insertSet(DataSetDto dto) {
|
||||
List<DataSetParamDto> dataSetParamDtoList = dto.getDataSetParamDtoList();
|
||||
List<DataSetTransformDto> dataSetTransformDtoList = dto.getDataSetTransformDtoList();
|
||||
// 1.新增数据集
|
||||
DataSet dataSet = new DataSet();
|
||||
BeanUtils.copyProperties(dto, dataSet);
|
||||
insert(dataSet);
|
||||
// 2.更新查询参数
|
||||
dataSetParamBatch(dataSetParamDtoList, dto.getSetCode());
|
||||
|
||||
//1.新增数据集
|
||||
DataSet dataSet = new DataSet();
|
||||
BeanUtils.copyProperties(dto, dataSet);
|
||||
insert(dataSet);
|
||||
//2.更新查询参数
|
||||
dataSetParamBatch(dataSetParamDtoList, dto.getSetCode());
|
||||
// 3.更新数据转换
|
||||
dataSetTransformBatch(dataSetTransformDtoList, dto.getSetCode());
|
||||
return dto;
|
||||
}
|
||||
|
||||
//3.更新数据转换
|
||||
dataSetTransformBatch(dataSetTransformDtoList, dto.getSetCode());
|
||||
return dto;
|
||||
}
|
||||
/**
|
||||
* 更新数据集、添加查询参数、数据转换
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateSet(DataSetDto dto) {
|
||||
List<DataSetParamDto> dataSetParamDtoList = dto.getDataSetParamDtoList();
|
||||
List<DataSetTransformDto> dataSetTransformDtoList = dto.getDataSetTransformDtoList();
|
||||
// 1.更新数据集
|
||||
DataSet dataSet = new DataSet();
|
||||
BeanUtils.copyProperties(dto, dataSet);
|
||||
update(dataSet);
|
||||
|
||||
/**
|
||||
* 更新数据集、添加查询参数、数据转换
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateSet(DataSetDto dto) {
|
||||
List<DataSetParamDto> dataSetParamDtoList = dto.getDataSetParamDtoList();
|
||||
List<DataSetTransformDto> dataSetTransformDtoList = dto.getDataSetTransformDtoList();
|
||||
//1.更新数据集
|
||||
DataSet dataSet = new DataSet();
|
||||
BeanUtils.copyProperties(dto, dataSet);
|
||||
update(dataSet);
|
||||
// 2.更新查询参数
|
||||
dataSetParamBatch(dataSetParamDtoList, dto.getSetCode());
|
||||
|
||||
//2.更新查询参数
|
||||
dataSetParamBatch(dataSetParamDtoList, dto.getSetCode());
|
||||
// 3.更新数据转换
|
||||
dataSetTransformBatch(dataSetTransformDtoList, dto.getSetCode());
|
||||
}
|
||||
|
||||
//3.更新数据转换
|
||||
dataSetTransformBatch(dataSetTransformDtoList, dto.getSetCode());
|
||||
}
|
||||
/**
|
||||
* 删除数据集、添加查询参数、数据转换
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void deleteSet(Long id) {
|
||||
DataSet dataSet = selectOne(id);
|
||||
String setCode = dataSet.getSetCode();
|
||||
// 1.删除数据集
|
||||
deleteById(id);
|
||||
|
||||
// 2.删除查询参数
|
||||
dataSetParamService.delete(new QueryWrapper<DataSetParam>().lambda().eq(DataSetParam::getSetCode, setCode));
|
||||
|
||||
/**
|
||||
* 删除数据集、添加查询参数、数据转换
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void deleteSet(Long id) {
|
||||
DataSet dataSet = selectOne(id);
|
||||
String setCode = dataSet.getSetCode();
|
||||
//1.删除数据集
|
||||
deleteById(id);
|
||||
// 3.删除数据转换
|
||||
dataSetTransformService
|
||||
.delete(new QueryWrapper<DataSetTransform>().lambda().eq(DataSetTransform::getSetCode, setCode));
|
||||
}
|
||||
|
||||
//2.删除查询参数
|
||||
dataSetParamService.delete(
|
||||
new QueryWrapper<DataSetParam>()
|
||||
.lambda()
|
||||
.eq(DataSetParam::getSetCode, setCode)
|
||||
);
|
||||
/**
|
||||
* 获取数据
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public OriginalDataDto getData(DataSetDto dto) {
|
||||
|
||||
//3.删除数据转换
|
||||
dataSetTransformService.delete(
|
||||
new QueryWrapper<DataSetTransform>()
|
||||
.lambda()
|
||||
.eq(DataSetTransform::getSetCode, setCode)
|
||||
);
|
||||
}
|
||||
OriginalDataDto originalDataDto = new OriginalDataDto();
|
||||
String setCode = dto.getSetCode();
|
||||
// 1.获取数据集、参数替换、数据转换
|
||||
DataSetDto dataSetDto = detailSet(setCode);
|
||||
String dynSentence = dataSetDto.getDynSentence();
|
||||
// 2.获取数据源
|
||||
DataSource dataSource;
|
||||
if (StringUtils.isNotBlank(dataSetDto.getSetType())
|
||||
&& dataSetDto.getSetType().equals(SetTypeEnum.HTTP.getCodeValue())) {
|
||||
// http不需要数据源,兼容已有的逻辑,将http所需要的数据塞进DataSource
|
||||
dataSource = new DataSource();
|
||||
dataSource.setSourceConfig(dynSentence);
|
||||
dataSource.setSourceType(JdbcConstants.HTTP);
|
||||
String body = JSONObject.parseObject(dynSentence).getString("body");
|
||||
if (StringUtils.isNotBlank(body)) {
|
||||
dynSentence = body;
|
||||
}
|
||||
else {
|
||||
dynSentence = "{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public OriginalDataDto getData(DataSetDto dto) {
|
||||
}
|
||||
else {
|
||||
dataSource = dataSourceService.selectOne("source_code", dataSetDto.getSourceCode());
|
||||
}
|
||||
|
||||
OriginalDataDto originalDataDto = new OriginalDataDto();
|
||||
String setCode = dto.getSetCode();
|
||||
//1.获取数据集、参数替换、数据转换
|
||||
DataSetDto dataSetDto = detailSet(setCode);
|
||||
String dynSentence = dataSetDto.getDynSentence();
|
||||
//2.获取数据源
|
||||
DataSource dataSource;
|
||||
if (StringUtils.isNotBlank(dataSetDto.getSetType())
|
||||
&& dataSetDto.getSetType().equals(SetTypeEnum.HTTP.getCodeValue())) {
|
||||
//http不需要数据源,兼容已有的逻辑,将http所需要的数据塞进DataSource
|
||||
dataSource = new DataSource();
|
||||
dataSource.setSourceConfig(dynSentence);
|
||||
dataSource.setSourceType(JdbcConstants.HTTP);
|
||||
String body = JSONObject.parseObject(dynSentence).getString("body");
|
||||
if (StringUtils.isNotBlank(body)) {
|
||||
dynSentence = body;
|
||||
}else {
|
||||
dynSentence = "{}";
|
||||
}
|
||||
// 3.参数替换
|
||||
// 3.1参数校验
|
||||
log.debug("参数校验替换前:{}", dto.getContextData());
|
||||
boolean verification = dataSetParamService.verification(dataSetDto.getDataSetParamDtoList(),
|
||||
dto.getContextData());
|
||||
if (!verification) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.RULE_FIELDS_CHECK_ERROR);
|
||||
}
|
||||
dynSentence = dataSetParamService.transform(dto.getContextData(), dynSentence);
|
||||
log.debug("参数校验替换后:{}", dto.getContextData());
|
||||
// 4.获取数据
|
||||
DataSourceDto dataSourceDto = new DataSourceDto();
|
||||
BeanUtils.copyProperties(dataSource, dataSourceDto);
|
||||
dataSourceDto.setDynSentence(dynSentence);
|
||||
dataSourceDto.setContextData(dto.getContextData());
|
||||
// 获取total,判断contextData中是否传入分页参数
|
||||
if (null != dto.getContextData() && dto.getContextData().containsKey("pageNumber")
|
||||
&& dto.getContextData().containsKey("pageSize")) {
|
||||
long total = dataSourceService.total(dataSourceDto, dto);
|
||||
originalDataDto.setTotal(total);
|
||||
}
|
||||
List<JSONObject> data = dataSourceService.execute(dataSourceDto);
|
||||
// 5.数据转换
|
||||
List<JSONObject> transform = dataSetTransformService.transform(dataSetDto.getDataSetTransformDtoList(), data);
|
||||
originalDataDto.setData(transform);
|
||||
return originalDataDto;
|
||||
}
|
||||
|
||||
}else {
|
||||
dataSource = dataSourceService.selectOne("source_code", dataSetDto.getSourceCode());
|
||||
}
|
||||
/**
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public OriginalDataDto testTransform(DataSetDto dto) {
|
||||
String dynSentence = dto.getDynSentence();
|
||||
|
||||
//3.参数替换
|
||||
//3.1参数校验
|
||||
log.debug("参数校验替换前:{}", dto.getContextData());
|
||||
boolean verification = dataSetParamService.verification(dataSetDto.getDataSetParamDtoList(), dto.getContextData());
|
||||
if (!verification) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.RULE_FIELDS_CHECK_ERROR);
|
||||
}
|
||||
dynSentence = dataSetParamService.transform(dto.getContextData(), dynSentence);
|
||||
log.debug("参数校验替换后:{}", dto.getContextData());
|
||||
//4.获取数据
|
||||
DataSourceDto dataSourceDto = new DataSourceDto();
|
||||
BeanUtils.copyProperties(dataSource, dataSourceDto);
|
||||
dataSourceDto.setDynSentence(dynSentence);
|
||||
dataSourceDto.setContextData(dto.getContextData());
|
||||
//获取total,判断contextData中是否传入分页参数
|
||||
if (null != dto.getContextData()
|
||||
&& dto.getContextData().containsKey("pageNumber")
|
||||
&& dto.getContextData().containsKey("pageSize")) {
|
||||
long total = dataSourceService.total(dataSourceDto, dto);
|
||||
originalDataDto.setTotal(total);
|
||||
}
|
||||
List<JSONObject> data = dataSourceService.execute(dataSourceDto);
|
||||
//5.数据转换
|
||||
List<JSONObject> transform = dataSetTransformService.transform(dataSetDto.getDataSetTransformDtoList(), data);
|
||||
originalDataDto.setData(transform);
|
||||
return originalDataDto;
|
||||
}
|
||||
OriginalDataDto originalDataDto = new OriginalDataDto();
|
||||
String sourceCode = dto.getSourceCode();
|
||||
// 1.获取数据源
|
||||
DataSource dataSource;
|
||||
if (dto.getSetType().equals(SetTypeEnum.HTTP.getCodeValue())) {
|
||||
// http不需要数据源,兼容已有的逻辑,将http所需要的数据塞进DataSource
|
||||
dataSource = new DataSource();
|
||||
dataSource.setSourceConfig(dynSentence);
|
||||
dataSource.setSourceType(JdbcConstants.HTTP);
|
||||
String body = JSONObject.parseObject(dynSentence).getString("body");
|
||||
if (StringUtils.isNotBlank(body)) {
|
||||
dynSentence = body;
|
||||
}
|
||||
else {
|
||||
dynSentence = "{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public OriginalDataDto testTransform(DataSetDto dto) {
|
||||
String dynSentence = dto.getDynSentence();
|
||||
}
|
||||
else {
|
||||
dataSource = dataSourceService.selectOne("source_code", sourceCode);
|
||||
}
|
||||
|
||||
OriginalDataDto originalDataDto = new OriginalDataDto();
|
||||
String sourceCode = dto.getSourceCode();
|
||||
//1.获取数据源
|
||||
DataSource dataSource;
|
||||
if (dto.getSetType().equals(SetTypeEnum.HTTP.getCodeValue())) {
|
||||
//http不需要数据源,兼容已有的逻辑,将http所需要的数据塞进DataSource
|
||||
dataSource = new DataSource();
|
||||
dataSource.setSourceConfig(dynSentence);
|
||||
dataSource.setSourceType(JdbcConstants.HTTP);
|
||||
String body = JSONObject.parseObject(dynSentence).getString("body");
|
||||
if (StringUtils.isNotBlank(body)) {
|
||||
dynSentence = body;
|
||||
}else {
|
||||
dynSentence = "{}";
|
||||
}
|
||||
// 3.参数替换
|
||||
// 3.1参数校验
|
||||
boolean verification = dataSetParamService.verification(dto.getDataSetParamDtoList(), null);
|
||||
if (!verification) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.RULE_FIELDS_CHECK_ERROR);
|
||||
}
|
||||
|
||||
}else {
|
||||
dataSource = dataSourceService.selectOne("source_code", sourceCode);
|
||||
}
|
||||
dynSentence = dataSetParamService.transform(dto.getDataSetParamDtoList(), dynSentence);
|
||||
// 4.获取数据
|
||||
DataSourceDto dataSourceDto = new DataSourceDto();
|
||||
BeanUtils.copyProperties(dataSource, dataSourceDto);
|
||||
dataSourceDto.setDynSentence(dynSentence);
|
||||
dataSourceDto.setContextData(setContextData(dto.getDataSetParamDtoList()));
|
||||
|
||||
//3.参数替换
|
||||
//3.1参数校验
|
||||
boolean verification = dataSetParamService.verification(dto.getDataSetParamDtoList(), null);
|
||||
if (!verification) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.RULE_FIELDS_CHECK_ERROR);
|
||||
}
|
||||
// 获取total,判断DataSetParamDtoList中是否传入分页参数
|
||||
Map<String, Object> collect = dto.getDataSetParamDtoList().stream()
|
||||
.collect(Collectors.toMap(DataSetParamDto::getParamName, DataSetParamDto::getSampleItem));
|
||||
if (collect.containsKey("pageNumber") && collect.containsKey("pageSize")) {
|
||||
dto.setContextData(collect);
|
||||
long total = dataSourceService.total(dataSourceDto, dto);
|
||||
originalDataDto.setTotal(total);
|
||||
}
|
||||
|
||||
dynSentence = dataSetParamService.transform(dto.getDataSetParamDtoList(), dynSentence);
|
||||
//4.获取数据
|
||||
DataSourceDto dataSourceDto = new DataSourceDto();
|
||||
BeanUtils.copyProperties(dataSource, dataSourceDto);
|
||||
dataSourceDto.setDynSentence(dynSentence);
|
||||
dataSourceDto.setContextData(setContextData(dto.getDataSetParamDtoList()));
|
||||
List<JSONObject> data = dataSourceService.execute(dataSourceDto);
|
||||
// 5.数据转换
|
||||
List<JSONObject> transform = dataSetTransformService.transform(dto.getDataSetTransformDtoList(), data);
|
||||
originalDataDto.setData(transform);
|
||||
return originalDataDto;
|
||||
}
|
||||
|
||||
//获取total,判断DataSetParamDtoList中是否传入分页参数
|
||||
Map<String, Object> collect = dto.getDataSetParamDtoList().stream().collect(Collectors.toMap(DataSetParamDto::getParamName, DataSetParamDto::getSampleItem));
|
||||
if (collect.containsKey("pageNumber") && collect.containsKey("pageSize")) {
|
||||
dto.setContextData(collect);
|
||||
long total = dataSourceService.total(dataSourceDto, dto);
|
||||
originalDataDto.setTotal(total);
|
||||
}
|
||||
/**
|
||||
* 获取所有数据集
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DataSet> queryAllDataSet() {
|
||||
LambdaQueryWrapper<DataSet> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.select(DataSet::getSetCode, DataSet::getSetName, DataSet::getSetDesc, DataSet::getId)
|
||||
.eq(DataSet::getEnableFlag, Enabled.YES.getValue());
|
||||
wrapper.orderByDesc(DataSet::getUpdateTime);
|
||||
return dataSetMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
List<JSONObject> data = dataSourceService.execute(dataSourceDto);
|
||||
//5.数据转换
|
||||
List<JSONObject> transform = dataSetTransformService.transform(dto.getDataSetTransformDtoList(), data);
|
||||
originalDataDto.setData(transform);
|
||||
return originalDataDto;
|
||||
}
|
||||
public void dataSetParamBatch(List<DataSetParamDto> dataSetParamDtoList, String setCode) {
|
||||
dataSetParamService.delete(new QueryWrapper<DataSetParam>().lambda().eq(DataSetParam::getSetCode, setCode));
|
||||
if (null == dataSetParamDtoList || dataSetParamDtoList.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
// List<DataSetParam> dataSetParamList = new ArrayList<>();
|
||||
dataSetParamDtoList.forEach(dataSetParamDto -> {
|
||||
DataSetParam dataSetParam = new DataSetParam();
|
||||
BeanUtils.copyProperties(dataSetParamDto, dataSetParam);
|
||||
dataSetParam.setSetCode(setCode);
|
||||
// 不采用批量
|
||||
dataSetParamService.insert(dataSetParam);
|
||||
// dataSetParamList.add(dataSetParam);
|
||||
});
|
||||
// dataSetParamService.insertBatch(dataSetParamList);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有数据集
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DataSet> queryAllDataSet() {
|
||||
LambdaQueryWrapper<DataSet> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.select(DataSet::getSetCode, DataSet::getSetName, DataSet::getSetDesc, DataSet::getId)
|
||||
.eq(DataSet::getEnableFlag, Enabled.YES.getValue());
|
||||
wrapper.orderByDesc(DataSet::getUpdateTime);
|
||||
return dataSetMapper.selectList(wrapper);
|
||||
}
|
||||
public void dataSetTransformBatch(List<DataSetTransformDto> dataSetTransformDtoList, String setCode) {
|
||||
dataSetTransformService
|
||||
.delete(new QueryWrapper<DataSetTransform>().lambda().eq(DataSetTransform::getSetCode, setCode));
|
||||
if (null == dataSetTransformDtoList || dataSetTransformDtoList.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
// List<DataSetTransform> dataSetTransformList = new ArrayList<>();
|
||||
for (int i = 0; i < dataSetTransformDtoList.size(); i++) {
|
||||
DataSetTransform dataSetTransform = new DataSetTransform();
|
||||
BeanUtils.copyProperties(dataSetTransformDtoList.get(i), dataSetTransform);
|
||||
dataSetTransform.setOrderNum(i + 1);
|
||||
dataSetTransform.setSetCode(setCode);
|
||||
// 不采用批量
|
||||
dataSetTransformService.insert(dataSetTransform);
|
||||
// dataSetTransformList.add(dataSetTransform);
|
||||
}
|
||||
// dataSetTransformService.insertBatch(dataSetTransformList);
|
||||
}
|
||||
|
||||
public void dataSetParamBatch(List<DataSetParamDto> dataSetParamDtoList,String setCode){
|
||||
dataSetParamService.delete(
|
||||
new QueryWrapper<DataSetParam>()
|
||||
.lambda()
|
||||
.eq(DataSetParam::getSetCode, setCode)
|
||||
);
|
||||
if (null == dataSetParamDtoList || dataSetParamDtoList.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
// List<DataSetParam> dataSetParamList = new ArrayList<>();
|
||||
dataSetParamDtoList.forEach(dataSetParamDto -> {
|
||||
DataSetParam dataSetParam = new DataSetParam();
|
||||
BeanUtils.copyProperties(dataSetParamDto, dataSetParam);
|
||||
dataSetParam.setSetCode(setCode);
|
||||
//不采用批量
|
||||
dataSetParamService.insert(dataSetParam);
|
||||
// dataSetParamList.add(dataSetParam);
|
||||
});
|
||||
// dataSetParamService.insertBatch(dataSetParamList);
|
||||
|
||||
}
|
||||
|
||||
public void dataSetTransformBatch(List<DataSetTransformDto> dataSetTransformDtoList,String setCode){
|
||||
dataSetTransformService.delete(
|
||||
new QueryWrapper<DataSetTransform>()
|
||||
.lambda()
|
||||
.eq(DataSetTransform::getSetCode, setCode)
|
||||
);
|
||||
if (null == dataSetTransformDtoList || dataSetTransformDtoList.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
// List<DataSetTransform> dataSetTransformList = new ArrayList<>();
|
||||
for (int i = 0; i < dataSetTransformDtoList.size(); i++) {
|
||||
DataSetTransform dataSetTransform = new DataSetTransform();
|
||||
BeanUtils.copyProperties(dataSetTransformDtoList.get(i), dataSetTransform);
|
||||
dataSetTransform.setOrderNum(i + 1);
|
||||
dataSetTransform.setSetCode(setCode);
|
||||
//不采用批量
|
||||
dataSetTransformService.insert(dataSetTransform);
|
||||
// dataSetTransformList.add(dataSetTransform);
|
||||
}
|
||||
// dataSetTransformService.insertBatch(dataSetTransformList);
|
||||
}
|
||||
|
||||
/**
|
||||
* dataSetParamDtoList转map
|
||||
* @param dataSetParamDtoList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> setContextData(List<DataSetParamDto> dataSetParamDtoList){
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (null != dataSetParamDtoList && dataSetParamDtoList.size() > 0) {
|
||||
dataSetParamDtoList.forEach(dataSetParamDto -> map.put(dataSetParamDto.getParamName(), dataSetParamDto.getSampleItem()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
/**
|
||||
* dataSetParamDtoList转map
|
||||
* @param dataSetParamDtoList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> setContextData(List<DataSetParamDto> dataSetParamDtoList) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (null != dataSetParamDtoList && dataSetParamDtoList.size() > 0) {
|
||||
dataSetParamDtoList.forEach(
|
||||
dataSetParamDto -> map.put(dataSetParamDto.getParamName(), dataSetParamDto.getSampleItem()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
+32
-31
@@ -18,44 +18,45 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @desc 数据集动态参数 controller
|
||||
* @website https://gitee.com/anji-plus/gaea
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:12:33.108033200
|
||||
**/
|
||||
* @desc 数据集动态参数 controller
|
||||
* @website https://gitee.com/anji-plus/gaea
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:12:33.108033200
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "数据集动态参数管理")
|
||||
@RequestMapping("/dataSetParam")
|
||||
public class DataSetParamController extends GaeaBaseController<DataSetParamParam, DataSetParam, DataSetParamDto> {
|
||||
|
||||
@Autowired
|
||||
private DataSetParamService dataSetParamService;
|
||||
@Autowired
|
||||
private DataSetParamService dataSetParamService;
|
||||
|
||||
@Override
|
||||
public GaeaBaseService<DataSetParamParam, DataSetParam> getService() {
|
||||
return dataSetParamService;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseService<DataSetParamParam, DataSetParam> getService() {
|
||||
return dataSetParamService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSetParam getEntity() {
|
||||
return new DataSetParam();
|
||||
}
|
||||
@Override
|
||||
public DataSetParam getEntity() {
|
||||
return new DataSetParam();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSetParamDto getDTO() {
|
||||
return new DataSetParamDto();
|
||||
}
|
||||
@Override
|
||||
public DataSetParamDto getDTO() {
|
||||
return new DataSetParamDto();
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 查询参数是否正确
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/verification")
|
||||
public ResponseBean verification(@Validated @RequestBody DataSetParamValidationParam param) {
|
||||
DataSetParamDto dto = new DataSetParamDto();
|
||||
dto.setSampleItem(param.getSampleItem());
|
||||
dto.setValidationRules(param.getValidationRules());
|
||||
return responseSuccessWithData(dataSetParamService.verification(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 查询参数是否正确
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/verification")
|
||||
public ResponseBean verification(@Validated @RequestBody DataSetParamValidationParam param) {
|
||||
DataSetParamDto dto = new DataSetParamDto();
|
||||
dto.setSampleItem(param.getSampleItem());
|
||||
dto.setValidationRules(param.getValidationRules());
|
||||
return responseSuccessWithData(dataSetParamService.verification(dto));
|
||||
}
|
||||
}
|
||||
+25
-26
@@ -6,43 +6,42 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 数据集动态参数 dto
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:12:33.108033200
|
||||
**/
|
||||
* @description 数据集动态参数 dto
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:12:33.108033200
|
||||
**/
|
||||
@Data
|
||||
public class DataSetParamDto extends GaeaBaseDTO implements Serializable {
|
||||
/** 数据集编码 */
|
||||
private String setCode;
|
||||
|
||||
/** 参数名 */
|
||||
private String paramName;
|
||||
/** 数据集编码 */
|
||||
private String setCode;
|
||||
|
||||
/** 参数描述 */
|
||||
private String paramDesc;
|
||||
/** 参数名 */
|
||||
private String paramName;
|
||||
|
||||
/** 参数类型,字典= */
|
||||
private String paramType;
|
||||
/** 参数描述 */
|
||||
private String paramDesc;
|
||||
|
||||
/** 参数示例项 */
|
||||
private String sampleItem;
|
||||
/** 参数类型,字典= */
|
||||
private String paramType;
|
||||
|
||||
/** 0--非必填 1--必填 DIC_NAME=REQUIRED_FLAG */
|
||||
private Integer requiredFlag;
|
||||
/** 参数示例项 */
|
||||
private String sampleItem;
|
||||
|
||||
/** js校验字段值规则,满足校验返回 true */
|
||||
private String validationRules;
|
||||
/** 0--非必填 1--必填 DIC_NAME=REQUIRED_FLAG */
|
||||
private Integer requiredFlag;
|
||||
|
||||
/** 排序 */
|
||||
private Integer orderNum;
|
||||
/** js校验字段值规则,满足校验返回 true */
|
||||
private String validationRules;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
/** 排序 */
|
||||
private Integer orderNum;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */
|
||||
private Integer deleteFlag;
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */
|
||||
private Integer deleteFlag;
|
||||
|
||||
}
|
||||
+6
-6
@@ -6,12 +6,12 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* @desc DataSetParam 数据集动态参数查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:12:33.108033200
|
||||
**/
|
||||
* @desc DataSetParam 数据集动态参数查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:12:33.108033200
|
||||
**/
|
||||
@Data
|
||||
public class DataSetParamParam extends PageParam implements Serializable{
|
||||
public class DataSetParamParam extends PageParam implements Serializable {
|
||||
|
||||
}
|
||||
+6
-6
@@ -11,12 +11,12 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class DataSetParamValidationParam implements Serializable {
|
||||
|
||||
/** 参数示例项 */
|
||||
@NotBlank(message = "sampleItem not empty")
|
||||
private String sampleItem;
|
||||
/** 参数示例项 */
|
||||
@NotBlank(message = "sampleItem not empty")
|
||||
private String sampleItem;
|
||||
|
||||
/** js校验字段值规则,满足校验返回 true */
|
||||
@NotBlank(message = "validationRules not empty")
|
||||
private String validationRules;
|
||||
|
||||
/** js校验字段值规则,满足校验返回 true */
|
||||
@NotBlank(message = "validationRules not empty")
|
||||
private String validationRules;
|
||||
}
|
||||
+5
-4
@@ -5,10 +5,11 @@ import com.anjiplus.template.gaea.business.modules.datasetparam.dao.entity.DataS
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* DataSetParam Mapper
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:12:33.108033200
|
||||
**/
|
||||
* DataSetParam Mapper
|
||||
*
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:12:33.108033200
|
||||
**/
|
||||
@Mapper
|
||||
public interface DataSetParamMapper extends GaeaBaseMapper<DataSetParam> {
|
||||
|
||||
|
||||
+25
-25
@@ -7,42 +7,42 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description 数据集动态参数 entity
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:12:33.108033200
|
||||
**/
|
||||
@TableName(keepGlobalPrefix=true, value="gaea_report_data_set_param")
|
||||
* @description 数据集动态参数 entity
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:12:33.108033200
|
||||
**/
|
||||
@TableName(keepGlobalPrefix = true, value = "gaea_report_data_set_param")
|
||||
@Data
|
||||
public class DataSetParam extends GaeaBaseEntity {
|
||||
@ApiModelProperty(value = "数据集编码")
|
||||
private String setCode;
|
||||
|
||||
@ApiModelProperty(value = "参数名")
|
||||
private String paramName;
|
||||
@ApiModelProperty(value = "数据集编码")
|
||||
private String setCode;
|
||||
|
||||
@ApiModelProperty(value = "参数描述")
|
||||
private String paramDesc;
|
||||
@ApiModelProperty(value = "参数名")
|
||||
private String paramName;
|
||||
|
||||
@ApiModelProperty(value = "参数类型,字典=")
|
||||
private String paramType;
|
||||
@ApiModelProperty(value = "参数描述")
|
||||
private String paramDesc;
|
||||
|
||||
@ApiModelProperty(value = "参数示例项")
|
||||
private String sampleItem;
|
||||
@ApiModelProperty(value = "参数类型,字典=")
|
||||
private String paramType;
|
||||
|
||||
@ApiModelProperty(value = "0--非必填 1--必填 DIC_NAME=REQUIRED_FLAG")
|
||||
private Integer requiredFlag;
|
||||
@ApiModelProperty(value = "参数示例项")
|
||||
private String sampleItem;
|
||||
|
||||
@ApiModelProperty(value = "js校验字段值规则,满足校验返回 true")
|
||||
private String validationRules;
|
||||
@ApiModelProperty(value = "0--非必填 1--必填 DIC_NAME=REQUIRED_FLAG")
|
||||
private Integer requiredFlag;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer orderNum;
|
||||
@ApiModelProperty(value = "js校验字段值规则,满足校验返回 true")
|
||||
private String validationRules;
|
||||
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
private Integer enableFlag;
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer orderNum;
|
||||
|
||||
@ApiModelProperty(value = "0--未删除 1--已删除 DIC_NAME=DELETE_FLAG")
|
||||
private Integer deleteFlag;
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
private Integer enableFlag;
|
||||
|
||||
@ApiModelProperty(value = "0--未删除 1--已删除 DIC_NAME=DELETE_FLAG")
|
||||
private Integer deleteFlag;
|
||||
|
||||
}
|
||||
+27
-29
@@ -16,36 +16,34 @@ import java.util.Map;
|
||||
**/
|
||||
public interface DataSetParamService extends GaeaBaseService<DataSetParamParam, DataSetParam> {
|
||||
|
||||
/**
|
||||
* 参数替换
|
||||
*
|
||||
* @param contextData
|
||||
* @param dynSentence
|
||||
* @return
|
||||
*/
|
||||
String transform(Map<String, Object> contextData, String dynSentence);
|
||||
/**
|
||||
* 参数替换
|
||||
* @param contextData
|
||||
* @param dynSentence
|
||||
* @return
|
||||
*/
|
||||
String transform(Map<String, Object> contextData, String dynSentence);
|
||||
|
||||
/**
|
||||
* 参数替换
|
||||
*
|
||||
* @param dataSetParamDtoList
|
||||
* @param dynSentence
|
||||
* @return
|
||||
*/
|
||||
String transform(List<DataSetParamDto> dataSetParamDtoList, String dynSentence);
|
||||
/**
|
||||
* 参数替换
|
||||
* @param dataSetParamDtoList
|
||||
* @param dynSentence
|
||||
* @return
|
||||
*/
|
||||
String transform(List<DataSetParamDto> dataSetParamDtoList, String dynSentence);
|
||||
|
||||
/**
|
||||
* 参数校验 js脚本
|
||||
* @param dataSetParamDto
|
||||
* @return
|
||||
*/
|
||||
Object verification(DataSetParamDto dataSetParamDto);
|
||||
/**
|
||||
* 参数校验 js脚本
|
||||
* @param dataSetParamDto
|
||||
* @return
|
||||
*/
|
||||
Object verification(DataSetParamDto dataSetParamDto);
|
||||
|
||||
/**
|
||||
* 参数校验 js脚本
|
||||
* @param dataSetParamDtoList
|
||||
* @return
|
||||
*/
|
||||
boolean verification(List<DataSetParamDto> dataSetParamDtoList, Map<String, Object> contextData);
|
||||
|
||||
/**
|
||||
* 参数校验 js脚本
|
||||
*
|
||||
* @param dataSetParamDtoList
|
||||
* @return
|
||||
*/
|
||||
boolean verification(List<DataSetParamDto> dataSetParamDtoList, Map<String, Object> contextData);
|
||||
}
|
||||
+114
-114
@@ -3,12 +3,12 @@ package com.anjiplus.template.gaea.business.modules.datasetparam.service.impl;
|
||||
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anji.plus.gaea.exception.BusinessExceptionBuilder;
|
||||
import com.anjiplus.template.gaea.business.code.ResponseCode;
|
||||
import com.anjiplus.template.gaea.business.modules.datasetparam.controller.dto.DataSetParamDto;
|
||||
import com.anjiplus.template.gaea.business.modules.datasetparam.dao.DataSetParamMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.datasetparam.dao.entity.DataSetParam;
|
||||
import com.anjiplus.template.gaea.business.modules.datasetparam.service.DataSetParamService;
|
||||
import com.anjiplus.template.gaea.business.modules.datasetparam.util.ParamsResolverHelper;
|
||||
import com.anjiplus.template.gaea.business.code.ResponseCode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -23,135 +23,135 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @desc DataSetParam 数据集动态参数服务实现
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:12:33.108033200
|
||||
**/
|
||||
* @desc DataSetParam 数据集动态参数服务实现
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:12:33.108033200
|
||||
**/
|
||||
@Service
|
||||
//@RequiredArgsConstructor
|
||||
// @RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DataSetParamServiceImpl implements DataSetParamService {
|
||||
|
||||
private ScriptEngine engine;
|
||||
{
|
||||
ScriptEngineManager manager = new ScriptEngineManager();
|
||||
engine = manager.getEngineByName("JavaScript");
|
||||
}
|
||||
private ScriptEngine engine;
|
||||
|
||||
@Autowired
|
||||
private DataSetParamMapper dataSetParamMapper;
|
||||
{
|
||||
ScriptEngineManager manager = new ScriptEngineManager();
|
||||
engine = manager.getEngineByName("JavaScript");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GaeaBaseMapper<DataSetParam> getMapper() {
|
||||
return dataSetParamMapper;
|
||||
}
|
||||
@Autowired
|
||||
private DataSetParamMapper dataSetParamMapper;
|
||||
|
||||
/**
|
||||
* 参数替换
|
||||
*
|
||||
* @param contextData
|
||||
* @param dynSentence
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String transform(Map<String, Object> contextData, String dynSentence) {
|
||||
if (StringUtils.isBlank(dynSentence)) {
|
||||
return dynSentence;
|
||||
}
|
||||
if (dynSentence.contains("${")) {
|
||||
dynSentence = ParamsResolverHelper.resolveParams(contextData, dynSentence);
|
||||
}
|
||||
if (dynSentence.contains("${")) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.INCOMPLETE_PARAMETER_REPLACEMENT_VALUES, dynSentence);
|
||||
}
|
||||
return dynSentence;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseMapper<DataSetParam> getMapper() {
|
||||
return dataSetParamMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数替换
|
||||
*
|
||||
* @param dataSetParamDtoList
|
||||
* @param dynSentence
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String transform(List<DataSetParamDto> dataSetParamDtoList, String dynSentence) {
|
||||
Map<String, Object> contextData = new HashMap<>();
|
||||
if (null == dataSetParamDtoList || dataSetParamDtoList.size() <= 0) {
|
||||
return dynSentence;
|
||||
}
|
||||
dataSetParamDtoList.forEach(dataSetParamDto -> {
|
||||
contextData.put(dataSetParamDto.getParamName(), dataSetParamDto.getSampleItem());
|
||||
});
|
||||
return transform(contextData, dynSentence);
|
||||
}
|
||||
/**
|
||||
* 参数替换
|
||||
* @param contextData
|
||||
* @param dynSentence
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String transform(Map<String, Object> contextData, String dynSentence) {
|
||||
if (StringUtils.isBlank(dynSentence)) {
|
||||
return dynSentence;
|
||||
}
|
||||
if (dynSentence.contains("${")) {
|
||||
dynSentence = ParamsResolverHelper.resolveParams(contextData, dynSentence);
|
||||
}
|
||||
if (dynSentence.contains("${")) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.INCOMPLETE_PARAMETER_REPLACEMENT_VALUES, dynSentence);
|
||||
}
|
||||
return dynSentence;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验 js脚本
|
||||
*
|
||||
* @param dataSetParamDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object verification(DataSetParamDto dataSetParamDto) {
|
||||
/**
|
||||
* 参数替换
|
||||
* @param dataSetParamDtoList
|
||||
* @param dynSentence
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String transform(List<DataSetParamDto> dataSetParamDtoList, String dynSentence) {
|
||||
Map<String, Object> contextData = new HashMap<>();
|
||||
if (null == dataSetParamDtoList || dataSetParamDtoList.size() <= 0) {
|
||||
return dynSentence;
|
||||
}
|
||||
dataSetParamDtoList.forEach(dataSetParamDto -> {
|
||||
contextData.put(dataSetParamDto.getParamName(), dataSetParamDto.getSampleItem());
|
||||
});
|
||||
return transform(contextData, dynSentence);
|
||||
}
|
||||
|
||||
String validationRules = dataSetParamDto.getValidationRules();
|
||||
if (StringUtils.isNotBlank(validationRules)) {
|
||||
try {
|
||||
engine.eval(validationRules);
|
||||
if(engine instanceof Invocable){
|
||||
Invocable invocable = (Invocable) engine;
|
||||
Object exec = invocable.invokeFunction("verification", dataSetParamDto);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
if (exec instanceof Boolean) {
|
||||
return objectMapper.convertValue(exec, Boolean.class);
|
||||
}else {
|
||||
return objectMapper.convertValue(exec, String.class);
|
||||
}
|
||||
/**
|
||||
* 参数校验 js脚本
|
||||
* @param dataSetParamDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object verification(DataSetParamDto dataSetParamDto) {
|
||||
|
||||
}
|
||||
String validationRules = dataSetParamDto.getValidationRules();
|
||||
if (StringUtils.isNotBlank(validationRules)) {
|
||||
try {
|
||||
engine.eval(validationRules);
|
||||
if (engine instanceof Invocable) {
|
||||
Invocable invocable = (Invocable) engine;
|
||||
Object exec = invocable.invokeFunction("verification", dataSetParamDto);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
if (exec instanceof Boolean) {
|
||||
return objectMapper.convertValue(exec, Boolean.class);
|
||||
}
|
||||
else {
|
||||
return objectMapper.convertValue(exec, String.class);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_JS_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_JS_ERROR, ex.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验 js脚本
|
||||
*
|
||||
* @param dataSetParamDtoList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean verification(List<DataSetParamDto> dataSetParamDtoList, Map<String, Object> contextData) {
|
||||
if (null == dataSetParamDtoList || dataSetParamDtoList.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
for (DataSetParamDto dataSetParamDto : dataSetParamDtoList) {
|
||||
if (null != contextData) {
|
||||
String value = contextData.getOrDefault(dataSetParamDto.getParamName(), "").toString();
|
||||
dataSetParamDto.setSampleItem(value);
|
||||
}
|
||||
/**
|
||||
* 参数校验 js脚本
|
||||
* @param dataSetParamDtoList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean verification(List<DataSetParamDto> dataSetParamDtoList, Map<String, Object> contextData) {
|
||||
if (null == dataSetParamDtoList || dataSetParamDtoList.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Object verification = verification(dataSetParamDto);
|
||||
if (verification instanceof Boolean) {
|
||||
if (!(Boolean) verification) {
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
//将得到的值重新赋值给contextData
|
||||
if (null != contextData) {
|
||||
contextData.put(dataSetParamDto.getParamName(), verification);
|
||||
}
|
||||
dataSetParamDto.setSampleItem(verification.toString());
|
||||
}
|
||||
for (DataSetParamDto dataSetParamDto : dataSetParamDtoList) {
|
||||
if (null != contextData) {
|
||||
String value = contextData.getOrDefault(dataSetParamDto.getParamName(), "").toString();
|
||||
dataSetParamDto.setSampleItem(value);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Object verification = verification(dataSetParamDto);
|
||||
if (verification instanceof Boolean) {
|
||||
if (!(Boolean) verification) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 将得到的值重新赋值给contextData
|
||||
if (null != contextData) {
|
||||
contextData.put(dataSetParamDto.getParamName(), verification);
|
||||
}
|
||||
dataSetParamDto.setSampleItem(verification.toString());
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+20
-17
@@ -12,25 +12,28 @@ import java.util.regex.Pattern;
|
||||
* Created by raodeming on 2021/3/23.
|
||||
*/
|
||||
public class ParamsResolverHelper {
|
||||
private static String placeholderPrefix = "${";
|
||||
private static String placeholderSuffix = "}";
|
||||
private static PropertyPlaceholderHelper helper =
|
||||
new PropertyPlaceholderHelper(placeholderPrefix, placeholderSuffix);
|
||||
|
||||
public static String resolveParams(final Map<String, Object> param, String con) {
|
||||
con = helper.replacePlaceholders(con, (key -> param.get(key) + ""));
|
||||
return con;
|
||||
}
|
||||
private static String placeholderPrefix = "${";
|
||||
|
||||
private static Pattern key = Pattern.compile("\\$\\{(.*?)\\}");
|
||||
private static String placeholderSuffix = "}";
|
||||
|
||||
public static List<String> findParamKeys(String con) {
|
||||
Matcher m = key.matcher(con);
|
||||
List ret = new ArrayList();
|
||||
while (m.find()) {
|
||||
ret.add(m.group(1));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
private static PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper(placeholderPrefix,
|
||||
placeholderSuffix);
|
||||
|
||||
public static String resolveParams(final Map<String, Object> param, String con) {
|
||||
con = helper.replacePlaceholders(con, (key -> param.get(key) + ""));
|
||||
return con;
|
||||
}
|
||||
|
||||
private static Pattern key = Pattern.compile("\\$\\{(.*?)\\}");
|
||||
|
||||
public static List<String> findParamKeys(String con) {
|
||||
Matcher m = key.matcher(con);
|
||||
List ret = new ArrayList();
|
||||
while (m.find()) {
|
||||
ret.add(m.group(1));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
+21
-20
@@ -13,32 +13,33 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @desc 数据集数据转换 controller
|
||||
* @website https://gitee.com/anji-plus/gaea
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
* @desc 数据集数据转换 controller
|
||||
* @website https://gitee.com/anji-plus/gaea
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "数据集数据转换管理")
|
||||
@RequestMapping("/dataSetTransform")
|
||||
public class DataSetTransformController extends GaeaBaseController<DataSetTransformParam, DataSetTransform, DataSetTransformDto> {
|
||||
public class DataSetTransformController
|
||||
extends GaeaBaseController<DataSetTransformParam, DataSetTransform, DataSetTransformDto> {
|
||||
|
||||
@Autowired
|
||||
private DataSetTransformService dataSetTransformService;
|
||||
@Autowired
|
||||
private DataSetTransformService dataSetTransformService;
|
||||
|
||||
@Override
|
||||
public GaeaBaseService<DataSetTransformParam, DataSetTransform> getService() {
|
||||
return dataSetTransformService;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseService<DataSetTransformParam, DataSetTransform> getService() {
|
||||
return dataSetTransformService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSetTransform getEntity() {
|
||||
return new DataSetTransform();
|
||||
}
|
||||
@Override
|
||||
public DataSetTransform getEntity() {
|
||||
return new DataSetTransform();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSetTransformDto getDTO() {
|
||||
return new DataSetTransformDto();
|
||||
}
|
||||
@Override
|
||||
public DataSetTransformDto getDTO() {
|
||||
return new DataSetTransformDto();
|
||||
}
|
||||
|
||||
}
|
||||
+17
-18
@@ -6,31 +6,30 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 数据集数据转换 dto
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
* @description 数据集数据转换 dto
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
@Data
|
||||
public class DataSetTransformDto extends GaeaBaseDTO implements Serializable {
|
||||
/** 数据集编码 */
|
||||
private String setCode;
|
||||
|
||||
/** 数据转换类型,DIC_NAME=TRANSFORM_TYPE; js,javaBean,字典转换 */
|
||||
private String transformType;
|
||||
/** 数据集编码 */
|
||||
private String setCode;
|
||||
|
||||
/** 数据转换script,处理逻辑 */
|
||||
private String transformScript;
|
||||
/** 数据转换类型,DIC_NAME=TRANSFORM_TYPE; js,javaBean,字典转换 */
|
||||
private String transformType;
|
||||
|
||||
/** 排序,执行数据转换顺序 */
|
||||
private Integer orderNum;
|
||||
/** 数据转换script,处理逻辑 */
|
||||
private String transformScript;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
/** 排序,执行数据转换顺序 */
|
||||
private Integer orderNum;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */
|
||||
private Integer deleteFlag;
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */
|
||||
private Integer deleteFlag;
|
||||
|
||||
}
|
||||
+6
-6
@@ -6,12 +6,12 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* @desc DataSetTransform 数据集数据转换查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
* @desc DataSetTransform 数据集数据转换查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
@Data
|
||||
public class DataSetTransformParam extends PageParam implements Serializable{
|
||||
public class DataSetTransformParam extends PageParam implements Serializable {
|
||||
|
||||
}
|
||||
+5
-4
@@ -5,10 +5,11 @@ import com.anjiplus.template.gaea.business.modules.datasettransform.dao.entity.D
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* DataSetTransform Mapper
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
* DataSetTransform Mapper
|
||||
*
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
@Mapper
|
||||
public interface DataSetTransformMapper extends GaeaBaseMapper<DataSetTransform> {
|
||||
|
||||
|
||||
+17
-17
@@ -7,30 +7,30 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description 数据集数据转换 entity
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
@TableName(keepGlobalPrefix=true, value="gaea_report_data_set_transform")
|
||||
* @description 数据集数据转换 entity
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
@TableName(keepGlobalPrefix = true, value = "gaea_report_data_set_transform")
|
||||
@Data
|
||||
public class DataSetTransform extends GaeaBaseEntity {
|
||||
@ApiModelProperty(value = "数据集编码")
|
||||
private String setCode;
|
||||
|
||||
@ApiModelProperty(value = "数据转换类型,DIC_NAME=TRANSFORM_TYPE; js,javaBean,字典转换")
|
||||
private String transformType;
|
||||
@ApiModelProperty(value = "数据集编码")
|
||||
private String setCode;
|
||||
|
||||
@ApiModelProperty(value = "数据转换script,处理逻辑")
|
||||
private String transformScript;
|
||||
@ApiModelProperty(value = "数据转换类型,DIC_NAME=TRANSFORM_TYPE; js,javaBean,字典转换")
|
||||
private String transformType;
|
||||
|
||||
@ApiModelProperty(value = "排序,执行数据转换顺序")
|
||||
private Integer orderNum;
|
||||
@ApiModelProperty(value = "数据转换script,处理逻辑")
|
||||
private String transformScript;
|
||||
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
private Integer enableFlag;
|
||||
@ApiModelProperty(value = "排序,执行数据转换顺序")
|
||||
private Integer orderNum;
|
||||
|
||||
@ApiModelProperty(value = "0--未删除 1--已删除 DIC_NAME=DELETE_FLAG")
|
||||
private Integer deleteFlag;
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
private Integer enableFlag;
|
||||
|
||||
@ApiModelProperty(value = "0--未删除 1--已删除 DIC_NAME=DELETE_FLAG")
|
||||
private Integer deleteFlag;
|
||||
|
||||
}
|
||||
+5
-5
@@ -10,12 +10,12 @@ import com.anjiplus.template.gaea.business.modules.datasettransform.dao.entity.D
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @desc DataSetTransform 数据集数据转换服务接口
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
* @desc DataSetTransform 数据集数据转换服务接口
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
public interface DataSetTransformService extends GaeaBaseService<DataSetTransformParam, DataSetTransform> {
|
||||
|
||||
List<JSONObject> transform(List<DataSetTransformDto> dataSetTransformDtoList, List<JSONObject> data);
|
||||
List<JSONObject> transform(List<DataSetTransformDto> dataSetTransformDtoList, List<JSONObject> data);
|
||||
|
||||
}
|
||||
+14
-12
@@ -9,17 +9,19 @@ import java.util.List;
|
||||
* Created by raodeming on 2021/3/23.
|
||||
*/
|
||||
public interface TransformStrategy {
|
||||
/**
|
||||
* 数据清洗转换 类型
|
||||
* @return
|
||||
*/
|
||||
String type();
|
||||
|
||||
/***
|
||||
* 清洗转换算法接口
|
||||
* @param def
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
List<JSONObject> transform(DataSetTransformDto def, List<JSONObject> data);
|
||||
/**
|
||||
* 数据清洗转换 类型
|
||||
* @return
|
||||
*/
|
||||
String type();
|
||||
|
||||
/***
|
||||
* 清洗转换算法接口
|
||||
* @param def
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
List<JSONObject> transform(DataSetTransformDto def, List<JSONObject> data);
|
||||
|
||||
}
|
||||
+40
-38
@@ -20,52 +20,54 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @desc DataSetTransform 数据集数据转换服务实现
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
* @desc DataSetTransform 数据集数据转换服务实现
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:13:15.591309400
|
||||
**/
|
||||
@Service
|
||||
//@RequiredArgsConstructor
|
||||
// @RequiredArgsConstructor
|
||||
public class DataSetTransformServiceImpl implements DataSetTransformService, InitializingBean, ApplicationContextAware {
|
||||
|
||||
private final Map<String, TransformStrategy> queryServiceImplMap = new HashMap<>();
|
||||
private ApplicationContext applicationContext;
|
||||
private final Map<String, TransformStrategy> queryServiceImplMap = new HashMap<>();
|
||||
|
||||
@Autowired
|
||||
private DataSetTransformMapper dataSetTransformMapper;
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public GaeaBaseMapper<DataSetTransform> getMapper() {
|
||||
return dataSetTransformMapper;
|
||||
}
|
||||
@Autowired
|
||||
private DataSetTransformMapper dataSetTransformMapper;
|
||||
|
||||
public TransformStrategy getTarget(String type) {
|
||||
return queryServiceImplMap.get(type);
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseMapper<DataSetTransform> getMapper() {
|
||||
return dataSetTransformMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Map<String, TransformStrategy> beanMap = applicationContext.getBeansOfType(TransformStrategy.class);
|
||||
//遍历该接口的所有实现,将其放入map中
|
||||
for (TransformStrategy serviceImpl : beanMap.values()) {
|
||||
queryServiceImplMap.put(serviceImpl.type(), serviceImpl);
|
||||
}
|
||||
}
|
||||
public TransformStrategy getTarget(String type) {
|
||||
return queryServiceImplMap.get(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Map<String, TransformStrategy> beanMap = applicationContext.getBeansOfType(TransformStrategy.class);
|
||||
// 遍历该接口的所有实现,将其放入map中
|
||||
for (TransformStrategy serviceImpl : beanMap.values()) {
|
||||
queryServiceImplMap.put(serviceImpl.type(), serviceImpl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> transform(List<DataSetTransformDto> dataSetTransformDtoList, List<JSONObject> data) {
|
||||
if (dataSetTransformDtoList == null || dataSetTransformDtoList.size() <= 0) {
|
||||
return data;
|
||||
}
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> transform(List<DataSetTransformDto> dataSetTransformDtoList, List<JSONObject> data) {
|
||||
if (dataSetTransformDtoList == null || dataSetTransformDtoList.size() <= 0) {
|
||||
return data;
|
||||
}
|
||||
|
||||
for (DataSetTransformDto dataSetTransformDto : dataSetTransformDtoList) {
|
||||
data = getTarget(dataSetTransformDto.getTransformType()).transform(dataSetTransformDto, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
for (DataSetTransformDto dataSetTransformDto : dataSetTransformDtoList) {
|
||||
data = getTarget(dataSetTransformDto.getTransformType()).transform(dataSetTransformDto, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
+34
-35
@@ -11,46 +11,45 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 字典转换
|
||||
* Created by raodeming on 2021/3/29.
|
||||
* 字典转换 Created by raodeming on 2021/3/29.
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DictTransformServiceImpl implements TransformStrategy {
|
||||
|
||||
/**
|
||||
* 数据清洗转换 类型
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return "dict";
|
||||
}
|
||||
/**
|
||||
* 数据清洗转换 类型
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return "dict";
|
||||
}
|
||||
|
||||
/***
|
||||
* 清洗转换算法接口
|
||||
* @param def
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<JSONObject> transform(DataSetTransformDto def, List<JSONObject> data) {
|
||||
String transformScript = def.getTransformScript();
|
||||
if (StringUtils.isBlank(transformScript)) {
|
||||
return data;
|
||||
}
|
||||
JSONObject jsonObject = JSONObject.parseObject(transformScript);
|
||||
Set<String> keys = jsonObject.keySet();
|
||||
/***
|
||||
* 清洗转换算法接口
|
||||
* @param def
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<JSONObject> transform(DataSetTransformDto def, List<JSONObject> data) {
|
||||
String transformScript = def.getTransformScript();
|
||||
if (StringUtils.isBlank(transformScript)) {
|
||||
return data;
|
||||
}
|
||||
JSONObject jsonObject = JSONObject.parseObject(transformScript);
|
||||
Set<String> keys = jsonObject.keySet();
|
||||
|
||||
data.forEach(dataDetail -> dataDetail.forEach((key, value) -> {
|
||||
if (keys.contains(key)) {
|
||||
String string = jsonObject.getJSONObject(key).getString(value.toString());
|
||||
if (StringUtils.isNotBlank(string)) {
|
||||
dataDetail.put(key, string);
|
||||
}
|
||||
}
|
||||
}));
|
||||
return data;
|
||||
}
|
||||
|
||||
data.forEach(dataDetail -> dataDetail.forEach((key, value) -> {
|
||||
if (keys.contains(key)) {
|
||||
String string = jsonObject.getJSONObject(key).getString(value.toString());
|
||||
if (StringUtils.isNotBlank(string)) {
|
||||
dataDetail.put(key, string);
|
||||
}
|
||||
}
|
||||
}));
|
||||
return data;
|
||||
}
|
||||
}
|
||||
+39
-38
@@ -5,7 +5,6 @@ import com.anji.plus.gaea.exception.BusinessExceptionBuilder;
|
||||
import com.anjiplus.template.gaea.business.code.ResponseCode;
|
||||
import com.anjiplus.template.gaea.business.modules.datasettransform.controller.dto.DataSetTransformDto;
|
||||
import com.anjiplus.template.gaea.business.modules.datasettransform.service.TransformStrategy;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -21,45 +20,47 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class JsTransformServiceImpl implements TransformStrategy {
|
||||
|
||||
private ScriptEngine engine;
|
||||
{
|
||||
ScriptEngineManager manager = new ScriptEngineManager();
|
||||
engine = manager.getEngineByName("JavaScript");
|
||||
}
|
||||
private ScriptEngine engine;
|
||||
|
||||
/**
|
||||
* 数据清洗转换 类型
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return "js";
|
||||
}
|
||||
{
|
||||
ScriptEngineManager manager = new ScriptEngineManager();
|
||||
engine = manager.getEngineByName("JavaScript");
|
||||
}
|
||||
|
||||
/***
|
||||
* 清洗转换算法接口
|
||||
* @param def
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<JSONObject> transform(DataSetTransformDto def, List<JSONObject> data) {
|
||||
return getValueFromJs(def,data);
|
||||
}
|
||||
/**
|
||||
* 数据清洗转换 类型
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return "js";
|
||||
}
|
||||
|
||||
private List<JSONObject> getValueFromJs(DataSetTransformDto def, List<JSONObject> data) {
|
||||
String js = def.getTransformScript();
|
||||
try {
|
||||
engine.eval(js);
|
||||
if(engine instanceof Invocable){
|
||||
Invocable invocable = (Invocable) engine;
|
||||
return (List<JSONObject>) invocable.invokeFunction("dataTransform", data);
|
||||
}
|
||||
/***
|
||||
* 清洗转换算法接口
|
||||
* @param def
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<JSONObject> transform(DataSetTransformDto def, List<JSONObject> data) {
|
||||
return getValueFromJs(def, data);
|
||||
}
|
||||
|
||||
private List<JSONObject> getValueFromJs(DataSetTransformDto def, List<JSONObject> data) {
|
||||
String js = def.getTransformScript();
|
||||
try {
|
||||
engine.eval(js);
|
||||
if (engine instanceof Invocable) {
|
||||
Invocable invocable = (Invocable) engine;
|
||||
return (List<JSONObject>) invocable.invokeFunction("dataTransform", data);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_JS_ERROR, ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_JS_ERROR, ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+149
-149
@@ -47,168 +47,168 @@ import java.util.*;
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class HttpClientConfig {
|
||||
@Autowired
|
||||
private HttpClientPoolConfig httpClientPoolConfig;
|
||||
|
||||
/**
|
||||
* 创建HTTP客户端工厂
|
||||
*/
|
||||
@Bean(name = "clientHttpRequestFactory")
|
||||
public ClientHttpRequestFactory clientHttpRequestFactory() {
|
||||
/**
|
||||
* maxTotalConnection 和 maxConnectionPerRoute 必须要配
|
||||
*/
|
||||
if (httpClientPoolConfig.getMaxTotalConnect() <= 0) {
|
||||
throw new IllegalArgumentException("invalid maxTotalConnection: " + httpClientPoolConfig.getMaxTotalConnect());
|
||||
}
|
||||
if (httpClientPoolConfig.getMaxConnectPerRoute() <= 0) {
|
||||
throw new IllegalArgumentException("invalid maxConnectionPerRoute: " + httpClientPoolConfig.getMaxConnectPerRoute());
|
||||
}
|
||||
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient());
|
||||
// 连接超时
|
||||
clientHttpRequestFactory.setConnectTimeout(httpClientPoolConfig.getConnectTimeout());
|
||||
// 数据读取超时时间,即SocketTimeout
|
||||
clientHttpRequestFactory.setReadTimeout(httpClientPoolConfig.getReadTimeout());
|
||||
// 从连接池获取请求连接的超时时间,不宜过长,必须设置,比如连接不够用时,时间过长将是灾难性的
|
||||
clientHttpRequestFactory.setConnectionRequestTimeout(httpClientPoolConfig.getConnectionRequestTimout());
|
||||
return clientHttpRequestFactory;
|
||||
}
|
||||
@Autowired
|
||||
private HttpClientPoolConfig httpClientPoolConfig;
|
||||
|
||||
/**
|
||||
* 初始化RestTemplate,并加入spring的Bean工厂,由spring统一管理
|
||||
*/
|
||||
@Bean(name = "dataSourceRestTemplate")
|
||||
public RestTemplate restTemplate(@Qualifier("clientHttpRequestFactory") ClientHttpRequestFactory factory) {
|
||||
return createRestTemplate(factory);
|
||||
}
|
||||
/**
|
||||
* 创建HTTP客户端工厂
|
||||
*/
|
||||
@Bean(name = "clientHttpRequestFactory")
|
||||
public ClientHttpRequestFactory clientHttpRequestFactory() {
|
||||
/**
|
||||
* maxTotalConnection 和 maxConnectionPerRoute 必须要配
|
||||
*/
|
||||
if (httpClientPoolConfig.getMaxTotalConnect() <= 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"invalid maxTotalConnection: " + httpClientPoolConfig.getMaxTotalConnect());
|
||||
}
|
||||
if (httpClientPoolConfig.getMaxConnectPerRoute() <= 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"invalid maxConnectionPerRoute: " + httpClientPoolConfig.getMaxConnectPerRoute());
|
||||
}
|
||||
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(
|
||||
httpClient());
|
||||
// 连接超时
|
||||
clientHttpRequestFactory.setConnectTimeout(httpClientPoolConfig.getConnectTimeout());
|
||||
// 数据读取超时时间,即SocketTimeout
|
||||
clientHttpRequestFactory.setReadTimeout(httpClientPoolConfig.getReadTimeout());
|
||||
// 从连接池获取请求连接的超时时间,不宜过长,必须设置,比如连接不够用时,时间过长将是灾难性的
|
||||
clientHttpRequestFactory.setConnectionRequestTimeout(httpClientPoolConfig.getConnectionRequestTimout());
|
||||
return clientHttpRequestFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置httpClient
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public HttpClient httpClient() {
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
try {
|
||||
//设置信任ssl访问
|
||||
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, (arg0, arg1) -> true).build();
|
||||
/**
|
||||
* 初始化RestTemplate,并加入spring的Bean工厂,由spring统一管理
|
||||
*/
|
||||
@Bean(name = "dataSourceRestTemplate")
|
||||
public RestTemplate restTemplate(@Qualifier("clientHttpRequestFactory") ClientHttpRequestFactory factory) {
|
||||
return createRestTemplate(factory);
|
||||
}
|
||||
|
||||
httpClientBuilder.setSSLContext(sslContext);
|
||||
HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
|
||||
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
// 注册http和https请求
|
||||
.register("http", PlainConnectionSocketFactory.getSocketFactory())
|
||||
.register("https", sslConnectionSocketFactory).build();
|
||||
/**
|
||||
* 配置httpClient
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public HttpClient httpClient() {
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
try {
|
||||
// 设置信任ssl访问
|
||||
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, (arg0, arg1) -> true).build();
|
||||
|
||||
//使用Httpclient连接池的方式配置(推荐),同时支持netty,okHttp以及其他http框架
|
||||
PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
||||
// 最大连接数
|
||||
poolingHttpClientConnectionManager.setMaxTotal(httpClientPoolConfig.getMaxTotalConnect());
|
||||
// 同路由并发数
|
||||
poolingHttpClientConnectionManager.setDefaultMaxPerRoute(httpClientPoolConfig.getMaxConnectPerRoute());
|
||||
//配置连接池
|
||||
httpClientBuilder.setConnectionManager(poolingHttpClientConnectionManager);
|
||||
// 重试次数
|
||||
httpClientBuilder.setRetryHandler(new DefaultHttpRequestRetryHandler(httpClientPoolConfig.getRetryTimes(), true));
|
||||
httpClientBuilder.setSSLContext(sslContext);
|
||||
HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
|
||||
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext,
|
||||
hostnameVerifier);
|
||||
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
// 注册http和https请求
|
||||
.register("http", PlainConnectionSocketFactory.getSocketFactory())
|
||||
.register("https", sslConnectionSocketFactory).build();
|
||||
|
||||
//设置默认请求头
|
||||
List<Header> headers = getDefaultHeaders();
|
||||
httpClientBuilder.setDefaultHeaders(headers);
|
||||
//设置长连接保持策略
|
||||
httpClientBuilder.setKeepAliveStrategy(connectionKeepAliveStrategy());
|
||||
return httpClientBuilder.build();
|
||||
} catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
|
||||
log.error("初始化HTTP连接池出错", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// 使用Httpclient连接池的方式配置(推荐),同时支持netty,okHttp以及其他http框架
|
||||
PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(
|
||||
socketFactoryRegistry);
|
||||
// 最大连接数
|
||||
poolingHttpClientConnectionManager.setMaxTotal(httpClientPoolConfig.getMaxTotalConnect());
|
||||
// 同路由并发数
|
||||
poolingHttpClientConnectionManager.setDefaultMaxPerRoute(httpClientPoolConfig.getMaxConnectPerRoute());
|
||||
// 配置连接池
|
||||
httpClientBuilder.setConnectionManager(poolingHttpClientConnectionManager);
|
||||
// 重试次数
|
||||
httpClientBuilder
|
||||
.setRetryHandler(new DefaultHttpRequestRetryHandler(httpClientPoolConfig.getRetryTimes(), true));
|
||||
|
||||
// 设置默认请求头
|
||||
List<Header> headers = getDefaultHeaders();
|
||||
httpClientBuilder.setDefaultHeaders(headers);
|
||||
// 设置长连接保持策略
|
||||
httpClientBuilder.setKeepAliveStrategy(connectionKeepAliveStrategy());
|
||||
return httpClientBuilder.build();
|
||||
}
|
||||
catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
|
||||
log.error("初始化HTTP连接池出错", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置长连接保持策略
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ConnectionKeepAliveStrategy connectionKeepAliveStrategy() {
|
||||
return (response, context) -> {
|
||||
// Honor 'keep-alive' header
|
||||
HeaderElementIterator it = new BasicHeaderElementIterator(
|
||||
response.headerIterator(HTTP.CONN_KEEP_ALIVE));
|
||||
while (it.hasNext()) {
|
||||
HeaderElement he = it.nextElement();
|
||||
log.info("HeaderElement:{}", JSON.toJSONString(he));
|
||||
String param = he.getName();
|
||||
String value = he.getValue();
|
||||
if (value != null && "timeout".equalsIgnoreCase(param)) {
|
||||
try {
|
||||
return Long.parseLong(value) * 1000;
|
||||
} catch (NumberFormatException ignore) {
|
||||
log.error("解析长连接过期时间异常", ignore);
|
||||
}
|
||||
}
|
||||
}
|
||||
HttpHost target = (HttpHost) context.getAttribute(
|
||||
HttpClientContext.HTTP_TARGET_HOST);
|
||||
//如果请求目标地址,单独配置了长连接保持时间,使用该配置
|
||||
Optional<Map.Entry<String, Integer>> any = Optional.ofNullable(httpClientPoolConfig.getKeepAliveTargetHost()).orElseGet(HashMap::new)
|
||||
.entrySet().stream().filter(
|
||||
e -> e.getKey().equalsIgnoreCase(target.getHostName())).findAny();
|
||||
//否则使用默认长连接保持时间
|
||||
return any.map(en -> en.getValue() * 1000L).orElse(httpClientPoolConfig.getKeepAliveTime() * 1000L);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 配置长连接保持策略
|
||||
* @return
|
||||
*/
|
||||
public ConnectionKeepAliveStrategy connectionKeepAliveStrategy() {
|
||||
return (response, context) -> {
|
||||
// Honor 'keep-alive' header
|
||||
HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
|
||||
while (it.hasNext()) {
|
||||
HeaderElement he = it.nextElement();
|
||||
log.info("HeaderElement:{}", JSON.toJSONString(he));
|
||||
String param = he.getName();
|
||||
String value = he.getValue();
|
||||
if (value != null && "timeout".equalsIgnoreCase(param)) {
|
||||
try {
|
||||
return Long.parseLong(value) * 1000;
|
||||
}
|
||||
catch (NumberFormatException ignore) {
|
||||
log.error("解析长连接过期时间异常", ignore);
|
||||
}
|
||||
}
|
||||
}
|
||||
HttpHost target = (HttpHost) context.getAttribute(HttpClientContext.HTTP_TARGET_HOST);
|
||||
// 如果请求目标地址,单独配置了长连接保持时间,使用该配置
|
||||
Optional<Map.Entry<String, Integer>> any = Optional
|
||||
.ofNullable(httpClientPoolConfig.getKeepAliveTargetHost()).orElseGet(HashMap::new).entrySet()
|
||||
.stream().filter(e -> e.getKey().equalsIgnoreCase(target.getHostName())).findAny();
|
||||
// 否则使用默认长连接保持时间
|
||||
return any.map(en -> en.getValue() * 1000L).orElse(httpClientPoolConfig.getKeepAliveTime() * 1000L);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求头
|
||||
* @return
|
||||
*/
|
||||
private List<Header> getDefaultHeaders() {
|
||||
List<Header> headers = new ArrayList<>();
|
||||
headers.add(new BasicHeader("User-Agent",
|
||||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36"));
|
||||
headers.add(new BasicHeader("Accept-Encoding", "gzip,deflate"));
|
||||
headers.add(new BasicHeader("Accept-Language", "zh-CN"));
|
||||
headers.add(new BasicHeader("Connection", "Keep-Alive"));
|
||||
return headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求头
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<Header> getDefaultHeaders() {
|
||||
List<Header> headers = new ArrayList<>();
|
||||
headers.add(new BasicHeader("User-Agent",
|
||||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36"));
|
||||
headers.add(new BasicHeader("Accept-Encoding", "gzip,deflate"));
|
||||
headers.add(new BasicHeader("Accept-Language", "zh-CN"));
|
||||
headers.add(new BasicHeader("Connection", "Keep-Alive"));
|
||||
return headers;
|
||||
}
|
||||
private RestTemplate createRestTemplate(ClientHttpRequestFactory factory) {
|
||||
RestTemplate restTemplate = new RestTemplate(factory);
|
||||
|
||||
// 我们采用RestTemplate内部的MessageConverter
|
||||
// 重新设置StringHttpMessageConverter字符集,解决中文乱码问题
|
||||
modifyDefaultCharset(restTemplate);
|
||||
|
||||
private RestTemplate createRestTemplate(ClientHttpRequestFactory factory) {
|
||||
RestTemplate restTemplate = new RestTemplate(factory);
|
||||
// 设置错误处理器
|
||||
restTemplate.setErrorHandler(new DefaultResponseErrorHandler());
|
||||
|
||||
//我们采用RestTemplate内部的MessageConverter
|
||||
//重新设置StringHttpMessageConverter字符集,解决中文乱码问题
|
||||
modifyDefaultCharset(restTemplate);
|
||||
return restTemplate;
|
||||
}
|
||||
|
||||
//设置错误处理器
|
||||
restTemplate.setErrorHandler(new DefaultResponseErrorHandler());
|
||||
/**
|
||||
* 修改默认的字符集类型为utf-8
|
||||
* @param restTemplate
|
||||
*/
|
||||
private void modifyDefaultCharset(RestTemplate restTemplate) {
|
||||
List<HttpMessageConverter<?>> converterList = restTemplate.getMessageConverters();
|
||||
HttpMessageConverter<?> converterTarget = null;
|
||||
for (HttpMessageConverter<?> item : converterList) {
|
||||
if (StringHttpMessageConverter.class == item.getClass()) {
|
||||
converterTarget = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (null != converterTarget) {
|
||||
converterList.remove(converterTarget);
|
||||
}
|
||||
Charset defaultCharset = Charset.forName(httpClientPoolConfig.getCharset());
|
||||
converterList.add(1, new StringHttpMessageConverter(defaultCharset));
|
||||
}
|
||||
|
||||
return restTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改默认的字符集类型为utf-8
|
||||
*
|
||||
* @param restTemplate
|
||||
*/
|
||||
private void modifyDefaultCharset(RestTemplate restTemplate) {
|
||||
List<HttpMessageConverter<?>> converterList = restTemplate.getMessageConverters();
|
||||
HttpMessageConverter<?> converterTarget = null;
|
||||
for (HttpMessageConverter<?> item : converterList) {
|
||||
if (StringHttpMessageConverter.class == item.getClass()) {
|
||||
converterTarget = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (null != converterTarget) {
|
||||
converterList.remove(converterTarget);
|
||||
}
|
||||
Charset defaultCharset = Charset.forName(httpClientPoolConfig.getCharset());
|
||||
converterList.add(1, new StringHttpMessageConverter(defaultCharset));
|
||||
}
|
||||
}
|
||||
|
||||
+45
-36
@@ -13,41 +13,50 @@ import java.util.Map;
|
||||
@ConfigurationProperties(prefix = "spring.http-client.pool")
|
||||
@Data
|
||||
public class HttpClientPoolConfig {
|
||||
/**
|
||||
* java配置的优先级低于yml配置;如果yml配置不存在,会采用java配置
|
||||
*/
|
||||
/**
|
||||
* 连接池的最大连接数
|
||||
*/
|
||||
private int maxTotalConnect = 1000;
|
||||
/**
|
||||
* 同路由的并发数
|
||||
*/
|
||||
private int maxConnectPerRoute = 200;
|
||||
/**
|
||||
* 客户端和服务器建立连接超时,默认2s
|
||||
*/
|
||||
private int connectTimeout = 2 * 1000;
|
||||
/**
|
||||
* 指客户端从服务器读取数据包的间隔超时时间,不是总读取时间,默认30s
|
||||
*/
|
||||
private int readTimeout = 30 * 1000;
|
||||
|
||||
private String charset = "UTF-8";
|
||||
/**
|
||||
* 重试次数,默认2次
|
||||
*/
|
||||
private int retryTimes = 2;
|
||||
/**
|
||||
* 从连接池获取连接的超时时间,不宜过长,单位ms
|
||||
*/
|
||||
private int connectionRequestTimout = 200;
|
||||
/**
|
||||
* 针对不同的地址,特别设置不同的长连接保持时间
|
||||
*/
|
||||
private Map<String,Integer> keepAliveTargetHost;
|
||||
/**
|
||||
* 针对不同的地址,特别设置不同的长连接保持时间,单位 s
|
||||
*/
|
||||
private int keepAliveTime = 60;
|
||||
/**
|
||||
* java配置的优先级低于yml配置;如果yml配置不存在,会采用java配置
|
||||
*/
|
||||
/**
|
||||
* 连接池的最大连接数
|
||||
*/
|
||||
private int maxTotalConnect = 1000;
|
||||
|
||||
/**
|
||||
* 同路由的并发数
|
||||
*/
|
||||
private int maxConnectPerRoute = 200;
|
||||
|
||||
/**
|
||||
* 客户端和服务器建立连接超时,默认2s
|
||||
*/
|
||||
private int connectTimeout = 2 * 1000;
|
||||
|
||||
/**
|
||||
* 指客户端从服务器读取数据包的间隔超时时间,不是总读取时间,默认30s
|
||||
*/
|
||||
private int readTimeout = 30 * 1000;
|
||||
|
||||
private String charset = "UTF-8";
|
||||
|
||||
/**
|
||||
* 重试次数,默认2次
|
||||
*/
|
||||
private int retryTimes = 2;
|
||||
|
||||
/**
|
||||
* 从连接池获取连接的超时时间,不宜过长,单位ms
|
||||
*/
|
||||
private int connectionRequestTimout = 200;
|
||||
|
||||
/**
|
||||
* 针对不同的地址,特别设置不同的长连接保持时间
|
||||
*/
|
||||
private Map<String, Integer> keepAliveTargetHost;
|
||||
|
||||
/**
|
||||
* 针对不同的地址,特别设置不同的长连接保持时间,单位 s
|
||||
*/
|
||||
private int keepAliveTime = 60;
|
||||
|
||||
}
|
||||
+37
-37
@@ -16,53 +16,53 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @desc 数据源 controller
|
||||
* @website https://gitee.com/anji-plus/gaea
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:09:57.728203200
|
||||
**/
|
||||
* @desc 数据源 controller
|
||||
* @website https://gitee.com/anji-plus/gaea
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:09:57.728203200
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "数据源管理")
|
||||
@Permission(code = "datasourceManage", name = "数据源管理")
|
||||
@RequestMapping("/dataSource")
|
||||
public class DataSourceController extends GaeaBaseController<DataSourceParam, DataSource, DataSourceDto> {
|
||||
|
||||
@Autowired
|
||||
private DataSourceService dataSourceService;
|
||||
@Autowired
|
||||
private DataSourceService dataSourceService;
|
||||
|
||||
@Override
|
||||
public GaeaBaseService<DataSourceParam, DataSource> getService() {
|
||||
return dataSourceService;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseService<DataSourceParam, DataSource> getService() {
|
||||
return dataSourceService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource getEntity() {
|
||||
return new DataSource();
|
||||
}
|
||||
@Override
|
||||
public DataSource getEntity() {
|
||||
return new DataSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceDto getDTO() {
|
||||
return new DataSourceDto();
|
||||
}
|
||||
@Override
|
||||
public DataSourceDto getDTO() {
|
||||
return new DataSourceDto();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有数据源
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryAllDataSource")
|
||||
public ResponseBean queryAllDataSource() {
|
||||
return responseSuccessWithData(dataSourceService.queryAllDataSource());
|
||||
}
|
||||
/**
|
||||
* 获取所有数据源
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryAllDataSource")
|
||||
public ResponseBean queryAllDataSource() {
|
||||
return responseSuccessWithData(dataSourceService.queryAllDataSource());
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 连接
|
||||
* @param connectionParam
|
||||
* @return
|
||||
*/
|
||||
@Permission( code = "query", name = "测试数据源")
|
||||
@PostMapping("/testConnection")
|
||||
public ResponseBean testConnection(@Validated @RequestBody ConnectionParam connectionParam) {
|
||||
return responseSuccessWithData(dataSourceService.testConnection(connectionParam));
|
||||
}
|
||||
/**
|
||||
* 测试 连接
|
||||
* @param connectionParam
|
||||
* @return
|
||||
*/
|
||||
@Permission(code = "query", name = "测试数据源")
|
||||
@PostMapping("/testConnection")
|
||||
public ResponseBean testConnection(@Validated @RequestBody ConnectionParam connectionParam) {
|
||||
return responseSuccessWithData(dataSourceService.testConnection(connectionParam));
|
||||
}
|
||||
|
||||
}
|
||||
+49
-43
@@ -7,68 +7,74 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 数据源 dto
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:09:57.728203200
|
||||
**/
|
||||
* @description 数据源 dto
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:09:57.728203200
|
||||
**/
|
||||
@Data
|
||||
public class DataSourceDto extends GaeaBaseDTO implements Serializable {
|
||||
/** 数据源编码 */
|
||||
private String sourceCode;
|
||||
|
||||
/** 数据源名称 */
|
||||
private String sourceName;
|
||||
/** 数据源编码 */
|
||||
private String sourceCode;
|
||||
|
||||
/** 数据源描述 */
|
||||
private String sourceDesc;
|
||||
/** 数据源名称 */
|
||||
private String sourceName;
|
||||
|
||||
/** 数据源类型 DIC_NAME=SOURCE_TYPE; mysql,orace,sqlserver,elasticsearch,接口,javaBean,数据源类型字典中item-extend动态生成表单 */
|
||||
private String sourceType;
|
||||
/** 数据源描述 */
|
||||
private String sourceDesc;
|
||||
|
||||
/** 数据源连接配置json:关系库{ jdbcUrl:'', username:'', password:'','driverName':''}ES-sql{ apiUrl:'http://127.0.0.1:9092/_xpack/sql?format=json','method':'POST','body':'{"query":"select 1"}' } 接口{ apiUrl:'http://ip:port/url', method:'' } javaBean{ beanNamw:'xxx' } */
|
||||
private String sourceConfig;
|
||||
/**
|
||||
* 数据源类型 DIC_NAME=SOURCE_TYPE;
|
||||
* mysql,orace,sqlserver,elasticsearch,接口,javaBean,数据源类型字典中item-extend动态生成表单
|
||||
*/
|
||||
private String sourceType;
|
||||
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
/**
|
||||
* 数据源连接配置json:关系库{ jdbcUrl:'', username:'', password:'','driverName':''}ES-sql{
|
||||
* apiUrl:'http://127.0.0.1:9092/_xpack/sql?format=json','method':'POST','body':'{"query":"select
|
||||
* 1"}' } 接口{ apiUrl:'http://ip:port/url', method:'' } javaBean{ beanNamw:'xxx' }
|
||||
*/
|
||||
private String sourceConfig;
|
||||
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */
|
||||
private Integer deleteFlag;
|
||||
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
|
||||
private Integer enableFlag;
|
||||
|
||||
/**************************************************************/
|
||||
/**关系型数据库jdbcUrl */
|
||||
private String jdbcUrl;
|
||||
/** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */
|
||||
private Integer deleteFlag;
|
||||
|
||||
/** 关系型数据库用户名 */
|
||||
private String username;
|
||||
/**************************************************************/
|
||||
/** 关系型数据库jdbcUrl */
|
||||
private String jdbcUrl;
|
||||
|
||||
/** 关系型数据库密码 */
|
||||
private String password;
|
||||
/** 关系型数据库用户名 */
|
||||
private String username;
|
||||
|
||||
/** 关系型数据库驱动类 */
|
||||
private String driverName;
|
||||
/** 关系型数据库密码 */
|
||||
private String password;
|
||||
|
||||
/** 关系型数据库sql */
|
||||
private String sql;
|
||||
/** 关系型数据库驱动类 */
|
||||
private String driverName;
|
||||
|
||||
/** http requestUrl */
|
||||
private String apiUrl;
|
||||
/** 关系型数据库sql */
|
||||
private String sql;
|
||||
|
||||
/** http method */
|
||||
private String method;
|
||||
/** http requestUrl */
|
||||
private String apiUrl;
|
||||
|
||||
/** http header */
|
||||
private String header;
|
||||
/** http method */
|
||||
private String method;
|
||||
|
||||
/** http 请求体 */
|
||||
private String body;
|
||||
/** http header */
|
||||
private String header;
|
||||
|
||||
/** 动态查询sql或者接口中的请求体 */
|
||||
private String dynSentence;
|
||||
/** http 请求体 */
|
||||
private String body;
|
||||
|
||||
/** 传入的自定义参数,解决url中存在的动态参数*/
|
||||
private Map<String, Object> contextData;
|
||||
/** 动态查询sql或者接口中的请求体 */
|
||||
private String dynSentence;
|
||||
|
||||
/** 传入的自定义参数,解决url中存在的动态参数 */
|
||||
private Map<String, Object> contextData;
|
||||
|
||||
}
|
||||
+14
-6
@@ -11,11 +11,19 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class ConnectionParam implements Serializable {
|
||||
|
||||
/** 数据源类型 DIC_NAME=SOURCE_TYPE; mysql,orace,sqlserver,elasticsearch,接口,javaBean,数据源类型字典中item-extend动态生成表单 */
|
||||
@NotBlank(message = "sourceType not empty")
|
||||
private String sourceType;
|
||||
/**
|
||||
* 数据源类型 DIC_NAME=SOURCE_TYPE;
|
||||
* mysql,orace,sqlserver,elasticsearch,接口,javaBean,数据源类型字典中item-extend动态生成表单
|
||||
*/
|
||||
@NotBlank(message = "sourceType not empty")
|
||||
private String sourceType;
|
||||
|
||||
/**
|
||||
* 数据源连接配置json:关系库{ jdbcUrl:'', username:'', password:'','driverName':''}ES-sql{
|
||||
* apiUrl:'http://127.0.0.1:9092/_xpack/sql?format=json','method':'POST','body':'{"query":"select
|
||||
* 1"}' } 接口{ apiUrl:'http://ip:port/url', method:'' } javaBean{ beanNamw:'xxx' }
|
||||
*/
|
||||
@NotBlank(message = "sourceConfig not empty")
|
||||
private String sourceConfig;
|
||||
|
||||
/** 数据源连接配置json:关系库{ jdbcUrl:'', username:'', password:'','driverName':''}ES-sql{ apiUrl:'http://127.0.0.1:9092/_xpack/sql?format=json','method':'POST','body':'{"query":"select 1"}' } 接口{ apiUrl:'http://ip:port/url', method:'' } javaBean{ beanNamw:'xxx' } */
|
||||
@NotBlank(message = "sourceConfig not empty")
|
||||
private String sourceConfig;
|
||||
}
|
||||
+18
-15
@@ -8,24 +8,27 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* @desc DataSource 数据集查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:09:57.728203200
|
||||
**/
|
||||
* @desc DataSource 数据集查询输入类
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:09:57.728203200
|
||||
**/
|
||||
@Data
|
||||
public class DataSourceParam extends PageParam implements Serializable{
|
||||
public class DataSourceParam extends PageParam implements Serializable {
|
||||
|
||||
/** 数据源名称 */
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String sourceName;
|
||||
/** 数据源名称 */
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String sourceName;
|
||||
|
||||
/** 数据源编码 */
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String sourceCode;
|
||||
/** 数据源编码 */
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String sourceCode;
|
||||
|
||||
/**
|
||||
* 数据源类型 DIC_NAME=SOURCE_TYPE;
|
||||
* mysql,orace,sqlserver,elasticsearch,接口,javaBean,数据源类型字典中item-extend动态生成表单
|
||||
*/
|
||||
@Query(QueryEnum.EQ)
|
||||
private String sourceType;
|
||||
|
||||
/** 数据源类型 DIC_NAME=SOURCE_TYPE; mysql,orace,sqlserver,elasticsearch,接口,javaBean,数据源类型字典中item-extend动态生成表单 */
|
||||
@Query(QueryEnum.EQ)
|
||||
private String sourceType;
|
||||
}
|
||||
+6
-6
@@ -1,15 +1,15 @@
|
||||
package com.anjiplus.template.gaea.business.modules.datasource.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.datasource.dao.entity.DataSource;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* DataSource Mapper
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:09:57.728203200
|
||||
**/
|
||||
* DataSource Mapper
|
||||
*
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:09:57.728203200
|
||||
**/
|
||||
@Mapper
|
||||
public interface DataSourceMapper extends GaeaBaseMapper<DataSource> {
|
||||
|
||||
|
||||
+22
-20
@@ -9,34 +9,36 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description 数据源 entity
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:09:57.728203200
|
||||
**/
|
||||
@TableName(keepGlobalPrefix=true, value="gaea_report_data_source")
|
||||
* @description 数据源 entity
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:09:57.728203200
|
||||
**/
|
||||
@TableName(keepGlobalPrefix = true, value = "gaea_report_data_source")
|
||||
@Data
|
||||
public class DataSource extends GaeaBaseEntity {
|
||||
@ApiModelProperty(value = "数据源编码")
|
||||
@Unique(code = ResponseCode.SOURCE_CODE_ISEXIST)
|
||||
private String sourceCode;
|
||||
|
||||
@ApiModelProperty(value = "数据源名称")
|
||||
private String sourceName;
|
||||
@ApiModelProperty(value = "数据源编码")
|
||||
@Unique(code = ResponseCode.SOURCE_CODE_ISEXIST)
|
||||
private String sourceCode;
|
||||
|
||||
@ApiModelProperty(value = "数据源描述")
|
||||
private String sourceDesc;
|
||||
@ApiModelProperty(value = "数据源名称")
|
||||
private String sourceName;
|
||||
|
||||
@ApiModelProperty(value = "数据源类型 DIC_NAME=SOURCE_TYPE; mysql,orace,sqlserver,elasticsearch,接口,javaBean,数据源类型字典中item-extend动态生成表单")
|
||||
private String sourceType;
|
||||
@ApiModelProperty(value = "数据源描述")
|
||||
private String sourceDesc;
|
||||
|
||||
@ApiModelProperty(value = "数据源连接配置json:关系库{ jdbcUrl:'', username:'', password:'','driverName':''}ES-sql{ apiUrl:'http://127.0.0.1:9092/_xpack/sql?format=json','method':'POST','body':'{\"query\":\"select 1\"}' } 接口{ apiUrl:'http://ip:port/url', method:'' } javaBean{ beanNamw:'xxx' }")
|
||||
private String sourceConfig;
|
||||
@ApiModelProperty(
|
||||
value = "数据源类型 DIC_NAME=SOURCE_TYPE; mysql,orace,sqlserver,elasticsearch,接口,javaBean,数据源类型字典中item-extend动态生成表单")
|
||||
private String sourceType;
|
||||
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
private Integer enableFlag;
|
||||
@ApiModelProperty(
|
||||
value = "数据源连接配置json:关系库{ jdbcUrl:'', username:'', password:'','driverName':''}ES-sql{ apiUrl:'http://127.0.0.1:9092/_xpack/sql?format=json','method':'POST','body':'{\"query\":\"select 1\"}' } 接口{ apiUrl:'http://ip:port/url', method:'' } javaBean{ beanNamw:'xxx' }")
|
||||
private String sourceConfig;
|
||||
|
||||
@ApiModelProperty(value = "0--未删除 1--已删除 DIC_NAME=DELETE_FLAG")
|
||||
private Integer deleteFlag;
|
||||
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
|
||||
private Integer enableFlag;
|
||||
|
||||
@ApiModelProperty(value = "0--未删除 1--已删除 DIC_NAME=DELETE_FLAG")
|
||||
private Integer deleteFlag;
|
||||
|
||||
}
|
||||
+29
-28
@@ -12,37 +12,38 @@ import com.anjiplus.template.gaea.business.modules.datasource.dao.entity.DataSou
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @desc DataSource 数据集服务接口
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:09:57.728203200
|
||||
**/
|
||||
* @desc DataSource 数据集服务接口
|
||||
* @author Raod
|
||||
* @date 2021-03-18 12:09:57.728203200
|
||||
**/
|
||||
public interface DataSourceService extends GaeaBaseService<DataSourceParam, DataSource> {
|
||||
|
||||
/**
|
||||
* 获取所有数据源
|
||||
* @return
|
||||
*/
|
||||
List<DataSource> queryAllDataSource();
|
||||
/**
|
||||
* 获取所有数据源
|
||||
* @return
|
||||
*/
|
||||
List<DataSource> queryAllDataSource();
|
||||
|
||||
/**
|
||||
* 测试 连接
|
||||
* @param connectionParam
|
||||
* @return
|
||||
*/
|
||||
Boolean testConnection(ConnectionParam connectionParam);
|
||||
/**
|
||||
* 测试 连接
|
||||
* @param connectionParam
|
||||
* @return
|
||||
*/
|
||||
Boolean testConnection(ConnectionParam connectionParam);
|
||||
|
||||
/**
|
||||
* 执行sql
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<JSONObject> execute(DataSourceDto dto);
|
||||
/**
|
||||
* 执行sql
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<JSONObject> execute(DataSourceDto dto);
|
||||
|
||||
/**
|
||||
* 执行sql,统计数据total
|
||||
* @param dataSourceDto
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
long total(DataSourceDto dataSourceDto, DataSetDto dto);
|
||||
|
||||
/**
|
||||
* 执行sql,统计数据total
|
||||
* @param dataSourceDto
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
long total(DataSourceDto dataSourceDto, DataSetDto dto);
|
||||
}
|
||||
+20
-23
@@ -10,30 +10,27 @@ import java.sql.SQLException;
|
||||
*/
|
||||
public interface JdbcService {
|
||||
|
||||
/**
|
||||
* 删除数据库连接池
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void removeJdbcConnectionPool(Long id);
|
||||
/**
|
||||
* 删除数据库连接池
|
||||
* @param id
|
||||
*/
|
||||
void removeJdbcConnectionPool(Long id);
|
||||
|
||||
/**
|
||||
* 获取连接
|
||||
* @param dataSource
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
Connection getPooledConnection(DataSourceDto dataSource) throws SQLException;
|
||||
|
||||
/**
|
||||
* 获取连接
|
||||
*
|
||||
* @param dataSource
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
Connection getPooledConnection(DataSourceDto dataSource) throws SQLException;
|
||||
/**
|
||||
* 测试数据库连接 获取一个连接
|
||||
* @param dataSource
|
||||
* @return
|
||||
* @throws ClassNotFoundException driverName不正确
|
||||
* @throws SQLException
|
||||
*/
|
||||
Connection getUnPooledConnection(DataSourceDto dataSource) throws SQLException;
|
||||
|
||||
/**
|
||||
* 测试数据库连接 获取一个连接
|
||||
*
|
||||
* @param dataSource
|
||||
* @return
|
||||
* @throws ClassNotFoundException driverName不正确
|
||||
* @throws SQLException
|
||||
*/
|
||||
Connection getUnPooledConnection(DataSourceDto dataSource) throws SQLException;
|
||||
}
|
||||
+381
-373
@@ -33,7 +33,10 @@ import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -48,405 +51,410 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class DataSourceServiceImpl implements DataSourceService {
|
||||
|
||||
@Autowired
|
||||
private DataSourceMapper dataSourceMapper;
|
||||
@Autowired
|
||||
private DataSourceMapper dataSourceMapper;
|
||||
|
||||
@Resource(name = "dataSourceRestTemplate")
|
||||
private RestTemplate restTemplate;
|
||||
@Resource(name = "dataSourceRestTemplate")
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
private DataSetParamService dataSetParamService;
|
||||
@Autowired
|
||||
private DataSetParamService dataSetParamService;
|
||||
|
||||
@Autowired
|
||||
private JdbcService jdbcService;
|
||||
@Autowired
|
||||
private JdbcService jdbcService;
|
||||
|
||||
@Override
|
||||
public GaeaBaseMapper<DataSource> getMapper() {
|
||||
return dataSourceMapper;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseMapper<DataSource> getMapper() {
|
||||
return dataSourceMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有数据源
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DataSource> queryAllDataSource() {
|
||||
LambdaQueryWrapper<DataSource> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.select(DataSource::getSourceCode, DataSource::getSourceName).eq(DataSource::getEnableFlag,
|
||||
Enabled.YES.getValue());
|
||||
wrapper.orderByDesc(DataSource::getUpdateTime);
|
||||
return dataSourceMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有数据源
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DataSource> queryAllDataSource() {
|
||||
LambdaQueryWrapper<DataSource> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.select(DataSource::getSourceCode, DataSource::getSourceName)
|
||||
.eq(DataSource::getEnableFlag, Enabled.YES.getValue());
|
||||
wrapper.orderByDesc(DataSource::getUpdateTime);
|
||||
return dataSourceMapper.selectList(wrapper);
|
||||
}
|
||||
/**
|
||||
* 测试 连接
|
||||
* @param connectionParam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean testConnection(ConnectionParam connectionParam) {
|
||||
String sourceType = connectionParam.getSourceType();
|
||||
String sourceConfig = connectionParam.getSourceConfig();
|
||||
DataSourceDto dto = new DataSourceDto();
|
||||
dto.setSourceConfig(sourceConfig);
|
||||
switch (sourceType) {
|
||||
case JdbcConstants.ELASTIC_SEARCH_SQL:
|
||||
testElasticsearchSqlConnection(dto);
|
||||
break;
|
||||
case JdbcConstants.MYSQL:
|
||||
case JdbcConstants.KUDU_IMAPLA:
|
||||
case JdbcConstants.ORACLE:
|
||||
case JdbcConstants.SQL_SERVER:
|
||||
case JdbcConstants.JDBC:
|
||||
case JdbcConstants.POSTGRESQL:
|
||||
testRelationalDb(dto);
|
||||
break;
|
||||
case JdbcConstants.HTTP:
|
||||
testHttp(dto);
|
||||
break;
|
||||
default:
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_TYPE_DOES_NOT_MATCH_TEMPORARILY);
|
||||
}
|
||||
log.info("测试连接成功:{}", JSONObject.toJSONString(connectionParam));
|
||||
return true;
|
||||
|
||||
/**
|
||||
* 测试 连接
|
||||
*
|
||||
* @param connectionParam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean testConnection(ConnectionParam connectionParam) {
|
||||
String sourceType = connectionParam.getSourceType();
|
||||
String sourceConfig = connectionParam.getSourceConfig();
|
||||
DataSourceDto dto = new DataSourceDto();
|
||||
dto.setSourceConfig(sourceConfig);
|
||||
switch (sourceType) {
|
||||
case JdbcConstants.ELASTIC_SEARCH_SQL:
|
||||
testElasticsearchSqlConnection(dto);
|
||||
break;
|
||||
case JdbcConstants.MYSQL:
|
||||
case JdbcConstants.KUDU_IMAPLA:
|
||||
case JdbcConstants.ORACLE:
|
||||
case JdbcConstants.SQL_SERVER:
|
||||
case JdbcConstants.JDBC:
|
||||
case JdbcConstants.POSTGRESQL:
|
||||
testRelationalDb(dto);
|
||||
break;
|
||||
case JdbcConstants.HTTP:
|
||||
testHttp(dto);
|
||||
break;
|
||||
default:
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_TYPE_DOES_NOT_MATCH_TEMPORARILY);
|
||||
}
|
||||
log.info("测试连接成功:{}", JSONObject.toJSONString(connectionParam));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public List<JSONObject> execute(DataSourceDto dto) {
|
||||
String sourceType = dto.getSourceType();
|
||||
switch (sourceType) {
|
||||
case JdbcConstants.ELASTIC_SEARCH_SQL:
|
||||
return executeElasticsearchSql(dto);
|
||||
case JdbcConstants.MYSQL:
|
||||
case JdbcConstants.KUDU_IMAPLA:
|
||||
case JdbcConstants.ORACLE:
|
||||
case JdbcConstants.SQL_SERVER:
|
||||
case JdbcConstants.JDBC:
|
||||
case JdbcConstants.POSTGRESQL:
|
||||
return executeRelationalDb(dto);
|
||||
case JdbcConstants.HTTP:
|
||||
return executeHttp(dto);
|
||||
default:
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_TYPE_DOES_NOT_MATCH_TEMPORARILY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> execute(DataSourceDto dto) {
|
||||
String sourceType = dto.getSourceType();
|
||||
switch (sourceType) {
|
||||
case JdbcConstants.ELASTIC_SEARCH_SQL:
|
||||
return executeElasticsearchSql(dto);
|
||||
case JdbcConstants.MYSQL:
|
||||
case JdbcConstants.KUDU_IMAPLA:
|
||||
case JdbcConstants.ORACLE:
|
||||
case JdbcConstants.SQL_SERVER:
|
||||
case JdbcConstants.JDBC:
|
||||
case JdbcConstants.POSTGRESQL:
|
||||
return executeRelationalDb(dto);
|
||||
case JdbcConstants.HTTP:
|
||||
return executeHttp(dto);
|
||||
default:
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_TYPE_DOES_NOT_MATCH_TEMPORARILY);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 执行sql,统计数据total
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public long total(DataSourceDto sourceDto, DataSetDto dto) {
|
||||
// 区分数据类型
|
||||
String sourceType = sourceDto.getSourceType();
|
||||
switch (sourceType) {
|
||||
case JdbcConstants.ELASTIC_SEARCH_SQL:
|
||||
return 0;
|
||||
case JdbcConstants.MYSQL:
|
||||
return mysqlTotal(sourceDto, dto);
|
||||
default:
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_TYPE_DOES_NOT_MATCH_TEMPORARILY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行sql,统计数据total
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public long total(DataSourceDto sourceDto, DataSetDto dto) {
|
||||
//区分数据类型
|
||||
String sourceType = sourceDto.getSourceType();
|
||||
switch (sourceType) {
|
||||
case JdbcConstants.ELASTIC_SEARCH_SQL:
|
||||
return 0;
|
||||
case JdbcConstants.MYSQL:
|
||||
return mysqlTotal(sourceDto, dto);
|
||||
default:
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_TYPE_DOES_NOT_MATCH_TEMPORARILY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 获取mysql count 和添加limit分页信息
|
||||
* @param sourceDto
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public long mysqlTotal(DataSourceDto sourceDto, DataSetDto dto) {
|
||||
String dynSentence = sourceDto.getDynSentence();
|
||||
String sql = "select count(1) as count from (" + dynSentence + ") as gaeaExecute";
|
||||
sourceDto.setDynSentence(sql);
|
||||
List<JSONObject> result = execute(sourceDto);
|
||||
|
||||
/**
|
||||
* 获取mysql count 和添加limit分页信息
|
||||
* @param sourceDto
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public long mysqlTotal(DataSourceDto sourceDto, DataSetDto dto){
|
||||
String dynSentence = sourceDto.getDynSentence();
|
||||
String sql = "select count(1) as count from (" + dynSentence + ") as gaeaExecute";
|
||||
sourceDto.setDynSentence(sql);
|
||||
List<JSONObject> result = execute(sourceDto);
|
||||
// sql 拼接 limit 分页信息
|
||||
int pageNumber = Integer.parseInt(dto.getContextData().getOrDefault("pageNumber", "1").toString());
|
||||
int pageSize = Integer.parseInt(dto.getContextData().getOrDefault("pageSize", "10").toString());
|
||||
String sqlLimit = " limit " + (pageNumber - 1) * pageSize + "," + pageSize;
|
||||
sourceDto.setDynSentence(dynSentence.concat(sqlLimit));
|
||||
log.info("当前total:{}, 添加分页参数,sql语句:{}", JSONObject.toJSONString(result), sourceDto.getDynSentence());
|
||||
return result.get(0).getLongValue("count");
|
||||
}
|
||||
|
||||
//sql 拼接 limit 分页信息
|
||||
int pageNumber = Integer.parseInt(dto.getContextData().getOrDefault("pageNumber", "1").toString());
|
||||
int pageSize = Integer.parseInt(dto.getContextData().getOrDefault("pageSize", "10").toString());
|
||||
String sqlLimit = " limit " + (pageNumber - 1) * pageSize + "," + pageSize;
|
||||
sourceDto.setDynSentence(dynSentence.concat(sqlLimit));
|
||||
log.info("当前total:{}, 添加分页参数,sql语句:{}", JSONObject.toJSONString(result), sourceDto.getDynSentence());
|
||||
return result.get(0).getLongValue("count");
|
||||
}
|
||||
public List<JSONObject> executeElasticsearchSql(DataSourceDto dto) {
|
||||
analysisHttpConfig(dto);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAll(JSONObject.parseObject(dto.getHeader(), Map.class));
|
||||
HttpEntity<String> entity = new HttpEntity<>(dto.getDynSentence(), headers);
|
||||
ResponseEntity<JSONObject> exchange;
|
||||
try {
|
||||
exchange = restTemplate.exchange(dto.getApiUrl(), HttpMethod.valueOf(dto.getMethod()), entity,
|
||||
JSONObject.class);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("error", e);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
|
||||
}
|
||||
if (exchange.getStatusCode().isError()) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, exchange.getBody());
|
||||
}
|
||||
List<JSONObject> result;
|
||||
try {
|
||||
JSONObject body = exchange.getBody();
|
||||
// 解析es sql数据
|
||||
if (null == body) {
|
||||
return null;
|
||||
}
|
||||
JSONArray columns = body.getJSONArray("columns");
|
||||
JSONArray rows = body.getJSONArray("rows");
|
||||
result = new ArrayList<>();
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONArray row = rows.getJSONArray(i);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
for (int j = 0; j < row.size(); j++) {
|
||||
String name = columns.getJSONObject(j).getString("name");
|
||||
String value = row.getString(j);
|
||||
jsonObject.put(name, value);
|
||||
}
|
||||
result.add(jsonObject);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("error", e);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.ANALYSIS_DATA_ERROR, e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<JSONObject> executeRelationalDb(DataSourceDto dto) {
|
||||
analysisRelationalDbConfig(dto);
|
||||
Connection pooledConnection = null;
|
||||
try {
|
||||
pooledConnection = jdbcService.getPooledConnection(dto);
|
||||
|
||||
PreparedStatement statement = pooledConnection.prepareStatement(dto.getDynSentence());
|
||||
ResultSet rs = statement.executeQuery();
|
||||
|
||||
public List<JSONObject> executeElasticsearchSql(DataSourceDto dto) {
|
||||
analysisHttpConfig(dto);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAll(JSONObject.parseObject(dto.getHeader(), Map.class));
|
||||
HttpEntity<String> entity = new HttpEntity<>(dto.getDynSentence(), headers);
|
||||
ResponseEntity<JSONObject> exchange;
|
||||
try {
|
||||
exchange = restTemplate.exchange(dto.getApiUrl(), HttpMethod.valueOf(dto.getMethod()), entity, JSONObject.class);
|
||||
} catch (Exception e) {
|
||||
log.error("error",e);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
|
||||
}
|
||||
if (exchange.getStatusCode().isError()) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, exchange.getBody());
|
||||
}
|
||||
List<JSONObject> result;
|
||||
try {
|
||||
JSONObject body = exchange.getBody();
|
||||
//解析es sql数据
|
||||
if (null == body) {
|
||||
return null;
|
||||
}
|
||||
JSONArray columns = body.getJSONArray("columns");
|
||||
JSONArray rows = body.getJSONArray("rows");
|
||||
result = new ArrayList<>();
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONArray row = rows.getJSONArray(i);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
for (int j = 0; j < row.size(); j++) {
|
||||
String name = columns.getJSONObject(j).getString("name");
|
||||
String value = row.getString(j);
|
||||
jsonObject.put(name, value);
|
||||
}
|
||||
result.add(jsonObject);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("error",e);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.ANALYSIS_DATA_ERROR, e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
int columnCount = rs.getMetaData().getColumnCount();
|
||||
|
||||
public List<JSONObject> executeRelationalDb(DataSourceDto dto) {
|
||||
analysisRelationalDbConfig(dto);
|
||||
Connection pooledConnection = null;
|
||||
try {
|
||||
pooledConnection = jdbcService.getPooledConnection(dto);
|
||||
List<String> columns = new ArrayList<>();
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
String columnName = rs.getMetaData().getColumnLabel(i);
|
||||
columns.add(columnName);
|
||||
}
|
||||
List<JSONObject> list = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
JSONObject jo = new JSONObject();
|
||||
columns.forEach(t -> {
|
||||
try {
|
||||
Object value = rs.getObject(t);
|
||||
// 数据类型转换
|
||||
Object result = dealResult(value);
|
||||
jo.put(t, result);
|
||||
}
|
||||
catch (SQLException throwable) {
|
||||
log.error("error", throwable);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage());
|
||||
}
|
||||
});
|
||||
list.add(jo);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
catch (Exception throwable) {
|
||||
log.error("error", throwable);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage());
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (pooledConnection != null) {
|
||||
pooledConnection.close();
|
||||
}
|
||||
}
|
||||
catch (SQLException throwable) {
|
||||
log.error("error", throwable);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED,
|
||||
throwable.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PreparedStatement statement = pooledConnection.prepareStatement(dto.getDynSentence());
|
||||
ResultSet rs = statement.executeQuery();
|
||||
/**
|
||||
* 解决sql返回值 类型问题 (through reference chain:
|
||||
* java.util.HashMap["pageData"]->java.util.ArrayList[0]->java.util.HashMap["UPDATE_TIME"]->oracle.sql.TIMESTAMP["stream"])
|
||||
* @param result
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
private Object dealResult(Object result) throws SQLException {
|
||||
if (null == result) {
|
||||
return result;
|
||||
}
|
||||
String type = result.getClass().getName();
|
||||
if ("oracle.sql.TIMESTAMP".equals(type)) {
|
||||
// oracle.sql.TIMESTAMP处理逻辑
|
||||
return new Date((Long) JSONObject.toJSON(result));
|
||||
}
|
||||
|
||||
int columnCount = rs.getMetaData().getColumnCount();
|
||||
return result;
|
||||
}
|
||||
|
||||
List<String> columns = new ArrayList<>();
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
String columnName = rs.getMetaData().getColumnLabel(i);
|
||||
columns.add(columnName);
|
||||
}
|
||||
List<JSONObject> list = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
JSONObject jo = new JSONObject();
|
||||
columns.forEach(t -> {
|
||||
try {
|
||||
Object value = rs.getObject(t);
|
||||
//数据类型转换
|
||||
Object result = dealResult(value);
|
||||
jo.put(t, result);
|
||||
} catch (SQLException throwable) {
|
||||
log.error("error",throwable);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage());
|
||||
}
|
||||
});
|
||||
list.add(jo);
|
||||
}
|
||||
return list;
|
||||
} catch (Exception throwable) {
|
||||
log.error("error",throwable);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (pooledConnection != null) {
|
||||
pooledConnection.close();
|
||||
}
|
||||
} catch (SQLException throwable) {
|
||||
log.error("error",throwable);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, throwable.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* http 执行获取数据
|
||||
* @param dto
|
||||
*/
|
||||
public List<JSONObject> executeHttp(DataSourceDto dto) {
|
||||
analysisHttpConfig(dto);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAll(JSONObject.parseObject(dto.getHeader(), Map.class));
|
||||
HttpEntity<String> entity = new HttpEntity<>(dto.getDynSentence(), headers);
|
||||
ResponseEntity<Object> exchange;
|
||||
try {
|
||||
exchange = restTemplate.exchange(dto.getApiUrl(), HttpMethod.valueOf(dto.getMethod()), entity,
|
||||
Object.class);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("error", e);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
|
||||
}
|
||||
if (exchange.getStatusCode().isError()) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, exchange.getBody());
|
||||
}
|
||||
Object body = exchange.getBody();
|
||||
String jsonStr = JSONObject.toJSONString(body);
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
if (jsonStr.trim().startsWith(BusinessConstant.LEFT_BIG_BOAST)
|
||||
&& jsonStr.trim().endsWith(BusinessConstant.RIGTH_BIG_BOAST)) {
|
||||
// JSONObject
|
||||
result.add(JSONObject.parseObject(jsonStr));
|
||||
}
|
||||
else if (jsonStr.trim().startsWith(BusinessConstant.LEFT_MIDDLE_BOAST)
|
||||
&& jsonStr.trim().endsWith(BusinessConstant.RIGHT_MIDDLE_BOAST)) {
|
||||
// List
|
||||
result = JSONArray.parseArray(jsonStr, JSONObject.class);
|
||||
}
|
||||
else {
|
||||
result.add(new JSONObject());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解决sql返回值 类型问题
|
||||
* (through reference chain: java.util.HashMap["pageData"]->java.util.ArrayList[0]->java.util.HashMap["UPDATE_TIME"]->oracle.sql.TIMESTAMP["stream"])
|
||||
* @param result
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
private Object dealResult(Object result) throws SQLException {
|
||||
if (null == result) {
|
||||
return result;
|
||||
}
|
||||
String type = result.getClass().getName();
|
||||
if ("oracle.sql.TIMESTAMP".equals(type)) {
|
||||
//oracle.sql.TIMESTAMP处理逻辑
|
||||
return new Date((Long) JSONObject.toJSON(result));
|
||||
}
|
||||
/**
|
||||
* 关系型数据库 测试连接
|
||||
* @param dto
|
||||
*/
|
||||
public void testRelationalDb(DataSourceDto dto) {
|
||||
analysisRelationalDbConfig(dto);
|
||||
try {
|
||||
Connection unPooledConnection = jdbcService.getUnPooledConnection(dto);
|
||||
String catalog = unPooledConnection.getCatalog();
|
||||
log.info("数据库测试连接成功:{}", catalog);
|
||||
unPooledConnection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
log.error("error", e);
|
||||
if (e.getCause() instanceof ClassNotFoundException) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.CLASS_NOT_FOUND, e.getCause().getMessage());
|
||||
}
|
||||
else {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* http 执行获取数据
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public List<JSONObject> executeHttp(DataSourceDto dto) {
|
||||
analysisHttpConfig(dto);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAll(JSONObject.parseObject(dto.getHeader(), Map.class));
|
||||
HttpEntity<String> entity = new HttpEntity<>(dto.getDynSentence(), headers);
|
||||
ResponseEntity<Object> exchange;
|
||||
try {
|
||||
exchange = restTemplate.exchange(dto.getApiUrl(), HttpMethod.valueOf(dto.getMethod()), entity, Object.class);
|
||||
} catch (Exception e) {
|
||||
log.error("error",e);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
|
||||
}
|
||||
if (exchange.getStatusCode().isError()) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, exchange.getBody());
|
||||
}
|
||||
Object body = exchange.getBody();
|
||||
String jsonStr = JSONObject.toJSONString(body);
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
if (jsonStr.trim().startsWith(BusinessConstant.LEFT_BIG_BOAST) && jsonStr.trim().endsWith(BusinessConstant.RIGTH_BIG_BOAST)) {
|
||||
//JSONObject
|
||||
result.add(JSONObject.parseObject(jsonStr));
|
||||
} else if (jsonStr.trim().startsWith(BusinessConstant.LEFT_MIDDLE_BOAST) && jsonStr.trim().endsWith(BusinessConstant.RIGHT_MIDDLE_BOAST)) {
|
||||
//List
|
||||
result = JSONArray.parseArray(jsonStr, JSONObject.class);
|
||||
} else {
|
||||
result.add(new JSONObject());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* http 测试连接
|
||||
* @param dto
|
||||
*/
|
||||
public void testHttp(DataSourceDto dto) {
|
||||
analysisHttpConfig(dto);
|
||||
String apiUrl = dto.getApiUrl();
|
||||
String method = dto.getMethod();
|
||||
String body = dto.getBody();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAll(JSONObject.parseObject(dto.getHeader(), Map.class));
|
||||
HttpEntity<String> entity = new HttpEntity<>(body, headers);
|
||||
ResponseEntity<Object> exchange;
|
||||
try {
|
||||
exchange = restTemplate.exchange(apiUrl, HttpMethod.valueOf(method), entity, Object.class);
|
||||
if (exchange.getStatusCode().isError()) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, exchange.getBody());
|
||||
}
|
||||
}
|
||||
catch (RestClientException e) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关系型数据库 测试连接
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public void testRelationalDb(DataSourceDto dto) {
|
||||
analysisRelationalDbConfig(dto);
|
||||
try {
|
||||
Connection unPooledConnection = jdbcService.getUnPooledConnection(dto);
|
||||
String catalog = unPooledConnection.getCatalog();
|
||||
log.info("数据库测试连接成功:{}", catalog);
|
||||
unPooledConnection.close();
|
||||
} catch (SQLException e) {
|
||||
log.error("error",e);
|
||||
if (e.getCause() instanceof ClassNotFoundException) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.CLASS_NOT_FOUND, e.getCause().getMessage());
|
||||
} else {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
|
||||
}
|
||||
/**
|
||||
* 关系型数据库 测试连接
|
||||
* @param dto
|
||||
*/
|
||||
public void testElasticsearchSqlConnection(DataSourceDto dto) {
|
||||
analysisHttpConfig(dto);
|
||||
String apiUrl = dto.getApiUrl();
|
||||
String method = dto.getMethod();
|
||||
String body = dto.getBody();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAll(JSONObject.parseObject(dto.getHeader(), Map.class));
|
||||
HttpEntity<String> entity = new HttpEntity<>(body, headers);
|
||||
ResponseEntity<Object> exchange;
|
||||
try {
|
||||
exchange = restTemplate.exchange(apiUrl, HttpMethod.valueOf(method), entity, Object.class);
|
||||
if (exchange.getStatusCode().isError()) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, exchange.getBody());
|
||||
}
|
||||
}
|
||||
catch (RestClientException e) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* http 测试连接
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public void testHttp(DataSourceDto dto) {
|
||||
analysisHttpConfig(dto);
|
||||
String apiUrl = dto.getApiUrl();
|
||||
String method = dto.getMethod();
|
||||
String body = dto.getBody();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAll(JSONObject.parseObject(dto.getHeader(), Map.class));
|
||||
HttpEntity<String> entity = new HttpEntity<>(body, headers);
|
||||
ResponseEntity<Object> exchange;
|
||||
try {
|
||||
exchange = restTemplate.exchange(apiUrl, HttpMethod.valueOf(method), entity, Object.class);
|
||||
if (exchange.getStatusCode().isError()) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, exchange.getBody());
|
||||
}
|
||||
} catch (RestClientException e) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
|
||||
}
|
||||
}
|
||||
public void analysisRelationalDbConfig(DataSourceDto dto) {
|
||||
JSONObject json = JSONObject.parseObject(dto.getSourceConfig());
|
||||
GaeaAssert.isFalse(json.containsKey("jdbcUrl"), ResponseCode.PARAM_IS_NULL, "jdbcUrl not empty");
|
||||
GaeaAssert.isFalse(json.containsKey("driverName"), ResponseCode.PARAM_IS_NULL, "driverName not empty");
|
||||
String jdbcUrl = json.getString("jdbcUrl");
|
||||
String username = json.getString("username");
|
||||
String password = json.getString("password");
|
||||
String driverName = json.getString("driverName");
|
||||
dto.setJdbcUrl(jdbcUrl);
|
||||
dto.setDriverName(driverName);
|
||||
dto.setUsername(username);
|
||||
dto.setPassword(password);
|
||||
}
|
||||
|
||||
/**
|
||||
* es通过api获取数据
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public void analysisHttpConfig(DataSourceDto dto) {
|
||||
JSONObject json = JSONObject.parseObject(dto.getSourceConfig());
|
||||
GaeaAssert.isFalse(json.containsKey("apiUrl"), ResponseCode.PARAM_IS_NULL, "apiUrl not empty");
|
||||
GaeaAssert.isFalse(json.containsKey("method"), ResponseCode.PARAM_IS_NULL, "method not empty");
|
||||
GaeaAssert.isFalse(json.containsKey("header"), ResponseCode.PARAM_IS_NULL, "header not empty");
|
||||
GaeaAssert.isFalse(json.containsKey("body"), ResponseCode.PARAM_IS_NULL, "body not empty");
|
||||
String apiUrl = json.getString("apiUrl");
|
||||
String method = json.getString("method");
|
||||
String header = json.getString("header");
|
||||
String body = json.getString("body");
|
||||
// 解决url中存在的动态参数
|
||||
apiUrl = dataSetParamService.transform(dto.getContextData(), apiUrl);
|
||||
// 请求头中动态参数
|
||||
header = dataSetParamService.transform(dto.getContextData(), header);
|
||||
dto.setApiUrl(apiUrl);
|
||||
dto.setMethod(method);
|
||||
dto.setHeader(header);
|
||||
dto.setBody(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关系型数据库 测试连接
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public void testElasticsearchSqlConnection(DataSourceDto dto) {
|
||||
analysisHttpConfig(dto);
|
||||
String apiUrl = dto.getApiUrl();
|
||||
String method = dto.getMethod();
|
||||
String body = dto.getBody();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAll(JSONObject.parseObject(dto.getHeader(), Map.class));
|
||||
HttpEntity<String> entity = new HttpEntity<>(body, headers);
|
||||
ResponseEntity<Object> exchange;
|
||||
try {
|
||||
exchange = restTemplate.exchange(apiUrl, HttpMethod.valueOf(method), entity, Object.class);
|
||||
if (exchange.getStatusCode().isError()) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, exchange.getBody());
|
||||
}
|
||||
} catch (RestClientException e) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
|
||||
}
|
||||
/**
|
||||
* 操作后续处理
|
||||
* @param entity
|
||||
* @param operationEnum 操作类型
|
||||
* @throws BusinessException 阻止程序继续执行或回滚事务
|
||||
*/
|
||||
@Override
|
||||
public void processAfterOperation(DataSource entity, BaseOperationEnum operationEnum) throws BusinessException {
|
||||
jdbcService.removeJdbcConnectionPool(entity.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void analysisRelationalDbConfig(DataSourceDto dto) {
|
||||
JSONObject json = JSONObject.parseObject(dto.getSourceConfig());
|
||||
GaeaAssert.isFalse(json.containsKey("jdbcUrl"), ResponseCode.PARAM_IS_NULL,"jdbcUrl not empty");
|
||||
GaeaAssert.isFalse(json.containsKey("driverName"), ResponseCode.PARAM_IS_NULL,"driverName not empty");
|
||||
String jdbcUrl = json.getString("jdbcUrl");
|
||||
String username = json.getString("username");
|
||||
String password = json.getString("password");
|
||||
String driverName = json.getString("driverName");
|
||||
dto.setJdbcUrl(jdbcUrl);
|
||||
dto.setDriverName(driverName);
|
||||
dto.setUsername(username);
|
||||
dto.setPassword(password);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* es通过api获取数据
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public void analysisHttpConfig(DataSourceDto dto) {
|
||||
JSONObject json = JSONObject.parseObject(dto.getSourceConfig());
|
||||
GaeaAssert.isFalse(json.containsKey("apiUrl"), ResponseCode.PARAM_IS_NULL,"apiUrl not empty");
|
||||
GaeaAssert.isFalse(json.containsKey("method"), ResponseCode.PARAM_IS_NULL,"method not empty");
|
||||
GaeaAssert.isFalse(json.containsKey("header"), ResponseCode.PARAM_IS_NULL,"header not empty");
|
||||
GaeaAssert.isFalse(json.containsKey("body"), ResponseCode.PARAM_IS_NULL,"body not empty");
|
||||
String apiUrl = json.getString("apiUrl");
|
||||
String method = json.getString("method");
|
||||
String header = json.getString("header");
|
||||
String body = json.getString("body");
|
||||
//解决url中存在的动态参数
|
||||
apiUrl = dataSetParamService.transform(dto.getContextData(), apiUrl);
|
||||
//请求头中动态参数
|
||||
header = dataSetParamService.transform(dto.getContextData(), header);
|
||||
dto.setApiUrl(apiUrl);
|
||||
dto.setMethod(method);
|
||||
dto.setHeader(header);
|
||||
dto.setBody(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作后续处理
|
||||
*
|
||||
* @param entity
|
||||
* @param operationEnum 操作类型
|
||||
* @throws BusinessException 阻止程序继续执行或回滚事务
|
||||
*/
|
||||
@Override
|
||||
public void processAfterOperation(DataSource entity, BaseOperationEnum operationEnum) throws BusinessException {
|
||||
jdbcService.removeJdbcConnectionPool(entity.getId());
|
||||
}
|
||||
}
|
||||
+67
-67
@@ -20,77 +20,77 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@Slf4j
|
||||
public class JdbcServiceImpl implements JdbcService {
|
||||
|
||||
@Autowired
|
||||
private DruidProperties druidProperties;
|
||||
@Autowired
|
||||
private DruidProperties druidProperties;
|
||||
|
||||
/**
|
||||
* 所有数据源的连接池存在map里
|
||||
*/
|
||||
static Map<Long, DruidDataSource> map = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* 所有数据源的连接池存在map里
|
||||
*/
|
||||
static Map<Long, DruidDataSource> map = new ConcurrentHashMap<>();
|
||||
|
||||
public DruidDataSource getJdbcConnectionPool(DataSourceDto dataSource) {
|
||||
if (map.containsKey(dataSource.getId())) {
|
||||
return map.get(dataSource.getId());
|
||||
} else {
|
||||
try {
|
||||
if (!map.containsKey(dataSource.getId())) {
|
||||
DruidDataSource pool = druidProperties.dataSource(dataSource.getJdbcUrl(),
|
||||
dataSource.getUsername(), dataSource.getPassword(), dataSource.getDriverName());
|
||||
map.put(dataSource.getId(), pool);
|
||||
log.info("创建连接池成功:{}", dataSource.getJdbcUrl());
|
||||
}
|
||||
return map.get(dataSource.getId());
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
}
|
||||
public DruidDataSource getJdbcConnectionPool(DataSourceDto dataSource) {
|
||||
if (map.containsKey(dataSource.getId())) {
|
||||
return map.get(dataSource.getId());
|
||||
}
|
||||
else {
|
||||
try {
|
||||
if (!map.containsKey(dataSource.getId())) {
|
||||
DruidDataSource pool = druidProperties.dataSource(dataSource.getJdbcUrl(), dataSource.getUsername(),
|
||||
dataSource.getPassword(), dataSource.getDriverName());
|
||||
map.put(dataSource.getId(), pool);
|
||||
log.info("创建连接池成功:{}", dataSource.getJdbcUrl());
|
||||
}
|
||||
return map.get(dataSource.getId());
|
||||
}
|
||||
finally {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据库连接池
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void removeJdbcConnectionPool(Long id) {
|
||||
try {
|
||||
DruidDataSource pool = map.get(id);
|
||||
if (pool != null) {
|
||||
log.info("remove pool success, datasourceId:{}", id);
|
||||
map.remove(id);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("error", e);
|
||||
}
|
||||
finally {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据库连接池
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void removeJdbcConnectionPool(Long id) {
|
||||
try {
|
||||
DruidDataSource pool = map.get(id);
|
||||
if (pool != null) {
|
||||
log.info("remove pool success, datasourceId:{}", id);
|
||||
map.remove(id);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("error", e);
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取连接
|
||||
* @param dataSource
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
@Override
|
||||
public Connection getPooledConnection(DataSourceDto dataSource) throws SQLException {
|
||||
DruidDataSource pool = getJdbcConnectionPool(dataSource);
|
||||
return pool.getConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取连接
|
||||
*
|
||||
* @param dataSource
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
@Override
|
||||
public Connection getPooledConnection(DataSourceDto dataSource) throws SQLException{
|
||||
DruidDataSource pool = getJdbcConnectionPool(dataSource);
|
||||
return pool.getConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试数据库连接 获取一个连接
|
||||
*
|
||||
* @param dataSource
|
||||
* @return
|
||||
* @throws ClassNotFoundException driverName不正确
|
||||
* @throws SQLException
|
||||
*/
|
||||
@Override
|
||||
public Connection getUnPooledConnection(DataSourceDto dataSource) throws SQLException {
|
||||
DruidDataSource druidDataSource = druidProperties.dataSource(dataSource.getJdbcUrl(),
|
||||
dataSource.getUsername(), dataSource.getPassword(), dataSource.getDriverName());
|
||||
return druidDataSource.getConnection();
|
||||
}
|
||||
/**
|
||||
* 测试数据库连接 获取一个连接
|
||||
* @param dataSource
|
||||
* @return
|
||||
* @throws ClassNotFoundException driverName不正确
|
||||
* @throws SQLException
|
||||
*/
|
||||
@Override
|
||||
public Connection getUnPooledConnection(DataSourceDto dataSource) throws SQLException {
|
||||
DruidDataSource druidDataSource = druidProperties.dataSource(dataSource.getJdbcUrl(), dataSource.getUsername(),
|
||||
dataSource.getPassword(), dataSource.getDriverName());
|
||||
return druidDataSource.getConnection();
|
||||
}
|
||||
|
||||
}
|
||||
+76
-73
@@ -15,7 +15,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* (GaeaDict)实体类
|
||||
@@ -28,89 +31,89 @@ import java.util.*;
|
||||
@Api(value = "/gaeaDict", tags = "")
|
||||
public class GaeaDictController extends GaeaBaseController<GaeaDictParam, GaeaDict, GaeaDictDTO> {
|
||||
|
||||
@Autowired
|
||||
private GaeaDictService gaeaDictService;
|
||||
@Autowired
|
||||
private GaeaDictService gaeaDictService;
|
||||
|
||||
@Autowired
|
||||
private GaeaDictItemService gaeaDictItemService;
|
||||
@Autowired
|
||||
private GaeaDictItemService gaeaDictItemService;
|
||||
|
||||
@Override
|
||||
public GaeaBaseService<GaeaDictParam, GaeaDict> getService() {
|
||||
return gaeaDictService;
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseService<GaeaDictParam, GaeaDict> getService() {
|
||||
return gaeaDictService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GaeaDict getEntity() {
|
||||
return new GaeaDict();
|
||||
}
|
||||
@Override
|
||||
public GaeaDict getEntity() {
|
||||
return new GaeaDict();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GaeaDictDTO getDTO() {
|
||||
return new GaeaDictDTO();
|
||||
}
|
||||
@Override
|
||||
public GaeaDictDTO getDTO() {
|
||||
return new GaeaDictDTO();
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新指定字典项
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/freshDict")
|
||||
@Permission(code = "fresh", name = "刷新")
|
||||
public ResponseBean refreshDict(@RequestBody List<String> dictCodes) {
|
||||
// 刷新
|
||||
gaeaDictService.refreshCache(dictCodes);
|
||||
return responseSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新指定字典项
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/freshDict")
|
||||
@Permission(code = "fresh",name = "刷新")
|
||||
public ResponseBean refreshDict(@RequestBody List<String> dictCodes) {
|
||||
//刷新
|
||||
gaeaDictService.refreshCache(dictCodes);
|
||||
return responseSuccess();
|
||||
}
|
||||
/**
|
||||
* 下拉菜单
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/select/{dictCode}")
|
||||
@Permission(code = "query", name = "下拉")
|
||||
public ResponseBean select(@PathVariable("dictCode") String dictName) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
// 语言
|
||||
String language = locale.getLanguage();
|
||||
|
||||
/**
|
||||
* 下拉菜单
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/select/{dictCode}")
|
||||
@Permission(code = "query",name = "下拉")
|
||||
public ResponseBean select(@PathVariable("dictCode") String dictName){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
//语言
|
||||
String language = locale.getLanguage();
|
||||
List<KeyValue> keyValues = gaeaDictService.select(dictName, language);
|
||||
return responseSuccessWithData(keyValues);
|
||||
}
|
||||
|
||||
List<KeyValue> keyValues = gaeaDictService.select(dictName,language);
|
||||
return responseSuccessWithData(keyValues);
|
||||
}
|
||||
/**
|
||||
* 指定语言的字典项
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/map/{dictCode}")
|
||||
public ResponseBean dictItemByLang(@PathVariable("dictCode") String dictCode) {
|
||||
return responseSuccessWithData(gaeaDictItemService.getItemMap(dictCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉菜单
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/selectAll/{project}")
|
||||
public ResponseBean selectTypecodes(@PathVariable String project) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
// 语言
|
||||
String language = locale.getLanguage();
|
||||
|
||||
/**
|
||||
* 指定语言的字典项
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/map/{dictCode}")
|
||||
public ResponseBean dictItemByLang(@PathVariable("dictCode") String dictCode){
|
||||
return responseSuccessWithData(gaeaDictItemService.getItemMap(dictCode));
|
||||
}
|
||||
/**
|
||||
* 下拉菜单
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/selectAll/{project}")
|
||||
public ResponseBean selectTypecodes(@PathVariable String project){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
//语言
|
||||
String language = locale.getLanguage();
|
||||
Collection<KeyValue> keyValues = gaeaDictService.selectTypeCode(project, language);
|
||||
return responseSuccessWithData(keyValues);
|
||||
}
|
||||
|
||||
Collection<KeyValue> keyValues = gaeaDictService.selectTypeCode(project,language);
|
||||
return responseSuccessWithData(keyValues);
|
||||
}
|
||||
/**
|
||||
* 获取所有字典
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public ResponseBean all() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
// 语言
|
||||
String language = locale.getLanguage();
|
||||
|
||||
/**
|
||||
* 获取所有字典
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public ResponseBean all(){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
//语言
|
||||
String language = locale.getLanguage();
|
||||
Map<String, List<KeyValue>> all = gaeaDictService.all(language);
|
||||
return responseSuccessWithData(all);
|
||||
}
|
||||
|
||||
Map<String, List<KeyValue>> all = gaeaDictService.all(language);
|
||||
return responseSuccessWithData(all);
|
||||
}
|
||||
}
|
||||
+21
-19
@@ -1,15 +1,15 @@
|
||||
package com.anjiplus.template.gaea.business.modules.dict.controller;
|
||||
|
||||
import com.anji.plus.gaea.curd.controller.GaeaBaseController;
|
||||
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDictItem;
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
import com.anjiplus.template.gaea.business.modules.dict.controller.dto.GaeaDictItemDTO;
|
||||
import com.anjiplus.template.gaea.business.modules.dict.controller.param.GaeaDictItemParam;
|
||||
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDictItem;
|
||||
import com.anjiplus.template.gaea.business.modules.dict.service.GaeaDictItemService;
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* 数据字典项(GaeaDictItem)实体类
|
||||
@@ -21,21 +21,23 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
@RequestMapping("/gaeaDictItem")
|
||||
@Api(value = "/gaeaDictItem", tags = "数据字典项")
|
||||
public class GaeaDictItemController extends GaeaBaseController<GaeaDictItemParam, GaeaDictItem, GaeaDictItemDTO> {
|
||||
@Autowired
|
||||
private GaeaDictItemService gaeaDictItemService;
|
||||
|
||||
@Override
|
||||
public GaeaBaseService<GaeaDictItemParam, GaeaDictItem> getService() {
|
||||
return gaeaDictItemService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GaeaDictItem getEntity() {
|
||||
return new GaeaDictItem();
|
||||
}
|
||||
@Autowired
|
||||
private GaeaDictItemService gaeaDictItemService;
|
||||
|
||||
@Override
|
||||
public GaeaDictItemDTO getDTO() {
|
||||
return new GaeaDictItemDTO();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public GaeaBaseService<GaeaDictItemParam, GaeaDictItem> getService() {
|
||||
return gaeaDictItemService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GaeaDictItem getEntity() {
|
||||
return new GaeaDictItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GaeaDictItemDTO getDTO() {
|
||||
return new GaeaDictItemDTO();
|
||||
}
|
||||
|
||||
}
|
||||
+17
-15
@@ -16,21 +16,23 @@ import java.io.Serializable;
|
||||
@ApiModel(value = "")
|
||||
@Data
|
||||
public class GaeaDictDTO extends GaeaBaseDTO implements Serializable {
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@ApiModelProperty(value = "字典名称")
|
||||
private String dictName;
|
||||
/**
|
||||
* 字典编号
|
||||
*/
|
||||
@ApiModelProperty(value = "字典编号")
|
||||
private String dictCode;
|
||||
/**
|
||||
* 字典描述
|
||||
*/
|
||||
@ApiModelProperty(value = "字典描述")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@ApiModelProperty(value = "字典名称")
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 字典编号
|
||||
*/
|
||||
@ApiModelProperty(value = "字典编号")
|
||||
private String dictCode;
|
||||
|
||||
/**
|
||||
* 字典描述
|
||||
*/
|
||||
@ApiModelProperty(value = "字典描述")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
+46
-39
@@ -16,45 +16,52 @@ import java.io.Serializable;
|
||||
@ApiModel(value = "数据字典项")
|
||||
@Data
|
||||
public class GaeaDictItemDTO extends GaeaBaseDTO implements Serializable {
|
||||
/**
|
||||
* 数据字典编码
|
||||
*/
|
||||
@ApiModelProperty(value = "数据字典编码")
|
||||
private String dictCode;
|
||||
/**
|
||||
* 字典项名称
|
||||
*/
|
||||
@ApiModelProperty(value = "字典项名称")
|
||||
private String itemName;
|
||||
/**
|
||||
* 字典项值
|
||||
*/
|
||||
@ApiModelProperty(value = "字典项值")
|
||||
private String itemValue;
|
||||
|
||||
/**
|
||||
* 字典项扩展
|
||||
*/
|
||||
@ApiModelProperty(value = "字典项扩展")
|
||||
private String itemExtend;
|
||||
/**
|
||||
* 语言标识
|
||||
*/
|
||||
@ApiModelProperty(value = "语言标识")
|
||||
private String locale;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String remark;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
/**
|
||||
* 数据字典编码
|
||||
*/
|
||||
@ApiModelProperty(value = "数据字典编码")
|
||||
private String dictCode;
|
||||
|
||||
/**
|
||||
* 字典项名称
|
||||
*/
|
||||
@ApiModelProperty(value = "字典项名称")
|
||||
private String itemName;
|
||||
|
||||
/**
|
||||
* 字典项值
|
||||
*/
|
||||
@ApiModelProperty(value = "字典项值")
|
||||
private String itemValue;
|
||||
|
||||
/**
|
||||
* 字典项扩展
|
||||
*/
|
||||
@ApiModelProperty(value = "字典项扩展")
|
||||
private String itemExtend;
|
||||
|
||||
/**
|
||||
* 语言标识
|
||||
*/
|
||||
@ApiModelProperty(value = "语言标识")
|
||||
private String locale;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 1:启用,0:禁用
|
||||
*/
|
||||
private Integer enabled;
|
||||
|
||||
/**
|
||||
* 1:启用,0:禁用
|
||||
*/
|
||||
private Integer enabled;
|
||||
}
|
||||
+19
-18
@@ -1,6 +1,5 @@
|
||||
package com.anjiplus.template.gaea.business.modules.dict.controller.param;
|
||||
|
||||
|
||||
import com.anji.plus.gaea.annotation.Query;
|
||||
import com.anji.plus.gaea.constant.QueryEnum;
|
||||
import com.anji.plus.gaea.curd.params.PageParam;
|
||||
@@ -17,23 +16,25 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class GaeaDictItemParam extends PageParam implements Serializable {
|
||||
|
||||
/**
|
||||
* 数据字典编码
|
||||
*/
|
||||
private String dictCode;
|
||||
/**
|
||||
* 字典项名称
|
||||
*/
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String itemName;
|
||||
/**
|
||||
* 数据字典编码
|
||||
*/
|
||||
private String dictCode;
|
||||
|
||||
/**
|
||||
* 语言标识
|
||||
*/
|
||||
private String locale;
|
||||
/**
|
||||
* 字典项名称
|
||||
*/
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String itemName;
|
||||
|
||||
/**
|
||||
* 语言标识
|
||||
*/
|
||||
private String locale;
|
||||
|
||||
/**
|
||||
* 1:启用,0:禁用
|
||||
*/
|
||||
private Integer enabled;
|
||||
|
||||
/**
|
||||
* 1:启用,0:禁用
|
||||
*/
|
||||
private Integer enabled;
|
||||
}
|
||||
+13
-11
@@ -1,6 +1,5 @@
|
||||
package com.anjiplus.template.gaea.business.modules.dict.controller.param;
|
||||
|
||||
|
||||
import com.anji.plus.gaea.annotation.Query;
|
||||
import com.anji.plus.gaea.constant.QueryEnum;
|
||||
import com.anji.plus.gaea.curd.params.PageParam;
|
||||
@@ -16,14 +15,17 @@ import java.io.Serializable;
|
||||
*/
|
||||
@Data
|
||||
public class GaeaDictParam extends PageParam implements Serializable {
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String dictName;
|
||||
/**
|
||||
* 字典编号
|
||||
*/
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String dictCode;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 字典编号
|
||||
*/
|
||||
@Query(QueryEnum.LIKE)
|
||||
private String dictCode;
|
||||
|
||||
}
|
||||
+2
-3
@@ -1,7 +1,7 @@
|
||||
package com.anjiplus.template.gaea.business.modules.dict.dao;
|
||||
|
||||
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDictItem;
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDictItem;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
@@ -13,5 +13,4 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface GaeaDictItemMapper extends GaeaBaseMapper<GaeaDictItem> {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -1,7 +1,7 @@
|
||||
package com.anjiplus.template.gaea.business.modules.dict.dao;
|
||||
|
||||
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDict;
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.dict.dao.entity.GaeaDict;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
@@ -13,5 +13,4 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface GaeaDictMapper extends GaeaBaseMapper<GaeaDict> {
|
||||
|
||||
|
||||
}
|
||||
+35
-32
@@ -13,44 +13,47 @@ import java.io.Serializable;
|
||||
* @author lr
|
||||
* @since 2021-02-23 10:01:02
|
||||
*/
|
||||
@TableName(keepGlobalPrefix=true, value = "gaea_dict")
|
||||
@TableName(keepGlobalPrefix = true, value = "gaea_dict")
|
||||
public class GaeaDict extends GaeaBaseEntity implements Serializable {
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dictName;
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
@Unique(code = ResponseCode.DICCODE_ISEXIST)
|
||||
private String dictCode;
|
||||
|
||||
/**
|
||||
* 字典描述
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dictName;
|
||||
|
||||
public String getDictName() {
|
||||
return dictName;
|
||||
}
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
@Unique(code = ResponseCode.DICCODE_ISEXIST)
|
||||
private String dictCode;
|
||||
|
||||
public void setDictName(String dictName) {
|
||||
this.dictName = dictName;
|
||||
}
|
||||
/**
|
||||
* 字典描述
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public String getDictCode() {
|
||||
return dictCode;
|
||||
}
|
||||
public String getDictName() {
|
||||
return dictName;
|
||||
}
|
||||
|
||||
public void setDictCode(String dictCode) {
|
||||
this.dictCode = dictCode;
|
||||
}
|
||||
public void setDictName(String dictName) {
|
||||
this.dictName = dictName;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
public String getDictCode() {
|
||||
return dictCode;
|
||||
}
|
||||
|
||||
public void setDictCode(String dictCode) {
|
||||
this.dictCode = dictCode;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
||||
+91
-85
@@ -2,8 +2,8 @@ package com.anjiplus.template.gaea.business.modules.dict.dao.entity;
|
||||
|
||||
import com.anji.plus.gaea.annotation.UnionUnique;
|
||||
import com.anji.plus.gaea.annotation.UnionUniqueCode;
|
||||
import com.anjiplus.template.gaea.business.code.*;
|
||||
import com.anji.plus.gaea.curd.entity.GaeaBaseEntity;
|
||||
import com.anjiplus.template.gaea.business.code.ResponseCode;
|
||||
import com.anjiplus.template.gaea.business.constant.BusinessConstant;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
@@ -15,109 +15,115 @@ import java.io.Serializable;
|
||||
* @author lirui
|
||||
* @since 2021-03-09 15:52:41
|
||||
*/
|
||||
@TableName(keepGlobalPrefix=true,value = "gaea_dict_item")
|
||||
@TableName(keepGlobalPrefix = true, value = "gaea_dict_item")
|
||||
@UnionUniqueCode(group = BusinessConstant.DICT_ITEM_EXIST_GROUP, code = ResponseCode.DICT_ITEM_REPEAT)
|
||||
public class GaeaDictItem extends GaeaBaseEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 数据字典编码
|
||||
*/
|
||||
@UnionUnique(group = BusinessConstant.DICT_ITEM_EXIST_GROUP)
|
||||
private String dictCode;
|
||||
/**
|
||||
* 字典项名称
|
||||
*/
|
||||
private String itemName;
|
||||
/**
|
||||
* 字典项值
|
||||
*/
|
||||
@UnionUnique(group = BusinessConstant.DICT_ITEM_EXIST_GROUP)
|
||||
private String itemValue;
|
||||
/**
|
||||
* 数据字典编码
|
||||
*/
|
||||
@UnionUnique(group = BusinessConstant.DICT_ITEM_EXIST_GROUP)
|
||||
private String dictCode;
|
||||
|
||||
/**
|
||||
* 字典项扩展
|
||||
*/
|
||||
private String itemExtend;
|
||||
/**
|
||||
* 语言标识
|
||||
*/
|
||||
@UnionUnique(group = BusinessConstant.DICT_ITEM_EXIST_GROUP)
|
||||
private String locale;
|
||||
/**
|
||||
* 字典项名称
|
||||
*/
|
||||
private String itemName;
|
||||
|
||||
/**
|
||||
* 1:启用,0:禁用
|
||||
*/
|
||||
private Integer enabled;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 字典项值
|
||||
*/
|
||||
@UnionUnique(group = BusinessConstant.DICT_ITEM_EXIST_GROUP)
|
||||
private String itemValue;
|
||||
|
||||
public String getDictCode() {
|
||||
return dictCode;
|
||||
}
|
||||
/**
|
||||
* 字典项扩展
|
||||
*/
|
||||
private String itemExtend;
|
||||
|
||||
public void setDictCode(String dictCode) {
|
||||
this.dictCode = dictCode;
|
||||
}
|
||||
/**
|
||||
* 语言标识
|
||||
*/
|
||||
@UnionUnique(group = BusinessConstant.DICT_ITEM_EXIST_GROUP)
|
||||
private String locale;
|
||||
|
||||
public String getItemName() {
|
||||
return itemName;
|
||||
}
|
||||
/**
|
||||
* 1:启用,0:禁用
|
||||
*/
|
||||
private Integer enabled;
|
||||
|
||||
public void setItemName(String itemName) {
|
||||
this.itemName = itemName;
|
||||
}
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public String getItemValue() {
|
||||
return itemValue;
|
||||
}
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
public void setItemValue(String itemValue) {
|
||||
this.itemValue = itemValue;
|
||||
}
|
||||
public String getDictCode() {
|
||||
return dictCode;
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
public void setDictCode(String dictCode) {
|
||||
this.dictCode = dictCode;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
public String getItemName() {
|
||||
return itemName;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
public void setItemName(String itemName) {
|
||||
this.itemName = itemName;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
public String getItemValue() {
|
||||
return itemValue;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
public void setItemValue(String itemValue) {
|
||||
this.itemValue = itemValue;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public Integer getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public void setEnabled(Integer enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public String getItemExtend() {
|
||||
return itemExtend;
|
||||
}
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public Integer getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(Integer enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getItemExtend() {
|
||||
return itemExtend;
|
||||
}
|
||||
|
||||
public void setItemExtend(String itemExtend) {
|
||||
this.itemExtend = itemExtend;
|
||||
}
|
||||
|
||||
public void setItemExtend(String itemExtend) {
|
||||
this.itemExtend = itemExtend;
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -14,10 +14,11 @@ import java.util.Map;
|
||||
*/
|
||||
public interface GaeaDictItemService extends GaeaBaseService<GaeaDictItemParam, GaeaDictItem> {
|
||||
|
||||
/**
|
||||
* 根据字典编码获取字典项
|
||||
* @param dictCode
|
||||
* @return
|
||||
*/
|
||||
Map<String,String> getItemMap(String dictCode);
|
||||
/**
|
||||
* 根据字典编码获取字典项
|
||||
* @param dictCode
|
||||
* @return
|
||||
*/
|
||||
Map<String, String> getItemMap(String dictCode);
|
||||
|
||||
}
|
||||
Loaded 100 of 142 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user