satoken修改
This commit is contained in:
parent
bd64722905
commit
763faa6f84
|
|
@ -11,8 +11,8 @@ import java.lang.annotation.Target;
|
|||
* 校验后台是否登录
|
||||
* @author Administrator
|
||||
*/
|
||||
//@SaCheckLogin(type = "admin")
|
||||
@SaCheckLogin(type = "user")
|
||||
@SaCheckLogin(type = "admin")
|
||||
//@SaCheckLogin(type = "user")
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE})
|
||||
public @interface SaAdminCheckLogin {
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ import java.lang.annotation.Target;
|
|||
* @author click33
|
||||
*
|
||||
*/
|
||||
//@SaCheckPermission(type = "admin")
|
||||
@SaCheckPermission(type = "user")
|
||||
@SaCheckPermission(type = "admin")
|
||||
//@SaCheckPermission(type = "user")
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE})
|
||||
public @interface SaAdminCheckPermission {
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ import java.lang.annotation.Target;
|
|||
* @author click33
|
||||
*
|
||||
*/
|
||||
@SaCheckRole(type = "user")
|
||||
//@SaCheckRole(type = "admin")
|
||||
//@SaCheckRole(type = "user")
|
||||
@SaCheckRole(type = "admin")
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE})
|
||||
public @interface SaAdminCheckRole {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import java.lang.annotation.Target;
|
|||
* 校验用户端是否登录
|
||||
* @author Administrator
|
||||
*/
|
||||
@SaCheckLogin(type = "user")
|
||||
@SaCheckLogin(type = "client")
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE})
|
||||
public @interface SaUserCheckLogin {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import java.lang.annotation.Target;
|
|||
* @author click33
|
||||
*
|
||||
*/
|
||||
@SaCheckPermission(type = "user")
|
||||
@SaCheckPermission(type = "client")
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE})
|
||||
public @interface SaUserCheckPermission {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import java.lang.annotation.Target;
|
|||
* @author click33
|
||||
*
|
||||
*/
|
||||
@SaCheckRole(type = "user")
|
||||
@SaCheckRole(type = "client")
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE})
|
||||
public @interface SaUserCheckRole {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ import cn.dev33.satoken.context.SaHolder;
|
|||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||
import cn.dev33.satoken.router.SaRouter;
|
||||
import cn.dev33.satoken.strategy.SaAnnotationStrategy;
|
||||
import cn.dev33.satoken.strategy.SaStrategy;
|
||||
import cn.dev33.satoken.util.SaFoxUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.czg.sa.MyStpLogic;
|
||||
import com.czg.sa.StpKit;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -25,11 +29,11 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|||
@PostConstruct
|
||||
public void setSaTokenConfig() {
|
||||
// admin配置
|
||||
// SaTokenConfig adminConfig = new SaTokenConfig();
|
||||
// adminConfig.setTokenName("token");
|
||||
// config1.setTimeout(1000);
|
||||
// adminConfig.setTokenStyle("simple-uuid");
|
||||
// StpKit.ADMIN.setConfig(adminConfig);
|
||||
SaTokenConfig adminConfig = new SaTokenConfig();
|
||||
adminConfig.setTokenName("token");
|
||||
adminConfig.setTimeout(1000);
|
||||
adminConfig.setTokenStyle("simple-uuid");
|
||||
MyStpLogic.ADMIN_LOGIC.setConfig(adminConfig);
|
||||
|
||||
// 小程序配置
|
||||
SaTokenConfig userConfig = new SaTokenConfig();
|
||||
|
|
@ -38,7 +42,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|||
userConfig.setIsShare(false);
|
||||
// config2.setTimeout(2000);
|
||||
userConfig.setTokenStyle("simple-uuid");
|
||||
StpKit.USER.setConfig(userConfig);
|
||||
MyStpLogic.CLIENT_LOGIC.setConfig(userConfig);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
|
|
@ -47,6 +51,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|||
SaAnnotationStrategy.instance.getAnnotation = AnnotatedElementUtils::getMergedAnnotation;
|
||||
}
|
||||
|
||||
|
||||
// 注册 Sa-Token 的拦截器
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
|
|
@ -57,13 +62,13 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|||
ApplicationInfo.routePrefix = "";
|
||||
|
||||
SaRouter.match("/user/**").notMatch("/user/login", "/user/test", "/user/geo/**", "/user/home/**")
|
||||
.check(r -> StpKit.USER.checkMiniUser())
|
||||
.check(r -> MyStpLogic.CLIENT_LOGIC.checkLogin())
|
||||
.setHit(true)
|
||||
// .match("/**")
|
||||
.notMatch("/user/**")
|
||||
.notMatch("/admin/auth/**")
|
||||
.notMatch("/notify/**")
|
||||
.check(r -> StpKit.USER.checkManager());
|
||||
.check(r -> MyStpLogic.ADMIN_LOGIC.checkLogin());
|
||||
|
||||
})).addPathPatterns("/**");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,44 +1,52 @@
|
|||
package com.czg.sa;
|
||||
|
||||
import cn.dev33.satoken.config.SaTokenConfig;
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
import cn.dev33.satoken.exception.NotPermissionException;
|
||||
import cn.dev33.satoken.fun.SaFunction;
|
||||
import cn.dev33.satoken.router.SaRouter;
|
||||
import cn.dev33.satoken.session.SaSession;
|
||||
import cn.dev33.satoken.session.TokenSign;
|
||||
import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Getter
|
||||
public class MyStpLogic extends StpLogic {
|
||||
public class MyStpLogic {
|
||||
public static final StpLogic CLIENT_LOGIC = new StpLogic("client");
|
||||
public static final StpLogic ADMIN_LOGIC = new StpLogic("admin");
|
||||
|
||||
|
||||
/**
|
||||
* 初始化 StpLogic, 并指定账号类型
|
||||
*
|
||||
* @param loginType 账号类型标识
|
||||
*/
|
||||
public MyStpLogic(String loginType) {
|
||||
super(loginType);
|
||||
private StpLogic getLogic() {
|
||||
boolean hit = SaRouter.match("/admin/**").isHit();
|
||||
if (hit) {
|
||||
return ADMIN_LOGIC;
|
||||
}
|
||||
return CLIENT_LOGIC;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id 登录账号id
|
||||
* @param shopId 店铺id
|
||||
* @param isManager true 管理端 false 用户端
|
||||
* @param isAdmin 是否为管理员账号
|
||||
*/
|
||||
public void login(Long id, Long shopId, boolean isManager, boolean isAdmin) {
|
||||
login(id);
|
||||
StpLogic logic = getLogic();
|
||||
logic.login(id);
|
||||
if (isManager && shopId == null) {
|
||||
throw new ApiNotPrintException("管理端登录必须传递店铺id");
|
||||
}
|
||||
SaSession session = getSession().set("userId", id).set("isAdmin", isAdmin).set("isManager", isManager);
|
||||
SaSession session = logic.getSession().set("userId", id).set("isAdmin", isAdmin).set("isManager", isManager);
|
||||
if (shopId != null) {
|
||||
session.set("shopId", shopId);
|
||||
}
|
||||
|
|
@ -46,16 +54,18 @@ public class MyStpLogic extends StpLogic {
|
|||
|
||||
/**
|
||||
* 获取店铺id
|
||||
*
|
||||
* @param defaultValue 默认值,传递多个只取第一个
|
||||
* @return 返回店铺id,不存在抛出异常,如果传递了默认值不存在返回默认值
|
||||
*/
|
||||
public Long getShopId(Long... defaultValue) {
|
||||
StpLogic logic = getLogic();
|
||||
Long defaultVal = defaultValue.length > 0 ? defaultValue[0] : null;
|
||||
Object object = StpKit.USER.getSession().get("isManager");
|
||||
Object object = logic.getSession().get("isManager");
|
||||
Long shopId;
|
||||
int errType;
|
||||
if (object instanceof Boolean t && t) {
|
||||
Object info = StpKit.USER.getSession().get("shopId");
|
||||
Object info = logic.getSession().get("shopId");
|
||||
shopId = info instanceof Long l ? l : null;
|
||||
errType = 0;
|
||||
} else {
|
||||
|
|
@ -74,8 +84,9 @@ public class MyStpLogic extends StpLogic {
|
|||
* 校验是否为管理端登录
|
||||
*/
|
||||
public void checkManager() {
|
||||
StpKit.USER.checkLogin();
|
||||
Object object = StpKit.USER.getSession().get("isManager");
|
||||
StpLogic logic = getLogic();
|
||||
logic.checkLogin();
|
||||
Object object = logic.getSession().get("isManager");
|
||||
if (object instanceof Boolean t && !t) {
|
||||
throw new NotPermissionException("权限不足");
|
||||
}
|
||||
|
|
@ -85,8 +96,9 @@ public class MyStpLogic extends StpLogic {
|
|||
* 校验是否为小程序登录
|
||||
*/
|
||||
public void checkMiniUser() {
|
||||
StpKit.USER.checkLogin();
|
||||
Object object = StpKit.USER.getSession().get("isManager");
|
||||
StpLogic logic = getLogic();
|
||||
logic.checkLogin();
|
||||
Object object = logic.getSession().get("isManager");
|
||||
if (object instanceof Boolean t && t) {
|
||||
throw new NotPermissionException("权限不足");
|
||||
}
|
||||
|
|
@ -94,30 +106,851 @@ public class MyStpLogic extends StpLogic {
|
|||
|
||||
/**
|
||||
* 是否为管理员
|
||||
*
|
||||
* @return 布尔值
|
||||
*/
|
||||
public boolean isAdmin() {
|
||||
Object object = StpKit.USER.getSession().get("isAdmin");
|
||||
StpLogic logic = getLogic();
|
||||
Object object = logic.getSession().get("isAdmin");
|
||||
return object instanceof Boolean t && t;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加当前账号的角色
|
||||
*
|
||||
* @param roleList 角色列表
|
||||
* @return 当前实例
|
||||
*/
|
||||
public MyStpLogic addRoleList(List<String> roleList) {
|
||||
getSession().set("sa:roleList:" + getLoginType() + ":" + getLoginId(), roleList);
|
||||
StpLogic logic = getLogic();
|
||||
logic.getSession().set("sa:roleList:" + logic.getLoginType() + ":" + logic.getLoginId(), roleList);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加当前账号的权限
|
||||
*
|
||||
* @param permissionList 角色列表
|
||||
* @return 当前实例
|
||||
*/
|
||||
public MyStpLogic addPermissionList(List<String> permissionList) {
|
||||
getSession().set("sa:permissionList:" + getLoginType() + ":" + getLoginId(), permissionList);
|
||||
StpLogic logic = getLogic();
|
||||
logic.getSession().set("sa:permissionList:" + logic.getLoginType() + ":" + logic.getLoginId(), permissionList);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public String getLoginType() {
|
||||
return getLogic().getLoginType();
|
||||
}
|
||||
|
||||
|
||||
public StpLogic setLoginType(String loginType) {
|
||||
return getLogic().setLoginType(loginType);
|
||||
}
|
||||
|
||||
|
||||
public StpLogic setConfig(SaTokenConfig config) {
|
||||
return getLogic().setConfig(config);
|
||||
}
|
||||
|
||||
|
||||
public SaTokenConfig getConfig() {
|
||||
return getLogic().getConfig();
|
||||
}
|
||||
|
||||
|
||||
public SaTokenConfig getConfigOrGlobal() {
|
||||
return getLogic().getConfigOrGlobal();
|
||||
}
|
||||
|
||||
|
||||
public String getTokenName() {
|
||||
return getLogic().getTokenName();
|
||||
}
|
||||
|
||||
|
||||
public String createTokenValue(Object loginId, String device, long timeout, Map<String, Object> extraData) {
|
||||
return getLogic().createTokenValue(loginId, device, timeout, extraData);
|
||||
}
|
||||
|
||||
|
||||
public void setTokenValue(String tokenValue) {
|
||||
getLogic().setTokenValue(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public void setTokenValue(String tokenValue, int cookieTimeout) {
|
||||
getLogic().setTokenValue(tokenValue, cookieTimeout);
|
||||
}
|
||||
|
||||
|
||||
public void setTokenValue(String tokenValue, SaLoginModel loginModel) {
|
||||
getLogic().setTokenValue(tokenValue, loginModel);
|
||||
}
|
||||
|
||||
|
||||
public void setTokenValueToStorage(String tokenValue) {
|
||||
getLogic().setTokenValueToStorage(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public void setTokenValueToCookie(String tokenValue, int cookieTimeout) {
|
||||
getLogic().setTokenValueToCookie(tokenValue, cookieTimeout);
|
||||
}
|
||||
|
||||
|
||||
public void setTokenValueToResponseHeader(String tokenValue) {
|
||||
getLogic().setTokenValueToResponseHeader(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public String getTokenValue() {
|
||||
return getLogic().getTokenValue();
|
||||
}
|
||||
|
||||
|
||||
public String getTokenValue(boolean noPrefixThrowException) {
|
||||
return getLogic().getTokenValue(noPrefixThrowException);
|
||||
}
|
||||
|
||||
|
||||
public String getTokenValueNotCut() {
|
||||
return getLogic().getTokenValueNotCut();
|
||||
}
|
||||
|
||||
|
||||
public String getTokenValueNotNull() {
|
||||
return getLogic().getTokenValueNotNull();
|
||||
}
|
||||
|
||||
|
||||
public SaTokenInfo getTokenInfo() {
|
||||
return getLogic().getTokenInfo();
|
||||
}
|
||||
|
||||
|
||||
public void login(Object id) {
|
||||
getLogic().login(id);
|
||||
}
|
||||
|
||||
|
||||
public void login(Object id, String device) {
|
||||
getLogic().login(id, device);
|
||||
}
|
||||
|
||||
|
||||
public void login(Object id, boolean isLastingCookie) {
|
||||
getLogic().login(id, isLastingCookie);
|
||||
}
|
||||
|
||||
|
||||
public void login(Object id, long timeout) {
|
||||
getLogic().login(id, timeout);
|
||||
}
|
||||
|
||||
|
||||
public void login(Object id, SaLoginModel loginModel) {
|
||||
getLogic().login(id, loginModel);
|
||||
}
|
||||
|
||||
|
||||
public String createLoginSession(Object id) {
|
||||
return getLogic().createLoginSession(id);
|
||||
}
|
||||
|
||||
|
||||
public String createLoginSession(Object id, SaLoginModel loginModel) {
|
||||
return getLogic().createLoginSession(id, loginModel);
|
||||
}
|
||||
|
||||
|
||||
public String getOrCreateLoginSession(Object id) {
|
||||
return getLogic().getOrCreateLoginSession(id);
|
||||
}
|
||||
|
||||
|
||||
public void logout() {
|
||||
getLogic().logout();
|
||||
}
|
||||
|
||||
|
||||
public void logout(Object loginId) {
|
||||
getLogic().logout(loginId);
|
||||
}
|
||||
|
||||
|
||||
public void logout(Object loginId, String device) {
|
||||
getLogic().logout(loginId, device);
|
||||
}
|
||||
|
||||
|
||||
public void logoutByMaxLoginCount(Object loginId, SaSession session, String device, int maxLoginCount) {
|
||||
getLogic().logoutByMaxLoginCount(loginId, session, device, maxLoginCount);
|
||||
}
|
||||
|
||||
|
||||
public void logoutByTokenValue(String tokenValue) {
|
||||
getLogic().logoutByTokenValue(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public void kickout(Object loginId) {
|
||||
getLogic().kickout(loginId);
|
||||
}
|
||||
|
||||
|
||||
public void kickout(Object loginId, String device) {
|
||||
getLogic().kickout(loginId, device);
|
||||
}
|
||||
|
||||
|
||||
public void kickoutByTokenValue(String tokenValue) {
|
||||
getLogic().kickoutByTokenValue(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public void replaced(Object loginId, String device) {
|
||||
getLogic().replaced(loginId, device);
|
||||
}
|
||||
|
||||
|
||||
public boolean isLogin() {
|
||||
return getLogic().isLogin();
|
||||
}
|
||||
|
||||
|
||||
public boolean isLogin(Object loginId) {
|
||||
return getLogic().isLogin(loginId);
|
||||
}
|
||||
|
||||
|
||||
public void checkLogin() {
|
||||
getLogic().checkLogin();
|
||||
}
|
||||
|
||||
|
||||
public Object getLoginId() {
|
||||
return getLogic().getLoginId();
|
||||
}
|
||||
|
||||
|
||||
public <T> T getLoginId(T defaultValue) {
|
||||
return getLogic().getLoginId(defaultValue);
|
||||
}
|
||||
|
||||
|
||||
public Object getLoginIdDefaultNull() {
|
||||
return getLogic().getLoginIdDefaultNull();
|
||||
}
|
||||
|
||||
|
||||
public String getLoginIdAsString() {
|
||||
return getLogic().getLoginIdAsString();
|
||||
}
|
||||
|
||||
|
||||
public int getLoginIdAsInt() {
|
||||
return getLogic().getLoginIdAsInt();
|
||||
}
|
||||
|
||||
|
||||
public long getLoginIdAsLong() {
|
||||
return getLogic().getLoginIdAsLong();
|
||||
}
|
||||
|
||||
|
||||
public Object getLoginIdByToken(String tokenValue) {
|
||||
return getLogic().getLoginIdByToken(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public String getLoginIdNotHandle(String tokenValue) {
|
||||
return getLogic().getLoginIdNotHandle(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public Object getExtra(String key) {
|
||||
return getLogic().getExtra(key);
|
||||
}
|
||||
|
||||
|
||||
public Object getExtra(String tokenValue, String key) {
|
||||
return getLogic().getExtra(tokenValue, key);
|
||||
}
|
||||
|
||||
|
||||
public boolean isValidLoginId(Object loginId) {
|
||||
return getLogic().isValidLoginId(loginId);
|
||||
}
|
||||
|
||||
|
||||
public void saveTokenToIdMapping(String tokenValue, Object loginId, long timeout) {
|
||||
getLogic().saveTokenToIdMapping(tokenValue, loginId, timeout);
|
||||
}
|
||||
|
||||
|
||||
public void updateTokenToIdMapping(String tokenValue, Object loginId) {
|
||||
getLogic().updateTokenToIdMapping(tokenValue, loginId);
|
||||
}
|
||||
|
||||
|
||||
public void deleteTokenToIdMapping(String tokenValue) {
|
||||
getLogic().deleteTokenToIdMapping(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public SaSession getSessionBySessionId(String sessionId, boolean isCreate, Long timeout, Consumer<SaSession> appendOperation) {
|
||||
return getLogic().getSessionBySessionId(sessionId, isCreate, timeout, appendOperation);
|
||||
}
|
||||
|
||||
|
||||
public SaSession getSessionBySessionId(String sessionId) {
|
||||
return getLogic().getSessionBySessionId(sessionId);
|
||||
}
|
||||
|
||||
|
||||
public SaSession getSessionByLoginId(Object loginId, boolean isCreate, Long timeout) {
|
||||
return getLogic().getSessionByLoginId(loginId, isCreate, timeout);
|
||||
}
|
||||
|
||||
|
||||
public SaSession getSessionByLoginId(Object loginId, boolean isCreate) {
|
||||
return getLogic().getSessionByLoginId(loginId, isCreate);
|
||||
}
|
||||
|
||||
|
||||
public SaSession getSessionByLoginId(Object loginId) {
|
||||
return getLogic().getSessionByLoginId(loginId);
|
||||
}
|
||||
|
||||
|
||||
public SaSession getSession(boolean isCreate) {
|
||||
return getLogic().getSession(isCreate);
|
||||
}
|
||||
|
||||
|
||||
public SaSession getSession() {
|
||||
return getLogic().getSession();
|
||||
}
|
||||
|
||||
|
||||
public SaSession getTokenSessionByToken(String tokenValue, boolean isCreate) {
|
||||
return getLogic().getTokenSessionByToken(tokenValue, isCreate);
|
||||
}
|
||||
|
||||
|
||||
public SaSession getTokenSessionByToken(String tokenValue) {
|
||||
return getLogic().getTokenSessionByToken(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public SaSession getTokenSession(boolean isCreate) {
|
||||
return getLogic().getTokenSession(isCreate);
|
||||
}
|
||||
|
||||
|
||||
public SaSession getTokenSession() {
|
||||
return getLogic().getTokenSession();
|
||||
}
|
||||
|
||||
|
||||
public SaSession getAnonTokenSession(boolean isCreate) {
|
||||
return getLogic().getAnonTokenSession(isCreate);
|
||||
}
|
||||
|
||||
|
||||
public SaSession getAnonTokenSession() {
|
||||
return getLogic().getAnonTokenSession();
|
||||
}
|
||||
|
||||
|
||||
public void deleteTokenSession(String tokenValue) {
|
||||
getLogic().deleteTokenSession(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public void updateLastActiveToNow(String tokenValue) {
|
||||
getLogic().updateLastActiveToNow(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public void updateLastActiveToNow() {
|
||||
getLogic().updateLastActiveToNow();
|
||||
}
|
||||
|
||||
|
||||
public void checkActiveTimeout(String tokenValue) {
|
||||
getLogic().checkActiveTimeout(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public void checkActiveTimeout() {
|
||||
getLogic().checkActiveTimeout();
|
||||
}
|
||||
|
||||
|
||||
public Long getTokenUseActiveTimeout(String tokenValue) {
|
||||
return getLogic().getTokenUseActiveTimeout(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public long getTokenUseActiveTimeoutOrGlobalConfig(String tokenValue) {
|
||||
return getLogic().getTokenUseActiveTimeoutOrGlobalConfig(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public long getTokenLastActiveTime(String tokenValue) {
|
||||
return getLogic().getTokenLastActiveTime(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public long getTokenLastActiveTime() {
|
||||
return getLogic().getTokenLastActiveTime();
|
||||
}
|
||||
|
||||
|
||||
public long getTokenTimeout() {
|
||||
return getLogic().getTokenTimeout();
|
||||
}
|
||||
|
||||
|
||||
public long getTokenTimeout(String token) {
|
||||
return getLogic().getTokenTimeout(token);
|
||||
}
|
||||
|
||||
|
||||
public long getTokenTimeoutByLoginId(Object loginId) {
|
||||
return getLogic().getTokenTimeoutByLoginId(loginId);
|
||||
}
|
||||
|
||||
|
||||
public long getSessionTimeout() {
|
||||
return getLogic().getSessionTimeout();
|
||||
}
|
||||
|
||||
|
||||
public long getSessionTimeoutByLoginId(Object loginId) {
|
||||
return getLogic().getSessionTimeoutByLoginId(loginId);
|
||||
}
|
||||
|
||||
|
||||
public long getTokenSessionTimeout() {
|
||||
return getLogic().getTokenSessionTimeout();
|
||||
}
|
||||
|
||||
|
||||
public long getTokenSessionTimeoutByTokenValue(String tokenValue) {
|
||||
return getLogic().getTokenSessionTimeoutByTokenValue(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public long getTokenActiveTimeout() {
|
||||
return getLogic().getTokenActiveTimeout();
|
||||
}
|
||||
|
||||
|
||||
public long getTokenActiveTimeoutByToken(String tokenValue) {
|
||||
return getLogic().getTokenActiveTimeoutByToken(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public void renewTimeout(long timeout) {
|
||||
getLogic().renewTimeout(timeout);
|
||||
}
|
||||
|
||||
|
||||
public void renewTimeout(String tokenValue, long timeout) {
|
||||
getLogic().renewTimeout(tokenValue, timeout);
|
||||
}
|
||||
|
||||
|
||||
public List<String> getRoleList() {
|
||||
return getLogic().getRoleList();
|
||||
}
|
||||
|
||||
|
||||
public List<String> getRoleList(Object loginId) {
|
||||
return getLogic().getRoleList(loginId);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasRole(String role) {
|
||||
return getLogic().hasRole(role);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasRole(Object loginId, String role) {
|
||||
return getLogic().hasRole(loginId, role);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasRoleAnd(String... roleArray) {
|
||||
return getLogic().hasRoleAnd(roleArray);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasRoleOr(String... roleArray) {
|
||||
return getLogic().hasRoleOr(roleArray);
|
||||
}
|
||||
|
||||
|
||||
public void checkRole(String role) {
|
||||
getLogic().checkRole(role);
|
||||
}
|
||||
|
||||
|
||||
public void checkRoleAnd(String... roleArray) {
|
||||
getLogic().checkRoleAnd(roleArray);
|
||||
}
|
||||
|
||||
|
||||
public void checkRoleOr(String... roleArray) {
|
||||
getLogic().checkRoleOr(roleArray);
|
||||
}
|
||||
|
||||
|
||||
public List<String> getPermissionList() {
|
||||
return getLogic().getPermissionList();
|
||||
}
|
||||
|
||||
|
||||
public List<String> getPermissionList(Object loginId) {
|
||||
return getLogic().getPermissionList(loginId);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPermission(String permission) {
|
||||
return getLogic().hasPermission(permission);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPermission(Object loginId, String permission) {
|
||||
return getLogic().hasPermission(loginId, permission);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPermissionAnd(String... permissionArray) {
|
||||
return getLogic().hasPermissionAnd(permissionArray);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPermissionOr(String... permissionArray) {
|
||||
return getLogic().hasPermissionOr(permissionArray);
|
||||
}
|
||||
|
||||
|
||||
public void checkPermission(String permission) {
|
||||
getLogic().checkPermission(permission);
|
||||
}
|
||||
|
||||
|
||||
public void checkPermissionAnd(String... permissionArray) {
|
||||
getLogic().checkPermissionAnd(permissionArray);
|
||||
}
|
||||
|
||||
|
||||
public void checkPermissionOr(String... permissionArray) {
|
||||
getLogic().checkPermissionOr(permissionArray);
|
||||
}
|
||||
|
||||
|
||||
public String getTokenValueByLoginId(Object loginId) {
|
||||
return getLogic().getTokenValueByLoginId(loginId);
|
||||
}
|
||||
|
||||
|
||||
public String getTokenValueByLoginId(Object loginId, String device) {
|
||||
return getLogic().getTokenValueByLoginId(loginId, device);
|
||||
}
|
||||
|
||||
|
||||
public List<String> getTokenValueListByLoginId(Object loginId) {
|
||||
return getLogic().getTokenValueListByLoginId(loginId);
|
||||
}
|
||||
|
||||
|
||||
public List<String> getTokenValueListByLoginId(Object loginId, String device) {
|
||||
return getLogic().getTokenValueListByLoginId(loginId, device);
|
||||
}
|
||||
|
||||
|
||||
public List<TokenSign> getTokenSignListByLoginId(Object loginId, String device) {
|
||||
return getLogic().getTokenSignListByLoginId(loginId, device);
|
||||
}
|
||||
|
||||
|
||||
public String getLoginDevice() {
|
||||
return getLogic().getLoginDevice();
|
||||
}
|
||||
|
||||
|
||||
public String getLoginDeviceByToken(String tokenValue) {
|
||||
return getLogic().getLoginDeviceByToken(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public List<String> searchTokenValue(String keyword, int start, int size, boolean sortType) {
|
||||
return getLogic().searchTokenValue(keyword, start, size, sortType);
|
||||
}
|
||||
|
||||
|
||||
public List<String> searchSessionId(String keyword, int start, int size, boolean sortType) {
|
||||
return getLogic().searchSessionId(keyword, start, size, sortType);
|
||||
}
|
||||
|
||||
|
||||
public List<String> searchTokenSessionId(String keyword, int start, int size, boolean sortType) {
|
||||
return getLogic().searchTokenSessionId(keyword, start, size, sortType);
|
||||
}
|
||||
|
||||
|
||||
public void disable(Object loginId, long time) {
|
||||
getLogic().disable(loginId, time);
|
||||
}
|
||||
|
||||
|
||||
public boolean isDisable(Object loginId) {
|
||||
return getLogic().isDisable(loginId);
|
||||
}
|
||||
|
||||
|
||||
public void checkDisable(Object loginId) {
|
||||
getLogic().checkDisable(loginId);
|
||||
}
|
||||
|
||||
|
||||
public long getDisableTime(Object loginId) {
|
||||
return getLogic().getDisableTime(loginId);
|
||||
}
|
||||
|
||||
|
||||
public void untieDisable(Object loginId) {
|
||||
getLogic().untieDisable(loginId);
|
||||
}
|
||||
|
||||
|
||||
public void disable(Object loginId, String service, long time) {
|
||||
getLogic().disable(loginId, service, time);
|
||||
}
|
||||
|
||||
|
||||
public boolean isDisable(Object loginId, String service) {
|
||||
return getLogic().isDisable(loginId, service);
|
||||
}
|
||||
|
||||
|
||||
public void checkDisable(Object loginId, String... services) {
|
||||
getLogic().checkDisable(loginId, services);
|
||||
}
|
||||
|
||||
|
||||
public long getDisableTime(Object loginId, String service) {
|
||||
return getLogic().getDisableTime(loginId, service);
|
||||
}
|
||||
|
||||
|
||||
public void untieDisable(Object loginId, String... services) {
|
||||
getLogic().untieDisable(loginId, services);
|
||||
}
|
||||
|
||||
|
||||
public void disableLevel(Object loginId, int level, long time) {
|
||||
getLogic().disableLevel(loginId, level, time);
|
||||
}
|
||||
|
||||
|
||||
public void disableLevel(Object loginId, String service, int level, long time) {
|
||||
getLogic().disableLevel(loginId, service, level, time);
|
||||
}
|
||||
|
||||
|
||||
public boolean isDisableLevel(Object loginId, int level) {
|
||||
return getLogic().isDisableLevel(loginId, level);
|
||||
}
|
||||
|
||||
|
||||
public boolean isDisableLevel(Object loginId, String service, int level) {
|
||||
return getLogic().isDisableLevel(loginId, service, level);
|
||||
}
|
||||
|
||||
|
||||
public void checkDisableLevel(Object loginId, int level) {
|
||||
getLogic().checkDisableLevel(loginId, level);
|
||||
}
|
||||
|
||||
|
||||
public void checkDisableLevel(Object loginId, String service, int level) {
|
||||
getLogic().checkDisableLevel(loginId, service, level);
|
||||
}
|
||||
|
||||
|
||||
public int getDisableLevel(Object loginId) {
|
||||
return getLogic().getDisableLevel(loginId);
|
||||
}
|
||||
|
||||
|
||||
public int getDisableLevel(Object loginId, String service) {
|
||||
return getLogic().getDisableLevel(loginId, service);
|
||||
}
|
||||
|
||||
|
||||
public void switchTo(Object loginId) {
|
||||
getLogic().switchTo(loginId);
|
||||
}
|
||||
|
||||
|
||||
public void endSwitch() {
|
||||
getLogic().endSwitch();
|
||||
}
|
||||
|
||||
|
||||
public boolean isSwitch() {
|
||||
return getLogic().isSwitch();
|
||||
}
|
||||
|
||||
|
||||
public Object getSwitchLoginId() {
|
||||
return getLogic().getSwitchLoginId();
|
||||
}
|
||||
|
||||
|
||||
public void switchTo(Object loginId, SaFunction function) {
|
||||
getLogic().switchTo(loginId, function);
|
||||
}
|
||||
|
||||
|
||||
public void openSafe(long safeTime) {
|
||||
getLogic().openSafe(safeTime);
|
||||
}
|
||||
|
||||
|
||||
public void openSafe(String service, long safeTime) {
|
||||
getLogic().openSafe(service, safeTime);
|
||||
}
|
||||
|
||||
|
||||
public boolean isSafe() {
|
||||
return getLogic().isSafe();
|
||||
}
|
||||
|
||||
|
||||
public boolean isSafe(String service) {
|
||||
return getLogic().isSafe(service);
|
||||
}
|
||||
|
||||
|
||||
public boolean isSafe(String tokenValue, String service) {
|
||||
return getLogic().isSafe(tokenValue, service);
|
||||
}
|
||||
|
||||
|
||||
public void checkSafe() {
|
||||
getLogic().checkSafe();
|
||||
}
|
||||
|
||||
|
||||
public void checkSafe(String service) {
|
||||
getLogic().checkSafe(service);
|
||||
}
|
||||
|
||||
|
||||
public long getSafeTime() {
|
||||
return getLogic().getSafeTime();
|
||||
}
|
||||
|
||||
|
||||
public long getSafeTime(String service) {
|
||||
return getLogic().getSafeTime(service);
|
||||
}
|
||||
|
||||
|
||||
public void closeSafe() {
|
||||
getLogic().closeSafe();
|
||||
}
|
||||
|
||||
|
||||
public void closeSafe(String service) {
|
||||
getLogic().closeSafe(service);
|
||||
}
|
||||
|
||||
|
||||
public String splicingKeyTokenName() {
|
||||
return getLogic().splicingKeyTokenName();
|
||||
}
|
||||
|
||||
|
||||
public String splicingKeyTokenValue(String tokenValue) {
|
||||
return getLogic().splicingKeyTokenValue(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public String splicingKeySession(Object loginId) {
|
||||
return getLogic().splicingKeySession(loginId);
|
||||
}
|
||||
|
||||
|
||||
public String splicingKeyTokenSession(String tokenValue) {
|
||||
return getLogic().splicingKeyTokenSession(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public String splicingKeyLastActiveTime(String tokenValue) {
|
||||
return getLogic().splicingKeyLastActiveTime(tokenValue);
|
||||
}
|
||||
|
||||
|
||||
public String splicingKeySwitch() {
|
||||
return getLogic().splicingKeySwitch();
|
||||
}
|
||||
|
||||
|
||||
public String splicingKeyJustCreatedSave() {
|
||||
return getLogic().splicingKeyJustCreatedSave();
|
||||
}
|
||||
|
||||
|
||||
public String splicingKeyDisable(Object loginId, String service) {
|
||||
return getLogic().splicingKeyDisable(loginId, service);
|
||||
}
|
||||
|
||||
|
||||
public String splicingKeySafe(String tokenValue, String service) {
|
||||
return getLogic().splicingKeySafe(tokenValue, service);
|
||||
}
|
||||
|
||||
|
||||
public SaTokenDao getSaTokenDao() {
|
||||
return getLogic().getSaTokenDao();
|
||||
}
|
||||
|
||||
|
||||
public boolean getConfigOfIsShare() {
|
||||
return getLogic().getConfigOfIsShare();
|
||||
}
|
||||
|
||||
|
||||
public boolean isOpenCheckActiveTimeout() {
|
||||
return getLogic().isOpenCheckActiveTimeout();
|
||||
}
|
||||
|
||||
|
||||
public int getConfigOfCookieTimeout() {
|
||||
return getLogic().getConfigOfCookieTimeout();
|
||||
}
|
||||
|
||||
|
||||
public int getConfigOfMaxTryTimes() {
|
||||
return getLogic().getConfigOfMaxTryTimes();
|
||||
}
|
||||
|
||||
|
||||
public boolean hasElement(List<String> list, String element) {
|
||||
return getLogic().hasElement(list, element);
|
||||
}
|
||||
|
||||
|
||||
public boolean isSupportExtra() {
|
||||
return getLogic().isSupportExtra();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class StpKit {
|
|||
/**
|
||||
* User 会话对象,管理 User 表所有账号的登录、权限认证
|
||||
*/
|
||||
public static final MyStpLogic USER = new MyStpLogic("user");
|
||||
public static final MyStpLogic USER = new MyStpLogic();
|
||||
|
||||
|
||||
// public StpKit() {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,13 @@ import java.util.Set;
|
|||
*/
|
||||
public interface ShopCouponService extends IService<ShopCoupon> {
|
||||
|
||||
List<ShopCouponDTO> getList(ShopCouponDTO couponDTO);
|
||||
/**
|
||||
* 优惠券列表
|
||||
* @param shopId 店铺id
|
||||
* @param status 状态 0 未使用 1已使用 -1已过期
|
||||
* @return
|
||||
*/
|
||||
List<ShopCouponDTO> getList(Long shopId, Integer status);
|
||||
ShopCouponDTO getCouponById(ShopCouponDTO couponDTO);
|
||||
|
||||
Boolean add(ShopCouponDTO couponDTO);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.czg.account.dto.ShopCouponDTO;
|
||||
import com.czg.account.entity.ShopActivateInRecord;
|
||||
import com.czg.account.entity.ShopActivateOutRecord;
|
||||
import com.czg.account.service.ShopActivateInRecordService;
|
||||
import com.czg.account.service.ShopActivateOutRecordService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopCoupon;
|
||||
import com.czg.account.service.ShopCouponService;
|
||||
|
|
@ -30,8 +32,31 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
|||
private ShopActivateOutRecordService outService;
|
||||
|
||||
@Override
|
||||
public List<ShopCouponDTO> getList(ShopCouponDTO couponDTO) {
|
||||
return null;
|
||||
public List<ShopCouponDTO> getList(Long shopId, Integer status) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
if (shopId != null) {
|
||||
if (status == 1) {
|
||||
queryWrapper.eq(ShopActivateOutRecord::getShopId, shopId);
|
||||
}else {
|
||||
queryWrapper.eq(ShopActivateInRecord::getShopId, shopId);
|
||||
}
|
||||
}
|
||||
return switch (status) {
|
||||
case -1 -> {
|
||||
queryWrapper.ge(ShopActivateInRecord::getUseEndTime, DateUtil.date());
|
||||
// yield list(queryWrapper);
|
||||
yield null;
|
||||
}
|
||||
case 0 -> {
|
||||
yield null;
|
||||
|
||||
}
|
||||
case 1 -> {
|
||||
yield null;
|
||||
|
||||
}
|
||||
default -> throw new IllegalStateException("Unexpected value: " + status);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue