Commit 71d0292b authored by xiaoguang.xu's avatar xiaoguang.xu

修复类名相同无法启动问题,修复策略 postConstruct 执行时机错误问题。

parent a8d1bd8c
package cn.quantgroup.xyqb.controller.middleoffice.common;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
@Component
public class VerifyStrategyFactory{
public class VerifyStrategyFactory {
private static final Map<VerifyTypeEnum, IVerifyStrategy> strategiesMap = new HashMap<>();
@PostConstruct
public void init(){
static {
//cache
WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
Map<String, IVerifyStrategy> beansOfType = context.getBeansOfType(IVerifyStrategy.class);
beansOfType.values().forEach(strategy -> strategiesMap.put(strategy.strategyName(), strategy));
}
public static IVerifyStrategy get(VerifyTypeEnum verifyTypeEnum){
public static IVerifyStrategy get(VerifyTypeEnum verifyTypeEnum) {
return strategiesMap.get(verifyTypeEnum);
}
......
package cn.quantgroup.xyqb.controller.middleoffice.common.image;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
@Component
public class ImageVerifyStrategyFactory {
private static final Map<ImageVerifyTypeEnum, IImageVerifyStrategy> strategiesMap = new HashMap<>();
@PostConstruct
public void init(){
static {
//cache
WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
Map<String, IImageVerifyStrategy> beansOfType = context.getBeansOfType(IImageVerifyStrategy.class);
beansOfType.values().forEach(strategy -> strategiesMap.put(strategy.strategyName(), strategy));
}
public static IImageVerifyStrategy get(ImageVerifyTypeEnum verifyTypeEnum){
public static IImageVerifyStrategy get(ImageVerifyTypeEnum verifyTypeEnum) {
return strategiesMap.get(verifyTypeEnum);
}
......
......@@ -15,7 +15,7 @@ import javax.annotation.Resource;
/**
* 短信
*/
@RestController
@RestController("middleSmsController")
@RequestMapping("/middle_office/sms")
public class SmsController {
......
......@@ -10,7 +10,7 @@ import javax.annotation.Resource;
/**
* 用户信息
*/
@RestController
@RestController("middleUserController")
@RequestMapping("/middle_office/user")
public class UserController {
......
......@@ -18,7 +18,7 @@ import java.sql.Timestamp;
/**
* 用户实名信息
*/
@RestController
@RestController("middleUserDetailController")
@RequestMapping("/middle_office/user_detail")
public class UserDetailController {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment