Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
363bfc48a8
|
|
@ -4,6 +4,7 @@ import com.czg.account.dto.SysLoginDTO;
|
||||||
import com.czg.account.service.AuthorizationService;
|
import com.czg.account.service.AuthorizationService;
|
||||||
import com.czg.account.service.PermissionService;
|
import com.czg.account.service.PermissionService;
|
||||||
import com.czg.account.vo.LoginVO;
|
import com.czg.account.vo.LoginVO;
|
||||||
|
import com.czg.annotation.SaAdminCheckPermission;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
|
@ -49,9 +50,9 @@ public class AuthorizationController {
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SaAdminCheckPermission("/adadas")
|
||||||
@GetMapping("test")
|
@GetMapping("test")
|
||||||
public CzgResult<?> login() {
|
public CzgResult<?> login() {
|
||||||
StpKit.ADMIN.login(1);
|
return CzgResult.success(Map.of("token", StpKit.ADMIN.getShopId()));
|
||||||
return CzgResult.success(Map.of("token", StpKit.ADMIN.getTokenInfo()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,8 @@ public class StpInterfaceImpl implements StpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @Nullable List<String> getCashInfo(String key) {
|
private static @Nullable List<String> getCashInfo(String key) {
|
||||||
Object value = StpKit.ADMIN.getSaTokenDao().getObject(key);
|
Object value = StpKit.ADMIN.getSession().get(key);
|
||||||
if (value instanceof List<?> list) {
|
if (value instanceof List<?> list) {
|
||||||
// 续费时间
|
|
||||||
long timeout = StpKit.ADMIN.getTokenTimeout();
|
|
||||||
if (timeout > 0) {
|
|
||||||
StpKit.ADMIN.getSaTokenDao().updateObjectTimeout(key, StpKit.ADMIN.getTokenTimeout() + 120);
|
|
||||||
}
|
|
||||||
return (List<String>) list;
|
return (List<String>) list;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -26,41 +26,18 @@ public class MyStpLogic extends StpLogic {
|
||||||
super(loginType);
|
super(loginType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户登录
|
|
||||||
* @param sysUserId 系统用户id
|
|
||||||
* @param shopId 店铺id
|
|
||||||
*/
|
|
||||||
public void login(Long sysUserId, Long shopId) {
|
|
||||||
login(sysUserId);
|
|
||||||
setShopId(shopId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取店铺id
|
* 获取店铺id
|
||||||
* @return 返回店铺id,不存在抛出异常
|
* @return 返回店铺id,不存在抛出异常
|
||||||
*/
|
*/
|
||||||
public Long getShopId() {
|
public Long getShopId() {
|
||||||
String key = "sa:shopId:" + getLoginType() + ":" + getLoginId();
|
Object object = StpKit.ADMIN.getSession().get("shopId");
|
||||||
Object object = getSaTokenDao().getObject(key);
|
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
throw new ApiNotPrintException("shopId获取失败");
|
throw new ApiNotPrintException("shopId获取失败");
|
||||||
}
|
}
|
||||||
// 续费时间
|
|
||||||
long timeout = getTokenTimeout();
|
|
||||||
if (timeout > 0) {
|
|
||||||
getSaTokenDao().updateObjectTimeout(key, getTokenTimeout() + 120);
|
|
||||||
}
|
|
||||||
return (Long) object;
|
return (Long) object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置店铺id
|
|
||||||
* @param shopId 店铺id
|
|
||||||
*/
|
|
||||||
private void setShopId(Long shopId) {
|
|
||||||
this.getSaTokenDao().setObject("sa:shopId:" + getLoginType() + ":" + getLoginId(), shopId, getTokenTimeout() + 120);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加当前账号的角色
|
* 添加当前账号的角色
|
||||||
|
|
@ -68,7 +45,7 @@ public class MyStpLogic extends StpLogic {
|
||||||
* @return 当前实例
|
* @return 当前实例
|
||||||
*/
|
*/
|
||||||
public MyStpLogic addRoleList(List<String> roleList) {
|
public MyStpLogic addRoleList(List<String> roleList) {
|
||||||
this.getSaTokenDao().setObject("sa:roleList:" + getLoginType() + ":" + getLoginId(), roleList, getTokenTimeout() + 120);
|
getSession().set("sa:roleList:" + getLoginType() + ":" + getLoginId(), roleList);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,7 +55,7 @@ public class MyStpLogic extends StpLogic {
|
||||||
* @return 当前实例
|
* @return 当前实例
|
||||||
*/
|
*/
|
||||||
public MyStpLogic addPermissionList(List<String> permissionList) {
|
public MyStpLogic addPermissionList(List<String> permissionList) {
|
||||||
this.getSaTokenDao().setObject("sa:permissionList:" + getLoginType() + ":" + getLoginId(), permissionList, getTokenTimeout() + 120);
|
getSession().set("sa:permissionList:" + getLoginType() + ":" + getLoginId(), permissionList);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,8 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StpKit.ADMIN.login(user.getId(), shopInfo.getId());
|
StpKit.ADMIN.login(user.getId());
|
||||||
|
StpKit.ADMIN.getSession().set("userId", user.getId()).set("shopId", shopInfo.getId()).set("isAdmin", user.getIsAdmin());
|
||||||
StpKit.ADMIN.setAdmin(user.getIsAdmin());
|
StpKit.ADMIN.setAdmin(user.getIsAdmin());
|
||||||
// 查询角色
|
// 查询角色
|
||||||
List<SysRole> roleList = sysRoleService.getByUserId(user.getId());
|
List<SysRole> roleList = sysRoleService.getByUserId(user.getId());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue