♻️ Refactoring code. 数据权限 DataScope.java 增加链式操作方便使用

This commit is contained in:
lbw committed 2022-05-13 10:51:22 +08:00
1 parent 73c6fa415d
commit c5f291943e
7 files changed
+36 -14

No files matched your search

@@ -56,4 +56,31 @@ public class DataScope extends HashMap {
*/
private DataScopeFuncEnum func = DataScopeFuncEnum.ALL;
/**
* of 获取实例
*/
public static DataScope of() {
return new DataScope();
}
public DataScope scopeName(String scopeName) {
this.scopeName = scopeName;
return this;
}
public DataScope deptIds(List<Long> deptIds) {
this.deptIds = deptIds;
return this;
}
public DataScope only(boolean isOnly) {
this.isOnly = isOnly;
return this;
}
public DataScope func(DataScopeFuncEnum func) {
this.func = func;
return this;
}
}
@@ -27,7 +27,7 @@ public class SelectCountByScope extends AbstractMethod {
this.sqlComment());
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
return this.addSelectMappedStatementForOther(mapperClass, sqlSource, Integer.class);
return this.addSelectMappedStatementForOther(mapperClass, sqlSource, Long.class);
}
}
@@ -36,7 +36,7 @@ public class FileProperties {
/**
* 默认的存储桶名称
*/
private String bucketName = "payerp";
private String bucketName = "local";
/**
* 本地文件配置信息
@@ -22,6 +22,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysUser;
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.core.util.RetOps;
import org.springframework.core.Ordered;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
@@ -29,10 +30,7 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.*;
/**
* @author lengleng
@@ -64,11 +62,8 @@ public interface PigxUserDetailsService extends UserDetailsService, Ordered {
* @return UserDetails
*/
default UserDetails getUserDetails(R<UserInfo> result) {
if (result == null || result.getData() == null) {
throw new UsernameNotFoundException("用户不存在");
}
UserInfo info = RetOps.of(result).getData().orElseThrow(() -> new UsernameNotFoundException("用户不存在"));
UserInfo info = result.getData();
Set<String> dbAuthsSet = new HashSet<>();
if (ArrayUtil.isNotEmpty(info.getRoles())) {
// 获取角色