review code.
This commit is contained in:
@@ -12,11 +12,6 @@ public class Const implements com.orion.lang.constant.Const {
|
|||||||
private Const() {
|
private Const() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 同 ${orion.version} 迭代时候需要手动更改
|
|
||||||
*/
|
|
||||||
public static String VERSION = "1.0.0";
|
|
||||||
|
|
||||||
public static final Integer NOT_DELETE = 0;
|
public static final Integer NOT_DELETE = 0;
|
||||||
|
|
||||||
public static final Integer IS_DELETED = 1;
|
public static final Integer IS_DELETED = 1;
|
||||||
|
|||||||
@@ -9,12 +9,15 @@ package com.orion.ops.framework.common.constant;
|
|||||||
*/
|
*/
|
||||||
public interface OrionOpsProConst {
|
public interface OrionOpsProConst {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同 ${orion.version} 迭代时候需要手动更改
|
||||||
|
*/
|
||||||
|
String VERSION = "1.0.0";
|
||||||
|
|
||||||
String GITHUB = "https://github.com/lijiahangmax/orion-ops-pro";
|
String GITHUB = "https://github.com/lijiahangmax/orion-ops-pro";
|
||||||
|
|
||||||
String GITEE = "https://gitee.com/lijiahangmax/orion-ops-pro";
|
String GITEE = "https://gitee.com/lijiahangmax/orion-ops-pro";
|
||||||
|
|
||||||
String ISSUES = "https://gitee.com/lijiahangmax/orion-ops-pro/issues";
|
String ISSUES = "https://gitee.com/lijiahangmax/orion-ops-pro/issues";
|
||||||
|
|
||||||
String VERSION = "1.0.0";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.orion.ops.framework.storage.core.client;
|
package com.orion.ops.framework.common.file;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
@@ -4,6 +4,8 @@ import com.orion.ops.framework.common.crypto.ValueCrypto;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密工具类
|
* 加密工具类
|
||||||
|
* <p>
|
||||||
|
* PrimaryValueCrypto 代理类工具
|
||||||
*
|
*
|
||||||
* @author Jiahang Li
|
* @author Jiahang Li
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
@@ -13,6 +15,9 @@ public class CryptoUtils {
|
|||||||
|
|
||||||
private static ValueCrypto delegate;
|
private static ValueCrypto delegate;
|
||||||
|
|
||||||
|
private CryptoUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密
|
* 加密
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,136 @@
|
|||||||
|
package com.orion.ops.framework.common.utils;
|
||||||
|
|
||||||
|
import com.orion.ops.framework.common.file.FileClient;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件客户端工具
|
||||||
|
* <p>
|
||||||
|
* PrimaryFileClient 代理类工具
|
||||||
|
*
|
||||||
|
* @author Jiahang Li
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2023/7/21 12:05
|
||||||
|
*/
|
||||||
|
public class FileClientUtils {
|
||||||
|
|
||||||
|
private static FileClient delegate;
|
||||||
|
|
||||||
|
private FileClientUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*
|
||||||
|
* @param path 文件路径
|
||||||
|
* @param content 文件内容
|
||||||
|
* @return 路径
|
||||||
|
* @throws Exception Exception
|
||||||
|
*/
|
||||||
|
public static String upload(String path, byte[] content) throws Exception {
|
||||||
|
return delegate.upload(path, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*
|
||||||
|
* @param path 文件路径
|
||||||
|
* @param content 文件内容
|
||||||
|
* @param overrideIfExist 文件存在是否覆盖
|
||||||
|
* @return 路径
|
||||||
|
* @throws Exception Exception
|
||||||
|
*/
|
||||||
|
public static String upload(String path, byte[] content, boolean overrideIfExist) throws Exception {
|
||||||
|
return delegate.upload(path, content, overrideIfExist);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*
|
||||||
|
* @param path 文件路径
|
||||||
|
* @param in in
|
||||||
|
* @return 路径
|
||||||
|
* @throws Exception Exception
|
||||||
|
*/
|
||||||
|
public static String upload(String path, InputStream in) throws Exception {
|
||||||
|
return delegate.upload(path, in);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*
|
||||||
|
* @param path 文件路径
|
||||||
|
* @param in in
|
||||||
|
* @param autoClose autoClose
|
||||||
|
* @return 路径
|
||||||
|
* @throws Exception Exception
|
||||||
|
*/
|
||||||
|
public static String upload(String path, InputStream in, boolean autoClose) throws Exception {
|
||||||
|
return delegate.upload(path, in, autoClose);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*
|
||||||
|
* @param path 文件路径
|
||||||
|
* @param in in
|
||||||
|
* @param autoClose autoClose
|
||||||
|
* @param overrideIfExist 文件存在是否覆盖
|
||||||
|
* @return 路径
|
||||||
|
* @throws Exception Exception
|
||||||
|
*/
|
||||||
|
public static String upload(String path, InputStream in, boolean autoClose, boolean overrideIfExist) throws Exception {
|
||||||
|
return delegate.upload(path, in, autoClose, overrideIfExist);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO getOutputStream
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测文件是否存在
|
||||||
|
*
|
||||||
|
* @param path path
|
||||||
|
* @return 是否存在
|
||||||
|
*/
|
||||||
|
public static boolean isExists(String path) {
|
||||||
|
return delegate.isExists(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文件
|
||||||
|
*
|
||||||
|
* @param path 路径
|
||||||
|
* @return 是否删除
|
||||||
|
* @throws Exception Exception
|
||||||
|
*/
|
||||||
|
public static boolean delete(String path) throws Exception {
|
||||||
|
return delegate.delete(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件内容
|
||||||
|
*
|
||||||
|
* @param path path
|
||||||
|
* @return bytes
|
||||||
|
* @throws Exception Exception
|
||||||
|
*/
|
||||||
|
public static byte[] getContent(String path) throws Exception {
|
||||||
|
return delegate.getContent(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件输入流
|
||||||
|
*
|
||||||
|
* @param path path
|
||||||
|
* @return stream
|
||||||
|
* @throws Exception Exception
|
||||||
|
*/
|
||||||
|
public static InputStream getContentInputStream(String path) throws Exception {
|
||||||
|
return delegate.getContentInputStream(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDelegate(FileClient delegate) {
|
||||||
|
FileClientUtils.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import com.orion.ops.framework.desensitize.core.serializer.DesensitizeJsonSerial
|
|||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 脱敏配置元注解
|
* FastJson / Jackson 脱敏配置元注解
|
||||||
* <p>
|
* <p>
|
||||||
* 标注在字段上则标记该字段执行 http 序列化时脱敏
|
* 标注在字段上则标记该字段执行 http 序列化时脱敏
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.orion.ops.framework.desensitize.core.annotation;
|
|||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 脱敏配置元注解
|
* FastJson 脱敏配置元注解
|
||||||
* <p>
|
* <p>
|
||||||
* 标注在类上则标记该类执行序列化时会执行脱敏
|
* 标注在类上则标记该类执行序列化时会执行脱敏
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
|||||||
import com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine;
|
import com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine;
|
||||||
import com.orion.lang.utils.Strings;
|
import com.orion.lang.utils.Strings;
|
||||||
import com.orion.lang.utils.reflect.Fields;
|
import com.orion.lang.utils.reflect.Fields;
|
||||||
import com.orion.ops.framework.common.constant.Const;
|
import com.orion.ops.framework.common.constant.OrionOpsProConst;
|
||||||
import org.apache.velocity.Template;
|
import org.apache.velocity.Template;
|
||||||
import org.apache.velocity.VelocityContext;
|
import org.apache.velocity.VelocityContext;
|
||||||
import org.apache.velocity.app.Velocity;
|
import org.apache.velocity.app.Velocity;
|
||||||
@@ -161,7 +161,7 @@ public class VelocityTemplateEngine extends AbstractTemplateEngine {
|
|||||||
// http 注释标识
|
// http 注释标识
|
||||||
objectMap.put("httpComment", "###");
|
objectMap.put("httpComment", "###");
|
||||||
// 版本
|
// 版本
|
||||||
objectMap.put("since", Const.VERSION);
|
objectMap.put("since", OrionOpsProConst.VERSION);
|
||||||
// 替换业务注释
|
// 替换业务注释
|
||||||
tableInfo.setComment(tables.get(tableInfo.getName()).getComment());
|
tableInfo.setComment(tables.get(tableInfo.getName()).getComment());
|
||||||
// 实体名称
|
// 实体名称
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.orion.ops.framework.mybatis.core.query.CacheQuery;
|
|||||||
import com.orion.ops.framework.mybatis.core.query.Conditions;
|
import com.orion.ops.framework.mybatis.core.query.Conditions;
|
||||||
import com.orion.ops.framework.mybatis.core.query.DataQuery;
|
import com.orion.ops.framework.mybatis.core.query.DataQuery;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,6 +56,16 @@ public interface IMapper<T> extends BaseMapper<T> {
|
|||||||
return CacheQuery.of(this);
|
return CacheQuery.of(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 CacheQuery 对象
|
||||||
|
*
|
||||||
|
* @param id id
|
||||||
|
* @return CacheQuery
|
||||||
|
*/
|
||||||
|
default CacheQuery<T> cache(Serializable id) {
|
||||||
|
return CacheQuery.of(this, id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入
|
* 批量插入
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -65,26 +65,31 @@ public class CacheQuery<T> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <R> Optional<R> get(Function<T, R> mapper) {
|
public <R> Optional<R> optional(Function<T, R> mapper) {
|
||||||
Valid.notNull(mapper, "convert function is null");
|
Valid.notNull(mapper, "convert function is null");
|
||||||
return this.get().map(mapper);
|
return Optional.ofNullable(this.get())
|
||||||
|
.map(mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<T> get() {
|
public Optional<T> optional() {
|
||||||
|
return Optional.ofNullable(this.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
public T get() {
|
||||||
// 不查询缓存
|
// 不查询缓存
|
||||||
if (!force) {
|
if (!force) {
|
||||||
// 从缓存中获取
|
// 从缓存中获取
|
||||||
Store<T> store = CacheHolder.get(dao, id);
|
Store<T> store = CacheHolder.get(dao, id);
|
||||||
// 命中直接返回
|
// 命中直接返回
|
||||||
if (store != null) {
|
if (store != null) {
|
||||||
return Optional.of(store).map(Store::get);
|
return store.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 查询
|
// 查询
|
||||||
T row = dao.selectById(id);
|
T row = dao.selectById(id);
|
||||||
// 设置缓存
|
// 设置缓存
|
||||||
CacheHolder.set(dao, id, row);
|
CacheHolder.set(dao, id, row);
|
||||||
return Optional.ofNullable(row);
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ package com.orion.ops.framework.security.config;
|
|||||||
|
|
||||||
import com.orion.ops.framework.common.constant.AutoConfigureOrderConst;
|
import com.orion.ops.framework.common.constant.AutoConfigureOrderConst;
|
||||||
import com.orion.ops.framework.common.crypto.ValueCrypto;
|
import com.orion.ops.framework.common.crypto.ValueCrypto;
|
||||||
|
import com.orion.ops.framework.security.core.crypto.PrimaryValueCrypto;
|
||||||
import com.orion.ops.framework.security.core.crypto.aes.AesCryptoProcessor;
|
import com.orion.ops.framework.security.core.crypto.aes.AesCryptoProcessor;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@@ -26,12 +28,21 @@ public class OrionCryptoAutoConfiguration {
|
|||||||
@Resource
|
@Resource
|
||||||
private CryptoConfig config;
|
private CryptoConfig config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 默认加密器
|
||||||
|
*/
|
||||||
|
@Bean(name = "valueCrypto")
|
||||||
|
@Primary
|
||||||
|
public ValueCrypto primaryValueCrypto() {
|
||||||
|
return new PrimaryValueCrypto();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return aes 加密器
|
* @return aes 加密器
|
||||||
*/
|
*/
|
||||||
@Bean(initMethod = "init")
|
@Bean(initMethod = "init")
|
||||||
@ConditionalOnProperty(value = "orion.crypto.aes.enabled", havingValue = "true")
|
@ConditionalOnProperty(value = "orion.crypto.aes.enabled", havingValue = "true")
|
||||||
public ValueCrypto aes() {
|
public ValueCrypto aesValueCrypto() {
|
||||||
return new AesCryptoProcessor(config.getAes());
|
return new AesCryptoProcessor(config.getAes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public abstract class CryptoProcessor<Config extends CryptoConfig> implements Va
|
|||||||
this.config = config;
|
this.config = config;
|
||||||
// 设置为默认加密器
|
// 设置为默认加密器
|
||||||
if (config.isPrimary()) {
|
if (config.isPrimary()) {
|
||||||
|
PrimaryValueCrypto.delegate = this;
|
||||||
CryptoUtils.setDelegate(this);
|
CryptoUtils.setDelegate(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.orion.ops.framework.security.core.crypto;
|
||||||
|
|
||||||
|
import com.orion.ops.framework.common.crypto.ValueCrypto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认加密器
|
||||||
|
*
|
||||||
|
* @author Jiahang Li
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2023/7/21 12:11
|
||||||
|
*/
|
||||||
|
public class PrimaryValueCrypto implements ValueCrypto {
|
||||||
|
|
||||||
|
protected static ValueCrypto delegate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] encrypt(byte[] plain) {
|
||||||
|
return delegate.encrypt(plain);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] decrypt(byte[] text) {
|
||||||
|
return delegate.decrypt(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.orion.ops.framework.storage.config;
|
package com.orion.ops.framework.storage.config;
|
||||||
|
|
||||||
import com.orion.ops.framework.common.constant.AutoConfigureOrderConst;
|
import com.orion.ops.framework.common.constant.AutoConfigureOrderConst;
|
||||||
import com.orion.ops.framework.storage.core.client.FileClient;
|
import com.orion.ops.framework.common.file.FileClient;
|
||||||
import com.orion.ops.framework.storage.core.client.PrimaryFileClient;
|
import com.orion.ops.framework.storage.core.client.PrimaryFileClient;
|
||||||
import com.orion.ops.framework.storage.core.client.local.LocalFileClient;
|
import com.orion.ops.framework.storage.core.client.local.LocalFileClient;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
@@ -31,16 +31,16 @@ public class OrionStorageAutoConfiguration {
|
|||||||
private StorageConfig config;
|
private StorageConfig config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认文件客户端
|
* @return 默认文件客户端
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean(name = "primaryFileClient")
|
||||||
@Primary
|
@Primary
|
||||||
public FileClient primaryFileClient() {
|
public FileClient primaryFileClient() {
|
||||||
return new PrimaryFileClient();
|
return new PrimaryFileClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地文件客户端
|
* @return 本地文件客户端
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(value = "orion.storage.local.enabled", havingValue = "true")
|
@ConditionalOnProperty(value = "orion.storage.local.enabled", havingValue = "true")
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.orion.lang.utils.io.Files1;
|
|||||||
import com.orion.lang.utils.io.Streams;
|
import com.orion.lang.utils.io.Streams;
|
||||||
import com.orion.lang.utils.time.Dates;
|
import com.orion.lang.utils.time.Dates;
|
||||||
import com.orion.ops.framework.common.constant.Const;
|
import com.orion.ops.framework.common.constant.Const;
|
||||||
|
import com.orion.ops.framework.common.file.FileClient;
|
||||||
|
import com.orion.ops.framework.common.utils.FileClientUtils;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -24,6 +26,7 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem
|
|||||||
// 设置默认文件客户端
|
// 设置默认文件客户端
|
||||||
if (config.isPrimary()) {
|
if (config.isPrimary()) {
|
||||||
PrimaryFileClient.delegate = this;
|
PrimaryFileClient.delegate = this;
|
||||||
|
FileClientUtils.setDelegate(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.orion.ops.framework.storage.core.client;
|
package com.orion.ops.framework.storage.core.client;
|
||||||
|
|
||||||
|
import com.orion.ops.framework.common.file.FileClient;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ public class AuthenticationController {
|
|||||||
return UserLoginVO.builder().token(token).build();
|
return UserLoginVO.builder().token(token).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@IgnoreLog
|
|
||||||
@PermitAll
|
@PermitAll
|
||||||
|
@IgnoreLog
|
||||||
@Operation(summary = "登出")
|
@Operation(summary = "登出")
|
||||||
@GetMapping("/logout")
|
@GetMapping("/logout")
|
||||||
public HttpWrapper<?> logout(HttpServletRequest servletRequest) {
|
public HttpWrapper<?> logout(HttpServletRequest servletRequest) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.orion.lang.define.wrapper.HttpWrapper;
|
|||||||
import com.orion.lang.utils.collect.Lists;
|
import com.orion.lang.utils.collect.Lists;
|
||||||
import com.orion.ops.framework.common.annotation.IgnoreLog;
|
import com.orion.ops.framework.common.annotation.IgnoreLog;
|
||||||
import com.orion.ops.framework.common.annotation.RestWrapper;
|
import com.orion.ops.framework.common.annotation.RestWrapper;
|
||||||
|
import com.orion.ops.framework.common.constant.IgnoreLogMode;
|
||||||
import com.orion.ops.module.infra.entity.request.user.*;
|
import com.orion.ops.module.infra.entity.request.user.*;
|
||||||
import com.orion.ops.module.infra.entity.vo.SystemUserVO;
|
import com.orion.ops.module.infra.entity.vo.SystemUserVO;
|
||||||
import com.orion.ops.module.infra.service.SystemUserRoleService;
|
import com.orion.ops.module.infra.service.SystemUserRoleService;
|
||||||
@@ -56,7 +57,7 @@ public class SystemUserController {
|
|||||||
return systemUserService.updateSystemUser(request);
|
return systemUserService.updateSystemUser(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 修改头像
|
// TODO 修改头像 最后再说 可有可无的功能 要是有 http 文件需求就写
|
||||||
|
|
||||||
@PutMapping("/update-status")
|
@PutMapping("/update-status")
|
||||||
@Operation(summary = "修改用户状态")
|
@Operation(summary = "修改用户状态")
|
||||||
@@ -86,7 +87,7 @@ public class SystemUserController {
|
|||||||
return HttpWrapper.ok();
|
return HttpWrapper.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@IgnoreLog
|
@IgnoreLog(IgnoreLogMode.RET)
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "通过 id 查询用户")
|
@Operation(summary = "通过 id 查询用户")
|
||||||
@Parameter(name = "id", description = "id", required = true)
|
@Parameter(name = "id", description = "id", required = true)
|
||||||
@@ -95,7 +96,7 @@ public class SystemUserController {
|
|||||||
return systemUserService.getSystemUser(id);
|
return systemUserService.getSystemUser(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@IgnoreLog
|
@IgnoreLog(IgnoreLogMode.RET)
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "查询所有用户")
|
@Operation(summary = "查询所有用户")
|
||||||
@PreAuthorize("@ss.hasPermission('infra:system-user:query')")
|
@PreAuthorize("@ss.hasPermission('infra:system-user:query')")
|
||||||
@@ -103,7 +104,7 @@ public class SystemUserController {
|
|||||||
return systemUserService.getSystemUserList();
|
return systemUserService.getSystemUserList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@IgnoreLog
|
@IgnoreLog(IgnoreLogMode.RET)
|
||||||
@PostMapping("/query")
|
@PostMapping("/query")
|
||||||
@Operation(summary = "分页查询用户")
|
@Operation(summary = "分页查询用户")
|
||||||
@PreAuthorize("@ss.hasPermission('infra:system-user:query')")
|
@PreAuthorize("@ss.hasPermission('infra:system-user:query')")
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import javax.annotation.Resource;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限服务
|
* 权限服务
|
||||||
@@ -153,11 +154,20 @@ public class PermissionServiceImpl implements PermissionService {
|
|||||||
return Lists.empty();
|
return Lists.empty();
|
||||||
}
|
}
|
||||||
// 查询角色菜单
|
// 查询角色菜单
|
||||||
List<SystemMenuVO> menus = roles.stream()
|
Stream<SystemMenuCacheDTO> mergeStream;
|
||||||
.map(roleMenuCache::get)
|
if (RoleDefine.containsAdmin(roles)) {
|
||||||
.filter(Objects::nonNull)
|
// 管理员拥有全部权限
|
||||||
.flatMap(Collection::stream)
|
mergeStream = menuCache.stream();
|
||||||
.distinct()
|
} else {
|
||||||
|
// 当前用户所适配的角色
|
||||||
|
mergeStream = roles.stream()
|
||||||
|
.map(roleMenuCache::get)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.flatMap(Collection::stream)
|
||||||
|
.distinct();
|
||||||
|
}
|
||||||
|
// 状态过滤
|
||||||
|
List<SystemMenuVO> menus = mergeStream
|
||||||
.filter(s -> MenuStatusEnum.ENABLED.getStatus().equals(s.getStatus()))
|
.filter(s -> MenuStatusEnum.ENABLED.getStatus().equals(s.getStatus()))
|
||||||
.filter(s -> !MenuTypeEnum.FUNCTION.getType().equals(s.getType()))
|
.filter(s -> !MenuTypeEnum.FUNCTION.getType().equals(s.getType()))
|
||||||
.map(SystemMenuConvert.MAPPER::to)
|
.map(SystemMenuConvert.MAPPER::to)
|
||||||
|
|||||||
Reference in New Issue
Block a user