- 后端:临时解决 Dubbo 内嵌在 Spring Boot 时,对本地的 Dubbo Service 引用报错的问题。
- 前端:完善商品推荐 - 前端:完善优惠劵
This commit is contained in:
@@ -12,6 +12,12 @@
|
||||
<artifactId>system-application</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>common-framework</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>system-service-impl</artifactId>
|
||||
@@ -22,11 +28,6 @@
|
||||
<artifactId>system-sdk</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>common-framework</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -48,11 +49,11 @@
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-devtools</artifactId>-->
|
||||
<!-- <optional>true</optional>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>de.codecentric</groupId>-->
|
||||
|
||||
@@ -20,7 +20,9 @@ import java.util.Set;
|
||||
@EnableWebMvc
|
||||
@Configuration
|
||||
@Import(value = {GlobalExceptionHandler.class, // 统一全局返回
|
||||
AdminSecurityInterceptor.class})
|
||||
AdminAccessLogInterceptor.class,
|
||||
AdminSecurityInterceptor.class
|
||||
})
|
||||
public class MVCConfiguration implements WebMvcConfigurer {
|
||||
|
||||
// @Autowired
|
||||
@@ -36,7 +38,6 @@ public class MVCConfiguration implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// registry.addInterceptor(securityInterceptor).addPathPatterns("/user/**", "/admin/**"); // 只拦截我们定义的接口
|
||||
registry.addInterceptor(adminAccessLogInterceptor).addPathPatterns("/admins/**");
|
||||
registry.addInterceptor(adminSecurityInterceptor.setIgnoreUrls(ignoreUrls)).addPathPatterns("/admins/**")
|
||||
.excludePathPatterns("/admins/passport/login"); // 排除登陆接口
|
||||
|
||||
@@ -23,7 +23,6 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
@@ -34,14 +33,11 @@ import java.util.stream.Collectors;
|
||||
@Api("管理员模块")
|
||||
public class AdminController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
@Reference(validation = "true", version = "${dubbo.provider.ResourceService.version}")
|
||||
private ResourceService resourceService;
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
@Reference(validation = "true", version = "${dubbo.provider.AdminService.version}")
|
||||
private AdminService adminService;
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
@Reference(validation = "true", version = "${dubbo.provider.RoleService.version}")
|
||||
private RoleService roleService;
|
||||
|
||||
// =========== 当前管理员相关的资源 API ===========
|
||||
|
||||
@@ -9,14 +9,13 @@ import cn.iocoder.mall.admin.application.convert.DataDictConvert;
|
||||
import cn.iocoder.mall.admin.application.vo.DataDictEnumVO;
|
||||
import cn.iocoder.mall.admin.application.vo.DataDictVO;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -27,8 +26,7 @@ import java.util.List;
|
||||
@Api("数据字典模块")
|
||||
public class DataDictController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
@Reference(validation = "true", version = "${dubbo.provider.DataDictService.version}")
|
||||
private DataDictService dataDictService;
|
||||
|
||||
@GetMapping("/list")
|
||||
|
||||
@@ -10,7 +10,6 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -21,8 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Api("Admin Passport 模块")
|
||||
public class PassportController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
@Reference(validation = "true", version = "${dubbo.provider.OAuth2Service.version}")
|
||||
private OAuth2Service oauth2Service;
|
||||
|
||||
@PostMapping("/login")
|
||||
|
||||
@@ -10,12 +10,11 @@ import cn.iocoder.mall.admin.application.convert.ResourceConvert;
|
||||
import cn.iocoder.mall.admin.application.vo.ResourceTreeNodeVO;
|
||||
import cn.iocoder.mall.admin.application.vo.ResourceVO;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -29,8 +28,7 @@ import java.util.stream.Collectors;
|
||||
@Api("资源模块")
|
||||
public class ResourceController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
@Reference(validation = "true", version = "${dubbo.provider.ResourceService.version}")
|
||||
private ResourceService resourceService;
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
|
||||
@@ -16,11 +16,10 @@ import cn.iocoder.mall.admin.application.vo.RolePageVO;
|
||||
import cn.iocoder.mall.admin.application.vo.RoleResourceTreeNodeVO;
|
||||
import cn.iocoder.mall.admin.application.vo.RoleVO;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
@@ -30,11 +29,9 @@ import java.util.stream.Collectors;
|
||||
@RequestMapping("admins/role")
|
||||
public class RoleController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
@Reference(validation = "true", version = "${dubbo.provider.RoleService.version}")
|
||||
private RoleService roleService;
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
@Reference(validation = "true", version = "${dubbo.provider.ResourceService.version}")
|
||||
private ResourceService resourceService;
|
||||
|
||||
@GetMapping("/page")
|
||||
|
||||
@@ -42,6 +42,10 @@
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
@@ -33,8 +32,7 @@ public class AdminAccessLogInterceptor extends HandlerInterceptorAdapter {
|
||||
*/
|
||||
private static final ThreadLocal<Integer> ADMIN_ID = new ThreadLocal<>();
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired(required = false) // TODO 芋艿,初始化时,会存在 spring boot 启动时,服务无法引用的情况,先暂时这么解决。
|
||||
@Reference(validation = "true", version = "${dubbo.consumer.AdminAccessLogService.version:1.0.0}")
|
||||
private AdminAccessLogService adminAccessLogService;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,15 +8,12 @@ import cn.iocoder.mall.admin.api.bo.OAuth2AuthenticationBO;
|
||||
import cn.iocoder.mall.admin.api.constant.AdminErrorCodeEnum;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContext;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -25,8 +22,7 @@ import java.util.Set;
|
||||
@Component
|
||||
public class AdminSecurityInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired(required = false) // TODO 芋艿,初始化时,会存在 spring boot 启动时,服务无法引用的情况,先暂时这么解决。
|
||||
@Reference(validation = "true", version = "${dubbo.consumer.OAuth2Service.version:1.0.0}")
|
||||
private OAuth2Service oauth2Service;
|
||||
/**
|
||||
* 忽略的 URL 集合,即无需经过认证
|
||||
@@ -44,13 +40,11 @@ public class AdminSecurityInterceptor extends HandlerInterceptorAdapter {
|
||||
String accessToken = HttpUtil.obtainAccess(request);
|
||||
OAuth2AuthenticationBO authentication = null;
|
||||
if (accessToken != null) {
|
||||
// CommonResult<OAuth2AuthenticationBO> result = oauth2Service.checkToken(accessToken);
|
||||
|
||||
CommonResult<OAuth2AuthenticationBO> result = oauth2Service.checkToken(accessToken);
|
||||
// TODO sin 先临时跳过 认证
|
||||
CommonResult<OAuth2AuthenticationBO> result = CommonResult.success(new OAuth2AuthenticationBO()
|
||||
.setAdminId(1)
|
||||
.setRoleIds(Sets.newHashSet(1, 2, 3, 4)));
|
||||
|
||||
// CommonResult<OAuth2AuthenticationBO> result = CommonResult.success(new OAuth2AuthenticationBO()
|
||||
// .setAdminId(1)
|
||||
// .setRoleIds(Sets.newHashSet(1, 2, 3, 4)));
|
||||
if (result.isError()) { // TODO 芋艿,如果访问的地址无需登录,这里也不用抛异常
|
||||
throw new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true")
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.AdminAccessLogService.version}")
|
||||
public class AdminAccessLogServiceImpl implements AdminAccessLogService {
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true")
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.AdminService.version}")
|
||||
public class AdminServiceImpl implements AdminService {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.stream.Collectors;
|
||||
* 数据字典 Service
|
||||
*/
|
||||
@Service
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true")
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.DataDictService.version}")
|
||||
public class DataDictServiceImpl implements DataDictService {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true")
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.OAuth2Service.version:1.0.0}")
|
||||
public class OAuth2ServiceImpl implements OAuth2Service {
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true")
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.ResourceService.version}")
|
||||
public class ResourceServiceImpl implements ResourceService {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true")
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.RoleService.version}")
|
||||
public class RoleServiceImpl implements RoleService {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -23,3 +23,16 @@ dubbo:
|
||||
name: dubbo
|
||||
scan:
|
||||
base-packages: cn.iocoder.mall.admin.service
|
||||
provider:
|
||||
AdminAccessLogService:
|
||||
version: 1.0.0
|
||||
AdminService:
|
||||
version: 1.0.0
|
||||
DataDictService:
|
||||
version: 1.0.0
|
||||
OAuth2Service:
|
||||
version: 1.0.0
|
||||
ResourceService:
|
||||
version: 1.0.0
|
||||
RoleService:
|
||||
version: 1.0.0
|
||||
|
||||
Reference in New Issue
Block a user