Merge remote-tracking branch 'origin/feature/REQ-1102' into feature/REQ-1102
This commit is contained in:
commit
2281bc3552
@ -0,0 +1,28 @@
|
||||
package cn.axzo.tyr.client.common.annotation;
|
||||
|
||||
import cn.axzo.tyr.client.common.validator.EnumValueValidator;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/8/29 18:31
|
||||
* @description:
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Documented
|
||||
@Constraint(validatedBy = EnumValueValidator.class)
|
||||
@Target({ElementType.FIELD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface EnumValidator {
|
||||
String message() default "Value is not valid";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
|
||||
Class<? extends Enum<?>> enumClass();
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
package cn.axzo.tyr.client.common.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/8 15:12
|
||||
* @description: 字典type字段枚举
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
|
||||
public enum DictTypeFiledEnum {
|
||||
|
||||
/**
|
||||
* 企业类型
|
||||
*/
|
||||
OUTYPE("ou_type","企业类型"),
|
||||
|
||||
/**
|
||||
* 端
|
||||
*/
|
||||
TERMINAL("terminal","端"),
|
||||
|
||||
/**
|
||||
* 工作台
|
||||
*/
|
||||
WORKSPACE("workspace","工作台")
|
||||
;
|
||||
|
||||
private final String value;
|
||||
|
||||
private final String description;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
DictTypeFiledEnum(String value, String description) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过value值获取枚举类型
|
||||
*
|
||||
* @param value value值
|
||||
* @return
|
||||
*/
|
||||
public static DictTypeFiledEnum getByValue(String value) {
|
||||
return Arrays.stream(values()).filter(l -> l.getValue().equals(value)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package cn.axzo.tyr.client.common.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/8 14:21
|
||||
* @description: 字典工作台类型枚举
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
public enum DictWorkSpaceTypeEnum {
|
||||
|
||||
/**
|
||||
* 企业工作台
|
||||
*/
|
||||
ENT("ent", "企业工作台"),
|
||||
|
||||
/**
|
||||
* 项目部工作台
|
||||
*/
|
||||
PROJ("proj", "项目部工作台"),
|
||||
|
||||
/**
|
||||
* OMS工作台
|
||||
*/
|
||||
OMS("oms", "OMS工作台");
|
||||
|
||||
private final String value;
|
||||
|
||||
private final String description;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
DictWorkSpaceTypeEnum(String value, String description) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过value值获取枚举类型
|
||||
*
|
||||
* @param value value值
|
||||
* @return
|
||||
*/
|
||||
public static DictWorkSpaceTypeEnum getByValue(String value) {
|
||||
return Arrays.stream(values()).filter(l -> l.getValue().equals(value)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
package cn.axzo.tyr.client.common.util;
|
||||
@ -0,0 +1,34 @@
|
||||
package cn.axzo.tyr.client.common.validator;
|
||||
|
||||
|
||||
import cn.axzo.tyr.client.common.annotation.EnumValidator;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/8/29 18:24
|
||||
* @description:
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class EnumValueValidator implements ConstraintValidator<EnumValidator, Enum<?>> {
|
||||
|
||||
@Override
|
||||
public boolean isValid(Enum<?> value, ConstraintValidatorContext context) {
|
||||
if (value == null) {
|
||||
return true;
|
||||
}
|
||||
Class<? extends Enum<?>> enumClass = value.getDeclaringClass();
|
||||
Enum<?>[] enumValues = enumClass.getEnumConstants();
|
||||
for (Enum<?> enumValue : enumValues) {
|
||||
if (enumValue.name().equals(value.name())) {
|
||||
// 找到匹配的枚举值
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// 未找到匹配的枚举值
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
package cn.axzo.tyr.client.feign;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictCreateReq;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictQueryReq;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictUpdateReq;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictUpdateStatusReq;
|
||||
import cn.axzo.tyr.client.model.dict.response.BasicDictNodeResp;
|
||||
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: chenwenjian
|
||||
* @date: 2023/9/6 15:33
|
||||
* @description: 企业字典api
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@FeignClient(name = "tyr", url = "http://tyr:8080")
|
||||
public interface SaasBasicDictApi {
|
||||
|
||||
/**
|
||||
* 获取字典树所有节点
|
||||
*
|
||||
* @param req 根据自身需求传入参数
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("api/dict/node-list")
|
||||
ApiResult<List<BasicDictNodeResp>> getBasicDictNodeList(@RequestBody BasicDictQueryReq req);
|
||||
|
||||
/**
|
||||
* 添加字典
|
||||
*
|
||||
* @param req 其中name同一个父级节点,名称不能重复,codeMap全局唯一
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("api/dict/create")
|
||||
ApiResult<Long> create(@RequestBody @Validated BasicDictCreateReq req);
|
||||
|
||||
/**
|
||||
* 编辑字典
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("api/dict/update")
|
||||
ApiResult<Boolean> update(@RequestBody @Validated BasicDictUpdateReq req);
|
||||
|
||||
/**
|
||||
* 更新字典状态
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/update-status")
|
||||
ApiResult<Boolean> updateStatus(@RequestBody @Validated BasicDictUpdateStatusReq req);
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package cn.axzo.tyr.client.model.dict.request;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/6 14:44
|
||||
* @description: 添加字典请求入参
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class BasicDictCreateReq {
|
||||
|
||||
/**
|
||||
* 工作台类型,"ent", "proj", "oms"
|
||||
*/
|
||||
@NotBlank(message = "工作台类型不能为空")
|
||||
private String workspaceType;
|
||||
|
||||
/**
|
||||
* 类型,"ouType", "terminal"
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 所属上级节点id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@NotBlank(message = "字典名称不能为空")
|
||||
@Length(max = 35, message = "字典名称长度不能超过35字符")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 编码code
|
||||
*/
|
||||
@NotBlank(message = "code不能为空")
|
||||
private String code;
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package cn.axzo.tyr.client.model.dict.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/6 15:46
|
||||
* @description:
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class BasicDictNodeReq {
|
||||
|
||||
/**
|
||||
* 工作台类型
|
||||
*/
|
||||
@NotBlank(message = "工作台类型不能为空")
|
||||
private String workspaceType;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@NotBlank(message = "类型不能为空")
|
||||
private String type;
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package cn.axzo.tyr.client.model.dict.request;
|
||||
|
||||
import cn.axzo.tyr.client.common.annotation.EnumValidator;
|
||||
import cn.axzo.tyr.client.common.enums.DictTypeFiledEnum;
|
||||
import cn.axzo.tyr.client.common.enums.DictWorkSpaceTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/6 14:02
|
||||
* @description: 获取企业字典树请求入参
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class BasicDictQueryReq {
|
||||
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* workspace
|
||||
*/
|
||||
@EnumValidator(enumClass = DictWorkSpaceTypeEnum.class, message = "枚举类型错误")
|
||||
private DictWorkSpaceTypeEnum workspaceType;
|
||||
|
||||
/**
|
||||
* type
|
||||
*/
|
||||
@EnumValidator(enumClass = DictTypeFiledEnum.class, message = "枚举类型错误")
|
||||
private DictTypeFiledEnum type;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字典code
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Boolean status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.axzo.tyr.client.model.dict.request;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/6 15:00
|
||||
* @description: 编辑请求入参
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class BasicDictUpdateReq {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@NotBlank(message = "字典名称不能为空")
|
||||
@Length(max = 35, message = "字典名称长度不能超过35字符")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package cn.axzo.tyr.client.model.dict.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/6 15:04
|
||||
* @description: 状态更改请求入参
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class BasicDictUpdateStatusReq {
|
||||
|
||||
/**
|
||||
* 节点id
|
||||
*/
|
||||
@NotNull(message = "节点id不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 状态,true启用,false禁用
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Boolean status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package cn.axzo.tyr.client.model.dict.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/6 15:39
|
||||
* @description:
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class BasicDictNodeResp {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 工作台类型,"ent", "proj", "oms"
|
||||
*/
|
||||
private String workspaceType;
|
||||
|
||||
/**
|
||||
* 类型,"ouType", "terminal"
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字典code
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 唯一code
|
||||
*/
|
||||
private String uniqueCode;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 层级
|
||||
*/
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 扩展字段
|
||||
*/
|
||||
private String ext;
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package cn.axzo.tyr.client.model.dict.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/6 14:08
|
||||
* @description:
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class BasicDictTreeResp {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字典code
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 当前节点下子节点
|
||||
*/
|
||||
private List<BasicDictTreeResp> children;
|
||||
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package cn.axzo.maven.archetype.client;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class AppTest {
|
||||
|
||||
}
|
||||
@ -14,4 +14,8 @@ public class PermissionConstant {
|
||||
|
||||
/** 无父级 **/
|
||||
public static final String FEATURE_NO_PARENT = "0";
|
||||
/** 顶级path **/
|
||||
public static final String FEATURE_TOP_PATH = "/0/";
|
||||
/** 权限点business_no前缀 **/
|
||||
public static final String FEATURE_BIZ_NO_PREFIX = "feature";
|
||||
}
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
package cn.axzo.tyr.server.common.enums;
|
||||
|
||||
import cn.axzo.framework.domain.web.code.IProjectRespCode;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/5
|
||||
* @Description: 响应码规范:一共8位,取值范围0~9,3位项目编号(首位不能为0)+2位模块编号+3位自定义编号
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ErrorCode implements IProjectRespCode {
|
||||
|
||||
USER_NOT_EXISTS("01001", "用户不存在,id=%s"),
|
||||
USER_PHONE_EMAIL_IS_NULL("01002", "电话和邮箱不能都为空");
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
@Override
|
||||
public String getProjectCode() {
|
||||
// 根据不同项目进行项目编码调整,可联系框架组获取项目编号(首位不能为0)
|
||||
return "100";
|
||||
}
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
package cn.axzo.tyr.server.common.enums;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/5
|
||||
* @Description:
|
||||
*/
|
||||
public enum ResultCode {
|
||||
/**
|
||||
* 成功 [GET]
|
||||
*/
|
||||
SUCCESS(200),
|
||||
/**
|
||||
* [POST/PUT/PATCH] 用户新建或修改数据成功
|
||||
*/
|
||||
CREATED(201),
|
||||
/**
|
||||
* [*] 标识一个请求已经进入后台排队 (异步任务)
|
||||
*/
|
||||
ACCEPTED(202),
|
||||
/**
|
||||
* [DELETE]: 用户删除数据成功
|
||||
*/
|
||||
NO_CONTENT(204),
|
||||
/**
|
||||
* [POST/PUT/PATCH] 用户发出的请求有错误, 服务器没有进行新建或修改数据的操作, 该操作是幂等的.
|
||||
*/
|
||||
FAIL(400),
|
||||
/**
|
||||
* [*] 标识没有权限 (令牌、用户名、密码错误)
|
||||
*/
|
||||
UNAUTHORIZED(401),
|
||||
/**
|
||||
* [*] 标识用户得到授权(与401错误相对), 但是访问是被禁止的
|
||||
*/
|
||||
FORBIDDEN(403),
|
||||
/**
|
||||
* [*] 用户发出的请求针对的是不存在的记录, 服务器没有进行操作
|
||||
*/
|
||||
NOT_FOUND(404),
|
||||
/**
|
||||
* [GET] 用户请求的格式不可得 (比如用户请求JSON格式, 但是只有XML格式)
|
||||
*/
|
||||
NOT_ACCEPTABLE(406),
|
||||
/**
|
||||
* [GET] 用户请求的资源被永久删除, 且不会再得到
|
||||
*/
|
||||
GONE(410),
|
||||
/**
|
||||
* [POST/PUT/PATCH] 当创建一个对象时, 发生一个验证错误646
|
||||
*/
|
||||
UNPROCESSABLE_ENTITY(422),
|
||||
/**
|
||||
* 服务器内部错误
|
||||
*/
|
||||
INTERNAL_SERVER_ERROR(9999),
|
||||
/**
|
||||
* 通用业务异常
|
||||
*/
|
||||
SERVICE_EXCEPTION_ERROR(9998),
|
||||
|
||||
/**
|
||||
* ####业务的响应码####
|
||||
* 按业务依次划分 :
|
||||
* 一共6位, 第6位是业务代码 第1-5位响应码, 按业务不同码不同
|
||||
* #100000 全局级别
|
||||
*/
|
||||
|
||||
/**
|
||||
* 100001 当前用户被强制下线
|
||||
*/
|
||||
CUSTOM_100001(100001),
|
||||
/**
|
||||
* 确认弹窗响应码
|
||||
*/
|
||||
CUSTOM_100002(100002);
|
||||
|
||||
public int code;
|
||||
|
||||
ResultCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
package cn.axzo.tyr.server.common.util;
|
||||
@ -1 +0,0 @@
|
||||
package cn.axzo.tyr.server.consumer;
|
||||
@ -0,0 +1,50 @@
|
||||
package cn.axzo.tyr.server.controller;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.feign.SaasBasicDictApi;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictCreateReq;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictQueryReq;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictUpdateReq;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictUpdateStatusReq;
|
||||
import cn.axzo.tyr.client.model.dict.response.BasicDictNodeResp;
|
||||
import cn.axzo.tyr.server.service.SaasBasicDictService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/8 14:32
|
||||
* @description:
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class SaasBasicDictController implements SaasBasicDictApi {
|
||||
|
||||
private final SaasBasicDictService saasBasicDictService;
|
||||
|
||||
@Override
|
||||
public ApiResult<List<BasicDictNodeResp>> getBasicDictNodeList(BasicDictQueryReq req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Long> create(BasicDictCreateReq req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Boolean> update(BasicDictUpdateReq req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Boolean> updateStatus(BasicDictUpdateStatusReq req) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
package cn.axzo.tyr.server.job;
|
||||
@ -0,0 +1,18 @@
|
||||
package cn.axzo.tyr.server.repository;
|
||||
|
||||
import cn.axzo.tyr.server.repository.entity.SaasBasicDict;
|
||||
import cn.axzo.tyr.server.repository.mapper.SaasBasicDictMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/7 17:43
|
||||
* @description:
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class SaasBasicDictDao extends ServiceImpl<SaasBasicDictMapper, SaasBasicDict> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
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 com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/7 17:39
|
||||
* @description: 字典实体类
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("saas_basic_dict")
|
||||
public class SaasBasicDict extends BaseEntity<SaasBasicDict> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 100L;
|
||||
|
||||
/**
|
||||
* 父节点id
|
||||
*/
|
||||
@TableField(value = "parent_id")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 工作台类型,"ent", "proj", "oms"
|
||||
*/
|
||||
@TableField(value = "workspace_type")
|
||||
private String workspaceType;
|
||||
|
||||
/**
|
||||
* 类型,"ouType", "terminal"
|
||||
*/
|
||||
@TableField(value = "type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* code
|
||||
*/
|
||||
@TableField(value = "code")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 唯一code
|
||||
*/
|
||||
@TableField(value = "unique_code")
|
||||
private String uniqueCode;
|
||||
|
||||
/**
|
||||
* 状态,0禁用,1启用
|
||||
*/
|
||||
@TableField(value = "status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField(value = "sort")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 层级
|
||||
*/
|
||||
@TableField(value = "level")
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
@TableField(value = "path")
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 扩展信息
|
||||
*/
|
||||
@TableField(value = "ex", typeHandler = JacksonTypeHandler.class)
|
||||
private Map<String, String> ext;
|
||||
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
package cn.axzo.tyr.server.repository.entity;
|
||||
@ -0,0 +1,17 @@
|
||||
package cn.axzo.tyr.server.repository.mapper;
|
||||
|
||||
import cn.axzo.tyr.server.repository.entity.SaasBasicDict;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/7 17:41
|
||||
* @description:
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface SaasBasicDictMapper extends BaseMapper<SaasBasicDict> {
|
||||
|
||||
}
|
||||
@ -15,7 +15,7 @@ import org.apache.ibatis.annotations.Update;
|
||||
public interface SaasFeatureMapper extends BaseMapper<SaasFeature> {
|
||||
|
||||
@Update("UPDATE saas_feature " +
|
||||
"SET path = REPLACE(path,#{pathPrefix}, #{newPathPrefix}) , update_by = #{updater}" +
|
||||
"SET path = REPLACE(path,#{pathPrefix}, #{newPathPrefix}) , update_by = #{updater} " +
|
||||
"WHERE path LIKE CONCAT(#{pathPrefix},'%') ")
|
||||
void updateChildrenPath(Long updater, String pathPrefix, String newPathPrefix);
|
||||
}
|
||||
@ -3,7 +3,10 @@ package cn.axzo.tyr.server.repository.service.impl;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeature;
|
||||
import cn.axzo.tyr.server.repository.mapper.SaasFeatureMapper;
|
||||
import cn.axzo.tyr.server.repository.service.SaasFeatureDao;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -31,7 +34,7 @@ public class SaasFeatureDaoImpl extends ServiceImpl<SaasFeatureMapper, SaasFeatu
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSort(Long permissionId, int switchIndex) {
|
||||
|
||||
public void updateSort(Long permissionId, int sort) {
|
||||
this.update(new LambdaUpdateWrapper<SaasFeature>().set(SaasFeature::getSort, sort).eq(SaasFeature::getId, permissionId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package cn.axzo.tyr.server.service;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/7 17:54
|
||||
* @description:
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
public interface SaasBasicDictService {
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.converter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/5
|
||||
* @Description:
|
||||
*/
|
||||
public interface EntityConverter<V, E>{
|
||||
|
||||
V toVo(E var);
|
||||
|
||||
List<V> toVo(List<E> var);
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.dto.request;
|
||||
@ -1 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.dto.response;
|
||||
@ -1 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.event;
|
||||
@ -28,8 +28,10 @@ import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.axzo.tyr.server.common.constants.PermissionConstant.FEATURE_BIZ_NO_PREFIX;
|
||||
import static cn.axzo.tyr.server.common.constants.PermissionConstant.FEATURE_NO_PARENT;
|
||||
import static cn.axzo.tyr.server.common.constants.PermissionConstant.FEATURE_PATH_DELIMITER;
|
||||
import static cn.axzo.tyr.server.common.constants.PermissionConstant.FEATURE_TOP_PATH;
|
||||
|
||||
/**
|
||||
* 权限点服务实现
|
||||
@ -173,12 +175,50 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
||||
|
||||
@Override
|
||||
public void save(PermissionPointDTO dto) {
|
||||
SaasFeature saasFeature = BeanMapper.copyBean(dto, SaasFeature.class);
|
||||
if (dto.getId() == null) {
|
||||
this.saasFeatureDao.save(saasFeature);
|
||||
doInsert(dto);
|
||||
} else {
|
||||
this.saasFeatureDao.updateById(saasFeature);
|
||||
doUpdate(dto);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void doUpdate(PermissionPointDTO dto) {
|
||||
SaasFeature feature = getAndCheck(dto.getId());
|
||||
SaasFeature saasFeature = BeanMapper.copyBean(dto, SaasFeature.class);
|
||||
//清理不可更新的数据
|
||||
saasFeature.setFeatureCode(null);
|
||||
saasFeature.setParentId(null);
|
||||
saasFeature.setPath(null);
|
||||
saasFeature.setSort(null);
|
||||
saasFeature.setTerminal(null);
|
||||
this.saasFeatureDao.updateById(saasFeature);
|
||||
}
|
||||
|
||||
private SaasFeature getAndCheck(Long permissionId) {
|
||||
SaasFeature feature = this.saasFeatureDao.getById(permissionId);
|
||||
if (feature == null) {
|
||||
log.error("未查询到权限点:{}", permissionId);
|
||||
throw new BizException(BaseCode.BAD_REQUEST, "未查询到权限点");
|
||||
}
|
||||
return feature;
|
||||
}
|
||||
|
||||
private void doInsert(PermissionPointDTO dto) {
|
||||
SaasFeature saasFeature = BeanMapper.copyBean(dto, SaasFeature.class);
|
||||
SaasFeature parent;
|
||||
if (dto.getParentId() == null || dto.getParentId() < 1) {
|
||||
parent = new SaasFeature();
|
||||
parent.setPath(FEATURE_TOP_PATH);
|
||||
parent.setBusinessNo("0");
|
||||
} else {
|
||||
parent = this.saasFeatureDao.getById(dto.getParentId());
|
||||
}
|
||||
//生成biz_no
|
||||
saasFeature.setBusinessNo(FEATURE_BIZ_NO_PREFIX + System.currentTimeMillis());
|
||||
saasFeature.setParentBusinessNo(parent.getBusinessNo());
|
||||
saasFeature.setPath(parent.getPath() + parent.getId() + FEATURE_PATH_DELIMITER);
|
||||
this.saasFeatureDao.save(saasFeature);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@ -197,7 +237,7 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
||||
return;
|
||||
}
|
||||
SaasFeature parent = this.saasFeatureDao.getById(newParentId);
|
||||
if (StrUtil.equals(feature.getTerminal(), parent.getTerminal())) {
|
||||
if (!StrUtil.equals(feature.getTerminal(), parent.getTerminal())) {
|
||||
throw new BizException(BaseCode.BAD_REQUEST, "不允许跨工作台");
|
||||
}
|
||||
if (parent.getPath().contains(String.valueOf(permissionId))) {
|
||||
@ -205,8 +245,9 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
||||
}
|
||||
//当前节点
|
||||
SaasFeature entity = new SaasFeature();
|
||||
entity.setParentId(feature.getId());
|
||||
entity.setId(feature.getId());
|
||||
entity.setParentId(newParentId);
|
||||
entity.setParentBusinessNo(parent.getBusinessNo());
|
||||
entity.setPath(parent.getPath() + parent.getId() + FEATURE_PATH_DELIMITER);
|
||||
entity.setUpdateBy(updater);
|
||||
this.saasFeatureDao.updateById(entity);
|
||||
@ -235,14 +276,14 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
||||
//已经是第一个
|
||||
return;
|
||||
}
|
||||
switchIndex = ++index;
|
||||
switchIndex = index - 1;
|
||||
} else {
|
||||
//向下
|
||||
if (index == sortedChildren.size() - 1) {
|
||||
//已经最后一个
|
||||
return;
|
||||
}
|
||||
switchIndex = --index;
|
||||
switchIndex = index + 1;
|
||||
}
|
||||
//更新当前节点
|
||||
this.saasFeatureDao.updateSort(permissionId, switchIndex);
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package cn.axzo.tyr.server.service.impl;
|
||||
|
||||
import cn.axzo.tyr.server.repository.SaasBasicDictDao;
|
||||
import cn.axzo.tyr.server.service.SaasBasicDictService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/8 15:40
|
||||
* @description:
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SaasBasicDictServiceImpl implements SaasBasicDictService {
|
||||
|
||||
private final SaasBasicDictDao saasBasicDictDao;
|
||||
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.manager;
|
||||
@ -1 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.validator;
|
||||
@ -1,14 +0,0 @@
|
||||
package cn.axzo.tyr.server;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class AppTest {
|
||||
|
||||
}
|
||||
@ -60,4 +60,62 @@ public class PermissionPointTest {
|
||||
System.out.println(JSON.toJSONString(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsert() {
|
||||
PermissionPointDTO permissionPoint = new PermissionPointDTO();
|
||||
permissionPoint.setFeatureName("测试合同权限点");
|
||||
permissionPoint.setFeatureCode("CMS_WEB_PROJ_0158");
|
||||
permissionPoint.setParentId(360L);
|
||||
permissionPoint.setPath("/0/354/360/");
|
||||
permissionPoint.setSort(6);
|
||||
permissionPoint.setTerminal("NT_CMS_WEB_PROJ");
|
||||
permissionPoint.setFeatureType(3);
|
||||
permissionPoint.setAppName("tyr");
|
||||
permissionPoint.setFeatureUrl("/tyr/test/permission");
|
||||
permissionPoint.setNeedAuth(true);
|
||||
permissionPoint.setNeedAuth(true);
|
||||
controller.savePermissionPoint(permissionPoint);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
PermissionPointDTO permissionPoint = new PermissionPointDTO();
|
||||
permissionPoint.setId(3479L);
|
||||
permissionPoint.setFeatureName("测试合同权限点");
|
||||
permissionPoint.setFeatureCode("CMS_WEB_PROJ_0159"); //不生效
|
||||
permissionPoint.setParentId(361L);//不生效
|
||||
permissionPoint.setPath("/0/354/361/");//不生效
|
||||
permissionPoint.setSort(9);//不生效
|
||||
permissionPoint.setTerminal("NT_CMS_WEB_PROJ-xx");//不生效
|
||||
permissionPoint.setFeatureType(3);
|
||||
permissionPoint.setAppName("tyr");
|
||||
permissionPoint.setFeatureUrl("/tyr/test/permission");
|
||||
permissionPoint.setNeedAuth(true);
|
||||
permissionPoint.setNeedAuth(true);
|
||||
controller.savePermissionPoint(permissionPoint);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSort() {
|
||||
//老数据可能会导致位置不对
|
||||
Long updater = 111L;
|
||||
Long permissionId = 3478L;
|
||||
Integer direction = 1;
|
||||
controller.updateSort(updater, permissionId, direction);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeParent() {
|
||||
Long updater = 111L;
|
||||
Long permissionId = 360L;
|
||||
Long newParentId = 354L;
|
||||
controller.changeParent(updater, permissionId, newParentId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete() {
|
||||
Long permissionId = 3478L;
|
||||
controller.deletePermissionPoint(permissionId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user