启动成功
This commit is contained in:
parent
db27985036
commit
48bd0c1b3c
@ -12,15 +12,15 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||||||
@EnableScheduling // 开启调度任务的功能,因为 ErrorCodeRemoteLoader 通过定时刷新错误码
|
@EnableScheduling // 开启调度任务的功能,因为 ErrorCodeRemoteLoader 通过定时刷新错误码
|
||||||
public class ErrorCodeAutoConfiguration {
|
public class ErrorCodeAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
// @Bean
|
||||||
public ErrorCodeAutoGenerator errorCodeAutoGenerator(ErrorCodeProperties errorCodeProperties) {
|
// public ErrorCodeAutoGenerator errorCodeAutoGenerator(ErrorCodeProperties errorCodeProperties) {
|
||||||
return new ErrorCodeAutoGenerator(errorCodeProperties.getGroup())
|
// return new ErrorCodeAutoGenerator(errorCodeProperties.getGroup())
|
||||||
.setErrorCodeConstantsClass(errorCodeProperties.getConstantsClass());
|
// .setErrorCodeConstantsClass(errorCodeProperties.getConstantsClass());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public ErrorCodeRemoteLoader errorCodeRemoteLoader(ErrorCodeProperties errorCodeProperties) {
|
// public ErrorCodeRemoteLoader errorCodeRemoteLoader(ErrorCodeProperties errorCodeProperties) {
|
||||||
return new ErrorCodeRemoteLoader(errorCodeProperties.getGroup());
|
// return new ErrorCodeRemoteLoader(errorCodeProperties.getGroup());
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,68 +17,68 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ErrorCodeAutoGenerator {
|
public class ErrorCodeAutoGenerator {
|
||||||
|
//
|
||||||
private Logger logger = LoggerFactory.getLogger(ErrorCodeAutoGenerator.class);
|
// private Logger logger = LoggerFactory.getLogger(ErrorCodeAutoGenerator.class);
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 应用分组
|
// * 应用分组
|
||||||
*/
|
// */
|
||||||
private final String group;
|
// private final String group;
|
||||||
/**
|
// /**
|
||||||
* 错误码枚举类
|
// * 错误码枚举类
|
||||||
*/
|
// */
|
||||||
private String errorCodeConstantsClass;
|
// private String errorCodeConstantsClass;
|
||||||
|
//
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private ErrorCodeFeign errorCodeFeign;
|
// private ErrorCodeFeign errorCodeFeign;
|
||||||
public ErrorCodeAutoGenerator(String group) {
|
// public ErrorCodeAutoGenerator(String group) {
|
||||||
this.group = group;
|
// this.group = group;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public ErrorCodeAutoGenerator setErrorCodeConstantsClass(String errorCodeConstantsClass) {
|
// public ErrorCodeAutoGenerator setErrorCodeConstantsClass(String errorCodeConstantsClass) {
|
||||||
this.errorCodeConstantsClass = errorCodeConstantsClass;
|
// this.errorCodeConstantsClass = errorCodeConstantsClass;
|
||||||
return this;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EventListener(ApplicationReadyEvent.class)
|
// @EventListener(ApplicationReadyEvent.class)
|
||||||
@Async // 异步,保证项目的启动过程,毕竟非关键流程
|
// @Async // 异步,保证项目的启动过程,毕竟非关键流程
|
||||||
public void execute() {
|
// public void execute() {
|
||||||
// 校验 errorCodeConstantsClass 参数
|
// // 校验 errorCodeConstantsClass 参数
|
||||||
if (!StringUtils.hasText(errorCodeConstantsClass)) {
|
// if (!StringUtils.hasText(errorCodeConstantsClass)) {
|
||||||
logger.info("[execute][未配置 mall.error-code.constants-class 配置项,不进行自动写入到 system-service 服务]");
|
// logger.info("[execute][未配置 mall.error-code.constants-class 配置项,不进行自动写入到 system-service 服务]");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
Class errorCodeConstantsClazz;
|
// Class errorCodeConstantsClazz;
|
||||||
try {
|
// try {
|
||||||
errorCodeConstantsClazz = Class.forName(errorCodeConstantsClass);
|
// errorCodeConstantsClazz = Class.forName(errorCodeConstantsClass);
|
||||||
} catch (ClassNotFoundException e) {
|
// } catch (ClassNotFoundException e) {
|
||||||
logger.error("[execute][配置的 ({}) 找不到对应的类]", errorCodeConstantsClass);
|
// logger.error("[execute][配置的 ({}) 找不到对应的类]", errorCodeConstantsClass);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
// 写入 system-service 服务
|
// // 写入 system-service 服务
|
||||||
logger.info("[execute][自动将 ({}) 类的错误码,准备写入到 system-service 服务]", errorCodeConstantsClass);
|
// logger.info("[execute][自动将 ({}) 类的错误码,准备写入到 system-service 服务]", errorCodeConstantsClass);
|
||||||
List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs = new ArrayList<>();
|
// List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs = new ArrayList<>();
|
||||||
Arrays.stream(errorCodeConstantsClazz.getFields()).forEach(field -> {
|
// Arrays.stream(errorCodeConstantsClazz.getFields()).forEach(field -> {
|
||||||
if (field.getType() != ErrorCode.class) {
|
// if (field.getType() != ErrorCode.class) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
try {
|
// try {
|
||||||
// TODO 芋艿:校验是否重复了;
|
// // TODO 芋艿:校验是否重复了;
|
||||||
ErrorCode errorCode = (ErrorCode) field.get(errorCodeConstantsClazz);
|
// ErrorCode errorCode = (ErrorCode) field.get(errorCodeConstantsClazz);
|
||||||
autoGenerateDTOs.add(new ErrorCodeAutoGenerateDTO().setGroup(group)
|
// autoGenerateDTOs.add(new ErrorCodeAutoGenerateDTO().setGroup(group)
|
||||||
.setCode(errorCode.getCode()).setMessage(errorCode.getMessage()));
|
// .setCode(errorCode.getCode()).setMessage(errorCode.getMessage()));
|
||||||
} catch (IllegalAccessException e) {
|
// } catch (IllegalAccessException e) {
|
||||||
throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
CommonResult<Boolean> autoGenerateErrorCodesResult = errorCodeFeign.autoGenerateErrorCodes(autoGenerateDTOs);
|
// CommonResult<Boolean> autoGenerateErrorCodesResult = errorCodeFeign.autoGenerateErrorCodes(autoGenerateDTOs);
|
||||||
if (autoGenerateErrorCodesResult.isSuccess()) {
|
// if (autoGenerateErrorCodesResult.isSuccess()) {
|
||||||
logger.info("[execute][自动将 ({}) 类的错误码,成功写入到 system-service 服务]", errorCodeConstantsClass);
|
// logger.info("[execute][自动将 ({}) 类的错误码,成功写入到 system-service 服务]", errorCodeConstantsClass);
|
||||||
} else {
|
// } else {
|
||||||
logger.error("[execute][自动将 ({}) 类的错误码,失败写入到 system-service 服务,原因为 ({}/{}/{})]", errorCodeConstantsClass,
|
// logger.error("[execute][自动将 ({}) 类的错误码,失败写入到 system-service 服务,原因为 ({}/{}/{})]", errorCodeConstantsClass,
|
||||||
autoGenerateErrorCodesResult.getCode(), autoGenerateErrorCodesResult.getMessage(), autoGenerateErrorCodesResult.getDetailMessage());
|
// autoGenerateErrorCodesResult.getCode(), autoGenerateErrorCodesResult.getMessage(), autoGenerateErrorCodesResult.getDetailMessage());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,54 +17,54 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ErrorCodeRemoteLoader {
|
public class ErrorCodeRemoteLoader {
|
||||||
|
//
|
||||||
private static final int REFRESH_ERROR_CODE_PERIOD = 60 * 1000;
|
// private static final int REFRESH_ERROR_CODE_PERIOD = 60 * 1000;
|
||||||
|
//
|
||||||
private Logger logger = LoggerFactory.getLogger(ErrorCodeRemoteLoader.class);
|
// private Logger logger = LoggerFactory.getLogger(ErrorCodeRemoteLoader.class);
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 应用分组
|
// * 应用分组
|
||||||
*/
|
// */
|
||||||
private final String group;
|
// private final String group;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private ErrorCodeFeign errorCodeFeign;
|
// private ErrorCodeFeign errorCodeFeign;
|
||||||
private Date maxUpdateTime;
|
// private Date maxUpdateTime;
|
||||||
|
//
|
||||||
public ErrorCodeRemoteLoader(String group) {
|
// public ErrorCodeRemoteLoader(String group) {
|
||||||
this.group = group;
|
// this.group = group;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EventListener(ApplicationReadyEvent.class)
|
// @EventListener(ApplicationReadyEvent.class)
|
||||||
public void loadErrorCodes() {
|
// public void loadErrorCodes() {
|
||||||
// 从 errorCodeFeign 全量加载 ErrorCode 错误码
|
// // 从 errorCodeFeign 全量加载 ErrorCode 错误码
|
||||||
CommonResult<List<ErrorCodeVO>> listErrorCodesResult = errorCodeFeign.listErrorCodes(group, null);
|
// CommonResult<List<ErrorCodeVO>> listErrorCodesResult = errorCodeFeign.listErrorCodes(group, null);
|
||||||
listErrorCodesResult.checkError();
|
// listErrorCodesResult.checkError();
|
||||||
logger.info("[loadErrorCodes][从 group({}) 全量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size());
|
// logger.info("[loadErrorCodes][从 group({}) 全量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size());
|
||||||
// 写入到 ServiceExceptionUtil 到
|
// // 写入到 ServiceExceptionUtil 到
|
||||||
listErrorCodesResult.getData().forEach(errorCodeVO -> {
|
// listErrorCodesResult.getData().forEach(errorCodeVO -> {
|
||||||
ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage());
|
// ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage());
|
||||||
// 记录下更新时间,方便增量更新
|
// // 记录下更新时间,方便增量更新
|
||||||
maxUpdateTime = DateUtil.max(maxUpdateTime, errorCodeVO.getUpdateTime());
|
// maxUpdateTime = DateUtil.max(maxUpdateTime, errorCodeVO.getUpdateTime());
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Scheduled(fixedDelay = REFRESH_ERROR_CODE_PERIOD, initialDelay = REFRESH_ERROR_CODE_PERIOD)
|
// @Scheduled(fixedDelay = REFRESH_ERROR_CODE_PERIOD, initialDelay = REFRESH_ERROR_CODE_PERIOD)
|
||||||
public void refreshErrorCodes() {
|
// public void refreshErrorCodes() {
|
||||||
// 从 errorCodeFeign 增量加载 ErrorCode 错误码
|
// // 从 errorCodeFeign 增量加载 ErrorCode 错误码
|
||||||
// TODO 优化点:假设删除错误码的配置,会存在问题;
|
// // TODO 优化点:假设删除错误码的配置,会存在问题;
|
||||||
CommonResult<List<ErrorCodeVO>> listErrorCodesResult = errorCodeFeign.listErrorCodes(group, maxUpdateTime);
|
// CommonResult<List<ErrorCodeVO>> listErrorCodesResult = errorCodeFeign.listErrorCodes(group, maxUpdateTime);
|
||||||
listErrorCodesResult.checkError();
|
// listErrorCodesResult.checkError();
|
||||||
if (CollectionUtils.isEmpty(listErrorCodesResult.getData())) {
|
// if (CollectionUtils.isEmpty(listErrorCodesResult.getData())) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
logger.info("[refreshErrorCodes][从 group({}) 增量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size());
|
// logger.info("[refreshErrorCodes][从 group({}) 增量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size());
|
||||||
// 写入到 ServiceExceptionUtil 到
|
// // 写入到 ServiceExceptionUtil 到
|
||||||
listErrorCodesResult.getData().forEach(errorCodeVO -> {
|
// listErrorCodesResult.getData().forEach(errorCodeVO -> {
|
||||||
ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage());
|
// ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage());
|
||||||
// 记录下更新时间,方便增量更新
|
// // 记录下更新时间,方便增量更新
|
||||||
maxUpdateTime = DateUtil.max(maxUpdateTime, errorCodeVO.getUpdateTime());
|
// maxUpdateTime = DateUtil.max(maxUpdateTime, errorCodeVO.getUpdateTime());
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,6 @@
|
|||||||
<guava.version>27.0.1-jre</guava.version>
|
<guava.version>27.0.1-jre</guava.version>
|
||||||
<org.projectlombok.version>1.16.14</org.projectlombok.version>
|
<org.projectlombok.version>1.16.14</org.projectlombok.version>
|
||||||
<org.mapstruct.version>1.3.0.Final</org.mapstruct.version>
|
<org.mapstruct.version>1.3.0.Final</org.mapstruct.version>
|
||||||
<spring-cloud.feign.version>3.0.4</spring-cloud.feign.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖管理 -->
|
<!-- 依赖管理 -->
|
||||||
@ -382,11 +381,6 @@
|
|||||||
<version>${hibernate-validator.version}</version>
|
<version>${hibernate-validator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
|
||||||
<version>${spring-cloud.feign.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
@ -8,7 +8,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableDiscoveryClient
|
@EnableDiscoveryClient
|
||||||
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.payservice.rpc"
|
@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 class ManagementWebApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -1,40 +1,40 @@
|
|||||||
### /admin/page 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /admin/create 成功
|
### /admin/create 成功
|
||||||
POST {{baseUrl}}/admin/create
|
POST http://127.0.0.1:18083/management-api/admin/create
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
username=admin02&password=buzhidao&name=测试管理员&departmentId=1
|
username=admin02&password=buzhidao&name=测试管理员&departmentId=1
|
||||||
|
|
||||||
### /admin/update 成功
|
### /admin/update 成功
|
||||||
POST {{baseUrl}}/admin/update
|
POST http://127.0.0.1:18083/management-api/admin/update
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
id=31&username=admin02&password=buzhidao&name=测试管理员&departmentId=1
|
id=31&username=admin02&password=buzhidao&name=测试管理员&departmentId=1
|
||||||
|
|
||||||
### /admin/update-status 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
adminId=31&status=1
|
adminId=31&status=1
|
||||||
|
|
||||||
### /admin/update-status 失败,参数缺失
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
adminId=31
|
adminId=31
|
||||||
|
|
||||||
### admin/update-status 失败,地址不存在
|
### 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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
adminId=31&status=sss
|
adminId=31&status=sss
|
||||||
|
|
||||||
|
@ -1,39 +1,39 @@
|
|||||||
### /department/create 成功
|
### /department/create 成功
|
||||||
POST {{baseUrl}}/department/create
|
POST http://127.0.0.1:18083/management-api/department/create
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
dubbo-tag: {{dubboTag}}
|
dubbo-tag: {{dubboTag}}
|
||||||
|
|
||||||
name=测试部门&pid=0&sort=0
|
name=测试部门&pid=0&sort=0
|
||||||
|
|
||||||
### /department/update 成功
|
### /department/update 成功
|
||||||
POST {{baseUrl}}/department/update
|
POST http://127.0.0.1:18083/management-api/department/update
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
id=1&name=测试部门&pid=0&sort=0
|
id=1&name=测试部门&pid=0&sort=0
|
||||||
|
|
||||||
### /resource/delete 成功
|
### /resource/delete 成功
|
||||||
POST {{baseUrl}}/department/delete
|
POST http://127.0.0.1:18083/management-api/department/delete
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
id=1
|
id=1
|
||||||
|
|
||||||
### /department/get 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /department/list 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /department/tree 成功
|
### /department/tree 成功
|
||||||
GET {{baseUrl}}/department/tree
|
GET http://127.0.0.1:18083/management-api/department/tree
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
### /passport/login 成功
|
### /passport/login 成功
|
||||||
POST {{baseUrl}}/passport/login
|
POST http://127.0.0.1:18083/management-api/passport/login
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
|
|
||||||
username=admin&password=buzhidao
|
username=admin&password=buzhidao
|
||||||
|
|
||||||
### /passport/login 密码不正确
|
### /passport/login 密码不正确
|
||||||
POST {{baseUrl}}/passport/login
|
POST http://127.0.0.1:18083/management-api/passport/login
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
|
|
||||||
username=admin&password=1024
|
username=admin&password=1024
|
||||||
|
|
||||||
### /passport/login 少传参数
|
### /passport/login 少传参数
|
||||||
POST {{baseUrl}}/passport/login
|
POST http://127.0.0.1:18083/management-api/passport/login
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
|
|
||||||
username=admin
|
username=admin
|
||||||
|
|
||||||
### /passport/info 成功
|
### /passport/info 成功
|
||||||
GET {{baseUrl}}/passport/info
|
GET http://127.0.0.1:18083/management-api/passport/info
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /passport/tree-admin-menu 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /passport/list-admin-permission 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
#Authorization: Bearer {{accessToken}}
|
#Authorization: Bearer yudaoyuanma
|
||||||
Authorization: Bearer 36dce986276b4d6c8f9f4f3b89b22810
|
Authorization: Bearer 36dce986276b4d6c8f9f4f3b89b22810
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
### /product-spu/page 成功(全部)
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
dubbo-tag: {{dubboTag}}
|
dubbo-tag: {{dubboTag}}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
### /permission/list 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /permission/list-admin-roles 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -1,37 +1,37 @@
|
|||||||
### /resource/create 成功
|
### /resource/create 成功
|
||||||
POST {{baseUrl}}/resource/create
|
POST http://127.0.0.1:18083/management-api/resource/create
|
||||||
Content-Type: application/x-www-form-urlencoded
|
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
|
name=测试菜单&permission=resource:add&type=1&sort=1&pid=0&route=/resource/list&icon=test
|
||||||
|
|
||||||
### /admin/update 成功
|
### /admin/update 成功
|
||||||
POST {{baseUrl}}/resource/update
|
POST http://127.0.0.1:18083/management-api/resource/update
|
||||||
Content-Type: application/x-www-form-urlencoded
|
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
|
id=61&name=测试菜单2&permission=resource:add&type=1&sort=1&pid=0&route=/resource/list&icon=test
|
||||||
|
|
||||||
### /resource/delete 成功
|
### /resource/delete 成功
|
||||||
POST {{baseUrl}}/resource/delete
|
POST http://127.0.0.1:18083/management-api/resource/delete
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
resourceId=61
|
resourceId=61
|
||||||
|
|
||||||
### /resource/get 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /resource/list 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /resource/tree 成功
|
### /resource/tree 成功
|
||||||
GET {{baseUrl}}/resource/tree
|
GET http://127.0.0.1:18083/management-api/resource/tree
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
### /role/create 成功
|
### /role/create 成功
|
||||||
POST {{baseUrl}}/role/create
|
POST http://127.0.0.1:18083/management-api/role/create
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
#Authorization: Bearer 9d250d9b6c034a6c88bf4034cdf1d4cc
|
#Authorization: Bearer 9d250d9b6c034a6c88bf4034cdf1d4cc
|
||||||
|
|
||||||
name=测试角色
|
name=测试角色
|
||||||
|
|
||||||
### /role/update 成功
|
### /role/update 成功
|
||||||
POST {{baseUrl}}/role/update
|
POST http://127.0.0.1:18083/management-api/role/update
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
id=14&name=test
|
id=14&name=test
|
||||||
|
|
||||||
### /resource/delete 成功
|
### /resource/delete 成功
|
||||||
POST {{baseUrl}}/role/delete
|
POST http://127.0.0.1:18083/management-api/role/delete
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
roleId=14
|
roleId=14
|
||||||
|
|
||||||
### /role/get 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /role/list-all 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /role/list 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /role/page 成功
|
### /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
|
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
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /product-spu/page 成功(有库存 + 上架)
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /product-spu/page 成功(无库存 + 下架)
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
### /product-spu/create 成功
|
### /product-spu/create 成功
|
||||||
POST http://127.0.0.1:18083/management-api/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
|
&skus[1].price=2&skus[1].quantity=50&skus[1].attrValueIds=2,4
|
||||||
|
|
||||||
### /product-spu/create 失败(规格不存在)
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
name=测试商品标题&description=测试商品描述&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true
|
name=测试商品标题&description=测试商品描述&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true
|
||||||
&skus[0].price=1&skus[0].quantity=100&skus[0].attrValueIds=1,0
|
&skus[0].price=1&skus[0].quantity=100&skus[0].attrValueIds=1,0
|
||||||
|
|
||||||
### /product-spu/create 失败(规格数量不匹配)
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
name=测试商品标题&description=测试商品描述&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true
|
name=测试商品标题&description=测试商品描述&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true
|
||||||
&skus[0].price=1&skus[0].quantity=100&skus[0].attrValueIds=1,3
|
&skus[0].price=1&skus[0].quantity=100&skus[0].attrValueIds=1,3
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
### /system-access-log/page 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
### /user/page 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
dubbo-tag: {{dubboTag}}
|
dubbo-tag: {{dubboTag}}
|
||||||
|
|
||||||
### /user/update 成功
|
### /user/update 成功
|
||||||
POST {{baseUrl}}/user/update
|
POST http://127.0.0.1:18083/management-api/user/update
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
dubbo-tag: {{dubboTag}}
|
dubbo-tag: {{dubboTag}}
|
||||||
|
|
||||||
id=31&username=user02&password=buzhidao&name=测试管理员&departmentId=1
|
id=31&username=user02&password=buzhidao&name=测试管理员&departmentId=1
|
||||||
|
|
||||||
### /user/update-status 成功
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
dubbo-tag: {{dubboTag}}
|
dubbo-tag: {{dubboTag}}
|
||||||
|
|
||||||
userId=243&status=2
|
userId=243&status=2
|
||||||
|
|
||||||
### /user/update-status 失败,参数缺失
|
### /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
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer yudaoyuanma
|
||||||
dubbo-tag: {{dubboTag}}
|
dubbo-tag: {{dubboTag}}
|
||||||
|
|
||||||
userId=31
|
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.UserUpdateInfoReqVO;
|
||||||
import cn.iocoder.mall.managementweb.controller.user.vo.UserUpdateStatusReqVO;
|
import cn.iocoder.mall.managementweb.controller.user.vo.UserUpdateStatusReqVO;
|
||||||
import cn.iocoder.mall.managementweb.convert.user.UserConvert;
|
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 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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -21,16 +21,16 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class UserManager {
|
public class UserManager {
|
||||||
|
|
||||||
@Reference(version = "${dubbo.consumer.UserRpc.version}", validation = "false")
|
|
||||||
private UserRpc userRpc;
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserFeign userFeign;
|
||||||
/**
|
/**
|
||||||
* 更新用户信息
|
* 更新用户信息
|
||||||
*
|
*
|
||||||
* @param updateInfoReqVO 更新用户信息 VO
|
* @param updateInfoReqVO 更新用户信息 VO
|
||||||
*/
|
*/
|
||||||
public void updateUserInfo(UserUpdateInfoReqVO updateInfoReqVO) {
|
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();
|
updateUserResult.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ public class UserManager {
|
|||||||
* @param updateStatusReqVO 更新用户状态 VO
|
* @param updateStatusReqVO 更新用户状态 VO
|
||||||
*/
|
*/
|
||||||
public void updateUserStatus(UserUpdateStatusReqVO updateStatusReqVO) {
|
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();
|
updateUserResult.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ public class UserManager {
|
|||||||
* @return 用户
|
* @return 用户
|
||||||
*/
|
*/
|
||||||
public UserRespVO getUser(Integer userId) {
|
public UserRespVO getUser(Integer userId) {
|
||||||
CommonResult<UserRespDTO> getUserResult = userRpc.getUser(userId);
|
CommonResult<UserRespDTO> getUserResult = userFeign.getUser(userId);
|
||||||
getUserResult.checkError();
|
getUserResult.checkError();
|
||||||
return UserConvert.INSTANCE.convert(getUserResult.getData());
|
return UserConvert.INSTANCE.convert(getUserResult.getData());
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public class UserManager {
|
|||||||
* @return 用户列表
|
* @return 用户列表
|
||||||
*/
|
*/
|
||||||
public List<UserRespVO> listUsers(List<Integer> userIds) {
|
public List<UserRespVO> listUsers(List<Integer> userIds) {
|
||||||
CommonResult<List<UserRespDTO>> listUserResult = userRpc.listUsers(userIds);
|
CommonResult<List<UserRespDTO>> listUserResult = userFeign.listUsers(userIds);
|
||||||
listUserResult.checkError();
|
listUserResult.checkError();
|
||||||
return UserConvert.INSTANCE.convertList(listUserResult.getData());
|
return UserConvert.INSTANCE.convertList(listUserResult.getData());
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ public class UserManager {
|
|||||||
* @return 用户分页结果
|
* @return 用户分页结果
|
||||||
*/
|
*/
|
||||||
public PageResult<UserRespVO> pageUser(UserPageReqVO pageVO) {
|
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();
|
pageUserResult.checkError();
|
||||||
return UserConvert.INSTANCE.convertPage(pageUserResult.getData());
|
return UserConvert.INSTANCE.convertPage(pageUserResult.getData());
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
|||||||
@EnableDiscoveryClient
|
@EnableDiscoveryClient
|
||||||
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.searchservice.rpc",
|
@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.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 class ShopWebApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package cn.iocoder.mall.shopweb.client.user;
|
package cn.iocoder.mall.shopweb.client.user;
|
||||||
|
|
||||||
import cn.iocoder.mall.userservice.rpc.address.UserAddressRpc;
|
import cn.iocoder.mall.userservice.rpc.address.UserAddressFeign;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class UserAddressClient {
|
public class UserAddressClient {
|
||||||
|
@Autowired
|
||||||
@DubboReference(version = "${dubbo.consumer.UserAddressRpc.version}")
|
private UserAddressFeign userAddressFeign;
|
||||||
private UserAddressRpc userAddressRpc;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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.OAuth2CreateAccessTokenReqDTO;
|
||||||
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO;
|
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO;
|
||||||
import cn.iocoder.mall.userservice.enums.sms.UserSmsSceneEnum;
|
import cn.iocoder.mall.userservice.enums.sms.UserSmsSceneEnum;
|
||||||
import cn.iocoder.mall.userservice.rpc.sms.UserSmsCodeRpc;
|
import cn.iocoder.mall.userservice.rpc.sms.UserSmsCodeFeign;
|
||||||
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.UserRespDTO;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PassportManager {
|
public class PassportManager {
|
||||||
|
|
||||||
@DubboReference(version = "${dubbo.consumer.UserSmsCodeRpc.version}", validation = "false")
|
private UserSmsCodeFeign userSmsCodeFeign;
|
||||||
private UserSmsCodeRpc userSmsCodeRpc;
|
private UserFeign userFeign;
|
||||||
@DubboReference(version = "${dubbo.consumer.UserRpc.version}", validation = "false")
|
|
||||||
private UserRpc userRpc;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OAuthFeign oAuthFeign;
|
private OAuthFeign oAuthFeign;
|
||||||
|
|
||||||
public PassportAccessTokenRespVO loginBySms(PassportLoginBySmsReqVO loginBySmsDTO, String ip) {
|
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));
|
PassportConvert.INSTANCE.convert(loginBySmsDTO).setScene(UserSmsSceneEnum.LOGIN_BY_SMS.getValue()).setIp(ip));
|
||||||
verifySmsCodeResult.checkError();
|
verifySmsCodeResult.checkError();
|
||||||
// 获得用户
|
// 获得用户
|
||||||
CommonResult<UserRespDTO> createUserResult = userRpc.createUserIfAbsent(
|
CommonResult<UserRespDTO> createUserResult = userFeign.createUserIfAbsent(
|
||||||
PassportConvert.INSTANCE.convert02(loginBySmsDTO).setIp(ip));
|
PassportConvert.INSTANCE.convert02(loginBySmsDTO).setIp(ip));
|
||||||
createUserResult.checkError();
|
createUserResult.checkError();
|
||||||
// 创建访问令牌
|
// 创建访问令牌
|
||||||
@ -48,7 +45,7 @@ public class PassportManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendSmsCode(PassportSendSmsRespVO sendSmsCodeDTO, String ip) {
|
public void sendSmsCode(PassportSendSmsRespVO sendSmsCodeDTO, String ip) {
|
||||||
CommonResult<Boolean> sendSmsCodeResult = userSmsCodeRpc.sendSmsCode(
|
CommonResult<Boolean> sendSmsCodeResult = userSmsCodeFeign.sendSmsCode(
|
||||||
PassportConvert.INSTANCE.convert(sendSmsCodeDTO).setIp(ip));
|
PassportConvert.INSTANCE.convert(sendSmsCodeDTO).setIp(ip));
|
||||||
sendSmsCodeResult.checkError();
|
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.controller.user.vo.address.UserAddressUpdateReqVO;
|
||||||
import cn.iocoder.mall.shopweb.convert.user.UserAddressConvert;
|
import cn.iocoder.mall.shopweb.convert.user.UserAddressConvert;
|
||||||
import cn.iocoder.mall.userservice.enums.address.UserAddressType;
|
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 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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,9 +23,8 @@ import static cn.iocoder.common.framework.exception.enums.GlobalErrorCodeConstan
|
|||||||
@Service
|
@Service
|
||||||
public class UserAddressManager {
|
public class UserAddressManager {
|
||||||
|
|
||||||
@DubboReference(version = "${dubbo.consumer.UserAddressRpc.version}")
|
@Autowired
|
||||||
private UserAddressRpc userAddressRpc;
|
private UserAddressFeign userAddressFeign;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建用户收件地址
|
* 创建用户收件地址
|
||||||
*
|
*
|
||||||
@ -34,7 +33,7 @@ public class UserAddressManager {
|
|||||||
* @return 用户收件地址
|
* @return 用户收件地址
|
||||||
*/
|
*/
|
||||||
public Integer createUserAddress(Integer userId, UserAddressCreateReqVO createVO) {
|
public Integer createUserAddress(Integer userId, UserAddressCreateReqVO createVO) {
|
||||||
CommonResult<Integer> createUserAddressResult = userAddressRpc.createUserAddress(
|
CommonResult<Integer> createUserAddressResult = userAddressFeign.createUserAddress(
|
||||||
UserAddressConvert.INSTANCE.convert(createVO).setUserId(userId));
|
UserAddressConvert.INSTANCE.convert(createVO).setUserId(userId));
|
||||||
createUserAddressResult.checkError();
|
createUserAddressResult.checkError();
|
||||||
return createUserAddressResult.getData();
|
return createUserAddressResult.getData();
|
||||||
@ -50,7 +49,7 @@ public class UserAddressManager {
|
|||||||
// 校验是否能够操作
|
// 校验是否能够操作
|
||||||
check(userId, updateVO.getId());
|
check(userId, updateVO.getId());
|
||||||
// 执行更新
|
// 执行更新
|
||||||
CommonResult<Boolean> updateUserAddressResult = userAddressRpc.updateUserAddress(UserAddressConvert.INSTANCE.convert(updateVO)
|
CommonResult<Boolean> updateUserAddressResult = userAddressFeign.updateUserAddress(UserAddressConvert.INSTANCE.convert(updateVO)
|
||||||
.setUserId(userId));
|
.setUserId(userId));
|
||||||
updateUserAddressResult.checkError();
|
updateUserAddressResult.checkError();
|
||||||
}
|
}
|
||||||
@ -65,7 +64,7 @@ public class UserAddressManager {
|
|||||||
// 校验是否能够操作
|
// 校验是否能够操作
|
||||||
check(userId, userAddressId);
|
check(userId, userAddressId);
|
||||||
// 执行删除
|
// 执行删除
|
||||||
CommonResult<Boolean> deleteUserAddressResult = userAddressRpc.deleteUserAddress(userAddressId);
|
CommonResult<Boolean> deleteUserAddressResult = userAddressFeign.deleteUserAddress(userAddressId);
|
||||||
deleteUserAddressResult.checkError();
|
deleteUserAddressResult.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +76,7 @@ public class UserAddressManager {
|
|||||||
* @return 用户收件地址
|
* @return 用户收件地址
|
||||||
*/
|
*/
|
||||||
public UserAddressRespVO getUserAddress(Integer userId, Integer userAddressId) {
|
public UserAddressRespVO getUserAddress(Integer userId, Integer userAddressId) {
|
||||||
CommonResult<UserAddressRespDTO> getUserAddressResult = userAddressRpc.getUserAddress(userAddressId);
|
CommonResult<UserAddressRespDTO> getUserAddressResult = userAddressFeign.getUserAddress(userAddressId);
|
||||||
getUserAddressResult.checkError();
|
getUserAddressResult.checkError();
|
||||||
// 校验是否能够操作
|
// 校验是否能够操作
|
||||||
this.check(userId, userAddressId);
|
this.check(userId, userAddressId);
|
||||||
@ -91,7 +90,7 @@ public class UserAddressManager {
|
|||||||
* @return 用户收件地址列表
|
* @return 用户收件地址列表
|
||||||
*/
|
*/
|
||||||
public List<UserAddressRespVO> listUserAddresses(Integer userId) {
|
public List<UserAddressRespVO> listUserAddresses(Integer userId) {
|
||||||
CommonResult<List<UserAddressRespDTO>> listUserAddressResult = userAddressRpc.listUserAddresses(userId, null);
|
CommonResult<List<UserAddressRespDTO>> listUserAddressResult = userAddressFeign.listUserAddresses(userId, null);
|
||||||
listUserAddressResult.checkError();
|
listUserAddressResult.checkError();
|
||||||
return UserAddressConvert.INSTANCE.convertList(listUserAddressResult.getData());
|
return UserAddressConvert.INSTANCE.convertList(listUserAddressResult.getData());
|
||||||
}
|
}
|
||||||
@ -103,7 +102,7 @@ public class UserAddressManager {
|
|||||||
* @return 用户收件地址
|
* @return 用户收件地址
|
||||||
*/
|
*/
|
||||||
public UserAddressRespVO getDefaultUserAddress(Integer userId) {
|
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();
|
listUserAddressResult.checkError();
|
||||||
return !CollectionUtils.isEmpty(listUserAddressResult.getData()) ?
|
return !CollectionUtils.isEmpty(listUserAddressResult.getData()) ?
|
||||||
UserAddressConvert.INSTANCE.convert(listUserAddressResult.getData().get(0)) : null;
|
UserAddressConvert.INSTANCE.convert(listUserAddressResult.getData().get(0)) : null;
|
||||||
@ -116,7 +115,7 @@ public class UserAddressManager {
|
|||||||
* @param userAddressId 用户收件地址
|
* @param userAddressId 用户收件地址
|
||||||
*/
|
*/
|
||||||
private void check(Integer userId, Integer userAddressId) {
|
private void check(Integer userId, Integer userAddressId) {
|
||||||
CommonResult<UserAddressRespDTO> getUserAddressResult = userAddressRpc.getUserAddress(userAddressId);
|
CommonResult<UserAddressRespDTO> getUserAddressResult = userAddressFeign.getUserAddress(userAddressId);
|
||||||
getUserAddressResult.checkError();
|
getUserAddressResult.checkError();
|
||||||
this.check(userId, getUserAddressResult.getData());
|
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.common.framework.vo.CommonResult;
|
||||||
import cn.iocoder.mall.shopweb.controller.user.vo.user.UserRespVO;
|
import cn.iocoder.mall.shopweb.controller.user.vo.user.UserRespVO;
|
||||||
import cn.iocoder.mall.shopweb.convert.user.UserConvert;
|
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.UserRespDTO;
|
||||||
import cn.iocoder.mall.userservice.rpc.user.dto.UserUpdateReqDTO;
|
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;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class UserManager {
|
public class UserManager {
|
||||||
|
|
||||||
@DubboReference(version = "${dubbo.consumer.UserRpc.version}")
|
@Autowired
|
||||||
private UserRpc userRpc;
|
private UserFeign userFeign;
|
||||||
|
|
||||||
public UserRespVO getUser(Integer id) {
|
public UserRespVO getUser(Integer id) {
|
||||||
CommonResult<UserRespDTO> userResult = userRpc.getUser(id);
|
CommonResult<UserRespDTO> userResult = userFeign.getUser(id);
|
||||||
userResult.checkError();
|
userResult.checkError();
|
||||||
return UserConvert.INSTANCE.convert(userResult.getData());
|
return UserConvert.INSTANCE.convert(userResult.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateUserAvatar(Integer userId, String avatar) {
|
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();
|
updateUserResult.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateUserNickname(Integer userId, String nickname) {
|
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();
|
updateUserResult.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</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.OAuth2RefreshAccessTokenReqDTO;
|
||||||
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO;
|
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
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.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
@ -13,17 +14,17 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
/**
|
/**
|
||||||
* 部门 Rpc 接口
|
* 部门 Rpc 接口
|
||||||
*/
|
*/
|
||||||
@FeignClient("system-service")
|
@FeignClient(value = "system-service")
|
||||||
public interface OAuthFeign {
|
public interface OAuthFeign {
|
||||||
|
|
||||||
@PostMapping("ccreateAccessToken")
|
@PostMapping("/system/oauth/createAccessToken")
|
||||||
public CommonResult<OAuth2AccessTokenRespDTO> createAccessToken(@RequestBody OAuth2CreateAccessTokenReqDTO createAccessTokenDTO);
|
public CommonResult<OAuth2AccessTokenRespDTO> createAccessToken(@RequestBody OAuth2CreateAccessTokenReqDTO createAccessTokenDTO);
|
||||||
|
|
||||||
@PostMapping("/system/oauthcheckAccessToken")
|
@GetMapping("/system/oauth/checkAccessToken")
|
||||||
public CommonResult<OAuth2AccessTokenRespDTO> checkAccessToken(@RequestParam("accessToken") String accessToken) ;
|
public CommonResult<OAuth2AccessTokenRespDTO> checkAccessToken(@RequestParam("accessToken") String accessToken) ;
|
||||||
|
|
||||||
@PostMapping("/system/oauthrefreshAccessToken")
|
@PostMapping("/system/oauth/refreshAccessToken")
|
||||||
public CommonResult<OAuth2AccessTokenRespDTO> refreshAccessToken(@RequestBody OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO);
|
public CommonResult<OAuth2AccessTokenRespDTO> refreshAccessToken(@RequestBody OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO);
|
||||||
@PostMapping("/system/oauthremoveToken")
|
@PostMapping("/system/oauth/removeToken")
|
||||||
public CommonResult<Boolean> removeToken(@RequestBody OAuth2RemoveTokenByUserReqDTO removeTokenDTO);
|
public CommonResult<Boolean> removeToken(@RequestBody OAuth2RemoveTokenByUserReqDTO removeTokenDTO);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,6 @@ public interface PermissionFeign {
|
|||||||
@PostMapping("/system/permission/assignAdminRole")
|
@PostMapping("/system/permission/assignAdminRole")
|
||||||
public CommonResult<Boolean> assignAdminRole(@RequestBody PermissionAssignAdminRoleDTO assignAdminRoleDTO);
|
public CommonResult<Boolean> assignAdminRole(@RequestBody PermissionAssignAdminRoleDTO assignAdminRoleDTO);
|
||||||
|
|
||||||
@PostMapping("/system/permission/scheckPermission")
|
@PostMapping("/system/permission/checkPermission")
|
||||||
public CommonResult<Boolean> checkPermission(@RequestBody PermissionCheckDTO checkDTO) ;
|
public CommonResult<Boolean> checkPermission(@RequestBody PermissionCheckDTO checkDTO) ;
|
||||||
}
|
}
|
||||||
|
@ -86,10 +86,6 @@
|
|||||||
<groupId>org.mapstruct</groupId>
|
<groupId>org.mapstruct</groupId>
|
||||||
<artifactId>mapstruct-jdk8</artifactId>
|
<artifactId>mapstruct-jdk8</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -30,7 +30,7 @@ public class OAuthController {
|
|||||||
return success(oAuth2Service.createAccessToken(createAccessTokenDTO));
|
return success(oAuth2Service.createAccessToken(createAccessTokenDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("checkAccessToken")
|
@GetMapping("checkAccessToken")
|
||||||
public CommonResult<OAuth2AccessTokenRespDTO> checkAccessToken(@RequestParam("accessToken") String accessToken) {
|
public CommonResult<OAuth2AccessTokenRespDTO> checkAccessToken(@RequestParam("accessToken") String accessToken) {
|
||||||
return success(oAuth2Service.checkAccessToken(accessToken));
|
return success(oAuth2Service.checkAccessToken(accessToken));
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
|||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableDiscoveryClient
|
@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 class TradeServiceApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.mall.tradeservice.client.user;
|
package cn.iocoder.mall.tradeservice.client.user;
|
||||||
|
|
||||||
import cn.iocoder.common.framework.vo.CommonResult;
|
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 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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -11,11 +11,10 @@ import java.util.Objects;
|
|||||||
@Service
|
@Service
|
||||||
public class UserAddressClient {
|
public class UserAddressClient {
|
||||||
|
|
||||||
@DubboReference(version = "${dubbo.consumer.UserAddressRpc.version}")
|
@Autowired
|
||||||
private UserAddressRpc userAddressRpc;
|
private UserAddressFeign userAddressFeign;
|
||||||
|
|
||||||
public UserAddressRespDTO getUserAddress(Integer userAddressId, Integer userId) {
|
public UserAddressRespDTO getUserAddress(Integer userAddressId, Integer userId) {
|
||||||
CommonResult<UserAddressRespDTO> getUserAddressResult = userAddressRpc.getUserAddress(userAddressId);
|
CommonResult<UserAddressRespDTO> getUserAddressResult = userAddressFeign.getUserAddress(userAddressId);
|
||||||
getUserAddressResult.checkError();
|
getUserAddressResult.checkError();
|
||||||
if (getUserAddressResult.getData() == null) {
|
if (getUserAddressResult.getData() == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -26,6 +26,12 @@
|
|||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</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.common.framework.vo.CommonResult;
|
||||||
import cn.iocoder.mall.userservice.manager.address.UserAddressManager;
|
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.UserAddressCreateReqDTO;
|
||||||
import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressRespDTO;
|
import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressRespDTO;
|
||||||
import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressUpdateReqDTO;
|
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.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||||
|
|
||||||
/**
|
@RestController
|
||||||
* 用户收件地址 Rpc 实现类
|
@RequestMapping("/user/address")
|
||||||
*/
|
public class UserAddressController {
|
||||||
@DubboService(version = "${dubbo.provider.UserAddressRpc.version}")
|
|
||||||
public class UserAddressRpcImpl implements UserAddressRpc {
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserAddressManager userAddressManager;
|
private UserAddressManager userAddressManager;
|
||||||
|
|
||||||
@Override
|
@PostMapping("createUserAddress")
|
||||||
public CommonResult<Integer> createUserAddress(UserAddressCreateReqDTO createDTO) {
|
public CommonResult<Integer> createUserAddress(@RequestBody UserAddressCreateReqDTO createDTO) {
|
||||||
return success(userAddressManager.createUserAddress(createDTO));
|
return success(userAddressManager.createUserAddress(createDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@PostMapping("updateUserAddress")
|
||||||
public CommonResult<Boolean> updateUserAddress(UserAddressUpdateReqDTO updateDTO) {
|
public CommonResult<Boolean> updateUserAddress(@RequestBody UserAddressUpdateReqDTO updateDTO) {
|
||||||
userAddressManager.updateUserAddress(updateDTO);
|
userAddressManager.updateUserAddress(updateDTO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@GetMapping("deleteUserAddress")
|
||||||
public CommonResult<Boolean> deleteUserAddress(Integer userAddressId) {
|
public CommonResult<Boolean> deleteUserAddress(@RequestParam("userAddressId") Integer userAddressId) {
|
||||||
userAddressManager.deleteUserAddress(userAddressId);
|
userAddressManager.deleteUserAddress(userAddressId);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@GetMapping("getUserAddress")
|
||||||
public CommonResult<UserAddressRespDTO> getUserAddress(Integer userAddressId) {
|
public CommonResult<UserAddressRespDTO> getUserAddress(@RequestParam("userAddressId")Integer userAddressId) {
|
||||||
return success(userAddressManager.getUserAddress(userAddressId));
|
return success(userAddressManager.getUserAddress(userAddressId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@GetMapping("listUserAddressesByIds")
|
||||||
public CommonResult<List<UserAddressRespDTO>> listUserAddresses(List<Integer> userAddressIds) {
|
public CommonResult<List<UserAddressRespDTO>> listUserAddresses(@RequestParam("userAddressIds")List<Integer> userAddressIds) {
|
||||||
return success(userAddressManager.listUserAddresses(userAddressIds));
|
return success(userAddressManager.listUserAddresses(userAddressIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@GetMapping("listUserAddresses")
|
||||||
public CommonResult<List<UserAddressRespDTO>> listUserAddresses(Integer userId, Integer type) {
|
public CommonResult<List<UserAddressRespDTO>> listUserAddresses(@RequestParam("userId")Integer userId, @RequestParam("type")Integer type) {
|
||||||
return success(userAddressManager.listUserAddresses(userId, 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.CommonResult;
|
||||||
import cn.iocoder.common.framework.vo.PageResult;
|
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.UserPageReqDTO;
|
||||||
import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO;
|
import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO;
|
||||||
import cn.iocoder.mall.userservice.rpc.user.dto.UserUpdateReqDTO;
|
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.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||||
|
|
||||||
@Service(version = "${dubbo.provider.UserRpc.version}", validation = "false")
|
@RestController
|
||||||
public class UserRpcImpl implements UserRpc {
|
@RequestMapping("/user/manage")
|
||||||
|
public class UserManageController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserManager userManager;
|
private UserManager userManager;
|
||||||
|
|
||||||
@Override
|
@GetMapping("getUser")
|
||||||
public CommonResult<UserRespDTO> getUser(Integer id) {
|
public CommonResult<UserRespDTO> getUser(@RequestParam("id") Integer id) {
|
||||||
return success(userManager.getUser(id));
|
return success(userManager.getUser(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@GetMapping("listUsers")
|
||||||
public CommonResult<List<UserRespDTO>> listUsers(List<Integer> userIds) {
|
public CommonResult<List<UserRespDTO>> listUsers(@RequestParam("userIds") List<Integer> userIds) {
|
||||||
return success(userManager.listUsers(userIds));
|
return success(userManager.listUsers(userIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@PostMapping("createUserIfAbsent")
|
||||||
public CommonResult<UserRespDTO> createUserIfAbsent(UserCreateReqDTO createDTO) {
|
public CommonResult<UserRespDTO> createUserIfAbsent(@RequestBody UserCreateReqDTO createDTO) {
|
||||||
return success(userManager.createUserIfAbsent(createDTO));
|
return success(userManager.createUserIfAbsent(createDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@PostMapping("updateUser")
|
||||||
public CommonResult<Boolean> updateUser(UserUpdateReqDTO updateDTO) {
|
public CommonResult<Boolean> updateUser(@RequestBody UserUpdateReqDTO updateDTO) {
|
||||||
userManager.updateUser(updateDTO);
|
userManager.updateUser(updateDTO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@PostMapping("pageUser")
|
||||||
public CommonResult<PageResult<UserRespDTO>> pageUser(UserPageReqDTO pageDTO) {
|
public CommonResult<PageResult<UserRespDTO>> pageUser(@RequestBody UserPageReqDTO pageDTO) {
|
||||||
return success(userManager.pageUser(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
Block a user