feat(server): rEQ-1902 增加数据权限
https://jira.axzo.cn/browse/REQ-1902?goToView=1 modify: 1. 创建数据资源规则 /api/data-resource/create 2. 更新数据资源规则 /api/data-resource/update 3. 删除数据资源 /api/data-resource/delete 4. 数据资源分页 /api/data-resource/page 5. 数据资源列表 /api/data-resource/list 6. 创建功能点和数据资源的关联 /api/data-resource/saas-feature 7. 删除功能点和数据资源的关联 /api/data-resource/saas-feature/delete 8. 获取某个功能点的数据资源信息 /api/data-resource/saas-feature/detail
This commit is contained in:
parent
0ac6eecde7
commit
712f53527e
112
integration-test/src/test/resources/data-resource.http
Normal file
112
integration-test/src/test/resources/data-resource.http
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
###
|
||||||
|
POST {{host}}/api/data-resource/create
|
||||||
|
Accept: application/json
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "急急急",
|
||||||
|
"attrs": [{"label": "用户名", "attr": "name"}],
|
||||||
|
"resourceScope": [{"attr": "dataPermission", "operation": "in", "value": ["ALL"]}],
|
||||||
|
"resourceCode": "testCode7",
|
||||||
|
"module": "PROJECT",
|
||||||
|
"ext": {"c": "测试"},
|
||||||
|
"parentId": 1
|
||||||
|
}
|
||||||
|
|
||||||
|
> reponse-check.js
|
||||||
|
|
||||||
|
###
|
||||||
|
POST {{host}}/api/data-resource/page
|
||||||
|
Accept: application/json
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"page": 1,
|
||||||
|
"name": "a"
|
||||||
|
}
|
||||||
|
|
||||||
|
> reponse-check.js
|
||||||
|
|
||||||
|
###
|
||||||
|
POST {{host}}/api/data-resource/list
|
||||||
|
Accept: application/json
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
> reponse-check.js
|
||||||
|
|
||||||
|
###
|
||||||
|
POST {{host}}/api/data-resource/update
|
||||||
|
Accept: application/json
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"attrs": [{"label": "用户名", "attr": "name"}],
|
||||||
|
"ext": {"c": "测试"},
|
||||||
|
"resourceScope": [{"attr": "dep", "operation": "in", "value": ["ALL"]}]
|
||||||
|
}
|
||||||
|
|
||||||
|
> reponse-check.js
|
||||||
|
|
||||||
|
###
|
||||||
|
POST {{host}}/api/data-resource/saas-feature
|
||||||
|
Accept: application/json
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"resourceCode": "testCode2",
|
||||||
|
"featureCodes": ["test"]
|
||||||
|
}
|
||||||
|
|
||||||
|
> reponse-check.js
|
||||||
|
|
||||||
|
###
|
||||||
|
POST {{host}}/api/data-resource/delete
|
||||||
|
Accept: application/json
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
|
|
||||||
|
> reponse-check.js
|
||||||
|
|
||||||
|
###
|
||||||
|
POST {{host}}/api/data-resource/saas-feature/delete
|
||||||
|
Accept: application/json
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"resourceCode": "testCode2",
|
||||||
|
"featureCodes": ["test"]
|
||||||
|
}
|
||||||
|
|
||||||
|
> reponse-check.js
|
||||||
|
|
||||||
|
###
|
||||||
|
POST {{host}}/api/data-resource/saas-feature
|
||||||
|
Accept: application/json
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"resourceCode": "testCode1",
|
||||||
|
"featureCodes": ["test"]
|
||||||
|
}
|
||||||
|
|
||||||
|
> reponse-check.js
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
POST {{host}}/api/data-resource/saas-feature/detail
|
||||||
|
Accept: application/json
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"featureCode": "test"
|
||||||
|
}
|
||||||
|
|
||||||
|
> reponse-check.js
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package cn.axzo.tyr.client.common.enums;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/16
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum DataResourceModuleEnum {
|
||||||
|
/**
|
||||||
|
* 项目
|
||||||
|
*/
|
||||||
|
PROJECT("PROJECT", "项目"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业
|
||||||
|
*/
|
||||||
|
ENTERPRISE("ENTERPRISE", "企业"),
|
||||||
|
;
|
||||||
|
@EnumValue
|
||||||
|
private final String value;
|
||||||
|
private final String desc;
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package cn.axzo.tyr.client.common.enums;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/16
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum DataResourceTypeEnum {
|
||||||
|
/**
|
||||||
|
* 数据资源 主对象
|
||||||
|
*/
|
||||||
|
MAIN_OBJECT("MAIN_OBJECT", "主对象"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据资源 子对象
|
||||||
|
*/
|
||||||
|
SUB_OBJECT("SUB_OBJECT", "子对象"),
|
||||||
|
;
|
||||||
|
|
||||||
|
@EnumValue
|
||||||
|
private final String value;
|
||||||
|
private final String desc;
|
||||||
|
}
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
package cn.axzo.tyr.client.feign;
|
||||||
|
|
||||||
|
import cn.axzo.framework.domain.web.result.ApiPageResult;
|
||||||
|
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.CreateDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.DataResourceSaasFeatureParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.DeleteDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.GetSaasFeatureDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.PageDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.SearchDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.UpdateDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.resp.DataResourceResp;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.resp.PageDataResourceResp;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/13
|
||||||
|
*/
|
||||||
|
@FeignClient(name = "tyr", url = "${axzo.service.tyr:http://tyr:8080}")
|
||||||
|
public interface DataResourceApi {
|
||||||
|
/**
|
||||||
|
* 创建数据资源规则
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/api/data-resource/create")
|
||||||
|
ApiResult<Void> create(@RequestBody @Validated CreateDataResourceParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据资源规则
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/api/data-resource/update")
|
||||||
|
ApiResult<Boolean> update(@RequestBody @Validated UpdateDataResourceParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据资源
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/api/data-resource/delete")
|
||||||
|
ApiResult<Boolean> delete(@RequestBody @Validated DeleteDataResourceParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据资源分页
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/api/data-resource/page")
|
||||||
|
ApiPageResult<PageDataResourceResp> page(@RequestBody @Validated PageDataResourceParam param);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据资源列表
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/api/data-resource/list")
|
||||||
|
ApiResult<List<DataResourceResp>> list(@RequestBody @Validated SearchDataResourceParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建功能点和数据资源的关联
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/api/data-resource/saas-feature")
|
||||||
|
ApiResult<Void> createDataResourceSaasFeature(@RequestBody @Validated DataResourceSaasFeatureParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除功能点和数据资源的关联
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/api/data-resource/saas-feature/delete")
|
||||||
|
ApiResult<Boolean> deleteDataResourceSaasFeature(@RequestBody @Validated DataResourceSaasFeatureParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后去某个功能点的数据资源信息
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/api/data-resource/saas-feature/detail")
|
||||||
|
ApiResult<List<DataResourceResp>> getSaasFeatureDataResource(@RequestBody @Validated GetSaasFeatureDataResourceParam param);
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package cn.axzo.tyr.client.model.dataresource;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class DataResourceAttrs {
|
||||||
|
/**
|
||||||
|
* 属性Code
|
||||||
|
*/
|
||||||
|
private String attr;
|
||||||
|
/**
|
||||||
|
* label 显示的名字
|
||||||
|
*/
|
||||||
|
private String label;
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package cn.axzo.tyr.client.model.dataresource;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ResourceScope {
|
||||||
|
/**
|
||||||
|
* 属性
|
||||||
|
*/
|
||||||
|
private String attr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作符
|
||||||
|
*/
|
||||||
|
private String operation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性值
|
||||||
|
*/
|
||||||
|
private List<String> value;
|
||||||
|
}
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
package cn.axzo.tyr.client.model.dataresource.req;
|
||||||
|
|
||||||
|
import cn.axzo.tyr.client.common.enums.DataResourceModuleEnum;
|
||||||
|
import cn.axzo.tyr.client.common.enums.DataResourceTypeEnum;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.DataResourceAttrs;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.ResourceScope;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class CreateDataResourceParam {
|
||||||
|
/**
|
||||||
|
* 数据对象名称
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "数据资源名称不能为空")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块名称 @see DataResourceModuleEnum
|
||||||
|
*/
|
||||||
|
@NotNull(message = "数据资源所属模块不能为空")
|
||||||
|
private DataResourceModuleEnum module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据对象code
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "数据资源code不能为空")
|
||||||
|
private String resourceCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对象属性例如:[{"attr": "name", "label": "名字"}]
|
||||||
|
*/
|
||||||
|
private List<DataResourceAttrs> attrs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据范围
|
||||||
|
*/
|
||||||
|
private List<ResourceScope> resourceScope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据对象类型0:主对象1:子对象
|
||||||
|
* @see DataResourceTypeEnum
|
||||||
|
*/
|
||||||
|
private DataResourceTypeEnum type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据对象code
|
||||||
|
*/
|
||||||
|
private Map ext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父对象ID
|
||||||
|
*/
|
||||||
|
private Long parentId;
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package cn.axzo.tyr.client.model.dataresource.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class DataResourceSaasFeatureParam {
|
||||||
|
/**
|
||||||
|
* 数据对象code
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "数据资源code不能为空")
|
||||||
|
private String resourceCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* featureCode
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "数据资源code不能为空")
|
||||||
|
private List<String> featureCodes;
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package cn.axzo.tyr.client.model.dataresource.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/16
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class DeleteDataResourceParam {
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@NotNull(message = "主键ID不能为空")
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package cn.axzo.tyr.client.model.dataresource.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class GetSaasFeatureDataResourceParam {
|
||||||
|
/**
|
||||||
|
* featureCode
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "featureCode 不能是空字符!")
|
||||||
|
private String featureCode;
|
||||||
|
}
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
package cn.axzo.tyr.client.model.dataresource.req;
|
||||||
|
|
||||||
|
import cn.axzo.core.domain.PageRequest;
|
||||||
|
import cn.axzo.tyr.client.common.enums.DataResourceModuleEnum;
|
||||||
|
import cn.axzo.tyr.client.common.enums.DataResourceTypeEnum;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/16
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PageDataResourceParam extends PageRequest {
|
||||||
|
/**
|
||||||
|
* 数据资源code列表
|
||||||
|
*/
|
||||||
|
private List<String> resourceCodes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块名称
|
||||||
|
*/
|
||||||
|
private DataResourceModuleEnum module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据对象类型0:主对象1:子对象
|
||||||
|
* @see DataResourceTypeEnum
|
||||||
|
*/
|
||||||
|
private DataResourceTypeEnum type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父对象ID
|
||||||
|
*/
|
||||||
|
private Long parentId;
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package cn.axzo.tyr.client.model.dataresource.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SearchDataResourceParam {
|
||||||
|
/**
|
||||||
|
* 数据资源code列表
|
||||||
|
*/
|
||||||
|
private List<String> resourceCodes;
|
||||||
|
}
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
package cn.axzo.tyr.client.model.dataresource.req;
|
||||||
|
|
||||||
|
import cn.axzo.tyr.client.common.enums.DataResourceModuleEnum;
|
||||||
|
import cn.axzo.tyr.client.common.enums.DataResourceTypeEnum;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.DataResourceAttrs;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.ResourceScope;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UpdateDataResourceParam {
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@NotNull(message = "主键ID不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据对象名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对象属性例如:[{"attr": "name", "label": "名字"}]
|
||||||
|
*/
|
||||||
|
private List<DataResourceAttrs> attrs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据范围
|
||||||
|
*/
|
||||||
|
private List<ResourceScope> resourceScope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据对象类型0:主对象1:子对象
|
||||||
|
*/
|
||||||
|
private DataResourceTypeEnum type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块名称 eg. 企业:enterprise, 项目:project
|
||||||
|
*/
|
||||||
|
private DataResourceModuleEnum module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扩展信息
|
||||||
|
*/
|
||||||
|
private Map ext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父对象ID
|
||||||
|
*/
|
||||||
|
private Long parentId;
|
||||||
|
}
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
package cn.axzo.tyr.client.model.dataresource.resp;
|
||||||
|
|
||||||
|
import cn.axzo.tyr.client.common.enums.DataResourceModuleEnum;
|
||||||
|
import cn.axzo.tyr.client.common.enums.DataResourceTypeEnum;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.DataResourceAttrs;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.ResourceScope;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class DataResourceResp implements Serializable {
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据对象名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块名称 eg. 企业:ENTERPRISE, 项目:PROJECT
|
||||||
|
*/
|
||||||
|
private DataResourceModuleEnum module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据资源code
|
||||||
|
*/
|
||||||
|
private String resourceCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对象属性例如:[{"attr": "name", "label": "名字"}]
|
||||||
|
*/
|
||||||
|
private List<DataResourceAttrs> attrs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据范围
|
||||||
|
*/
|
||||||
|
private List<ResourceScope> resourceScope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据对象类型0:主对象1:子对象
|
||||||
|
*/
|
||||||
|
private DataResourceTypeEnum type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扩展信息
|
||||||
|
*/
|
||||||
|
private Map ext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父对象ID
|
||||||
|
*/
|
||||||
|
private Long parentId;
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package cn.axzo.tyr.client.model.dataresource.resp;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/16
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PageDataResourceResp extends DataResourceResp {
|
||||||
|
}
|
||||||
@ -77,6 +77,10 @@
|
|||||||
<groupId>cn.axzo.basics</groupId>
|
<groupId>cn.axzo.basics</groupId>
|
||||||
<artifactId>basics-common</artifactId>
|
<artifactId>basics-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.axzo.framework.data</groupId>
|
||||||
|
<artifactId>axzo-data-mybatis-plus</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.axzo.workflow</groupId>
|
<groupId>cn.axzo.workflow</groupId>
|
||||||
<artifactId>workflow-engine-api</artifactId>
|
<artifactId>workflow-engine-api</artifactId>
|
||||||
|
|||||||
@ -0,0 +1,74 @@
|
|||||||
|
package cn.axzo.tyr.server.controller;
|
||||||
|
|
||||||
|
import cn.axzo.framework.domain.web.result.ApiPageResult;
|
||||||
|
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||||
|
import cn.axzo.tyr.client.feign.DataResourceApi;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.CreateDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.DataResourceSaasFeatureParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.DeleteDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.GetSaasFeatureDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.PageDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.SearchDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.UpdateDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.resp.DataResourceResp;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.resp.PageDataResourceResp;
|
||||||
|
import cn.axzo.tyr.server.service.DataResourceService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据资源相关接口
|
||||||
|
*
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/13
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DataResourceController implements DataResourceApi {
|
||||||
|
private final DataResourceService dataResourceService;
|
||||||
|
@Override
|
||||||
|
public ApiResult<Void> create(CreateDataResourceParam param) {
|
||||||
|
dataResourceService.create(param);
|
||||||
|
return ApiResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiResult<Boolean> update(UpdateDataResourceParam param) {
|
||||||
|
return ApiResult.ok(dataResourceService.update(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiResult<Boolean> delete(DeleteDataResourceParam param) {
|
||||||
|
return ApiResult.ok(dataResourceService.delete(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiPageResult<PageDataResourceResp> page(PageDataResourceParam param) {
|
||||||
|
return ApiPageResult.ok(dataResourceService.page(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiResult<List<DataResourceResp>> list(SearchDataResourceParam param) {
|
||||||
|
return ApiResult.ok(dataResourceService.list(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiResult<Void> createDataResourceSaasFeature(DataResourceSaasFeatureParam param) {
|
||||||
|
dataResourceService.createDataResourceSaasFeature(param);
|
||||||
|
return ApiResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiResult<Boolean> deleteDataResourceSaasFeature(DataResourceSaasFeatureParam param) {
|
||||||
|
return ApiResult.ok(dataResourceService.deleteDataResourceSaasFeature(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiResult<List<DataResourceResp>> getSaasFeatureDataResource(GetSaasFeatureDataResourceParam param) {
|
||||||
|
return ApiResult.ok(dataResourceService.getSaasFeatureDataResource(param));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package cn.axzo.tyr.server.repository.dao;
|
||||||
|
|
||||||
|
import cn.axzo.tyr.server.repository.entity.DataResource;
|
||||||
|
import cn.axzo.tyr.server.repository.mapper.DataResourceMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public class DataResourceDao extends ServiceImpl<DataResourceMapper, DataResource> {
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package cn.axzo.tyr.server.repository.dao;
|
||||||
|
|
||||||
|
import cn.axzo.tyr.server.repository.entity.SaasFeatureDataResource;
|
||||||
|
import cn.axzo.tyr.server.repository.mapper.SaasFeatureDataResourceMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public class SaasFeatureDataResourceDao extends ServiceImpl<SaasFeatureDataResourceMapper, SaasFeatureDataResource> {
|
||||||
|
}
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
package cn.axzo.tyr.server.repository.entity;
|
||||||
|
|
||||||
|
import cn.axzo.framework.data.mybatisplus.model.BaseEntity;
|
||||||
|
import cn.axzo.tyr.client.common.enums.DataResourceModuleEnum;
|
||||||
|
import cn.axzo.tyr.client.common.enums.DataResourceTypeEnum;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.DataResourceAttrs;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.ResourceScope;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/9
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName(value = "data_resource", autoResultMap = true)
|
||||||
|
public class DataResource extends BaseEntity<DataResource> implements Serializable {
|
||||||
|
/**
|
||||||
|
* 数据资源名称
|
||||||
|
*/
|
||||||
|
@TableField("name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块名称 eg. 企业:ENTERPRISE, 项目:PROJECT
|
||||||
|
* @see DataResourceModuleEnum
|
||||||
|
*/
|
||||||
|
@TableField("module")
|
||||||
|
private DataResourceModuleEnum module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据资源code
|
||||||
|
*/
|
||||||
|
@TableField("resource_code")
|
||||||
|
private String resourceCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对象属性例如:[{"attr": "name", "label": "名字"}]
|
||||||
|
*/
|
||||||
|
@TableField(value = "attrs", typeHandler = FastjsonTypeHandler.class)
|
||||||
|
private List<DataResourceAttrs> attrs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据范围
|
||||||
|
*/
|
||||||
|
@TableField(value = "resource_scope", typeHandler = FastjsonTypeHandler.class)
|
||||||
|
private List<ResourceScope> resourceScope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据对象类型0:主对象1:子对象
|
||||||
|
*/
|
||||||
|
@TableField("type")
|
||||||
|
private DataResourceTypeEnum type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据对象code
|
||||||
|
*/
|
||||||
|
@TableField(value = "ext", typeHandler = FastjsonTypeHandler.class)
|
||||||
|
private Map ext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父对象ID
|
||||||
|
*/
|
||||||
|
@TableField("parent_id")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package cn.axzo.tyr.server.repository.entity;
|
||||||
|
|
||||||
|
import cn.axzo.framework.data.mybatisplus.model.BaseEntity;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName(value = "saas_feature_data_resource", autoResultMap = true)
|
||||||
|
public class SaasFeatureDataResource extends BaseEntity<SaasFeatureDataResource> implements Serializable {
|
||||||
|
/**
|
||||||
|
* featureCode
|
||||||
|
*/
|
||||||
|
@TableField("feature_code")
|
||||||
|
private String featureCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据资源code
|
||||||
|
*/
|
||||||
|
@TableField("resource_code")
|
||||||
|
private String resourceCode;
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package cn.axzo.tyr.server.repository.mapper;
|
||||||
|
|
||||||
|
import cn.axzo.tyr.server.repository.entity.DataResource;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DataResourceMapper extends BaseMapper<DataResource> {
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package cn.axzo.tyr.server.repository.mapper;
|
||||||
|
|
||||||
|
import cn.axzo.tyr.server.repository.entity.SaasFeatureDataResource;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SaasFeatureDataResourceMapper extends BaseMapper<SaasFeatureDataResource> {
|
||||||
|
}
|
||||||
@ -0,0 +1,82 @@
|
|||||||
|
package cn.axzo.tyr.server.service;
|
||||||
|
|
||||||
|
import cn.axzo.framework.domain.page.PageResp;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.CreateDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.DataResourceSaasFeatureParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.DeleteDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.GetSaasFeatureDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.PageDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.SearchDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.UpdateDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.resp.DataResourceResp;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.resp.PageDataResourceResp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
public interface DataResourceService {
|
||||||
|
/**
|
||||||
|
* 创建数据资源
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
*/
|
||||||
|
void create(CreateDataResourceParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据资源
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean delete(DeleteDataResourceParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据资源列表
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DataResourceResp> list(SearchDataResourceParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据资源分页
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PageResp<PageDataResourceResp> page(PageDataResourceParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据资源更新
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean update(UpdateDataResourceParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建数据资源和featureCode关联关系
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
*/
|
||||||
|
void createDataResourceSaasFeature(DataResourceSaasFeatureParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据资源和featureCode关联关系
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean deleteDataResourceSaasFeature(DataResourceSaasFeatureParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取featureCode关联的数据资源
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DataResourceResp> getSaasFeatureDataResource(GetSaasFeatureDataResourceParam param);
|
||||||
|
}
|
||||||
@ -0,0 +1,175 @@
|
|||||||
|
package cn.axzo.tyr.server.service.impl;
|
||||||
|
|
||||||
|
import cn.axzo.basics.common.BeanMapper;
|
||||||
|
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
|
||||||
|
import cn.axzo.framework.domain.page.PageResp;
|
||||||
|
import cn.axzo.framework.domain.web.code.BaseCode;
|
||||||
|
import cn.axzo.tyr.client.common.enums.DataResourceTypeEnum;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.CreateDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.DataResourceSaasFeatureParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.DeleteDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.GetSaasFeatureDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.PageDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.SearchDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.req.UpdateDataResourceParam;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.resp.DataResourceResp;
|
||||||
|
import cn.axzo.tyr.client.model.dataresource.resp.PageDataResourceResp;
|
||||||
|
import cn.axzo.tyr.server.common.util.Throws;
|
||||||
|
import cn.axzo.tyr.server.repository.dao.DataResourceDao;
|
||||||
|
import cn.axzo.tyr.server.repository.dao.SaasFeatureDao;
|
||||||
|
import cn.axzo.tyr.server.repository.dao.SaasFeatureDataResourceDao;
|
||||||
|
import cn.axzo.tyr.server.repository.entity.DataResource;
|
||||||
|
import cn.axzo.tyr.server.repository.entity.SaasFeature;
|
||||||
|
import cn.axzo.tyr.server.repository.entity.SaasFeatureDataResource;
|
||||||
|
import cn.axzo.tyr.server.service.DataResourceService;
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author haiyangjin
|
||||||
|
* @date 2024/1/15
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class DataResourceServiceImpl implements DataResourceService {
|
||||||
|
private final DataResourceDao dataResourceDao;
|
||||||
|
private final SaasFeatureDao saasFeatureDao;
|
||||||
|
private final SaasFeatureDataResourceDao saasFeatureDataResourceDao;
|
||||||
|
@Override
|
||||||
|
public void create(CreateDataResourceParam param) {
|
||||||
|
DataResource existDataResource = dataResourceDao.lambdaQuery()
|
||||||
|
.eq(DataResource::getResourceCode, param.getResourceCode())
|
||||||
|
.eq(DataResource::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||||
|
.last("limit 1")
|
||||||
|
.one();
|
||||||
|
if (Objects.nonNull(existDataResource)) {
|
||||||
|
Throws.bizException(BaseCode.BAD_REQUEST, "数据对象code已经存在!");
|
||||||
|
}
|
||||||
|
DataResource dataResource = new DataResource();
|
||||||
|
BeanUtils.copyProperties(param, dataResource);
|
||||||
|
|
||||||
|
if (param.getParentId() > 0) {
|
||||||
|
DataResource parent = dataResourceDao.getById(param.getParentId());
|
||||||
|
if (Objects.isNull(parent)) {
|
||||||
|
Throws.bizException(BaseCode.BAD_REQUEST, "数据对象不存在!");
|
||||||
|
}
|
||||||
|
dataResource.setType(DataResourceTypeEnum.SUB_OBJECT);
|
||||||
|
}
|
||||||
|
|
||||||
|
dataResourceDao.save(dataResource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(DeleteDataResourceParam param) {
|
||||||
|
DataResource dataResource = dataResourceDao.getById(param.getId());
|
||||||
|
if (Objects.nonNull(dataResource)) {
|
||||||
|
List<SaasFeatureDataResource> saasFeatureDataResources = saasFeatureDataResourceDao.lambdaQuery()
|
||||||
|
.eq(SaasFeatureDataResource::getResourceCode, dataResource.getResourceCode())
|
||||||
|
.eq(SaasFeatureDataResource::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||||
|
.list();
|
||||||
|
if (CollectionUtils.isNotEmpty(saasFeatureDataResources)) {
|
||||||
|
Throws.bizException(BaseCode.BAD_REQUEST, "该数据资源和功能权限有关联不能删除!");
|
||||||
|
}
|
||||||
|
dataResourceDao.removeById(dataResource.getId());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DataResourceResp> list(SearchDataResourceParam param) {
|
||||||
|
List<DataResource> dataResources = dataResourceDao.lambdaQuery()
|
||||||
|
.in(CollectionUtils.isNotEmpty(param.getResourceCodes()), DataResource::getResourceCode, param.getResourceCodes())
|
||||||
|
.list();
|
||||||
|
return BeanUtil.copyToList(dataResources, DataResourceResp.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResp<PageDataResourceResp> page(PageDataResourceParam param) {
|
||||||
|
IPage<DataResource> page = dataResourceDao.lambdaQuery()
|
||||||
|
.like(Objects.nonNull(param.getName()), DataResource::getName, param.getName())
|
||||||
|
.eq(CollectionUtils.isNotEmpty(param.getResourceCodes()), DataResource::getResourceCode, param.getResourceCodes())
|
||||||
|
.eq(Objects.nonNull(param.getModule()), DataResource::getModule, param.getModule())
|
||||||
|
.eq(Objects.nonNull(param.getType()), DataResource::getType, param.getType())
|
||||||
|
.eq(Objects.nonNull(param.getParentId()), DataResource::getParentId, param.getParentId())
|
||||||
|
.page(param.toPage());
|
||||||
|
List<PageDataResourceResp> list = BeanMapper.copyList(page.getRecords(), PageDataResourceResp.class);
|
||||||
|
return PageResp.list(page.getCurrent(), page.getSize(), page.getTotal(), list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(UpdateDataResourceParam param) {
|
||||||
|
DataResource dataResource = new DataResource();
|
||||||
|
BeanUtils.copyProperties(param, dataResource);
|
||||||
|
return dataResourceDao.updateById(dataResource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createDataResourceSaasFeature(DataResourceSaasFeatureParam param) {
|
||||||
|
DataResource existDataResource = dataResourceDao.lambdaQuery()
|
||||||
|
.eq(DataResource::getResourceCode, param.getResourceCode())
|
||||||
|
.eq(DataResource::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||||
|
.last("limit 1")
|
||||||
|
.one();
|
||||||
|
if (Objects.isNull(existDataResource)) {
|
||||||
|
Throws.bizException(BaseCode.BAD_REQUEST, "数据对象不存在!");
|
||||||
|
}
|
||||||
|
List<String> existFeatureCodes = saasFeatureDataResourceDao.lambdaQuery()
|
||||||
|
.eq(SaasFeatureDataResource::getResourceCode, param.getResourceCode())
|
||||||
|
.in(SaasFeatureDataResource::getFeatureCode, param.getFeatureCodes())
|
||||||
|
.eq(SaasFeatureDataResource::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(SaasFeatureDataResource::getFeatureCode)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
param.getFeatureCodes().removeAll(existFeatureCodes);
|
||||||
|
if (CollectionUtils.isEmpty(param.getFeatureCodes())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<SaasFeature> saasFeatures = saasFeatureDao.lambdaQuery()
|
||||||
|
.in(SaasFeature::getFeatureCode, param.getFeatureCodes())
|
||||||
|
.eq(SaasFeature::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||||
|
.list();
|
||||||
|
|
||||||
|
Set<SaasFeatureDataResource> saasFeatureDataResources = saasFeatures.stream().map(e -> SaasFeatureDataResource.builder()
|
||||||
|
.resourceCode(param.getResourceCode())
|
||||||
|
.featureCode(e.getFeatureCode())
|
||||||
|
.build()).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
saasFeatureDataResourceDao.saveBatch(saasFeatureDataResources);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteDataResourceSaasFeature(DataResourceSaasFeatureParam param) {
|
||||||
|
return saasFeatureDataResourceDao.remove(new LambdaQueryWrapper<SaasFeatureDataResource>()
|
||||||
|
.eq(SaasFeatureDataResource::getResourceCode, param.getResourceCode())
|
||||||
|
.in(SaasFeatureDataResource::getFeatureCode, param.getFeatureCodes()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DataResourceResp> getSaasFeatureDataResource(GetSaasFeatureDataResourceParam param) {
|
||||||
|
Set<String> dataResourceCodes = saasFeatureDataResourceDao.lambdaQuery()
|
||||||
|
.eq(SaasFeatureDataResource::getFeatureCode, param.getFeatureCode())
|
||||||
|
.eq(SaasFeatureDataResource::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||||
|
.list()
|
||||||
|
.stream().map(SaasFeatureDataResource::getResourceCode).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
List<DataResource> dataResources = dataResourceDao.lambdaQuery()
|
||||||
|
.in(DataResource::getResourceCode, dataResourceCodes)
|
||||||
|
.eq(DataResource::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||||
|
.list();
|
||||||
|
return BeanUtil.copyToList(dataResources, DataResourceResp.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user