获取shopId
This commit is contained in:
@@ -61,6 +61,7 @@ public class MyStpLogic {
|
||||
|
||||
/**
|
||||
* 获取当前登录账号名称 管理端为用户账号 客户端为openId
|
||||
*
|
||||
* @return 账号或openId
|
||||
*/
|
||||
public String getAccount() {
|
||||
@@ -77,10 +78,9 @@ public class MyStpLogic {
|
||||
public Long getShopId(Long... defaultValue) {
|
||||
StpLogic logic = getLogic();
|
||||
Long defaultVal = defaultValue.length > 0 ? defaultValue[0] : null;
|
||||
Object object = logic.getSession().get("isManager");
|
||||
Long shopId;
|
||||
int errType;
|
||||
if (object instanceof Boolean t && t) {
|
||||
if ("admin".equals(logic.getLoginType())) {
|
||||
Object info = logic.getSession().get("shopId");
|
||||
shopId = info instanceof Long l ? l : null;
|
||||
errType = 0;
|
||||
@@ -90,11 +90,30 @@ public class MyStpLogic {
|
||||
if (StrUtil.isBlank(requestParam)) {
|
||||
String header = request.getHeader("shopId");
|
||||
shopId = StrUtil.isBlank(header) ? null : Long.parseLong(header);
|
||||
}else {
|
||||
} else {
|
||||
shopId = Long.parseLong(requestParam);
|
||||
}
|
||||
errType = 1;
|
||||
}
|
||||
// Long defaultVal = defaultValue.length > 0 ? defaultValue[0] : null;
|
||||
// Object object = logic.getSession().get("isManager");
|
||||
// Long shopId;
|
||||
// int errType;
|
||||
// if (object instanceof Boolean t && t) {
|
||||
// Object info = logic.getSession().get("shopId");
|
||||
// shopId = info instanceof Long l ? l : null;
|
||||
// errType = 0;
|
||||
// } else {
|
||||
// SaRequest request = SaHolder.getRequest();
|
||||
// String requestParam = request.getParam("shopId");
|
||||
// if (StrUtil.isBlank(requestParam)) {
|
||||
// String header = request.getHeader("shopId");
|
||||
// shopId = StrUtil.isBlank(header) ? null : Long.parseLong(header);
|
||||
// }else {
|
||||
// shopId = Long.parseLong(requestParam);
|
||||
// }
|
||||
// errType = 1;
|
||||
// }
|
||||
|
||||
if (defaultValue.length == 0 && shopId == null) {
|
||||
throw new ApiNotPrintException(errType == 0 ? "shopId获取失败" : "客户端请求头未携带shopId");
|
||||
|
||||
Reference in New Issue
Block a user