diff --git a/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/config/ErrorCodeAutoConfiguration.java b/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/config/ErrorCodeAutoConfiguration.java index 3917bb73c..1d929e97d 100644 --- a/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/config/ErrorCodeAutoConfiguration.java +++ b/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/config/ErrorCodeAutoConfiguration.java @@ -12,15 +12,15 @@ import org.springframework.scheduling.annotation.EnableScheduling; @EnableScheduling // 开启调度任务的功能,因为 ErrorCodeRemoteLoader 通过定时刷新错误码 public class ErrorCodeAutoConfiguration { - @Bean - public ErrorCodeAutoGenerator errorCodeAutoGenerator(ErrorCodeProperties errorCodeProperties) { - return new ErrorCodeAutoGenerator(errorCodeProperties.getGroup()) - .setErrorCodeConstantsClass(errorCodeProperties.getConstantsClass()); - } - - @Bean - public ErrorCodeRemoteLoader errorCodeRemoteLoader(ErrorCodeProperties errorCodeProperties) { - return new ErrorCodeRemoteLoader(errorCodeProperties.getGroup()); - } +// @Bean +// public ErrorCodeAutoGenerator errorCodeAutoGenerator(ErrorCodeProperties errorCodeProperties) { +// return new ErrorCodeAutoGenerator(errorCodeProperties.getGroup()) +// .setErrorCodeConstantsClass(errorCodeProperties.getConstantsClass()); +// } +// +// @Bean +// public ErrorCodeRemoteLoader errorCodeRemoteLoader(ErrorCodeProperties errorCodeProperties) { +// return new ErrorCodeRemoteLoader(errorCodeProperties.getGroup()); +// } } diff --git a/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/core/ErrorCodeAutoGenerator.java b/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/core/ErrorCodeAutoGenerator.java index ae8cfc289..5b82c8b6b 100644 --- a/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/core/ErrorCodeAutoGenerator.java +++ b/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/core/ErrorCodeAutoGenerator.java @@ -17,68 +17,68 @@ import java.util.Arrays; import java.util.List; public class ErrorCodeAutoGenerator { - - private Logger logger = LoggerFactory.getLogger(ErrorCodeAutoGenerator.class); - - /** - * 应用分组 - */ - private final String group; - /** - * 错误码枚举类 - */ - private String errorCodeConstantsClass; - - - @Autowired - private ErrorCodeFeign errorCodeFeign; - public ErrorCodeAutoGenerator(String group) { - this.group = group; - } - - public ErrorCodeAutoGenerator setErrorCodeConstantsClass(String errorCodeConstantsClass) { - this.errorCodeConstantsClass = errorCodeConstantsClass; - return this; - } - - @EventListener(ApplicationReadyEvent.class) - @Async // 异步,保证项目的启动过程,毕竟非关键流程 - public void execute() { - // 校验 errorCodeConstantsClass 参数 - if (!StringUtils.hasText(errorCodeConstantsClass)) { - logger.info("[execute][未配置 mall.error-code.constants-class 配置项,不进行自动写入到 system-service 服务]"); - return; - } - Class errorCodeConstantsClazz; - try { - errorCodeConstantsClazz = Class.forName(errorCodeConstantsClass); - } catch (ClassNotFoundException e) { - logger.error("[execute][配置的 ({}) 找不到对应的类]", errorCodeConstantsClass); - return; - } - // 写入 system-service 服务 - logger.info("[execute][自动将 ({}) 类的错误码,准备写入到 system-service 服务]", errorCodeConstantsClass); - List autoGenerateDTOs = new ArrayList<>(); - Arrays.stream(errorCodeConstantsClazz.getFields()).forEach(field -> { - if (field.getType() != ErrorCode.class) { - return; - } - try { - // TODO 芋艿:校验是否重复了; - ErrorCode errorCode = (ErrorCode) field.get(errorCodeConstantsClazz); - autoGenerateDTOs.add(new ErrorCodeAutoGenerateDTO().setGroup(group) - .setCode(errorCode.getCode()).setMessage(errorCode.getMessage())); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - }); - CommonResult autoGenerateErrorCodesResult = errorCodeFeign.autoGenerateErrorCodes(autoGenerateDTOs); - if (autoGenerateErrorCodesResult.isSuccess()) { - logger.info("[execute][自动将 ({}) 类的错误码,成功写入到 system-service 服务]", errorCodeConstantsClass); - } else { - logger.error("[execute][自动将 ({}) 类的错误码,失败写入到 system-service 服务,原因为 ({}/{}/{})]", errorCodeConstantsClass, - autoGenerateErrorCodesResult.getCode(), autoGenerateErrorCodesResult.getMessage(), autoGenerateErrorCodesResult.getDetailMessage()); - } - } +// +// private Logger logger = LoggerFactory.getLogger(ErrorCodeAutoGenerator.class); +// +// /** +// * 应用分组 +// */ +// private final String group; +// /** +// * 错误码枚举类 +// */ +// private String errorCodeConstantsClass; +// +// +// @Autowired +// private ErrorCodeFeign errorCodeFeign; +// public ErrorCodeAutoGenerator(String group) { +// this.group = group; +// } +// +// public ErrorCodeAutoGenerator setErrorCodeConstantsClass(String errorCodeConstantsClass) { +// this.errorCodeConstantsClass = errorCodeConstantsClass; +// return this; +// } +// +// @EventListener(ApplicationReadyEvent.class) +// @Async // 异步,保证项目的启动过程,毕竟非关键流程 +// public void execute() { +// // 校验 errorCodeConstantsClass 参数 +// if (!StringUtils.hasText(errorCodeConstantsClass)) { +// logger.info("[execute][未配置 mall.error-code.constants-class 配置项,不进行自动写入到 system-service 服务]"); +// return; +// } +// Class errorCodeConstantsClazz; +// try { +// errorCodeConstantsClazz = Class.forName(errorCodeConstantsClass); +// } catch (ClassNotFoundException e) { +// logger.error("[execute][配置的 ({}) 找不到对应的类]", errorCodeConstantsClass); +// return; +// } +// // 写入 system-service 服务 +// logger.info("[execute][自动将 ({}) 类的错误码,准备写入到 system-service 服务]", errorCodeConstantsClass); +// List autoGenerateDTOs = new ArrayList<>(); +// Arrays.stream(errorCodeConstantsClazz.getFields()).forEach(field -> { +// if (field.getType() != ErrorCode.class) { +// return; +// } +// try { +// // TODO 芋艿:校验是否重复了; +// ErrorCode errorCode = (ErrorCode) field.get(errorCodeConstantsClazz); +// autoGenerateDTOs.add(new ErrorCodeAutoGenerateDTO().setGroup(group) +// .setCode(errorCode.getCode()).setMessage(errorCode.getMessage())); +// } catch (IllegalAccessException e) { +// throw new RuntimeException(e); +// } +// }); +// CommonResult autoGenerateErrorCodesResult = errorCodeFeign.autoGenerateErrorCodes(autoGenerateDTOs); +// if (autoGenerateErrorCodesResult.isSuccess()) { +// logger.info("[execute][自动将 ({}) 类的错误码,成功写入到 system-service 服务]", errorCodeConstantsClass); +// } else { +// logger.error("[execute][自动将 ({}) 类的错误码,失败写入到 system-service 服务,原因为 ({}/{}/{})]", errorCodeConstantsClass, +// autoGenerateErrorCodesResult.getCode(), autoGenerateErrorCodesResult.getMessage(), autoGenerateErrorCodesResult.getDetailMessage()); +// } +// } } diff --git a/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/core/ErrorCodeRemoteLoader.java b/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/core/ErrorCodeRemoteLoader.java index ef05ab853..2fd5d8e3b 100644 --- a/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/core/ErrorCodeRemoteLoader.java +++ b/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/core/ErrorCodeRemoteLoader.java @@ -17,54 +17,54 @@ import java.util.Date; import java.util.List; public class ErrorCodeRemoteLoader { - - private static final int REFRESH_ERROR_CODE_PERIOD = 60 * 1000; - - private Logger logger = LoggerFactory.getLogger(ErrorCodeRemoteLoader.class); - - /** - * 应用分组 - */ - private final String group; - - @Autowired - private ErrorCodeFeign errorCodeFeign; - private Date maxUpdateTime; - - public ErrorCodeRemoteLoader(String group) { - this.group = group; - } - - @EventListener(ApplicationReadyEvent.class) - public void loadErrorCodes() { - // 从 errorCodeFeign 全量加载 ErrorCode 错误码 - CommonResult> listErrorCodesResult = errorCodeFeign.listErrorCodes(group, null); - listErrorCodesResult.checkError(); - logger.info("[loadErrorCodes][从 group({}) 全量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); - // 写入到 ServiceExceptionUtil 到 - listErrorCodesResult.getData().forEach(errorCodeVO -> { - ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage()); - // 记录下更新时间,方便增量更新 - maxUpdateTime = DateUtil.max(maxUpdateTime, errorCodeVO.getUpdateTime()); - }); - } - - @Scheduled(fixedDelay = REFRESH_ERROR_CODE_PERIOD, initialDelay = REFRESH_ERROR_CODE_PERIOD) - public void refreshErrorCodes() { - // 从 errorCodeFeign 增量加载 ErrorCode 错误码 - // TODO 优化点:假设删除错误码的配置,会存在问题; - CommonResult> listErrorCodesResult = errorCodeFeign.listErrorCodes(group, maxUpdateTime); - listErrorCodesResult.checkError(); - if (CollectionUtils.isEmpty(listErrorCodesResult.getData())) { - return; - } - logger.info("[refreshErrorCodes][从 group({}) 增量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); - // 写入到 ServiceExceptionUtil 到 - listErrorCodesResult.getData().forEach(errorCodeVO -> { - ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage()); - // 记录下更新时间,方便增量更新 - maxUpdateTime = DateUtil.max(maxUpdateTime, errorCodeVO.getUpdateTime()); - }); - } +// +// private static final int REFRESH_ERROR_CODE_PERIOD = 60 * 1000; +// +// private Logger logger = LoggerFactory.getLogger(ErrorCodeRemoteLoader.class); +// +// /** +// * 应用分组 +// */ +// private final String group; +// +// @Autowired +// private ErrorCodeFeign errorCodeFeign; +// private Date maxUpdateTime; +// +// public ErrorCodeRemoteLoader(String group) { +// this.group = group; +// } +// +// @EventListener(ApplicationReadyEvent.class) +// public void loadErrorCodes() { +// // 从 errorCodeFeign 全量加载 ErrorCode 错误码 +// CommonResult> listErrorCodesResult = errorCodeFeign.listErrorCodes(group, null); +// listErrorCodesResult.checkError(); +// logger.info("[loadErrorCodes][从 group({}) 全量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); +// // 写入到 ServiceExceptionUtil 到 +// listErrorCodesResult.getData().forEach(errorCodeVO -> { +// ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage()); +// // 记录下更新时间,方便增量更新 +// maxUpdateTime = DateUtil.max(maxUpdateTime, errorCodeVO.getUpdateTime()); +// }); +// } +// +// @Scheduled(fixedDelay = REFRESH_ERROR_CODE_PERIOD, initialDelay = REFRESH_ERROR_CODE_PERIOD) +// public void refreshErrorCodes() { +// // 从 errorCodeFeign 增量加载 ErrorCode 错误码 +// // TODO 优化点:假设删除错误码的配置,会存在问题; +// CommonResult> listErrorCodesResult = errorCodeFeign.listErrorCodes(group, maxUpdateTime); +// listErrorCodesResult.checkError(); +// if (CollectionUtils.isEmpty(listErrorCodesResult.getData())) { +// return; +// } +// logger.info("[refreshErrorCodes][从 group({}) 增量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); +// // 写入到 ServiceExceptionUtil 到 +// listErrorCodesResult.getData().forEach(errorCodeVO -> { +// ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage()); +// // 记录下更新时间,方便增量更新 +// maxUpdateTime = DateUtil.max(maxUpdateTime, errorCodeVO.getUpdateTime()); +// }); +// } } diff --git a/mall-dependencies/pom.xml b/mall-dependencies/pom.xml index 7b1953d1c..9795ddac5 100644 --- a/mall-dependencies/pom.xml +++ b/mall-dependencies/pom.xml @@ -64,7 +64,6 @@ 27.0.1-jre 1.16.14 1.3.0.Final - 3.0.4 @@ -382,11 +381,6 @@ ${hibernate-validator.version} - - org.springframework.cloud - spring-cloud-openfeign-core - ${spring-cloud.feign.version} - diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java index 71f0e93b4..7e141a365 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java @@ -8,7 +8,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.payservice.rpc" -,"cn.iocoder.mall.promotion.api.rpc","cn.iocoder.mall.systemservice.rpc"}) +,"cn.iocoder.mall.promotion.api.rpc","cn.iocoder.mall.systemservice.rpc","cn.iocoder.mall.userservice.rpc"}) public class ManagementWebApplication { public static void main(String[] args) { diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/AdminController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/AdminController.http index 2725d8d4a..d02f18830 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/AdminController.http +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/AdminController.http @@ -1,40 +1,40 @@ ### /admin/page 成功 -GET {{baseUrl}}/admin/page?pageNo=1&pageSize=10 +GET http://127.0.0.1:18083/management-api/admin/page?pageNo=1&pageSize=10 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### /admin/create 成功 -POST {{baseUrl}}/admin/create +POST http://127.0.0.1:18083/management-api/admin/create Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma username=admin02&password=buzhidao&name=测试管理员&departmentId=1 ### /admin/update 成功 -POST {{baseUrl}}/admin/update +POST http://127.0.0.1:18083/management-api/admin/update Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma id=31&username=admin02&password=buzhidao&name=测试管理员&departmentId=1 ### /admin/update-status 成功 -POST {{baseUrl}}/admin/update-status +POST http://127.0.0.1:18083/management-api/admin/update-status Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma adminId=31&status=1 ### /admin/update-status 失败,参数缺失 -POST {{baseUrl}}/admin/update-status +POST http://127.0.0.1:18083/management-api/admin/update-status Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma adminId=31 ### admin/update-status 失败,地址不存在 -GET {{baseUrl}}/admin/update-status--- +GET http://127.0.0.1:18083/management-api/admin/update-status--- Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma adminId=31&status=sss diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/DepartmentController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/DepartmentController.http index 64cc93945..b43f64d43 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/DepartmentController.http +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/DepartmentController.http @@ -1,39 +1,39 @@ ### /department/create 成功 -POST {{baseUrl}}/department/create +POST http://127.0.0.1:18083/management-api/department/create Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma dubbo-tag: {{dubboTag}} name=测试部门&pid=0&sort=0 ### /department/update 成功 -POST {{baseUrl}}/department/update +POST http://127.0.0.1:18083/management-api/department/update Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma id=1&name=测试部门&pid=0&sort=0 ### /resource/delete 成功 -POST {{baseUrl}}/department/delete +POST http://127.0.0.1:18083/management-api/department/delete Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma id=1 ### /department/get 成功 -GET {{baseUrl}}/department/get?departmentId=1 +GET http://127.0.0.1:18083/management-api/department/get?departmentId=1 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### /department/list 成功 -GET {{baseUrl}}/department/list?departmentIds=1,13 +GET http://127.0.0.1:18083/management-api/department/list?departmentIds=1,13 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### /department/tree 成功 -GET {{baseUrl}}/department/tree +GET http://127.0.0.1:18083/management-api/department/tree Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/passport/PassportController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/passport/PassportController.http index d5527e7e1..a6a9418d6 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/passport/PassportController.http +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/passport/PassportController.http @@ -1,34 +1,34 @@ ### /passport/login 成功 -POST {{baseUrl}}/passport/login +POST http://127.0.0.1:18083/management-api/passport/login Content-Type: application/x-www-form-urlencoded username=admin&password=buzhidao ### /passport/login 密码不正确 -POST {{baseUrl}}/passport/login +POST http://127.0.0.1:18083/management-api/passport/login Content-Type: application/x-www-form-urlencoded username=admin&password=1024 ### /passport/login 少传参数 -POST {{baseUrl}}/passport/login +POST http://127.0.0.1:18083/management-api/passport/login Content-Type: application/x-www-form-urlencoded username=admin ### /passport/info 成功 -GET {{baseUrl}}/passport/info -Authorization: Bearer {{accessToken}} +GET http://127.0.0.1:18083/management-api/passport/info +Authorization: Bearer yudaoyuanma ### /passport/tree-admin-menu 成功 -GET {{baseUrl}}/passport/tree-admin-menu +GET http://127.0.0.1:18083/management-api/passport/tree-admin-menu Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### /passport/list-admin-permission 成功 -GET {{baseUrl}}/passport/list-admin-permission +GET http://127.0.0.1:18083/management-api/passport/list-admin-permission Content-Type: application/x-www-form-urlencoded -#Authorization: Bearer {{accessToken}} +#Authorization: Bearer yudaoyuanma Authorization: Bearer 36dce986276b4d6c8f9f4f3b89b22810 ### diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/pay/PayTransactionController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/pay/PayTransactionController.http index 336284158..9a4eccefe 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/pay/PayTransactionController.http +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/pay/PayTransactionController.http @@ -1,7 +1,7 @@ ### /product-spu/page 成功(全部) -GET {{baseUrl}}/pay/transaction/page?pageNo=1&pageSize=10 +GET http://127.0.0.1:18083/management-api/pay/transaction/page?pageNo=1&pageSize=10 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma dubbo-tag: {{dubboTag}} ### diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/PermissionController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/PermissionController.http index 290bd3da2..c51cfb85e 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/PermissionController.http +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/PermissionController.http @@ -1,11 +1,11 @@ ### /permission/list 成功 -GET {{baseUrl}}/permission/list-role-resource?roleId=1 +GET http://127.0.0.1:18083/management-api/permission/list-role-resource?roleId=1 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### /permission/list-admin-roles 成功 -GET {{baseUrl}}/permission/list-admin-roles?adminId=1 +GET http://127.0.0.1:18083/management-api/permission/list-admin-roles?adminId=1 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/ResourceController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/ResourceController.http index 4e23931c8..3280a34c1 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/ResourceController.http +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/ResourceController.http @@ -1,37 +1,37 @@ ### /resource/create 成功 -POST {{baseUrl}}/resource/create +POST http://127.0.0.1:18083/management-api/resource/create Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma name=测试菜单&permission=resource:add&type=1&sort=1&pid=0&route=/resource/list&icon=test ### /admin/update 成功 -POST {{baseUrl}}/resource/update +POST http://127.0.0.1:18083/management-api/resource/update Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma id=61&name=测试菜单2&permission=resource:add&type=1&sort=1&pid=0&route=/resource/list&icon=test ### /resource/delete 成功 -POST {{baseUrl}}/resource/delete +POST http://127.0.0.1:18083/management-api/resource/delete Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma resourceId=61 ### /resource/get 成功 -GET {{baseUrl}}/resource/get?resourceId=61 +GET http://127.0.0.1:18083/management-api/resource/get?resourceId=61 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### /resource/list 成功 -GET {{baseUrl}}/resource/list?resourceIds=61,63 +GET http://127.0.0.1:18083/management-api/resource/list?resourceIds=61,63 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### /resource/tree 成功 -GET {{baseUrl}}/resource/tree +GET http://127.0.0.1:18083/management-api/resource/tree Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/RoleController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/RoleController.http index 15855497d..03eba63ab 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/RoleController.http +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/RoleController.http @@ -1,44 +1,44 @@ ### /role/create 成功 -POST {{baseUrl}}/role/create +POST http://127.0.0.1:18083/management-api/role/create Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma #Authorization: Bearer 9d250d9b6c034a6c88bf4034cdf1d4cc name=测试角色 ### /role/update 成功 -POST {{baseUrl}}/role/update +POST http://127.0.0.1:18083/management-api/role/update Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma id=14&name=test ### /resource/delete 成功 -POST {{baseUrl}}/role/delete +POST http://127.0.0.1:18083/management-api/role/delete Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma roleId=14 ### /role/get 成功 -GET {{baseUrl}}/role/get?roleId=13 +GET http://127.0.0.1:18083/management-api/role/get?roleId=13 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### /role/list-all 成功 -GET {{baseUrl}}/role/list-all +GET http://127.0.0.1:18083/management-api/role/list-all Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### /role/list 成功 -GET {{baseUrl}}/role/list?roleIds=1,13 +GET http://127.0.0.1:18083/management-api/role/list?roleIds=1,13 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### /role/page 成功 -GET {{baseUrl}}/role/page?pageNo=1&pageSize=10 +GET http://127.0.0.1:18083/management-api/role/page?pageNo=1&pageSize=10 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http index 301e8f1aa..9b1ba1498 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http @@ -4,14 +4,14 @@ Content-Type: application/x-www-form-urlencoded Authorization: Bearer yudaoyuanma ### /product-spu/page 成功(有库存 + 上架) -GET {{baseUrl}}/product-spu/page?pageNo=1&pageSize=10&hasQuantity=true&visible=true +GET http://127.0.0.1:18083/management-api/product-spu/page?pageNo=1&pageSize=10&hasQuantity=true&visible=true Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### /product-spu/page 成功(无库存 + 下架) -GET {{baseUrl}}/product-spu/page?pageNo=1&pageSize=10&hasQuantity=false&visible=false +GET http://127.0.0.1:18083/management-api/product-spu/page?pageNo=1&pageSize=10&hasQuantity=false&visible=false Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### /product-spu/create 成功 POST http://127.0.0.1:18083/management-api/product-spu/create @@ -23,17 +23,17 @@ name=新商品&description=新商品描述&cid=637&sellPoint=丑&picUrls=1,2,3&v &skus[1].price=2&skus[1].quantity=50&skus[1].attrValueIds=2,4 ### /product-spu/create 失败(规格不存在) -POST {{baseUrl}}/product-spu/create +POST http://127.0.0.1:18083/management-api/product-spu/create Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma name=测试商品标题&description=测试商品描述&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true &skus[0].price=1&skus[0].quantity=100&skus[0].attrValueIds=1,0 ### /product-spu/create 失败(规格数量不匹配) -POST {{baseUrl}}/product-spu/create +POST http://127.0.0.1:18083/management-api/product-spu/create Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma name=测试商品标题&description=测试商品描述&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true &skus[0].price=1&skus[0].quantity=100&skus[0].attrValueIds=1,3 diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemAccessLogController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemAccessLogController.http index 77a4884dd..495820cbe 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemAccessLogController.http +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemAccessLogController.http @@ -1,7 +1,7 @@ ### /system-access-log/page 成功 -GET {{baseUrl}}/system-access-log/page?pageNo=1&pageSize=10 +GET http://127.0.0.1:18083/management-api/system-access-log/page?pageNo=1&pageSize=10 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma ### diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/UserController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/UserController.http index 06f1b3356..d508139c7 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/UserController.http +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/UserController.http @@ -1,29 +1,29 @@ ### /user/page 成功 -GET {{baseUrl}}/user/page?pageNo=1&pageSize=10 +GET http://127.0.0.1:18083/management-api/user/page?pageNo=1&pageSize=10 Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma dubbo-tag: {{dubboTag}} ### /user/update 成功 -POST {{baseUrl}}/user/update +POST http://127.0.0.1:18083/management-api/user/update Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma dubbo-tag: {{dubboTag}} id=31&username=user02&password=buzhidao&name=测试管理员&departmentId=1 ### /user/update-status 成功 -POST {{baseUrl}}/user/update-status +POST http://127.0.0.1:18083/management-api/user/update-status Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma dubbo-tag: {{dubboTag}} userId=243&status=2 ### /user/update-status 失败,参数缺失 -POST {{baseUrl}}/user/update-status +POST http://127.0.0.1:18083/management-api/user/update-status Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} +Authorization: Bearer yudaoyuanma dubbo-tag: {{dubboTag}} userId=31 diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/user/UserManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/user/UserManager.java index b02b0c062..9f6a46c05 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/user/UserManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/user/UserManager.java @@ -8,9 +8,9 @@ import cn.iocoder.mall.managementweb.controller.user.vo.UserRespVO; import cn.iocoder.mall.managementweb.controller.user.vo.UserUpdateInfoReqVO; import cn.iocoder.mall.managementweb.controller.user.vo.UserUpdateStatusReqVO; import cn.iocoder.mall.managementweb.convert.user.UserConvert; -import cn.iocoder.mall.userservice.rpc.user.UserRpc; +import cn.iocoder.mall.userservice.rpc.user.UserFeign; import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; -import org.apache.dubbo.config.annotation.Reference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @@ -21,16 +21,16 @@ import java.util.List; @Service public class UserManager { - @Reference(version = "${dubbo.consumer.UserRpc.version}", validation = "false") - private UserRpc userRpc; + @Autowired + private UserFeign userFeign; /** * 更新用户信息 * * @param updateInfoReqVO 更新用户信息 VO */ public void updateUserInfo(UserUpdateInfoReqVO updateInfoReqVO) { - CommonResult updateUserResult = userRpc.updateUser(UserConvert.INSTANCE.convert(updateInfoReqVO)); + CommonResult updateUserResult = userFeign.updateUser(UserConvert.INSTANCE.convert(updateInfoReqVO)); updateUserResult.checkError(); } @@ -40,7 +40,7 @@ public class UserManager { * @param updateStatusReqVO 更新用户状态 VO */ public void updateUserStatus(UserUpdateStatusReqVO updateStatusReqVO) { - CommonResult updateUserResult = userRpc.updateUser(UserConvert.INSTANCE.convert(updateStatusReqVO)); + CommonResult updateUserResult = userFeign.updateUser(UserConvert.INSTANCE.convert(updateStatusReqVO)); updateUserResult.checkError(); } @@ -51,7 +51,7 @@ public class UserManager { * @return 用户 */ public UserRespVO getUser(Integer userId) { - CommonResult getUserResult = userRpc.getUser(userId); + CommonResult getUserResult = userFeign.getUser(userId); getUserResult.checkError(); return UserConvert.INSTANCE.convert(getUserResult.getData()); } @@ -63,7 +63,7 @@ public class UserManager { * @return 用户列表 */ public List listUsers(List userIds) { - CommonResult> listUserResult = userRpc.listUsers(userIds); + CommonResult> listUserResult = userFeign.listUsers(userIds); listUserResult.checkError(); return UserConvert.INSTANCE.convertList(listUserResult.getData()); } @@ -75,7 +75,7 @@ public class UserManager { * @return 用户分页结果 */ public PageResult pageUser(UserPageReqVO pageVO) { - CommonResult> pageUserResult = userRpc.pageUser(UserConvert.INSTANCE.convert(pageVO)); + CommonResult> pageUserResult = userFeign.pageUser(UserConvert.INSTANCE.convert(pageVO)); pageUserResult.checkError(); return UserConvert.INSTANCE.convertPage(pageUserResult.getData()); } diff --git a/pay-service-project/pay-service-api/pom.xml b/pay-service-project/pay-service-api/pom.xml index 2a8412977..1241319fa 100644 --- a/pay-service-project/pay-service-api/pom.xml +++ b/pay-service-project/pay-service-api/pom.xml @@ -34,6 +34,7 @@ org.springframework.cloud spring-cloud-openfeign-core + RELEASE diff --git a/product-service-project/product-service-api/pom.xml b/product-service-project/product-service-api/pom.xml index 9e48aed2e..1cbc81a0c 100644 --- a/product-service-project/product-service-api/pom.xml +++ b/product-service-project/product-service-api/pom.xml @@ -29,6 +29,7 @@ org.springframework.cloud spring-cloud-openfeign-core + RELEASE diff --git a/promotion-service-project/promotion-service-api/pom.xml b/promotion-service-project/promotion-service-api/pom.xml index ccc6b1379..404f45568 100644 --- a/promotion-service-project/promotion-service-api/pom.xml +++ b/promotion-service-project/promotion-service-api/pom.xml @@ -47,6 +47,7 @@ org.springframework.cloud spring-cloud-openfeign-core + RELEASE diff --git a/search-service-project/search-service-api/pom.xml b/search-service-project/search-service-api/pom.xml index 07f7d26c7..0d3eb3c2f 100644 --- a/search-service-project/search-service-api/pom.xml +++ b/search-service-project/search-service-api/pom.xml @@ -29,6 +29,7 @@ org.springframework.cloud spring-cloud-openfeign-core + RELEASE diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java index a8cb222ac..3c879fed7 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java @@ -9,7 +9,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @EnableDiscoveryClient @EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.searchservice.rpc", "cn.iocoder.mall.tradeservice.rpc","cn.iocoder.mall.payservice.rpc","cn.iocoder.mall.promotion.api.rpc", -"cn.iocoder.mall.systemservice.rpc"}) +"cn.iocoder.mall.systemservice.rpc","cn.iocoder.mall.userservice.rpc"}) public class ShopWebApplication { public static void main(String[] args) { diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/user/UserAddressClient.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/user/UserAddressClient.java index 7a99063ae..5f552e19a 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/user/UserAddressClient.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/user/UserAddressClient.java @@ -1,14 +1,13 @@ package cn.iocoder.mall.shopweb.client.user; -import cn.iocoder.mall.userservice.rpc.address.UserAddressRpc; -import org.apache.dubbo.config.annotation.DubboReference; +import cn.iocoder.mall.userservice.rpc.address.UserAddressFeign; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class UserAddressClient { - - @DubboReference(version = "${dubbo.consumer.UserAddressRpc.version}") - private UserAddressRpc userAddressRpc; + @Autowired + private UserAddressFeign userAddressFeign; diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/user/PassportManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/user/PassportManager.java index 0ca4a5441..210afc2b5 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/user/PassportManager.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/user/PassportManager.java @@ -11,31 +11,28 @@ import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO; import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO; import cn.iocoder.mall.userservice.enums.sms.UserSmsSceneEnum; -import cn.iocoder.mall.userservice.rpc.sms.UserSmsCodeRpc; -import cn.iocoder.mall.userservice.rpc.user.UserRpc; +import cn.iocoder.mall.userservice.rpc.sms.UserSmsCodeFeign; +import cn.iocoder.mall.userservice.rpc.user.UserFeign; import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class PassportManager { - @DubboReference(version = "${dubbo.consumer.UserSmsCodeRpc.version}", validation = "false") - private UserSmsCodeRpc userSmsCodeRpc; - @DubboReference(version = "${dubbo.consumer.UserRpc.version}", validation = "false") - private UserRpc userRpc; + private UserSmsCodeFeign userSmsCodeFeign; + private UserFeign userFeign; @Autowired private OAuthFeign oAuthFeign; public PassportAccessTokenRespVO loginBySms(PassportLoginBySmsReqVO loginBySmsDTO, String ip) { // 校验验证码 - CommonResult verifySmsCodeResult = userSmsCodeRpc.verifySmsCode( + CommonResult verifySmsCodeResult = userSmsCodeFeign.verifySmsCode( PassportConvert.INSTANCE.convert(loginBySmsDTO).setScene(UserSmsSceneEnum.LOGIN_BY_SMS.getValue()).setIp(ip)); verifySmsCodeResult.checkError(); // 获得用户 - CommonResult createUserResult = userRpc.createUserIfAbsent( + CommonResult createUserResult = userFeign.createUserIfAbsent( PassportConvert.INSTANCE.convert02(loginBySmsDTO).setIp(ip)); createUserResult.checkError(); // 创建访问令牌 @@ -48,7 +45,7 @@ public class PassportManager { } public void sendSmsCode(PassportSendSmsRespVO sendSmsCodeDTO, String ip) { - CommonResult sendSmsCodeResult = userSmsCodeRpc.sendSmsCode( + CommonResult sendSmsCodeResult = userSmsCodeFeign.sendSmsCode( PassportConvert.INSTANCE.convert(sendSmsCodeDTO).setIp(ip)); sendSmsCodeResult.checkError(); } diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/user/UserAddressManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/user/UserAddressManager.java index eaae4d863..2bf2f10a3 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/user/UserAddressManager.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/user/UserAddressManager.java @@ -8,9 +8,9 @@ import cn.iocoder.mall.shopweb.controller.user.vo.address.UserAddressRespVO; import cn.iocoder.mall.shopweb.controller.user.vo.address.UserAddressUpdateReqVO; import cn.iocoder.mall.shopweb.convert.user.UserAddressConvert; import cn.iocoder.mall.userservice.enums.address.UserAddressType; -import cn.iocoder.mall.userservice.rpc.address.UserAddressRpc; +import cn.iocoder.mall.userservice.rpc.address.UserAddressFeign; import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @@ -23,9 +23,8 @@ import static cn.iocoder.common.framework.exception.enums.GlobalErrorCodeConstan @Service public class UserAddressManager { - @DubboReference(version = "${dubbo.consumer.UserAddressRpc.version}") - private UserAddressRpc userAddressRpc; - + @Autowired + private UserAddressFeign userAddressFeign; /** * 创建用户收件地址 * @@ -34,7 +33,7 @@ public class UserAddressManager { * @return 用户收件地址 */ public Integer createUserAddress(Integer userId, UserAddressCreateReqVO createVO) { - CommonResult createUserAddressResult = userAddressRpc.createUserAddress( + CommonResult createUserAddressResult = userAddressFeign.createUserAddress( UserAddressConvert.INSTANCE.convert(createVO).setUserId(userId)); createUserAddressResult.checkError(); return createUserAddressResult.getData(); @@ -50,7 +49,7 @@ public class UserAddressManager { // 校验是否能够操作 check(userId, updateVO.getId()); // 执行更新 - CommonResult updateUserAddressResult = userAddressRpc.updateUserAddress(UserAddressConvert.INSTANCE.convert(updateVO) + CommonResult updateUserAddressResult = userAddressFeign.updateUserAddress(UserAddressConvert.INSTANCE.convert(updateVO) .setUserId(userId)); updateUserAddressResult.checkError(); } @@ -65,7 +64,7 @@ public class UserAddressManager { // 校验是否能够操作 check(userId, userAddressId); // 执行删除 - CommonResult deleteUserAddressResult = userAddressRpc.deleteUserAddress(userAddressId); + CommonResult deleteUserAddressResult = userAddressFeign.deleteUserAddress(userAddressId); deleteUserAddressResult.checkError(); } @@ -77,7 +76,7 @@ public class UserAddressManager { * @return 用户收件地址 */ public UserAddressRespVO getUserAddress(Integer userId, Integer userAddressId) { - CommonResult getUserAddressResult = userAddressRpc.getUserAddress(userAddressId); + CommonResult getUserAddressResult = userAddressFeign.getUserAddress(userAddressId); getUserAddressResult.checkError(); // 校验是否能够操作 this.check(userId, userAddressId); @@ -91,7 +90,7 @@ public class UserAddressManager { * @return 用户收件地址列表 */ public List listUserAddresses(Integer userId) { - CommonResult> listUserAddressResult = userAddressRpc.listUserAddresses(userId, null); + CommonResult> listUserAddressResult = userAddressFeign.listUserAddresses(userId, null); listUserAddressResult.checkError(); return UserAddressConvert.INSTANCE.convertList(listUserAddressResult.getData()); } @@ -103,7 +102,7 @@ public class UserAddressManager { * @return 用户收件地址 */ public UserAddressRespVO getDefaultUserAddress(Integer userId) { - CommonResult> listUserAddressResult = userAddressRpc.listUserAddresses(userId, UserAddressType.DEFAULT.getType()); + CommonResult> listUserAddressResult = userAddressFeign.listUserAddresses(userId, UserAddressType.DEFAULT.getType()); listUserAddressResult.checkError(); return !CollectionUtils.isEmpty(listUserAddressResult.getData()) ? UserAddressConvert.INSTANCE.convert(listUserAddressResult.getData().get(0)) : null; @@ -116,7 +115,7 @@ public class UserAddressManager { * @param userAddressId 用户收件地址 */ private void check(Integer userId, Integer userAddressId) { - CommonResult getUserAddressResult = userAddressRpc.getUserAddress(userAddressId); + CommonResult getUserAddressResult = userAddressFeign.getUserAddress(userAddressId); getUserAddressResult.checkError(); this.check(userId, getUserAddressResult.getData()); } diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/user/UserManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/user/UserManager.java index 3ab303e48..81956a133 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/user/UserManager.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/user/UserManager.java @@ -3,31 +3,30 @@ package cn.iocoder.mall.shopweb.service.user; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.shopweb.controller.user.vo.user.UserRespVO; import cn.iocoder.mall.shopweb.convert.user.UserConvert; -import cn.iocoder.mall.userservice.rpc.user.UserRpc; +import cn.iocoder.mall.userservice.rpc.user.UserFeign; import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; import cn.iocoder.mall.userservice.rpc.user.dto.UserUpdateReqDTO; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class UserManager { - @DubboReference(version = "${dubbo.consumer.UserRpc.version}") - private UserRpc userRpc; - + @Autowired + private UserFeign userFeign; public UserRespVO getUser(Integer id) { - CommonResult userResult = userRpc.getUser(id); + CommonResult userResult = userFeign.getUser(id); userResult.checkError(); return UserConvert.INSTANCE.convert(userResult.getData()); } public void updateUserAvatar(Integer userId, String avatar) { - CommonResult updateUserResult = userRpc.updateUser(new UserUpdateReqDTO().setId(userId).setAvatar(avatar)); + CommonResult updateUserResult = userFeign.updateUser(new UserUpdateReqDTO().setId(userId).setAvatar(avatar)); updateUserResult.checkError(); } public void updateUserNickname(Integer userId, String nickname) { - CommonResult updateUserResult = userRpc.updateUser(new UserUpdateReqDTO().setId(userId).setNickname(nickname)); + CommonResult updateUserResult = userFeign.updateUser(new UserUpdateReqDTO().setId(userId).setNickname(nickname)); updateUserResult.checkError(); } diff --git a/system-service-project/system-service-api/pom.xml b/system-service-project/system-service-api/pom.xml index 31d1aa6a3..e78e5c349 100644 --- a/system-service-project/system-service-api/pom.xml +++ b/system-service-project/system-service-api/pom.xml @@ -34,6 +34,7 @@ org.springframework.cloud spring-cloud-starter-openfeign + RELEASE diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuthFeign.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuthFeign.java index 483a20cb7..1998f57a2 100644 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuthFeign.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuthFeign.java @@ -6,6 +6,7 @@ import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO; import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; @@ -13,17 +14,17 @@ import org.springframework.web.bind.annotation.RequestParam; /** * 部门 Rpc 接口 */ -@FeignClient("system-service") +@FeignClient(value = "system-service") public interface OAuthFeign { - @PostMapping("ccreateAccessToken") + @PostMapping("/system/oauth/createAccessToken") public CommonResult createAccessToken(@RequestBody OAuth2CreateAccessTokenReqDTO createAccessTokenDTO); - @PostMapping("/system/oauthcheckAccessToken") + @GetMapping("/system/oauth/checkAccessToken") public CommonResult checkAccessToken(@RequestParam("accessToken") String accessToken) ; - @PostMapping("/system/oauthrefreshAccessToken") + @PostMapping("/system/oauth/refreshAccessToken") public CommonResult refreshAccessToken(@RequestBody OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO); - @PostMapping("/system/oauthremoveToken") + @PostMapping("/system/oauth/removeToken") public CommonResult removeToken(@RequestBody OAuth2RemoveTokenByUserReqDTO removeTokenDTO); } diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/permission/PermissionFeign.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/permission/PermissionFeign.java index 91d260069..20a7f55e4 100644 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/permission/PermissionFeign.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/permission/PermissionFeign.java @@ -34,6 +34,6 @@ public interface PermissionFeign { @PostMapping("/system/permission/assignAdminRole") public CommonResult assignAdminRole(@RequestBody PermissionAssignAdminRoleDTO assignAdminRoleDTO); - @PostMapping("/system/permission/scheckPermission") + @PostMapping("/system/permission/checkPermission") public CommonResult checkPermission(@RequestBody PermissionCheckDTO checkDTO) ; } diff --git a/system-service-project/system-service-app/pom.xml b/system-service-project/system-service-app/pom.xml index a80e56c5f..3d809a498 100644 --- a/system-service-project/system-service-app/pom.xml +++ b/system-service-project/system-service-app/pom.xml @@ -86,10 +86,6 @@ org.mapstruct mapstruct-jdk8 - - org.springframework.cloud - spring-cloud-starter-openfeign - diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/controller/OAuthController.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/controller/OAuthController.java index 8f1ca8ba7..21822383b 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/controller/OAuthController.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/controller/OAuthController.java @@ -30,7 +30,7 @@ public class OAuthController { return success(oAuth2Service.createAccessToken(createAccessTokenDTO)); } - @PostMapping("checkAccessToken") + @GetMapping("checkAccessToken") public CommonResult checkAccessToken(@RequestParam("accessToken") String accessToken) { return success(oAuth2Service.checkAccessToken(accessToken)); } diff --git a/trade-service-project/trade-service-api/pom.xml b/trade-service-project/trade-service-api/pom.xml index 6b261f641..750838dfa 100644 --- a/trade-service-project/trade-service-api/pom.xml +++ b/trade-service-project/trade-service-api/pom.xml @@ -29,6 +29,7 @@ org.springframework.cloud spring-cloud-openfeign-core + RELEASE diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/TradeServiceApplication.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/TradeServiceApplication.java index 57c0977a5..df175b0fc 100644 --- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/TradeServiceApplication.java +++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/TradeServiceApplication.java @@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient -@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.promotion.api.rpc"}) +@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.promotion.api.rpc","cn.iocoder.mall.userservice.rpc"}) public class TradeServiceApplication { public static void main(String[] args) { diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/user/UserAddressClient.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/user/UserAddressClient.java index c1cf7992b..1429ce4dc 100644 --- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/user/UserAddressClient.java +++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/user/UserAddressClient.java @@ -1,9 +1,9 @@ package cn.iocoder.mall.tradeservice.client.user; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.userservice.rpc.address.UserAddressRpc; +import cn.iocoder.mall.userservice.rpc.address.UserAddressFeign; import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Objects; @@ -11,11 +11,10 @@ import java.util.Objects; @Service public class UserAddressClient { - @DubboReference(version = "${dubbo.consumer.UserAddressRpc.version}") - private UserAddressRpc userAddressRpc; - + @Autowired + private UserAddressFeign userAddressFeign; public UserAddressRespDTO getUserAddress(Integer userAddressId, Integer userId) { - CommonResult getUserAddressResult = userAddressRpc.getUserAddress(userAddressId); + CommonResult getUserAddressResult = userAddressFeign.getUserAddress(userAddressId); getUserAddressResult.checkError(); if (getUserAddressResult.getData() == null) { return null; diff --git a/user-service-project/user-service-api/pom.xml b/user-service-project/user-service-api/pom.xml index a23b3f8bf..955a736a4 100644 --- a/user-service-project/user-service-api/pom.xml +++ b/user-service-project/user-service-api/pom.xml @@ -26,6 +26,12 @@ org.projectlombok lombok + + org.springframework.cloud + spring-cloud-openfeign-core + RELEASE + + diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/address/UserAddressFeign.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/address/UserAddressFeign.java new file mode 100644 index 000000000..e177da6cf --- /dev/null +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/address/UserAddressFeign.java @@ -0,0 +1,39 @@ +package cn.iocoder.mall.userservice.rpc.address; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressCreateReqDTO; +import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressRespDTO; +import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressUpdateReqDTO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** +* 用户收件地址 Rpc 接口 +*/ +@FeignClient("user-service") +public interface UserAddressFeign { + + @PostMapping("/user/address/createUserAddress") + public CommonResult createUserAddress(@RequestBody UserAddressCreateReqDTO createDTO); + + @PostMapping("/user/address/updateUserAddress") + public CommonResult updateUserAddress(@RequestBody UserAddressUpdateReqDTO updateDTO); + + @GetMapping("/user/address/deleteUserAddress") + public CommonResult deleteUserAddress(@RequestParam("userAddressId") Integer userAddressId); + + @GetMapping("/user/address/getUserAddress") + public CommonResult getUserAddress(@RequestParam("userAddressId")Integer userAddressId) ; + + @GetMapping("/user/address/listUserAddressesByIds") + public CommonResult> listUserAddresses(@RequestParam("userAddressIds")List userAddressIds) ; + + @GetMapping("/user/address/listUserAddresses") + public CommonResult> listUserAddresses(@RequestParam("userId")Integer userId, @RequestParam("type")Integer type); + +} diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/address/UserAddressRpc.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/address/UserAddressRpc.java deleted file mode 100644 index ebbcfc467..000000000 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/address/UserAddressRpc.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.mall.userservice.rpc.address; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressCreateReqDTO; -import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressRespDTO; -import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressUpdateReqDTO; - -import java.util.List; - -/** -* 用户收件地址 Rpc 接口 -*/ -public interface UserAddressRpc { - - /** - * 创建用户收件地址 - * - * @param createDTO 创建用户收件地址 DTO - * @return 用户收件地址编号 - */ - CommonResult createUserAddress(UserAddressCreateReqDTO createDTO); - - /** - * 更新用户收件地址 - * - * @param updateDTO 更新用户收件地址 DTO - */ - CommonResult updateUserAddress(UserAddressUpdateReqDTO updateDTO); - - /** - * 删除用户收件地址 - * - * @param userAddressId 用户收件地址编号 - */ - CommonResult deleteUserAddress(Integer userAddressId); - - /** - * 获得用户收件地址 - * - * @param userAddressId 用户收件地址编号 - * @return 用户收件地址 - */ - CommonResult getUserAddress(Integer userAddressId); - - /** - * 获得用户收件地址列表 - * - * @param userAddressIds 用户收件地址编号列表 - * @return 用户收件地址列表 - */ - CommonResult> listUserAddresses(List userAddressIds); - - /** - * 获取指定用户的收件地址列表 - * - * @param userId 用户编号 - * @param type 地址类型 - * @return 收件地址列表 - */ - CommonResult> listUserAddresses(Integer userId, Integer type); - -} diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeFeign.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeFeign.java new file mode 100644 index 000000000..eeb92be5e --- /dev/null +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeFeign.java @@ -0,0 +1,21 @@ +package cn.iocoder.mall.userservice.rpc.sms; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.userservice.rpc.sms.dto.UserSendSmsCodeReqDTO; +import cn.iocoder.mall.userservice.rpc.sms.dto.UserVerifySmsCodeReqDTO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * 用户短信验证码 Rpc 接口 + */ +@FeignClient("user-service") +public interface UserSmsCodeFeign { + @PostMapping("/user/sms/sendSmsCode") + public CommonResult sendSmsCode(@RequestBody UserSendSmsCodeReqDTO sendSmsCodeDTO) ; + + @PostMapping("/user/sms/sverifySmsCode") + public CommonResult verifySmsCode(@RequestBody UserVerifySmsCodeReqDTO verifySmsCodeDTO); + +} diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpc.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpc.java deleted file mode 100644 index c1f7cc4bc..000000000 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpc.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.mall.userservice.rpc.sms; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.userservice.rpc.sms.dto.UserSendSmsCodeReqDTO; -import cn.iocoder.mall.userservice.rpc.sms.dto.UserVerifySmsCodeReqDTO; - -/** - * 用户短信验证码 Rpc 接口 - */ -public interface UserSmsCodeRpc { - - CommonResult sendSmsCode(UserSendSmsCodeReqDTO sendSmsCodeDTO); - - CommonResult verifySmsCode(UserVerifySmsCodeReqDTO verifySmsCodeDTO); - -} diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserFeign.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserFeign.java new file mode 100644 index 000000000..6a7a3545d --- /dev/null +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserFeign.java @@ -0,0 +1,35 @@ +package cn.iocoder.mall.userservice.rpc.user; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.userservice.rpc.user.dto.UserCreateReqDTO; +import cn.iocoder.mall.userservice.rpc.user.dto.UserPageReqDTO; +import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; +import cn.iocoder.mall.userservice.rpc.user.dto.UserUpdateReqDTO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * 用户短信验证码 Rpc 接口 + */ +@FeignClient("user-service") +public interface UserFeign { + @GetMapping("/user/manage/getUser") + public CommonResult getUser(@RequestParam("id") Integer id) ; + + @GetMapping("/user/manage/listUsers") + public CommonResult> listUsers(@RequestParam("userIds") List userIds) ; + + @PostMapping("/user/manage/createUserIfAbsent") + public CommonResult createUserIfAbsent(@RequestBody UserCreateReqDTO createDTO); + @PostMapping("/user/manage/updateUser") + public CommonResult updateUser(@RequestBody UserUpdateReqDTO updateDTO); + + @PostMapping("/user/manage/pageUser") + public CommonResult> pageUser(@RequestBody UserPageReqDTO pageDTO); +} diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpc.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpc.java deleted file mode 100644 index 6ebff8f2f..000000000 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpc.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.mall.userservice.rpc.user; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.userservice.rpc.user.dto.UserCreateReqDTO; -import cn.iocoder.mall.userservice.rpc.user.dto.UserPageReqDTO; -import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; -import cn.iocoder.mall.userservice.rpc.user.dto.UserUpdateReqDTO; - -import java.util.List; - -public interface UserRpc { - - /** - * 获得用户 - * - * @param userId 用户编号 - * @return 用户 - */ - CommonResult getUser(Integer userId); - - /** - * 基于手机号创建用户。 - * 如果用户已经存在,则直接进行返回 - * - * @param createDTO 创建用户 DTO - * @return 用户信息 - */ - CommonResult createUserIfAbsent(UserCreateReqDTO createDTO); - - /** - * 更新用户 - * - * @param updateDTO 更新用户 DTO - */ - CommonResult updateUser(UserUpdateReqDTO updateDTO); - - /** - * 获得用户列表 - * - * @param userIds 用户编号列表 - * @return 用户列表 - */ - CommonResult> listUsers(List userIds); - - /** - * 获得用户分页 - * - * @param pageDTO 用户分页查询 - * @return 用户分页结果 - */ - CommonResult> pageUser(UserPageReqDTO pageDTO); - -} diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/address/UserAddressRpcImpl.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserAddressController.java similarity index 55% rename from user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/address/UserAddressRpcImpl.java rename to user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserAddressController.java index 4e9b331b2..5cfc918be 100644 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/address/UserAddressRpcImpl.java +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserAddressController.java @@ -1,56 +1,54 @@ -package cn.iocoder.mall.userservice.rpc.address; +package cn.iocoder.mall.userservice.controller; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.userservice.manager.address.UserAddressManager; import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressCreateReqDTO; import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressRespDTO; import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressUpdateReqDTO; -import org.apache.dubbo.config.annotation.DubboService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; import java.util.List; import static cn.iocoder.common.framework.vo.CommonResult.success; -/** -* 用户收件地址 Rpc 实现类 -*/ -@DubboService(version = "${dubbo.provider.UserAddressRpc.version}") -public class UserAddressRpcImpl implements UserAddressRpc { +@RestController +@RequestMapping("/user/address") +public class UserAddressController { @Autowired private UserAddressManager userAddressManager; - @Override - public CommonResult createUserAddress(UserAddressCreateReqDTO createDTO) { + @PostMapping("createUserAddress") + public CommonResult createUserAddress(@RequestBody UserAddressCreateReqDTO createDTO) { return success(userAddressManager.createUserAddress(createDTO)); } - @Override - public CommonResult updateUserAddress(UserAddressUpdateReqDTO updateDTO) { + @PostMapping("updateUserAddress") + public CommonResult updateUserAddress(@RequestBody UserAddressUpdateReqDTO updateDTO) { userAddressManager.updateUserAddress(updateDTO); return success(true); } - @Override - public CommonResult deleteUserAddress(Integer userAddressId) { + @GetMapping("deleteUserAddress") + public CommonResult deleteUserAddress(@RequestParam("userAddressId") Integer userAddressId) { userAddressManager.deleteUserAddress(userAddressId); return success(true); } - @Override - public CommonResult getUserAddress(Integer userAddressId) { + @GetMapping("getUserAddress") + public CommonResult getUserAddress(@RequestParam("userAddressId")Integer userAddressId) { return success(userAddressManager.getUserAddress(userAddressId)); } - @Override - public CommonResult> listUserAddresses(List userAddressIds) { + @GetMapping("listUserAddressesByIds") + public CommonResult> listUserAddresses(@RequestParam("userAddressIds")List userAddressIds) { return success(userAddressManager.listUserAddresses(userAddressIds)); } - @Override - public CommonResult> listUserAddresses(Integer userId, Integer type) { + @GetMapping("listUserAddresses") + public CommonResult> listUserAddresses(@RequestParam("userId")Integer userId, @RequestParam("type")Integer type) { return success(userAddressManager.listUserAddresses(userId, type)); } -} +} \ No newline at end of file diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpcImpl.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserManageController.java similarity index 54% rename from user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpcImpl.java rename to user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserManageController.java index e251bd652..f43ec9e91 100644 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpcImpl.java +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserManageController.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.userservice.rpc.user; +package cn.iocoder.mall.userservice.controller; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult; @@ -7,43 +7,44 @@ import cn.iocoder.mall.userservice.rpc.user.dto.UserCreateReqDTO; import cn.iocoder.mall.userservice.rpc.user.dto.UserPageReqDTO; import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; import cn.iocoder.mall.userservice.rpc.user.dto.UserUpdateReqDTO; -import org.apache.dubbo.config.annotation.Service; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; import java.util.List; import static cn.iocoder.common.framework.vo.CommonResult.success; -@Service(version = "${dubbo.provider.UserRpc.version}", validation = "false") -public class UserRpcImpl implements UserRpc { +@RestController +@RequestMapping("/user/manage") +public class UserManageController { @Autowired private UserManager userManager; - @Override - public CommonResult getUser(Integer id) { + @GetMapping("getUser") + public CommonResult getUser(@RequestParam("id") Integer id) { return success(userManager.getUser(id)); } - @Override - public CommonResult> listUsers(List userIds) { + @GetMapping("listUsers") + public CommonResult> listUsers(@RequestParam("userIds") List userIds) { return success(userManager.listUsers(userIds)); } - @Override - public CommonResult createUserIfAbsent(UserCreateReqDTO createDTO) { + @PostMapping("createUserIfAbsent") + public CommonResult createUserIfAbsent(@RequestBody UserCreateReqDTO createDTO) { return success(userManager.createUserIfAbsent(createDTO)); } - @Override - public CommonResult updateUser(UserUpdateReqDTO updateDTO) { + @PostMapping("updateUser") + public CommonResult updateUser(@RequestBody UserUpdateReqDTO updateDTO) { userManager.updateUser(updateDTO); return success(true); } - @Override - public CommonResult> pageUser(UserPageReqDTO pageDTO) { + @PostMapping("pageUser") + public CommonResult> pageUser(@RequestBody UserPageReqDTO pageDTO) { return success(userManager.pageUser(pageDTO)); } -} +} \ No newline at end of file diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserSmsCodeController.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserSmsCodeController.java new file mode 100644 index 000000000..5a3c2dec0 --- /dev/null +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserSmsCodeController.java @@ -0,0 +1,32 @@ +package cn.iocoder.mall.userservice.controller; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.userservice.manager.sms.UserSmsCodeManager; +import cn.iocoder.mall.userservice.rpc.sms.dto.UserSendSmsCodeReqDTO; +import cn.iocoder.mall.userservice.rpc.sms.dto.UserVerifySmsCodeReqDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/user/sms") +public class UserSmsCodeController { + + @Autowired + private UserSmsCodeManager userSmsCodeManager; + + @PostMapping("sendSmsCode") + public CommonResult sendSmsCode(@RequestBody UserSendSmsCodeReqDTO sendSmsCodeDTO) { + userSmsCodeManager.sendSmsCode(sendSmsCodeDTO); + return CommonResult.success(true); + } + + @PostMapping("verifySmsCode") + public CommonResult verifySmsCode(@RequestBody UserVerifySmsCodeReqDTO verifySmsCodeDTO) { + userSmsCodeManager.verifySmsCode(verifySmsCodeDTO); + return CommonResult.success(true); + } + +} \ No newline at end of file diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpcImpl.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpcImpl.java deleted file mode 100644 index db4050575..000000000 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpcImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.mall.userservice.rpc.sms; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.userservice.manager.sms.UserSmsCodeManager; -import cn.iocoder.mall.userservice.rpc.sms.dto.UserSendSmsCodeReqDTO; -import cn.iocoder.mall.userservice.rpc.sms.dto.UserVerifySmsCodeReqDTO; -import org.apache.dubbo.config.annotation.Service; -import org.springframework.beans.factory.annotation.Autowired; - -@Service(version = "${dubbo.provider.UserSmsCodeRpc.version}") -public class UserSmsCodeRpcImpl implements UserSmsCodeRpc { - - @Autowired - private UserSmsCodeManager userSmsCodeManager; - - @Override - public CommonResult sendSmsCode(UserSendSmsCodeReqDTO sendSmsCodeDTO) { - userSmsCodeManager.sendSmsCode(sendSmsCodeDTO); - return CommonResult.success(true); - } - - @Override - public CommonResult verifySmsCode(UserVerifySmsCodeReqDTO verifySmsCodeDTO) { - userSmsCodeManager.verifySmsCode(verifySmsCodeDTO); - return CommonResult.success(true); - } - -}