Commit f342210e by aye

代码提交

parent 9487a457
<component name="libraryTable">
<library name="Maven: javax.servlet:servlet-api:2.5">
<CLASSES>
<root url="jar://D:/Tool/apache-maven-3.3.1/maven-repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://D:/Tool/apache-maven-3.3.1/maven-repository/javax/servlet/servlet-api/2.5/servlet-api-2.5-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://D:/Tool/apache-maven-3.3.1/maven-repository/javax/servlet/servlet-api/2.5/servlet-api-2.5-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
package com.jty.wsxt.application; package com.jty.wsxt.application;
import com.jty.wsxt.application.feign.UserFeign; import com.jty.wsxt.application.feign.UserFeign;
import com.jty.wsxt.application.service.ModuleService;
import com.jty.wsxt.application.service.PaperService;
import com.jty.wsxt.application.service.SubjectService;
import com.jty.wsxt.application.service.TypeService;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
...@@ -21,6 +25,22 @@ public class ApplicationRegistry implements ApplicationContextAware { ...@@ -21,6 +25,22 @@ public class ApplicationRegistry implements ApplicationContextAware {
return applicationContext.getBean(UserFeign.class); return applicationContext.getBean(UserFeign.class);
} }
public static ModuleService moduleService(){
return applicationContext.getBean(ModuleService.class);
}
public static PaperService paperService(){
return applicationContext.getBean(PaperService.class);
}
public static SubjectService subjectService(){
return applicationContext.getBean(SubjectService.class);
}
public static TypeService typeService(){
return applicationContext.getBean(TypeService.class);
}
@Override @Override
public synchronized void setApplicationContext(ApplicationContext applicationContext) throws BeansException { public synchronized void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if(ApplicationRegistry.applicationContext==null) { if(ApplicationRegistry.applicationContext==null) {
......
package com.jty.wsxt.application.service;
/**
* ModuleService
*
* @author Manjiajie
* @since 2019-6-21 11:33:48
*/
public interface ModuleService {
}
package com.jty.wsxt.application.service;
/**
* PaperService
*
* @author Manjiajie
* @since 2019-6-21 11:35:20
*/
public interface PaperService {
}
package com.jty.wsxt.application.service;
/**
* SubjectService
*
* @author Manjiajie
* @since 2019-6-21 11:34:41
*/
public interface SubjectService {
}
package com.jty.wsxt.application.service;
/**
* TypeService
*
* @author Manjiajie
* @since 2019-6-21 11:35:54
*/
public interface TypeService {
}
package com.jty.wsxt.application.service.impl;
import com.jty.wsxt.application.service.ModuleService;
import org.springframework.stereotype.Service;
/**
* ModuleServiceImpl
*
* @author Manjiajie
* @since 2019-6-21 11:37:06
*/
@Service
public class ModuleServiceImpl implements ModuleService {
}
package com.jty.wsxt.application.service.impl;
import com.jty.wsxt.application.service.PaperService;
import org.springframework.stereotype.Service;
/**
* PaperServiceImpl
*
* @author Manjiajie
* @since 2019-6-21 11:38:06
*/
@Service
public class PaperServiceImpl implements PaperService {
}
package com.jty.wsxt.application.service.impl;
import com.jty.wsxt.application.service.SubjectService;
import org.springframework.stereotype.Service;
/**
* SubjectServiceImpl
*
* @author Manjiajie
* @since 2019-6-21 11:38:53
*/
@Service
public class SubjectServiceImpl implements SubjectService {
}
package com.jty.wsxt.application.service.impl;
import com.jty.wsxt.application.service.TypeService;
import org.springframework.stereotype.Service;
/**
* TypeServiceImpl
*
* @author Manjiajie
* @since 2019-6-21 11:39:44
*/
@Service
public class TypeServiceImpl implements TypeService {
}
package com.jty.wsxt.infrastructure.config;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
/**
* Feign调用配置Token转发
*
* @author Jason
* @since 2018/12/29 13:08
*/
@Configuration
public class FeignConfig implements RequestInterceptor {
@Override
public void apply(RequestTemplate template) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
//添加token
template.header("Access-Token", request.getHeader("Access-Token"));
template.header("Authorization", request.getHeader("Authorization"));
}
}
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