feat(login): 添加自定义 TokenBean 并更新相关逻辑
This commit is contained in:
@@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.tiesheng.annotation.role.RoleAuthority;
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
import com.tiesheng.annotation.token.TokenIgnore;
|
||||||
import com.tiesheng.database.config.DbBackupConfig;
|
import com.tiesheng.database.config.DbBackupConfig;
|
||||||
|
import com.tiesheng.demo.pojos.CustTokenBean;
|
||||||
import com.tiesheng.demo.pojos.JsonTest;
|
import com.tiesheng.demo.pojos.JsonTest;
|
||||||
import com.tiesheng.demo.pojos.PoiBean;
|
import com.tiesheng.demo.pojos.PoiBean;
|
||||||
import com.tiesheng.platform.config.ding.PlatformDingConfig;
|
import com.tiesheng.platform.config.ding.PlatformDingConfig;
|
||||||
@@ -43,7 +44,6 @@ import java.util.function.Consumer;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/test")
|
@RequestMapping("/test")
|
||||||
@RoleAuthority(value = "test", group = "test")
|
|
||||||
public class TestController {
|
public class TestController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -65,7 +65,6 @@ public class TestController {
|
|||||||
|
|
||||||
|
|
||||||
@RequestMapping("/index")
|
@RequestMapping("/index")
|
||||||
@TokenIgnore
|
|
||||||
public void index(HttpServletResponse response) {
|
public void index(HttpServletResponse response) {
|
||||||
globalConfig.redirectWithVer("mobile", "/test", response);
|
globalConfig.redirectWithVer("mobile", "/test", response);
|
||||||
}
|
}
|
||||||
@@ -113,8 +112,9 @@ public class TestController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("/send")
|
@GetMapping("/send")
|
||||||
@TokenIgnore
|
public ApiResp<String> sendMessage(CustTokenBean tokenBean) {
|
||||||
public ApiResp<String> sendMessage() {
|
|
||||||
|
tokenBean.test();
|
||||||
|
|
||||||
// MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"),
|
// MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"),
|
||||||
// JSONUtil.createObj().putOpt("action", "sms-visitor-invite"));
|
// JSONUtil.createObj().putOpt("action", "sms-visitor-invite"));
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.tiesheng.demo.pojos;
|
||||||
|
|
||||||
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
|
|
||||||
|
public class CustTokenBean extends TokenBean {
|
||||||
|
|
||||||
|
|
||||||
|
public void test() {
|
||||||
|
System.out.println("test: " + getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.tiesheng.login.config;
|
package com.tiesheng.login.config;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
import com.tiesheng.annotation.token.TokenIgnore;
|
||||||
@@ -40,7 +41,7 @@ public class TokenWebMvcConfigurer implements WebMvcConfigurer {
|
|||||||
resolvers.add(new HandlerMethodArgumentResolver() {
|
resolvers.add(new HandlerMethodArgumentResolver() {
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsParameter(MethodParameter parameter) {
|
public boolean supportsParameter(MethodParameter parameter) {
|
||||||
return parameter.getParameterType().isAssignableFrom(TokenBean.class);
|
return TokenBean.class.isAssignableFrom(parameter.getParameterType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -54,7 +55,9 @@ public class TokenWebMvcConfigurer implements WebMvcConfigurer {
|
|||||||
TokenIgnore annotation = method.getAnnotation(TokenIgnore.class);
|
TokenIgnore annotation = method.getAnnotation(TokenIgnore.class);
|
||||||
thrExp = annotation == null;
|
thrExp = annotation == null;
|
||||||
}
|
}
|
||||||
return tsTokenConfig.validToken(header, thrExp);
|
|
||||||
|
TokenBean tokenBean = tsTokenConfig.validToken(header, thrExp);
|
||||||
|
return BeanUtil.copyProperties(tokenBean, parameter.getParameterType());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user