mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-18 14:57:15 +08:00
refactor(open): 优化应用管理代码
This commit is contained in:
@@ -41,6 +41,10 @@ const options: Options = {
|
|||||||
btns: { hide: true },
|
btns: { hide: true },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { form, resetForm } = useForm({
|
||||||
|
// todo 待补充
|
||||||
|
})
|
||||||
|
|
||||||
const columns: Columns = reactive([
|
const columns: Columns = reactive([
|
||||||
<#list fieldConfigs as fieldConfig>
|
<#list fieldConfigs as fieldConfig>
|
||||||
<#if fieldConfig.showInForm>
|
<#if fieldConfig.showInForm>
|
||||||
@@ -81,10 +85,6 @@ const columns: Columns = reactive([
|
|||||||
</#list>
|
</#list>
|
||||||
])
|
])
|
||||||
|
|
||||||
const { form, resetForm } = useForm({
|
|
||||||
// todo 待补充
|
|
||||||
})
|
|
||||||
|
|
||||||
// 重置
|
// 重置
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
formRef.value?.formRef?.resetFields()
|
formRef.value?.formRef?.resetFields()
|
||||||
|
@@ -41,7 +41,7 @@ public class SaCheckPermissionHandler implements SaAnnotationHandlerInterface<Sa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkMethod(SaCheckPermission at, Method method) {
|
public void checkMethod(SaCheckPermission at, Method method) {
|
||||||
if (!ApiSignCheckUtils.isExistSignParam()) {
|
if (!ApiSignCheckUtils.isSignParamExists()) {
|
||||||
_checkMethod(at.type(), at.value(), at.mode(), at.orRole());
|
_checkMethod(at.type(), at.value(), at.mode(), at.orRole());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,11 @@
|
|||||||
|
|
||||||
package top.continew.admin.open.mapper;
|
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.starter.data.mp.base.BaseMapper;
|
||||||
import top.continew.admin.open.model.entity.AppDO;
|
import top.continew.admin.open.model.entity.AppDO;
|
||||||
|
import top.continew.starter.security.crypto.annotation.FieldEncrypt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 应用 Mapper
|
* 应用 Mapper
|
||||||
@@ -25,4 +28,14 @@ import top.continew.admin.open.model.entity.AppDO;
|
|||||||
* @author chengzi
|
* @author chengzi
|
||||||
* @since 2024/10/17 16:03
|
* @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.core.constant.StringConstants;
|
||||||
import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;
|
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
|
@Override
|
||||||
public String getSecretKeyByAccessKey(String accessKey) {
|
public String getSecretKeyByAccessKey(String accessKey) {
|
||||||
return baseMapper.lambdaQuery()
|
return Optional.ofNullable(baseMapper.selectByAccessKey(accessKey)).map(AppDO::getSecretKey).orElse(null);
|
||||||
.select(AppDO::getSecretKey)
|
|
||||||
.eq(AppDO::getAccessKey, accessKey)
|
|
||||||
.oneOpt()
|
|
||||||
.map(AppDO::getSecretKey)
|
|
||||||
.orElse(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAppExists(String accessKey) {
|
public boolean isAppExists(String accessKey) {
|
||||||
return baseMapper.lambdaQuery().eq(AppDO::getAccessKey, accessKey).exists();
|
return baseMapper.selectByAccessKey(accessKey) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAppSecretExpired(String accessKey) {
|
public boolean isAppSecretExpired(String accessKey) {
|
||||||
LocalDateTime expireTime = baseMapper.lambdaQuery()
|
AppDO app = baseMapper.selectByAccessKey(accessKey);
|
||||||
.select(AppDO::getExpireTime)
|
ValidationUtils.throwIfNull(app, "应用不存在");
|
||||||
.eq(AppDO::getAccessKey, accessKey)
|
if (app.getExpireTime() == null) {
|
||||||
.oneOpt()
|
|
||||||
.map(AppDO::getExpireTime)
|
|
||||||
.orElse(null);
|
|
||||||
if (expireTime == null) {
|
|
||||||
return false;
|
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.SaHolder;
|
||||||
import cn.dev33.satoken.context.model.SaRequest;
|
import cn.dev33.satoken.context.model.SaRequest;
|
||||||
|
import cn.dev33.satoken.sign.SaSignTemplate;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -37,10 +38,9 @@ public class ApiSignCheckUtils {
|
|||||||
*
|
*
|
||||||
* @return 是否包含sign参数(true:包含;false:不包含)
|
* @return 是否包含sign参数(true:包含;false:不包含)
|
||||||
*/
|
*/
|
||||||
public static boolean isExistSignParam() {
|
public static boolean isSignParamExists() {
|
||||||
SaRequest saRequest = SaHolder.getRequest();
|
SaRequest saRequest = SaHolder.getRequest();
|
||||||
List<String> paramNames = saRequest.getParamNames();
|
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