启动成功
parent
db27985036
commit
48bd0c1b3c
|
@ -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());
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -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<ErrorCodeAutoGenerateDTO> 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<Boolean> 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<ErrorCodeAutoGenerateDTO> 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<Boolean> 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());
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -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<List<ErrorCodeVO>> 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<List<ErrorCodeVO>> 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<List<ErrorCodeVO>> 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<List<ErrorCodeVO>> 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());
|
||||
// });
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,6 @@
|
|||
<guava.version>27.0.1-jre</guava.version>
|
||||
<org.projectlombok.version>1.16.14</org.projectlombok.version>
|
||||
<org.mapstruct.version>1.3.0.Final</org.mapstruct.version>
|
||||
<spring-cloud.feign.version>3.0.4</spring-cloud.feign.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖管理 -->
|
||||
|
@ -382,11 +381,6 @@
|
|||
<version>${hibernate-validator.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||
<version>${spring-cloud.feign.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
###
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
###
|
||||
|
|
|
@ -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}}
|
||||
|
||||
###
|
||||
|
|
|
@ -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
|
||||
|
||||
###
|
||||
|
|
|
@ -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
|
||||
|
||||
###
|
||||
|
|
|
@ -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
|
||||
|
||||
###
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
###
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<Boolean> updateUserResult = userRpc.updateUser(UserConvert.INSTANCE.convert(updateInfoReqVO));
|
||||
CommonResult<Boolean> 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<Boolean> updateUserResult = userRpc.updateUser(UserConvert.INSTANCE.convert(updateStatusReqVO));
|
||||
CommonResult<Boolean> updateUserResult = userFeign.updateUser(UserConvert.INSTANCE.convert(updateStatusReqVO));
|
||||
updateUserResult.checkError();
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class UserManager {
|
|||
* @return 用户
|
||||
*/
|
||||
public UserRespVO getUser(Integer userId) {
|
||||
CommonResult<UserRespDTO> getUserResult = userRpc.getUser(userId);
|
||||
CommonResult<UserRespDTO> getUserResult = userFeign.getUser(userId);
|
||||
getUserResult.checkError();
|
||||
return UserConvert.INSTANCE.convert(getUserResult.getData());
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class UserManager {
|
|||
* @return 用户列表
|
||||
*/
|
||||
public List<UserRespVO> listUsers(List<Integer> userIds) {
|
||||
CommonResult<List<UserRespDTO>> listUserResult = userRpc.listUsers(userIds);
|
||||
CommonResult<List<UserRespDTO>> listUserResult = userFeign.listUsers(userIds);
|
||||
listUserResult.checkError();
|
||||
return UserConvert.INSTANCE.convertList(listUserResult.getData());
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class UserManager {
|
|||
* @return 用户分页结果
|
||||
*/
|
||||
public PageResult<UserRespVO> pageUser(UserPageReqVO pageVO) {
|
||||
CommonResult<PageResult<UserRespDTO>> pageUserResult = userRpc.pageUser(UserConvert.INSTANCE.convert(pageVO));
|
||||
CommonResult<PageResult<UserRespDTO>> pageUserResult = userFeign.pageUser(UserConvert.INSTANCE.convert(pageVO));
|
||||
pageUserResult.checkError();
|
||||
return UserConvert.INSTANCE.convertPage(pageUserResult.getData());
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||
<version>RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||
<version>RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||
<version>RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||
<version>RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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<Boolean> verifySmsCodeResult = userSmsCodeRpc.verifySmsCode(
|
||||
CommonResult<Boolean> verifySmsCodeResult = userSmsCodeFeign.verifySmsCode(
|
||||
PassportConvert.INSTANCE.convert(loginBySmsDTO).setScene(UserSmsSceneEnum.LOGIN_BY_SMS.getValue()).setIp(ip));
|
||||
verifySmsCodeResult.checkError();
|
||||
// 获得用户
|
||||
CommonResult<UserRespDTO> createUserResult = userRpc.createUserIfAbsent(
|
||||
CommonResult<UserRespDTO> 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<Boolean> sendSmsCodeResult = userSmsCodeRpc.sendSmsCode(
|
||||
CommonResult<Boolean> sendSmsCodeResult = userSmsCodeFeign.sendSmsCode(
|
||||
PassportConvert.INSTANCE.convert(sendSmsCodeDTO).setIp(ip));
|
||||
sendSmsCodeResult.checkError();
|
||||
}
|
||||
|
|
|
@ -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<Integer> createUserAddressResult = userAddressRpc.createUserAddress(
|
||||
CommonResult<Integer> 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<Boolean> updateUserAddressResult = userAddressRpc.updateUserAddress(UserAddressConvert.INSTANCE.convert(updateVO)
|
||||
CommonResult<Boolean> updateUserAddressResult = userAddressFeign.updateUserAddress(UserAddressConvert.INSTANCE.convert(updateVO)
|
||||
.setUserId(userId));
|
||||
updateUserAddressResult.checkError();
|
||||
}
|
||||
|
@ -65,7 +64,7 @@ public class UserAddressManager {
|
|||
// 校验是否能够操作
|
||||
check(userId, userAddressId);
|
||||
// 执行删除
|
||||
CommonResult<Boolean> deleteUserAddressResult = userAddressRpc.deleteUserAddress(userAddressId);
|
||||
CommonResult<Boolean> deleteUserAddressResult = userAddressFeign.deleteUserAddress(userAddressId);
|
||||
deleteUserAddressResult.checkError();
|
||||
}
|
||||
|
||||
|
@ -77,7 +76,7 @@ public class UserAddressManager {
|
|||
* @return 用户收件地址
|
||||
*/
|
||||
public UserAddressRespVO getUserAddress(Integer userId, Integer userAddressId) {
|
||||
CommonResult<UserAddressRespDTO> getUserAddressResult = userAddressRpc.getUserAddress(userAddressId);
|
||||
CommonResult<UserAddressRespDTO> getUserAddressResult = userAddressFeign.getUserAddress(userAddressId);
|
||||
getUserAddressResult.checkError();
|
||||
// 校验是否能够操作
|
||||
this.check(userId, userAddressId);
|
||||
|
@ -91,7 +90,7 @@ public class UserAddressManager {
|
|||
* @return 用户收件地址列表
|
||||
*/
|
||||
public List<UserAddressRespVO> listUserAddresses(Integer userId) {
|
||||
CommonResult<List<UserAddressRespDTO>> listUserAddressResult = userAddressRpc.listUserAddresses(userId, null);
|
||||
CommonResult<List<UserAddressRespDTO>> 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<List<UserAddressRespDTO>> listUserAddressResult = userAddressRpc.listUserAddresses(userId, UserAddressType.DEFAULT.getType());
|
||||
CommonResult<List<UserAddressRespDTO>> 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<UserAddressRespDTO> getUserAddressResult = userAddressRpc.getUserAddress(userAddressId);
|
||||
CommonResult<UserAddressRespDTO> getUserAddressResult = userAddressFeign.getUserAddress(userAddressId);
|
||||
getUserAddressResult.checkError();
|
||||
this.check(userId, getUserAddressResult.getData());
|
||||
}
|
||||
|
|
|
@ -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<UserRespDTO> userResult = userRpc.getUser(id);
|
||||
CommonResult<UserRespDTO> userResult = userFeign.getUser(id);
|
||||
userResult.checkError();
|
||||
return UserConvert.INSTANCE.convert(userResult.getData());
|
||||
}
|
||||
|
||||
public void updateUserAvatar(Integer userId, String avatar) {
|
||||
CommonResult<Boolean> updateUserResult = userRpc.updateUser(new UserUpdateReqDTO().setId(userId).setAvatar(avatar));
|
||||
CommonResult<Boolean> updateUserResult = userFeign.updateUser(new UserUpdateReqDTO().setId(userId).setAvatar(avatar));
|
||||
updateUserResult.checkError();
|
||||
}
|
||||
|
||||
public void updateUserNickname(Integer userId, String nickname) {
|
||||
CommonResult<Boolean> updateUserResult = userRpc.updateUser(new UserUpdateReqDTO().setId(userId).setNickname(nickname));
|
||||
CommonResult<Boolean> updateUserResult = userFeign.updateUser(new UserUpdateReqDTO().setId(userId).setNickname(nickname));
|
||||
updateUserResult.checkError();
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
<version>RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -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<OAuth2AccessTokenRespDTO> createAccessToken(@RequestBody OAuth2CreateAccessTokenReqDTO createAccessTokenDTO);
|
||||
|
||||
@PostMapping("/system/oauthcheckAccessToken")
|
||||
@GetMapping("/system/oauth/checkAccessToken")
|
||||
public CommonResult<OAuth2AccessTokenRespDTO> checkAccessToken(@RequestParam("accessToken") String accessToken) ;
|
||||
|
||||
@PostMapping("/system/oauthrefreshAccessToken")
|
||||
@PostMapping("/system/oauth/refreshAccessToken")
|
||||
public CommonResult<OAuth2AccessTokenRespDTO> refreshAccessToken(@RequestBody OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO);
|
||||
@PostMapping("/system/oauthremoveToken")
|
||||
@PostMapping("/system/oauth/removeToken")
|
||||
public CommonResult<Boolean> removeToken(@RequestBody OAuth2RemoveTokenByUserReqDTO removeTokenDTO);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,6 @@ public interface PermissionFeign {
|
|||
@PostMapping("/system/permission/assignAdminRole")
|
||||
public CommonResult<Boolean> assignAdminRole(@RequestBody PermissionAssignAdminRoleDTO assignAdminRoleDTO);
|
||||
|
||||
@PostMapping("/system/permission/scheckPermission")
|
||||
@PostMapping("/system/permission/checkPermission")
|
||||
public CommonResult<Boolean> checkPermission(@RequestBody PermissionCheckDTO checkDTO) ;
|
||||
}
|
||||
|
|
|
@ -86,10 +86,6 @@
|
|||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-jdk8</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -30,7 +30,7 @@ public class OAuthController {
|
|||
return success(oAuth2Service.createAccessToken(createAccessTokenDTO));
|
||||
}
|
||||
|
||||
@PostMapping("checkAccessToken")
|
||||
@GetMapping("checkAccessToken")
|
||||
public CommonResult<OAuth2AccessTokenRespDTO> checkAccessToken(@RequestParam("accessToken") String accessToken) {
|
||||
return success(oAuth2Service.checkAccessToken(accessToken));
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||
<version>RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<UserAddressRespDTO> getUserAddressResult = userAddressRpc.getUserAddress(userAddressId);
|
||||
CommonResult<UserAddressRespDTO> getUserAddressResult = userAddressFeign.getUserAddress(userAddressId);
|
||||
getUserAddressResult.checkError();
|
||||
if (getUserAddressResult.getData() == null) {
|
||||
return null;
|
||||
|
|
|
@ -26,6 +26,12 @@
|
|||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||
<version>RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -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<Integer> createUserAddress(@RequestBody UserAddressCreateReqDTO createDTO);
|
||||
|
||||
@PostMapping("/user/address/updateUserAddress")
|
||||
public CommonResult<Boolean> updateUserAddress(@RequestBody UserAddressUpdateReqDTO updateDTO);
|
||||
|
||||
@GetMapping("/user/address/deleteUserAddress")
|
||||
public CommonResult<Boolean> deleteUserAddress(@RequestParam("userAddressId") Integer userAddressId);
|
||||
|
||||
@GetMapping("/user/address/getUserAddress")
|
||||
public CommonResult<UserAddressRespDTO> getUserAddress(@RequestParam("userAddressId")Integer userAddressId) ;
|
||||
|
||||
@GetMapping("/user/address/listUserAddressesByIds")
|
||||
public CommonResult<List<UserAddressRespDTO>> listUserAddresses(@RequestParam("userAddressIds")List<Integer> userAddressIds) ;
|
||||
|
||||
@GetMapping("/user/address/listUserAddresses")
|
||||
public CommonResult<List<UserAddressRespDTO>> listUserAddresses(@RequestParam("userId")Integer userId, @RequestParam("type")Integer type);
|
||||
|
||||
}
|
|
@ -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<Integer> createUserAddress(UserAddressCreateReqDTO createDTO);
|
||||
|
||||
/**
|
||||
* 更新用户收件地址
|
||||
*
|
||||
* @param updateDTO 更新用户收件地址 DTO
|
||||
*/
|
||||
CommonResult<Boolean> updateUserAddress(UserAddressUpdateReqDTO updateDTO);
|
||||
|
||||
/**
|
||||
* 删除用户收件地址
|
||||
*
|
||||
* @param userAddressId 用户收件地址编号
|
||||
*/
|
||||
CommonResult<Boolean> deleteUserAddress(Integer userAddressId);
|
||||
|
||||
/**
|
||||
* 获得用户收件地址
|
||||
*
|
||||
* @param userAddressId 用户收件地址编号
|
||||
* @return 用户收件地址
|
||||
*/
|
||||
CommonResult<UserAddressRespDTO> getUserAddress(Integer userAddressId);
|
||||
|
||||
/**
|
||||
* 获得用户收件地址列表
|
||||
*
|
||||
* @param userAddressIds 用户收件地址编号列表
|
||||
* @return 用户收件地址列表
|
||||
*/
|
||||
CommonResult<List<UserAddressRespDTO>> listUserAddresses(List<Integer> userAddressIds);
|
||||
|
||||
/**
|
||||
* 获取指定用户的收件地址列表
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param type 地址类型
|
||||
* @return 收件地址列表
|
||||
*/
|
||||
CommonResult<List<UserAddressRespDTO>> listUserAddresses(Integer userId, Integer type);
|
||||
|
||||
}
|
|
@ -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<Boolean> sendSmsCode(@RequestBody UserSendSmsCodeReqDTO sendSmsCodeDTO) ;
|
||||
|
||||
@PostMapping("/user/sms/sverifySmsCode")
|
||||
public CommonResult<Boolean> verifySmsCode(@RequestBody UserVerifySmsCodeReqDTO verifySmsCodeDTO);
|
||||
|
||||
}
|
|
@ -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<Boolean> sendSmsCode(UserSendSmsCodeReqDTO sendSmsCodeDTO);
|
||||
|
||||
CommonResult<Boolean> verifySmsCode(UserVerifySmsCodeReqDTO verifySmsCodeDTO);
|
||||
|
||||
}
|
|
@ -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<UserRespDTO> getUser(@RequestParam("id") Integer id) ;
|
||||
|
||||
@GetMapping("/user/manage/listUsers")
|
||||
public CommonResult<List<UserRespDTO>> listUsers(@RequestParam("userIds") List<Integer> userIds) ;
|
||||
|
||||
@PostMapping("/user/manage/createUserIfAbsent")
|
||||
public CommonResult<UserRespDTO> createUserIfAbsent(@RequestBody UserCreateReqDTO createDTO);
|
||||
@PostMapping("/user/manage/updateUser")
|
||||
public CommonResult<Boolean> updateUser(@RequestBody UserUpdateReqDTO updateDTO);
|
||||
|
||||
@PostMapping("/user/manage/pageUser")
|
||||
public CommonResult<PageResult<UserRespDTO>> pageUser(@RequestBody UserPageReqDTO pageDTO);
|
||||
}
|
|
@ -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<UserRespDTO> getUser(Integer userId);
|
||||
|
||||
/**
|
||||
* 基于手机号创建用户。
|
||||
* 如果用户已经存在,则直接进行返回
|
||||
*
|
||||
* @param createDTO 创建用户 DTO
|
||||
* @return 用户信息
|
||||
*/
|
||||
CommonResult<UserRespDTO> createUserIfAbsent(UserCreateReqDTO createDTO);
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
*
|
||||
* @param updateDTO 更新用户 DTO
|
||||
*/
|
||||
CommonResult<Boolean> updateUser(UserUpdateReqDTO updateDTO);
|
||||
|
||||
/**
|
||||
* 获得用户列表
|
||||
*
|
||||
* @param userIds 用户编号列表
|
||||
* @return 用户列表
|
||||
*/
|
||||
CommonResult<List<UserRespDTO>> listUsers(List<Integer> userIds);
|
||||
|
||||
/**
|
||||
* 获得用户分页
|
||||
*
|
||||
* @param pageDTO 用户分页查询
|
||||
* @return 用户分页结果
|
||||
*/
|
||||
CommonResult<PageResult<UserRespDTO>> pageUser(UserPageReqDTO pageDTO);
|
||||
|
||||
}
|
|
@ -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<Integer> createUserAddress(UserAddressCreateReqDTO createDTO) {
|
||||
@PostMapping("createUserAddress")
|
||||
public CommonResult<Integer> createUserAddress(@RequestBody UserAddressCreateReqDTO createDTO) {
|
||||
return success(userAddressManager.createUserAddress(createDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateUserAddress(UserAddressUpdateReqDTO updateDTO) {
|
||||
@PostMapping("updateUserAddress")
|
||||
public CommonResult<Boolean> updateUserAddress(@RequestBody UserAddressUpdateReqDTO updateDTO) {
|
||||
userAddressManager.updateUserAddress(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteUserAddress(Integer userAddressId) {
|
||||
@GetMapping("deleteUserAddress")
|
||||
public CommonResult<Boolean> deleteUserAddress(@RequestParam("userAddressId") Integer userAddressId) {
|
||||
userAddressManager.deleteUserAddress(userAddressId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<UserAddressRespDTO> getUserAddress(Integer userAddressId) {
|
||||
@GetMapping("getUserAddress")
|
||||
public CommonResult<UserAddressRespDTO> getUserAddress(@RequestParam("userAddressId")Integer userAddressId) {
|
||||
return success(userAddressManager.getUserAddress(userAddressId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<UserAddressRespDTO>> listUserAddresses(List<Integer> userAddressIds) {
|
||||
@GetMapping("listUserAddressesByIds")
|
||||
public CommonResult<List<UserAddressRespDTO>> listUserAddresses(@RequestParam("userAddressIds")List<Integer> userAddressIds) {
|
||||
return success(userAddressManager.listUserAddresses(userAddressIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<UserAddressRespDTO>> listUserAddresses(Integer userId, Integer type) {
|
||||
@GetMapping("listUserAddresses")
|
||||
public CommonResult<List<UserAddressRespDTO>> listUserAddresses(@RequestParam("userId")Integer userId, @RequestParam("type")Integer type) {
|
||||
return success(userAddressManager.listUserAddresses(userId, type));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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<UserRespDTO> getUser(Integer id) {
|
||||
@GetMapping("getUser")
|
||||
public CommonResult<UserRespDTO> getUser(@RequestParam("id") Integer id) {
|
||||
return success(userManager.getUser(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<UserRespDTO>> listUsers(List<Integer> userIds) {
|
||||
@GetMapping("listUsers")
|
||||
public CommonResult<List<UserRespDTO>> listUsers(@RequestParam("userIds") List<Integer> userIds) {
|
||||
return success(userManager.listUsers(userIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<UserRespDTO> createUserIfAbsent(UserCreateReqDTO createDTO) {
|
||||
@PostMapping("createUserIfAbsent")
|
||||
public CommonResult<UserRespDTO> createUserIfAbsent(@RequestBody UserCreateReqDTO createDTO) {
|
||||
return success(userManager.createUserIfAbsent(createDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateUser(UserUpdateReqDTO updateDTO) {
|
||||
@PostMapping("updateUser")
|
||||
public CommonResult<Boolean> updateUser(@RequestBody UserUpdateReqDTO updateDTO) {
|
||||
userManager.updateUser(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<PageResult<UserRespDTO>> pageUser(UserPageReqDTO pageDTO) {
|
||||
@PostMapping("pageUser")
|
||||
public CommonResult<PageResult<UserRespDTO>> pageUser(@RequestBody UserPageReqDTO pageDTO) {
|
||||
return success(userManager.pageUser(pageDTO));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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<Boolean> sendSmsCode(@RequestBody UserSendSmsCodeReqDTO sendSmsCodeDTO) {
|
||||
userSmsCodeManager.sendSmsCode(sendSmsCodeDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@PostMapping("verifySmsCode")
|
||||
public CommonResult<Boolean> verifySmsCode(@RequestBody UserVerifySmsCodeReqDTO verifySmsCodeDTO) {
|
||||
userSmsCodeManager.verifySmsCode(verifySmsCodeDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Boolean> sendSmsCode(UserSendSmsCodeReqDTO sendSmsCodeDTO) {
|
||||
userSmsCodeManager.sendSmsCode(sendSmsCodeDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> verifySmsCode(UserVerifySmsCodeReqDTO verifySmsCodeDTO) {
|
||||
userSmsCodeManager.verifySmsCode(verifySmsCodeDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue