1. 修复回滚父子角色功能时错误的代码逻辑,补全单元测试用例
2. 新增支持切换后业务菜单查询需限定只查询该公司业务数据能力
This commit is contained in:
@@ -38,4 +38,7 @@ public interface GlobalErrorCodeConstants {
|
|||||||
|
|
||||||
ErrorCode UNKNOWN = new ErrorCode(999, "未知错误");
|
ErrorCode UNKNOWN = new ErrorCode(999, "未知错误");
|
||||||
|
|
||||||
|
// ========== 业务错误段 ==========
|
||||||
|
// 用户未设置公司信息,无法办理当前业务
|
||||||
|
ErrorCode USER_NOT_SET_DEPT = new ErrorCode(1000, "用户未设置有效的公司或部门信息,无法办理当前业务");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,33 @@ public class CommonResult<T> implements Serializable {
|
|||||||
return error(result.getCode(), result.getMsg());
|
return error(result.getCode(), result.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义的中间返回
|
||||||
|
* @param data
|
||||||
|
* @param code
|
||||||
|
* @return
|
||||||
|
* @param <T>
|
||||||
|
*/
|
||||||
|
public static <T> CommonResult<T> customize(T data, int code, String msg) {
|
||||||
|
CommonResult<T> result = new CommonResult<>();
|
||||||
|
result.code = code;
|
||||||
|
result.data = data;
|
||||||
|
result.msg = msg;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义的中间返回
|
||||||
|
*/
|
||||||
|
public static <T> CommonResult<T> customize(T data, CommonResultCodeEnum commonResultCodeEnum) {
|
||||||
|
CommonResult<T> result = new CommonResult<>();
|
||||||
|
result.code = commonResultCodeEnum.getCode();
|
||||||
|
result.data = data;
|
||||||
|
result.msg = commonResultCodeEnum.getMessage();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static <T> CommonResult<T> error(Integer code, String message) {
|
public static <T> CommonResult<T> error(Integer code, String message) {
|
||||||
Assert.notEquals(GlobalErrorCodeConstants.SUCCESS.getCode(), code, "code 必须是错误的!");
|
Assert.notEquals(GlobalErrorCodeConstants.SUCCESS.getCode(), code, "code 必须是错误的!");
|
||||||
CommonResult<T> result = new CommonResult<>();
|
CommonResult<T> result = new CommonResult<>();
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package cn.iocoder.yudao.framework.common.pojo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenbowen
|
||||||
|
*/
|
||||||
|
|
||||||
|
public enum CommonResultCodeEnum {
|
||||||
|
// 成功
|
||||||
|
SUCCESS(0, "成功"),
|
||||||
|
|
||||||
|
// 根据返回重试
|
||||||
|
NEED_ADJUST(400, "需要根据返回二次重新请求"),
|
||||||
|
|
||||||
|
//
|
||||||
|
ERROR(500, "错误");
|
||||||
|
|
||||||
|
private final int code;
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
CommonResultCodeEnum(int code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.iocoder.yudao.framework.common.pojo;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录用户信息
|
||||||
|
*
|
||||||
|
* @author chenbowen
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CompanyDeptInfo {
|
||||||
|
/**
|
||||||
|
* 公司Id
|
||||||
|
*/
|
||||||
|
private Long companyId;
|
||||||
|
/**
|
||||||
|
* 公司名称
|
||||||
|
*/
|
||||||
|
private String companyName;
|
||||||
|
/**
|
||||||
|
* 部门Id
|
||||||
|
*/
|
||||||
|
private Long deptId;
|
||||||
|
/**
|
||||||
|
* 部门名称
|
||||||
|
*/
|
||||||
|
private String deptName;
|
||||||
|
}
|
||||||
@@ -11,20 +11,26 @@
|
|||||||
<artifactId>yudao-spring-boot-starter-biz-business</artifactId>
|
<artifactId>yudao-spring-boot-starter-biz-business</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.cloud</groupId>
|
|
||||||
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.cloud</groupId>
|
|
||||||
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.iocoder.cloud</groupId>
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
<artifactId>yudao-module-system-api</artifactId>
|
<artifactId>yudao-module-system-api</artifactId>
|
||||||
<version>2.6.0-SNAPSHOT</version>
|
<version>${revision}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-security</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
|
<artifactId>yudao-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-biz-data-permission</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package cn.iocoder.yudao.framework.business.annotation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenbowen
|
||||||
|
*
|
||||||
|
* 业务代码自动补全的注解,在 DO filed 中与 @TableField(fill = FieldFill.INSERT) 一起标注后自动新增时生成 Code chenbowen
|
||||||
|
*/
|
||||||
|
public @interface BusinessCode {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package cn.iocoder.yudao.framework.business.config;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.business.interceptor.BusinessHeaderInterceptor;
|
||||||
|
import cn.iocoder.yudao.framework.web.config.YudaoWebAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenbowen
|
||||||
|
*/
|
||||||
|
@AutoConfiguration(after = YudaoWebAutoConfiguration.class)
|
||||||
|
public class YudaoBusinessAutoConfiguration implements WebMvcConfigurer {
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
// 只拦截增删改和 set 相关的 url
|
||||||
|
registry.addInterceptor(new BusinessHeaderInterceptor())
|
||||||
|
.addPathPatterns("/**/add**", "/**/create**", "/**/update**", "/**/edit**", "/**/delete**", "/**/remove**", "/**/set**");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package cn.iocoder.yudao.framework.business.framework;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.datapermission.core.rule.company.CompanyDataPermissionRuleCustomizer;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenbowen
|
||||||
|
*/
|
||||||
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
public class BusinessDataPermissionConfiguration {
|
||||||
|
@Bean
|
||||||
|
public CompanyDataPermissionRuleCustomizer sysDeptDataPermissionRuleCustomizer() {
|
||||||
|
return rule -> {
|
||||||
|
// companyId
|
||||||
|
rule.addCompanyColumn("demo_contract", "company_id");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package cn.iocoder.yudao.framework.business.interceptor;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenbowen
|
||||||
|
* 标记是否业务接口,如果是业务接口需要确定唯一的公司和部门信息才能放行
|
||||||
|
*/
|
||||||
|
public interface BusinessControllerMarker {
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user