增加管理员模块~
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package cn.iocoder.mall.user.config;
|
||||
|
||||
import cn.iocoder.common.framework.config.GlobalExceptionHandler;
|
||||
import cn.iocoder.mall.user.sdk.interceptor.SecurityInterceptor;
|
||||
import cn.iocoder.mall.user.sdk.interceptor.UserSecurityInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -13,11 +13,11 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
@EnableWebMvc
|
||||
@Configuration
|
||||
@Import(value = {GlobalExceptionHandler.class, // 统一全局返回
|
||||
SecurityInterceptor.class}) // 安全拦截器,实现认证和授权功能。
|
||||
UserSecurityInterceptor.class}) // 安全拦截器,实现认证和授权功能。
|
||||
public class MVCConfiguration implements WebMvcConfigurer {
|
||||
|
||||
@Autowired
|
||||
private SecurityInterceptor securityInterceptor;
|
||||
private UserSecurityInterceptor securityInterceptor;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package cn.iocoder.mall.user.config;
|
||||
|
||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.mall.user.service.api.constant.UserErrorCodeEnum;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
||||
@Configuration
|
||||
public class ServiceExceptionConfiguration {
|
||||
|
||||
@EventListener(ApplicationReadyEvent.class) // 可参考 https://www.cnblogs.com/ssslinppp/p/7607509.html
|
||||
public void initMessages() {
|
||||
// 从 service_exception_message.properties 加载错误码的方案
|
||||
// Properties properties;
|
||||
// try {
|
||||
// properties = PropertiesLoaderUtils.loadAllProperties("classpath:service_exception_message.properties");
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
for (UserErrorCodeEnum item : UserErrorCodeEnum.values()) {
|
||||
ServiceExceptionUtil.put(item.getCode(), item.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class PassportController {
|
||||
})
|
||||
public CommonResult<MobileRegisterVO> mobileRegister(@RequestParam("mobile") String mobile,
|
||||
@RequestParam("code") String code) {
|
||||
CommonResult<OAuth2AccessTokenBO> result = oauth2Service.getAccessToken2(mobile, code);
|
||||
CommonResult<OAuth2AccessTokenBO> result = oauth2Service.getAccessToken(mobile, code);
|
||||
return PassportConvert.INSTANCE.convert(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.iocoder.mall.user.controller;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.user.sdk.context.SecurityContextHolder;
|
||||
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
|
||||
import cn.iocoder.mall.user.vo.UserInfoVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -18,7 +18,7 @@ public class UserController {
|
||||
@ApiOperation(value = "用户信息")
|
||||
public CommonResult<UserInfoVO> info() {
|
||||
// TODO 芋艿,正在实现中
|
||||
UserInfoVO user = new UserInfoVO().setId(SecurityContextHolder.getContext().getUid());
|
||||
UserInfoVO user = new UserInfoVO().setId(UserSecurityContextHolder.getContext().getUid());
|
||||
return CommonResult.success(user);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user