mirror of
https://gitee.com/dromara/sa-token.git
synced 2024-11-29 18:37:49 +08:00
solon 升为 3.0.1
This commit is contained in:
parent
d75e4b799d
commit
824a4fec30
@ -10,7 +10,7 @@
|
||||
<parent>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-parent</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<version>3.0.1</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<parent>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-parent</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<version>3.0.1</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
|
@ -10,14 +10,13 @@
|
||||
<parent>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-parent</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<version>3.0.1</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<!-- 定义 Sa-Token 版本号 -->
|
||||
<properties>
|
||||
<sa-token.version>1.39.0</sa-token.version>
|
||||
<solon.version>2.9.2</solon.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<parent>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-parent</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<version>3.0.1</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<parent>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-parent</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<version>3.0.1</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<parent>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-parent</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<version>3.0.1</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<servlet-api.version>3.1.0</servlet-api.version>
|
||||
<jakarta-servlet-api.version>6.0.0</jakarta-servlet-api.version>
|
||||
<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
|
||||
<solon.version>2.9.2</solon.version>
|
||||
<solon.version>3.0.1</solon.version>
|
||||
<noear-redisx.version>1.6.2</noear-redisx.version>
|
||||
<noear-snack3.version>3.2.88</noear-snack3.version>
|
||||
<jfinal.version>4.9.17</jfinal.version>
|
||||
|
@ -51,21 +51,9 @@ public class XPluginImp implements Plugin {
|
||||
|
||||
@Override
|
||||
public void start(AppContext context) {
|
||||
// Sa-Token 日志输出 Bean
|
||||
context.getBeanAsync(SaLog.class, bean -> {
|
||||
SaManager.setLog(bean);
|
||||
});
|
||||
|
||||
|
||||
//注入其它 Bean
|
||||
context.lifecycle(-99, () -> {
|
||||
beanInitDo(context);
|
||||
context.beanMake(SaSsoAutoConfigure.class);
|
||||
context.beanMake(SaOAuth2AutoConfigure.class);
|
||||
});
|
||||
}
|
||||
|
||||
private void beanInitDo(AppContext context) {
|
||||
// 注入上下文Bean
|
||||
SaManager.setSaTokenContext(new SaContextForSolon());
|
||||
|
||||
@ -78,6 +66,12 @@ public class XPluginImp implements Plugin {
|
||||
SaManager.setConfig(saTokenConfig);
|
||||
}
|
||||
|
||||
// Sa-Token 日志输出 Bean
|
||||
context.getBeanAsync(SaLog.class, bean -> {
|
||||
SaManager.setLog(bean);
|
||||
});
|
||||
|
||||
//注入 SaTokenConfig
|
||||
context.getBeanAsync(SaTokenConfig.class, bean -> {
|
||||
SaManager.setConfig(bean);
|
||||
});
|
||||
@ -146,6 +140,5 @@ public class XPluginImp implements Plugin {
|
||||
context.getBeanAsync(StpLogic.class, bean -> {
|
||||
StpUtil.setStpLogic(bean);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright 2020-2099 sa-token.cc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.dev33.satoken.solon.dao;
|
||||
|
||||
import cn.dev33.satoken.session.SaSession;
|
||||
import cn.dev33.satoken.util.SaFoxUtil;
|
||||
import org.noear.snack.ONode;
|
||||
|
||||
// 不能删;为保持与旧的序列化兼容
|
||||
/**
|
||||
* Snack3 定制版 SaSession,重写类型转换API
|
||||
*
|
||||
* @author noear
|
||||
* @since 1.12
|
||||
*/
|
||||
@Deprecated
|
||||
public class SaSessionForJson extends SaSession {
|
||||
|
||||
private static final long serialVersionUID = -7600983549653130681L;
|
||||
|
||||
public SaSessionForJson() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建一个 SaSession 对象
|
||||
* @param id Session 的 id
|
||||
*/
|
||||
public SaSessionForJson(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取值 (指定转换类型)
|
||||
* @param <T> 泛型
|
||||
* @param key key
|
||||
* @param cs 指定转换类型
|
||||
* @return 值
|
||||
*/
|
||||
@Override
|
||||
public <T> T getModel(String key, Class<T> cs) {
|
||||
if(SaFoxUtil.isBasicType(cs)) {
|
||||
return SaFoxUtil.getValueByType(get(key), cs);
|
||||
}
|
||||
return ONode.deserialize(getString(key), cs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取值 (指定转换类型, 并指定值为Null时返回的默认值)
|
||||
* @param <T> 泛型
|
||||
* @param key key
|
||||
* @param cs 指定转换类型
|
||||
* @param defaultValue 值为Null时返回的默认值
|
||||
* @return 值
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getModel(String key, Class<T> cs, Object defaultValue) {
|
||||
Object value = get(key);
|
||||
if(valueIsNull(value)) {
|
||||
return (T)defaultValue;
|
||||
}
|
||||
if(SaFoxUtil.isBasicType(cs)) {
|
||||
return SaFoxUtil.getValueByType(get(key), cs);
|
||||
}
|
||||
return ONode.deserialize(getString(key), cs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 忽略 timeout 字段的序列化
|
||||
*/
|
||||
@Override
|
||||
public long getTimeout() {
|
||||
return super.getTimeout();
|
||||
}
|
||||
|
||||
}
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package cn.dev33.satoken.solon.integration;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.dev33.satoken.exception.BackResultException;
|
||||
import cn.dev33.satoken.exception.SaTokenException;
|
||||
import cn.dev33.satoken.exception.StopMatchException;
|
||||
@ -24,7 +23,6 @@ import cn.dev33.satoken.filter.SaFilterErrorStrategy;
|
||||
import cn.dev33.satoken.filter.SaFilter;
|
||||
import cn.dev33.satoken.router.SaRouter;
|
||||
import cn.dev33.satoken.strategy.SaAnnotationStrategy;
|
||||
import cn.dev33.satoken.strategy.SaStrategy;
|
||||
import org.noear.solon.Solon;
|
||||
import org.noear.solon.core.handle.*;
|
||||
import org.noear.solon.core.route.RoutingTable;
|
||||
|
@ -33,7 +33,7 @@ public class SaRequestForSolon implements SaRequest {
|
||||
|
||||
protected Context ctx;
|
||||
|
||||
public SaRequestForSolon(){
|
||||
public SaRequestForSolon() {
|
||||
ctx = Context.current();
|
||||
}
|
||||
|
||||
@ -48,18 +48,18 @@ public class SaRequestForSolon implements SaRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getParamNames(){
|
||||
Set<String> names = ctx.paramMap().keySet();
|
||||
return new ArrayList<>(names);
|
||||
public List<String> getParamNames() {
|
||||
return new ArrayList<>(ctx.paramNames());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 [请求体] 里提交的所有参数
|
||||
*
|
||||
* @return 参数列表
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getParamMap(){
|
||||
return ctx.paramMap();
|
||||
public Map<String, String> getParamMap() {
|
||||
return ctx.paramMap().toValueMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,31 +76,19 @@ public class SaRequestForSolon implements SaRequest {
|
||||
* 在 [ Cookie作用域 ] 里获取一个值 (第一个此名称的)
|
||||
*/
|
||||
@Override
|
||||
public String getCookieFirstValue(String name){
|
||||
public String getCookieFirstValue(String name) {
|
||||
return ctx.cookie(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在 [ Cookie作用域 ] 里获取一个值 (最后一个此名称的)
|
||||
*
|
||||
* @param name 键
|
||||
* @return 值
|
||||
*/
|
||||
@Override
|
||||
public String getCookieLastValue(String name){
|
||||
String value = null;
|
||||
String cookieStr = ctx.header("Cookie");
|
||||
if(SaFoxUtil.isNotEmpty(cookieStr)) {
|
||||
String[] cookieItems = cookieStr.split(";");
|
||||
for (String item : cookieItems) {
|
||||
String[] kv = item.split("=");
|
||||
if (kv.length == 2) {
|
||||
if (kv[0].trim().equals(name)) {
|
||||
value = kv[1].trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
public String getCookieLastValue(String name) {
|
||||
return ctx.cookieMap().holder(name).getLastValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,7 +99,7 @@ public class SaRequestForSolon implements SaRequest {
|
||||
@Override
|
||||
public String getUrl() {
|
||||
String currDomain = SaManager.getConfig().getCurrDomain();
|
||||
if( ! SaFoxUtil.isEmpty(currDomain)) {
|
||||
if (!SaFoxUtil.isEmpty(currDomain)) {
|
||||
return currDomain + this.getRequestPath();
|
||||
}
|
||||
return ctx.url();
|
||||
@ -127,5 +115,4 @@ public class SaRequestForSolon implements SaRequest {
|
||||
ctx.forward(path);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ public class SaResponseForSolon implements SaResponse {
|
||||
|
||||
/**
|
||||
* 在响应头里添加一个值
|
||||
*
|
||||
* @param name 名字
|
||||
* @param value 值
|
||||
* @return 对象自身
|
||||
|
Loading…
Reference in New Issue
Block a user