mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-09 20:57:21 +08:00
refactor(open): 优化应用管理代码
This commit is contained in:
@@ -41,6 +41,10 @@ const options: Options = {
|
||||
btns: { hide: true },
|
||||
}
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
// todo 待补充
|
||||
})
|
||||
|
||||
const columns: Columns = reactive([
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInForm>
|
||||
@@ -81,10 +85,6 @@ const columns: Columns = reactive([
|
||||
</#list>
|
||||
])
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
// todo 待补充
|
||||
})
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
|
@@ -41,7 +41,7 @@ public class SaCheckPermissionHandler implements SaAnnotationHandlerInterface<Sa
|
||||
|
||||
@Override
|
||||
public void checkMethod(SaCheckPermission at, Method method) {
|
||||
if (!ApiSignCheckUtils.isExistSignParam()) {
|
||||
if (!ApiSignCheckUtils.isSignParamExists()) {
|
||||
_checkMethod(at.type(), at.value(), at.mode(), at.orRole());
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,11 @@
|
||||
|
||||
package top.continew.admin.open.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import top.continew.starter.data.mp.base.BaseMapper;
|
||||
import top.continew.admin.open.model.entity.AppDO;
|
||||
import top.continew.starter.security.crypto.annotation.FieldEncrypt;
|
||||
|
||||
/**
|
||||
* 应用 Mapper
|
||||
@@ -25,4 +28,14 @@ import top.continew.admin.open.model.entity.AppDO;
|
||||
* @author chengzi
|
||||
* @since 2024/10/17 16:03
|
||||
*/
|
||||
public interface AppMapper extends BaseMapper<AppDO> {}
|
||||
public interface AppMapper extends BaseMapper<AppDO> {
|
||||
|
||||
/**
|
||||
* 根据 Access Key 查询
|
||||
*
|
||||
* @param accessKey Access Key
|
||||
* @return 应用信息
|
||||
*/
|
||||
@Select("select * from sys_app where access_key = #{accessKey}")
|
||||
AppDO selectByAccessKey(@FieldEncrypt @Param("accessKey") String accessKey);
|
||||
}
|
@@ -33,7 +33,7 @@ import top.continew.admin.open.service.AppService;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 应用业务实现
|
||||
@@ -74,31 +74,22 @@ public class AppServiceImpl extends BaseServiceImpl<AppMapper, AppDO, AppResp, A
|
||||
|
||||
@Override
|
||||
public String getSecretKeyByAccessKey(String accessKey) {
|
||||
return baseMapper.lambdaQuery()
|
||||
.select(AppDO::getSecretKey)
|
||||
.eq(AppDO::getAccessKey, accessKey)
|
||||
.oneOpt()
|
||||
.map(AppDO::getSecretKey)
|
||||
.orElse(null);
|
||||
return Optional.ofNullable(baseMapper.selectByAccessKey(accessKey)).map(AppDO::getSecretKey).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAppExists(String accessKey) {
|
||||
return baseMapper.lambdaQuery().eq(AppDO::getAccessKey, accessKey).exists();
|
||||
return baseMapper.selectByAccessKey(accessKey) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAppSecretExpired(String accessKey) {
|
||||
LocalDateTime expireTime = baseMapper.lambdaQuery()
|
||||
.select(AppDO::getExpireTime)
|
||||
.eq(AppDO::getAccessKey, accessKey)
|
||||
.oneOpt()
|
||||
.map(AppDO::getExpireTime)
|
||||
.orElse(null);
|
||||
if (expireTime == null) {
|
||||
AppDO app = baseMapper.selectByAccessKey(accessKey);
|
||||
ValidationUtils.throwIfNull(app, "应用不存在");
|
||||
if (app.getExpireTime() == null) {
|
||||
return false;
|
||||
}
|
||||
return expireTime.isBefore(DateUtil.date().toLocalDateTime());
|
||||
return app.getExpireTime().isBefore(DateUtil.date().toLocalDateTime());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,6 +18,7 @@ package top.continew.admin.open.util;
|
||||
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.context.model.SaRequest;
|
||||
import cn.dev33.satoken.sign.SaSignTemplate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,10 +38,9 @@ public class ApiSignCheckUtils {
|
||||
*
|
||||
* @return 是否包含sign参数(true:包含;false:不包含)
|
||||
*/
|
||||
public static boolean isExistSignParam() {
|
||||
public static boolean isSignParamExists() {
|
||||
SaRequest saRequest = SaHolder.getRequest();
|
||||
List<String> paramNames = saRequest.getParamNames();
|
||||
return paramNames.stream().anyMatch(paramName -> paramName.equals("sign"));
|
||||
return paramNames.stream().anyMatch(SaSignTemplate.sign::equals);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user