diff --git a/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/config/DubboWebAutoConfiguration.java b/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/config/DubboWebAutoConfiguration.java index 92fbbd9cd..e9339d760 100644 --- a/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/config/DubboWebAutoConfiguration.java +++ b/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/config/DubboWebAutoConfiguration.java @@ -24,7 +24,7 @@ public class DubboWebAutoConfiguration implements WebMvcConfigurer { registry.addInterceptor(new DubboRouterTagWebInterceptor()).order(-1000); logger.info("[addInterceptors][加载 DubboRouterTagWebInterceptor 拦截器完成]"); } catch (NoSuchBeanDefinitionException e) { - logger.warn("[addInterceptors][无法获取 DubboRouterTagWebInterceptor 拦截器,无法使用 Dubbo 标签路由]"); + logger.warn("[addInterceptors][无法获取 DubboRouterTagWebInterceptor 拦截器,无法使用基于 dubbo-tag 请求头进行 Dubbo 标签路由]"); } } diff --git a/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/core/interceptor/AdminSecurityInterceptor.java b/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/core/interceptor/AdminSecurityInterceptor.java index 094a53332..8997f95aa 100644 --- a/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/core/interceptor/AdminSecurityInterceptor.java +++ b/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/core/interceptor/AdminSecurityInterceptor.java @@ -9,7 +9,7 @@ import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.security.admin.core.context.AdminSecurityContext; import cn.iocoder.mall.security.admin.core.context.AdminSecurityContextHolder; import cn.iocoder.mall.systemservice.rpc.oauth.OAuth2Rpc; -import cn.iocoder.mall.systemservice.rpc.oauth.vo.OAuth2AccessTokenVO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.mall.systemservice.rpc.permission.PermissionRpc; import cn.iocoder.mall.systemservice.rpc.permission.dto.PermissionCheckDTO; import cn.iocoder.mall.web.core.util.CommonWebUtil; @@ -48,7 +48,7 @@ public class AdminSecurityInterceptor extends HandlerInterceptorAdapter { String accessToken = HttpUtil.obtainAuthorization(request); Integer adminId = null; if (accessToken != null) { - CommonResult checkAccessTokenResult = oauth2Rpc.checkAccessToken(accessToken); + CommonResult checkAccessTokenResult = oauth2Rpc.checkAccessToken(accessToken); checkAccessTokenResult.checkError(); // 校验用户类型正确 if (!UserTypeEnum.ADMIN.getValue().equals(checkAccessTokenResult.getData().getUserType())) { diff --git a/common/mall-spring-boot-starter-security-user/src/main/java/cn/iocoder/mall/security/user/core/interceptor/UserSecurityInterceptor.java b/common/mall-spring-boot-starter-security-user/src/main/java/cn/iocoder/mall/security/user/core/interceptor/UserSecurityInterceptor.java index e0b2023ca..6e9c40ab3 100644 --- a/common/mall-spring-boot-starter-security-user/src/main/java/cn/iocoder/mall/security/user/core/interceptor/UserSecurityInterceptor.java +++ b/common/mall-spring-boot-starter-security-user/src/main/java/cn/iocoder/mall/security/user/core/interceptor/UserSecurityInterceptor.java @@ -1,14 +1,13 @@ package cn.iocoder.mall.security.user.core.interceptor; -import cn.iocoder.common.framework.exception.enums.GlobalErrorCodeEnum; import cn.iocoder.common.framework.enums.UserTypeEnum; -import cn.iocoder.common.framework.util.HttpUtil; import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil; +import cn.iocoder.common.framework.util.HttpUtil; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.security.user.core.context.UserSecurityContext; import cn.iocoder.mall.security.user.core.context.UserSecurityContextHolder; import cn.iocoder.mall.systemservice.rpc.oauth.OAuth2Rpc; -import cn.iocoder.mall.systemservice.rpc.oauth.vo.OAuth2AccessTokenVO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.mall.web.core.util.CommonWebUtil; import cn.iocoder.security.annotations.RequiresAuthenticate; import cn.iocoder.security.annotations.RequiresPermissions; @@ -19,6 +18,7 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import static cn.iocoder.common.framework.exception.enums.GlobalErrorCodeConstants.UNAUTHORIZED; import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.OAUTH_USER_TYPE_ERROR; public class UserSecurityInterceptor extends HandlerInterceptorAdapter { @@ -39,7 +39,7 @@ public class UserSecurityInterceptor extends HandlerInterceptorAdapter { String accessToken = HttpUtil.obtainAuthorization(request); Integer userId = null; if (accessToken != null) { - CommonResult checkAccessTokenResult = oauth2Rpc.checkAccessToken(accessToken); + CommonResult checkAccessTokenResult = oauth2Rpc.checkAccessToken(accessToken); checkAccessTokenResult.checkError(); // 校验用户类型正确 if (!UserTypeEnum.USER.getValue().equals(checkAccessTokenResult.getData().getUserType())) { @@ -64,7 +64,7 @@ public class UserSecurityInterceptor extends HandlerInterceptorAdapter { requiresAuthenticate = true; } if (requiresAuthenticate && userId == null) { - throw ServiceExceptionUtil.exception(GlobalErrorCodeEnum.UNAUTHORIZED); + throw ServiceExceptionUtil.exception(UNAUTHORIZED); } } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/passport/PassportController.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/passport/PassportController.java index d39423b56..15c06daed 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/passport/PassportController.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/passport/PassportController.java @@ -46,12 +46,14 @@ public class PassportController { return success(passportManager.getAdmin(AdminSecurityContextHolder.getAdminId())); } + // TODO 优化点:迁移到 PermissionController @GetMapping("/tree-admin-menu") @ApiOperation("获得当前管理员的菜单树") public CommonResult> treeAdminMenu() { return success(passportManager.treeAdminMenu(AdminSecurityContextHolder.getAdminId())); } + // TODO 优化点:迁移到 PermissionController @GetMapping("/list-admin-permission") @ApiOperation("获得当前管理员的权限列表") public CommonResult> listAdminPermission() { diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/UserController.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/UserController.java new file mode 100644 index 000000000..65f6400c9 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/UserController.java @@ -0,0 +1,68 @@ +package cn.iocoder.mall.managementweb.controller.user; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.managementweb.controller.user.vo.UserPageReqVO; +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.manager.user.UserManager; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +import static cn.iocoder.common.framework.vo.CommonResult.success; + +/** +* 用户 Controller +*/ +@RestController +@RequestMapping("/user") +@Api(tags = "用户") +@Validated +public class UserController { + + @Autowired + private UserManager userManager; + + @PostMapping("/update-info") + @ApiOperation("更新用户信息") + public CommonResult updateUserInfo(@Valid UserUpdateInfoReqVO updateInfoReqVO) { + userManager.updateUserInfo(updateInfoReqVO); + return success(true); + } + + @PostMapping("/update-status") + @ApiOperation("更新用户信息") + public CommonResult updateUserStatus(@Valid UserUpdateStatusReqVO updateStatusReqVO) { + userManager.updateUserStatus(updateStatusReqVO); + return success(true); + } + + @GetMapping("/get") + @ApiOperation("获得用户") + @ApiImplicitParam(name = "userId", value = "用户编号", required = true) + public CommonResult getUser(@RequestParam("userId") Integer userId) { + return success(userManager.getUser(userId)); + } + + @GetMapping("/list") + @ApiOperation("获得用户列表") + @ApiImplicitParam(name = "userIds", value = "用户编号列表", required = true) + public CommonResult> listUsers(@RequestParam("userIds") List userIds) { + return success(userManager.listUsers(userIds)); + } + + @GetMapping("/page") + @ApiOperation("获得用户分页") + public CommonResult> pageUser(UserPageReqVO pageVO) { + return success(userManager.pageUser(pageVO)); + } + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/dto/AdminsUserPageRequest.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/dto/AdminsUserPageRequest.java deleted file mode 100644 index 1cf5388ae..000000000 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/dto/AdminsUserPageRequest.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.mall.managementweb.controller.user.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * @Author: jiangweifan - * @Date: 2020/5/12 - * @Description: 管理员 - 用户信息 - 用户分页列表 - */ -@ApiModel("用户分页列表Request") -@Data -@Accessors(chain = true) -public class AdminsUserPageRequest { - - @ApiModelProperty(name = "nickname", value = "昵称,模糊匹配", example = "小王") - private String nickname; - - @ApiModelProperty(name = "status", value = "状态。1 - 开启;2 - 禁用", example = "0") - private Integer status; - - @ApiModelProperty(name = "pageNo", value = "页码,从 1 开始", example = "1") - private Integer pageNo = 1; - - @ApiModelProperty(name = "pageSize", value = "每页条数", required = true, example = "10") - private Integer pageSize = 10; -} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/dto/AdminsUserUpdateStatusRequest.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/dto/AdminsUserUpdateStatusRequest.java deleted file mode 100644 index 72250de83..000000000 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/dto/AdminsUserUpdateStatusRequest.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.mall.managementweb.controller.user.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotNull; - -/** - * @Author: jiangweifan - * @Date: 2020/5/12 - * @Description: 管理员 - 用户信息 - 更新用户状态 - */ -@ApiModel("更新用户状态Request") -@Data -@Accessors(chain = true) -public class AdminsUserUpdateStatusRequest { - - @ApiModelProperty(name = "id", value = "用户编号", required = true, example = "1") - @NotNull(message = "用户编号不能为空") - private Integer id; - - @ApiModelProperty(name = "status", value = "用户状态。1 - 开启;2 - 禁用", required = true, example = "1") - @NotNull(message = "用户状态不能为空") - private Integer status; - -} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserPageReqVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserPageReqVO.java new file mode 100644 index 000000000..6a66530cf --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserPageReqVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.mall.managementweb.controller.user.vo; + +import cn.iocoder.common.framework.vo.PageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@ApiModel("用户分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class UserPageReqVO extends PageParam { + + @ApiModelProperty(value = "昵称", example = "丑艿艿", notes = "模糊匹配") + private String nickname; + @ApiModelProperty(value = "状态", example = "1", notes = "见 CommonStatusEnum 枚举") + private Integer status; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserRespVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserRespVO.java new file mode 100644 index 000000000..ee953c3e2 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserRespVO.java @@ -0,0 +1,26 @@ +package cn.iocoder.mall.managementweb.controller.user.vo; + +import lombok.*; +import io.swagger.annotations.*; +import java.util.*; + +@ApiModel("用户 Response VO") +@Data +public class UserRespVO { + + @ApiModelProperty(value = "用户编号", required = true, example = "1") + private Integer id; + @ApiModelProperty(value = "昵称", example = "丑艿艿") + private String nickname; + @ApiModelProperty(value = "头像", example = "http://www.iocoder.cn/xxx.jpg") + private String avatar; + @ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举") + private Integer status; + @ApiModelProperty(value = "手机号", required = true, example = "15601691399") + private String mobile; + @ApiModelProperty(value = "注册 IP", required = true, example = "127.0.0.1") + private String createIp; + @ApiModelProperty(value = "创建时间", required = true) + private Date createTime; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserUpdateInfoReqVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserUpdateInfoReqVO.java new file mode 100644 index 000000000..d43288392 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserUpdateInfoReqVO.java @@ -0,0 +1,25 @@ +package cn.iocoder.mall.managementweb.controller.user.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@ApiModel("用户更新信息 Request VO") +@Data +public class UserUpdateInfoReqVO { + + @ApiModelProperty(value = "用户编号", required = true, example = "1") + @NotNull(message = "用户编号不能为空") + private Integer id; + @ApiModelProperty(value = "昵称", example = "臭艿艿") + private String nickname; + @ApiModelProperty(value = "头像", example = "http://www.iocoder.cn/nainainai.jpg") + private String avatar; + @ApiModelProperty(value = "手机号", example = "15601691300") + private String mobile; + @ApiModelProperty(value = "密码", example = "123456") + private String password; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserUpdateStatusReqVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserUpdateStatusReqVO.java new file mode 100644 index 000000000..2b2103e89 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/user/vo/UserUpdateStatusReqVO.java @@ -0,0 +1,23 @@ +package cn.iocoder.mall.managementweb.controller.user.vo; + +import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.validator.InEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@ApiModel("用户更新状态 Request VO") +@Data +public class UserUpdateStatusReqVO { + + @ApiModelProperty(value = "用户编号", required = true) + @NotNull(message = "用户编号不能为空") + private Integer id; + @ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举") + @NotNull(message = "状态不能为空") + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") + private Integer status; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/passport/AdminPassportConvert.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/passport/AdminPassportConvert.java index fe9a6fc96..6d3ae18ab 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/passport/AdminPassportConvert.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/passport/AdminPassportConvert.java @@ -5,7 +5,7 @@ import cn.iocoder.mall.managementweb.controller.passport.vo.PassportAccessTokenV import cn.iocoder.mall.managementweb.controller.passport.vo.PassportAdminVO; import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminVerifyPasswordDTO; import cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO; -import cn.iocoder.mall.systemservice.rpc.oauth.vo.OAuth2AccessTokenVO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -16,7 +16,7 @@ public interface AdminPassportConvert { AdminVerifyPasswordDTO convert(PassportLoginDTO bean); - PassportAccessTokenVO convert(OAuth2AccessTokenVO bean); + PassportAccessTokenVO convert(OAuth2AccessTokenRespDTO bean); PassportAdminVO convert(AdminVO bean); diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/user/UserConvert.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/user/UserConvert.java new file mode 100644 index 000000000..b95492fba --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/user/UserConvert.java @@ -0,0 +1,33 @@ +package cn.iocoder.mall.managementweb.convert.user; + +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.managementweb.controller.user.vo.UserPageReqVO; +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.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.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface UserConvert { + + UserConvert INSTANCE = Mappers.getMapper(UserConvert.class); + + UserUpdateReqDTO convert(UserUpdateInfoReqVO bean); + + UserRespVO convert(UserRespDTO bean); + + List convertList(List list); + + UserPageReqDTO convert(UserPageReqVO bean); + + PageResult convertPage(PageResult bean); + + UserUpdateReqDTO convert(UserUpdateStatusReqVO bean); + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/passport/PassportManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/passport/PassportManager.java index fef6f628a..cd2f11f08 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/passport/PassportManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/passport/PassportManager.java @@ -15,8 +15,8 @@ import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum; import cn.iocoder.mall.systemservice.rpc.admin.AdminRpc; import cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO; import cn.iocoder.mall.systemservice.rpc.oauth.OAuth2Rpc; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenDTO; -import cn.iocoder.mall.systemservice.rpc.oauth.vo.OAuth2AccessTokenVO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.mall.systemservice.rpc.permission.ResourceRpc; import cn.iocoder.mall.systemservice.rpc.permission.RoleRpc; import cn.iocoder.mall.systemservice.rpc.permission.vo.ResourceVO; @@ -45,8 +45,8 @@ public class PassportManager { CommonResult verifyPasswordResult = adminRpc.verifyPassword(AdminPassportConvert.INSTANCE.convert(loginDTO).setIp(ip)); verifyPasswordResult.checkError(); // 创建访问令牌 - CommonResult createAccessTokenResult = oauth2Rpc.createAccessToken( - new OAuth2CreateAccessTokenDTO().setUserId(verifyPasswordResult.getData().getId()) + CommonResult createAccessTokenResult = oauth2Rpc.createAccessToken( + new OAuth2CreateAccessTokenReqDTO().setUserId(verifyPasswordResult.getData().getId()) .setUserType(UserTypeEnum.ADMIN.getValue()).setCreateIp(ip)); createAccessTokenResult.checkError(); // 返回 diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/user/UserManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/user/UserManager.java new file mode 100644 index 000000000..36ccc3afc --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/user/UserManager.java @@ -0,0 +1,83 @@ +package cn.iocoder.mall.managementweb.manager.user; + + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.managementweb.controller.user.vo.UserPageReqVO; +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.dto.UserRespDTO; +import org.apache.dubbo.config.annotation.Reference; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 用户 Manager + */ +@Service +public class UserManager { + + @Reference(version = "$ {dubbo.consumer.UserRpc.version}", validation = "false") + private UserRpc userRpc; + + /** + * 更新用户信息 + * + * @param updateInfoReqVO 更新用户信息 VO + */ + public void updateUserInfo(UserUpdateInfoReqVO updateInfoReqVO) { + CommonResult updateUserResult = userRpc.updateUser(UserConvert.INSTANCE.convert(updateInfoReqVO)); + updateUserResult.checkError(); + } + + /** + * 更新用户状态 + * + * @param updateStatusReqVO 更新用户状态 VO + */ + public void updateUserStatus(UserUpdateStatusReqVO updateStatusReqVO) { + CommonResult updateUserResult = userRpc.updateUser(UserConvert.INSTANCE.convert(updateStatusReqVO)); + updateUserResult.checkError(); + } + + /** + * 获得用户 + * + * @param userId 用户编号 + * @return 用户 + */ + public UserRespVO getUser(Integer userId) { + CommonResult getUserResult = userRpc.getUser(userId); + getUserResult.checkError(); + return UserConvert.INSTANCE.convert(getUserResult.getData()); + } + + /** + * 获得用户列表 + * + * @param userIds 用户编号列表 + * @return 用户列表 + */ + public List listUsers(List userIds) { + CommonResult> listUserResult = userRpc.listUsers(userIds); + listUserResult.checkError(); + return UserConvert.INSTANCE.convertList(listUserResult.getData()); + } + + /** + * 获得用户分页 + * + * @param pageVO 用户分页查询 + * @return 用户分页结果 + */ + public PageResult pageUser(UserPageReqVO pageVO) { + CommonResult> pageUserResult = userRpc.pageUser(UserConvert.INSTANCE.convert(pageVO)); + pageUserResult.checkError(); + return UserConvert.INSTANCE.convertPage(pageUserResult.getData()); + } + +} diff --git a/pom.xml b/pom.xml index a2f94469e..d3796fc27 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ user common - system + diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuth2Rpc.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuth2Rpc.java index 6d509fb63..3d69c3c90 100644 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuth2Rpc.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuth2Rpc.java @@ -1,16 +1,19 @@ package cn.iocoder.mall.systemservice.rpc.oauth; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenDTO; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenDTO; -import cn.iocoder.mall.systemservice.rpc.oauth.vo.OAuth2AccessTokenVO; +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.OAuth2AccessTokenRespDTO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO; public interface OAuth2Rpc { - CommonResult createAccessToken(OAuth2CreateAccessTokenDTO createAccessTokenDTO); + CommonResult createAccessToken(OAuth2CreateAccessTokenReqDTO createAccessTokenDTO); - CommonResult checkAccessToken(String accessToken); + CommonResult checkAccessToken(String accessToken); - CommonResult refreshAccessToken(OAuth2RefreshAccessTokenDTO refreshAccessTokenDTO); + CommonResult refreshAccessToken(OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO); + + CommonResult removeToken(OAuth2RemoveTokenByUserReqDTO removeTokenDTO); } diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/vo/OAuth2AccessTokenVO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2AccessTokenRespDTO.java similarity index 75% rename from system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/vo/OAuth2AccessTokenVO.java rename to system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2AccessTokenRespDTO.java index 9b8c5d020..6e311484f 100644 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/vo/OAuth2AccessTokenVO.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2AccessTokenRespDTO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.systemservice.rpc.oauth.vo; +package cn.iocoder.mall.systemservice.rpc.oauth.dto; import lombok.Data; import lombok.experimental.Accessors; @@ -7,11 +7,11 @@ import java.io.Serializable; import java.util.Date; /** - * OAuth2.0 访问令牌 VO + * OAuth2.0 访问令牌 Response DTO */ @Data @Accessors(chain = true) -public class OAuth2AccessTokenVO implements Serializable { +public class OAuth2AccessTokenRespDTO implements Serializable { /** * 访问令牌 diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2CreateAccessTokenDTO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2CreateAccessTokenDTO.java deleted file mode 100644 index af75a8b1c..000000000 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2CreateAccessTokenDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.mall.systemservice.rpc.oauth.dto; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * OAuth2.0 访问令牌创建 DTO - */ -@Data -@Accessors(chain = true) -public class OAuth2CreateAccessTokenDTO implements Serializable { - - /** - * 用户编号 - */ - private Integer userId; - /** - * 用户类型 - */ - private Integer userType; - /** - * 创建 IP - */ - private String createIp; - -} diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2CreateAccessTokenReqDTO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2CreateAccessTokenReqDTO.java new file mode 100644 index 000000000..c2a06326c --- /dev/null +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2CreateAccessTokenReqDTO.java @@ -0,0 +1,34 @@ +package cn.iocoder.mall.systemservice.rpc.oauth.dto; + +import cn.iocoder.common.framework.enums.UserTypeEnum; +import cn.iocoder.common.framework.validator.InEnum; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * OAuth2.0 访问令牌创建 Request DTO + */ +@Data +@Accessors(chain = true) +public class OAuth2CreateAccessTokenReqDTO implements Serializable { + + /** + * 用户编号 + */ + @NotNull(message = "用户编号不能为空") + private Integer userId; + /** + * 用户类型 + */ + @NotNull(message = "用户类型不能为空") + @InEnum(value = UserTypeEnum.class, message = "用户类型必须是 {value}") + private Integer userType; + /** + * 创建 IP + */ + private String createIp; + +} diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RefreshAccessTokenDTO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RefreshAccessTokenReqDTO.java similarity index 73% rename from system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RefreshAccessTokenDTO.java rename to system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RefreshAccessTokenReqDTO.java index bb4cccb6b..17347d34a 100644 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RefreshAccessTokenDTO.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RefreshAccessTokenReqDTO.java @@ -6,11 +6,11 @@ import lombok.experimental.Accessors; import java.io.Serializable; /** - * OAuth2.0 访问令牌创建 DTO + * OAuth2.0 访问令牌创建 Request DTO */ @Data @Accessors(chain = true) -public class OAuth2RefreshAccessTokenDTO implements Serializable { +public class OAuth2RefreshAccessTokenReqDTO implements Serializable { /** * 刷新令牌 diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RemoveTokenByUserReqDTO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RemoveTokenByUserReqDTO.java new file mode 100644 index 000000000..e77e8fb43 --- /dev/null +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/dto/OAuth2RemoveTokenByUserReqDTO.java @@ -0,0 +1,31 @@ +package cn.iocoder.mall.systemservice.rpc.oauth.dto; + +import cn.iocoder.common.framework.enums.UserTypeEnum; +import cn.iocoder.common.framework.validator.InEnum; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * OAuth2.0 移除用户令牌 Request DTO + * + * 包括访问令牌和刷新令牌 + */ +@Data +@Accessors(chain = true) +public class OAuth2RemoveTokenByUserReqDTO { + + /** + * 用户编号 + */ + @NotNull(message = "用户编号不能为空") + private Integer userId; + /** + * 用户类型 + */ + @NotNull(message = "用户类型不能为空") + @InEnum(value = UserTypeEnum.class, message = "用户类型必须是 {value}") + private Integer userType; + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/oauth/OAuth2Convert.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/oauth/OAuth2Convert.java index 54486a8af..77e0b20d4 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/oauth/OAuth2Convert.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/oauth/OAuth2Convert.java @@ -1,7 +1,7 @@ package cn.iocoder.mall.systemservice.convert.oauth; import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO; -import cn.iocoder.mall.systemservice.rpc.oauth.vo.OAuth2AccessTokenVO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.mall.systemservice.service.oauth.bo.OAuth2AccessTokenBO; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -15,6 +15,6 @@ public interface OAuth2Convert { @Mapping(source = "id", target = "accessToken") OAuth2AccessTokenBO convert(OAuth2AccessTokenDO bean); - OAuth2AccessTokenVO convert(OAuth2AccessTokenBO bean); + OAuth2AccessTokenRespDTO convert(OAuth2AccessTokenBO bean); } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/oauth/OAuth2Manager.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/oauth/OAuth2Manager.java index 45d71546c..373390d28 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/oauth/OAuth2Manager.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/oauth/OAuth2Manager.java @@ -1,38 +1,47 @@ package cn.iocoder.mall.systemservice.manager.oauth; import cn.iocoder.mall.systemservice.convert.oauth.OAuth2Convert; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenDTO; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenDTO; -import cn.iocoder.mall.systemservice.rpc.oauth.vo.OAuth2AccessTokenVO; +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.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO; import cn.iocoder.mall.systemservice.service.oauth.OAuth2Service; import cn.iocoder.mall.systemservice.service.oauth.bo.OAuth2AccessTokenBO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; /** * OAuth2.0 Manager */ @Service +@Validated public class OAuth2Manager { @Autowired private OAuth2Service oauth2Service; - public OAuth2AccessTokenVO createAccessToken(OAuth2CreateAccessTokenDTO createAccessTokenDTO) { + public OAuth2AccessTokenRespDTO createAccessToken(@Valid OAuth2CreateAccessTokenReqDTO createAccessTokenDTO) { OAuth2AccessTokenBO accessTokenBO = oauth2Service.createAccessToken(createAccessTokenDTO.getUserId(), createAccessTokenDTO.getUserType(), createAccessTokenDTO.getCreateIp()); return OAuth2Convert.INSTANCE.convert(accessTokenBO); } - public OAuth2AccessTokenVO checkAccessToken(String accessToken) { + public OAuth2AccessTokenRespDTO checkAccessToken(String accessToken) { OAuth2AccessTokenBO accessTokenBO = oauth2Service.checkAccessToken(accessToken); return OAuth2Convert.INSTANCE.convert(accessTokenBO); } - public OAuth2AccessTokenVO refreshAccessToken(OAuth2RefreshAccessTokenDTO refreshAccessTokenDTO) { + public OAuth2AccessTokenRespDTO refreshAccessToken(@Valid OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO) { OAuth2AccessTokenBO accessTokenBO = oauth2Service.refreshAccessToken(refreshAccessTokenDTO.getRefreshToken(), refreshAccessTokenDTO.getCreateIp()); return OAuth2Convert.INSTANCE.convert(accessTokenBO); } + public void removeToken(@Valid OAuth2RemoveTokenByUserReqDTO removeTokenDTO) { + oauth2Service.removeToken(removeTokenDTO.getUserId(), removeTokenDTO.getUserType()); + } + } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuth2RpcImpl.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuth2RpcImpl.java index c2a055b44..1f90685fe 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuth2RpcImpl.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuth2RpcImpl.java @@ -2,9 +2,10 @@ package cn.iocoder.mall.systemservice.rpc.oauth; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.systemservice.manager.oauth.OAuth2Manager; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenDTO; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenDTO; -import cn.iocoder.mall.systemservice.rpc.oauth.vo.OAuth2AccessTokenVO; +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.OAuth2AccessTokenRespDTO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO; import org.apache.dubbo.config.annotation.Service; import org.springframework.beans.factory.annotation.Autowired; @@ -17,18 +18,24 @@ public class OAuth2RpcImpl implements OAuth2Rpc { private OAuth2Manager oauth2Manager; @Override - public CommonResult createAccessToken(OAuth2CreateAccessTokenDTO createAccessTokenDTO) { + public CommonResult createAccessToken(OAuth2CreateAccessTokenReqDTO createAccessTokenDTO) { return success(oauth2Manager.createAccessToken(createAccessTokenDTO)); } @Override - public CommonResult checkAccessToken(String accessToken) { + public CommonResult checkAccessToken(String accessToken) { return success(oauth2Manager.checkAccessToken(accessToken)); } @Override - public CommonResult refreshAccessToken(OAuth2RefreshAccessTokenDTO refreshAccessTokenDTO) { + public CommonResult refreshAccessToken(OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO) { return success(oauth2Manager.refreshAccessToken(refreshAccessTokenDTO)); } + @Override + public CommonResult removeToken(OAuth2RemoveTokenByUserReqDTO removeTokenDTO) { + oauth2Manager.removeToken(removeTokenDTO); + return success(true); + } + } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/AdminService.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/AdminService.java index 2ea251f5c..0651c77de 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/AdminService.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/AdminService.java @@ -81,34 +81,34 @@ public class AdminService { return DigestUtils.bcrypt(password, salt); } - public void updateAdmin(AdminUpdateBO updateDTO) { + public void updateAdmin(AdminUpdateBO updateBO) { // 校验账号存在 - AdminDO admin = adminMapper.selectById(updateDTO.getId()); - if (admin == null) { + AdminDO adminDO = adminMapper.selectById(updateBO.getId()); + if (adminDO == null) { throw ServiceExceptionUtil.exception(ADMIN_NOT_FOUND); } // 校验是否为特殊账号,不允许编辑 - if (AdminUsernameEnum.ADMIN.getUsername().equals(admin.getUsername()) - || AdminUsernameEnum.DEMO.getUsername().equals(admin.getUsername())) { + if (AdminUsernameEnum.ADMIN.getUsername().equals(adminDO.getUsername()) + || AdminUsernameEnum.DEMO.getUsername().equals(adminDO.getUsername())) { throw ServiceExceptionUtil.exception(ADMIN_ADMIN_CAN_NOT_UPDATE); } // 校验账号唯一 - if (StringUtils.hasText(updateDTO.getUsername())) { - AdminDO usernameAdmin = adminMapper.selectByUsername(updateDTO.getUsername()); - if (usernameAdmin != null && !usernameAdmin.getId().equals(updateDTO.getId())) { + if (StringUtils.hasText(updateBO.getUsername())) { + AdminDO usernameAdmin = adminMapper.selectByUsername(updateBO.getUsername()); + if (usernameAdmin != null && !usernameAdmin.getId().equals(updateBO.getId())) { throw ServiceExceptionUtil.exception(ADMIN_USERNAME_EXISTS); } } // 如果有更新状态,则校验是否已经是该状态 - if (updateDTO.getStatus() != null && updateDTO.getStatus().equals(admin.getStatus())) { + if (updateBO.getStatus() != null && updateBO.getStatus().equals(adminDO.getStatus())) { throw ServiceExceptionUtil.exception(ADMIN_STATUS_EQUALS); } // 更新到数据库 - AdminDO updateAdmin = AdminConvert.INSTANCE.convert(updateDTO); + AdminDO updateAdmin = AdminConvert.INSTANCE.convert(updateBO); // 如果更新密码,需要特殊加密 - if (StringUtils.hasText(updateDTO.getPassword())) { + if (StringUtils.hasText(updateBO.getPassword())) { String passwordSalt = genPasswordSalt(); - String password = encodePassword(updateDTO.getPassword(), passwordSalt); + String password = encodePassword(updateBO.getPassword(), passwordSalt); updateAdmin.setPassword(password).setPasswordSalt(passwordSalt); } adminMapper.updateById(updateAdmin); @@ -119,65 +119,4 @@ public class AdminService { return AdminConvert.INSTANCE.convert(adminDO); } -// -// @Override -// public Map> getAdminRolesMap(Collection adminIds) { -// // 查询管理员拥有的角色关联数据 -// List adminRoleList = adminRoleMapper.selectListByAdminIds(adminIds); -// if (adminRoleList.isEmpty()) { -// return Collections.emptyMap(); -// } -// // 查询角色数据 -// List roleList = roleService.getRoleList(CollectionUtil.convertSet(adminRoleList, AdminRoleDO::getRoleId)); -// Map roleMap = CollectionUtil.convertMap(roleList, RoleBO::getId); -// // 拼接数据 -// Multimap result = ArrayListMultimap.create(); -// adminRoleList.forEach(adminRole -> result.put(adminRole.getAdminId(), roleMap.get(adminRole.getRoleId()))); -// return result.asMap(); -// } -// -// @Override -// public List getRoleList(Integer adminId) { -// // 查询管理员拥有的角色关联数据 -// List adminRoleList = adminRoleMapper.selectByAdminId(adminId); -// if (adminRoleList.isEmpty()) { -// return Collections.emptyList(); -// } -// // 查询角色数据 -// return roleService.getRoleList(CollectionUtil.convertSet(adminRoleList, AdminRoleDO::getRoleId)); -// } -// -// @Override -// @Transactional -// public Boolean assignAdminRole(Integer adminId, AdminAssignRoleDTO adminAssignRoleDTO) { -// // 校验账号存在 -// AdminDO admin = adminMapper.selectById(adminAssignRoleDTO.getId()); -// if (admin == null) { -// throw ServiceExceptionUtil.exception(AdminErrorCodeEnum.ADMIN_USERNAME_NOT_REGISTERED.getCode()); -// } -// // 校验是否有不存在的角色 -// if (!CollectionUtil.isEmpty(adminAssignRoleDTO.getRoleIds())) { -// List roles = roleService.getRoles(adminAssignRoleDTO.getRoleIds()); -// if (roles.size() != adminAssignRoleDTO.getRoleIds().size()) { -// throw ServiceExceptionUtil.exception(AdminErrorCodeEnum.ADMIN_ASSIGN_ROLE_NOT_EXISTS.getCode()); -// } -// } -// // TODO 芋艿,这里先简单实现。即方式是,删除老的分配的角色关系,然后添加新的分配的角色关系 -// // 标记管理员角色源关系都为删除 -// adminRoleMapper.deleteByAdminId(adminAssignRoleDTO.getId()); -// // 创建 RoleResourceDO 数组,并插入到数据库 -// if (!CollectionUtil.isEmpty(adminAssignRoleDTO.getRoleIds())) { -// List adminRoleDOs = adminAssignRoleDTO.getRoleIds().stream().map(roleId -> { -// AdminRoleDO roleResource = new AdminRoleDO().setAdminId(adminAssignRoleDTO.getId()).setRoleId(roleId); -// roleResource.setCreateTime(new Date()); -// roleResource.setDeleted(DeletedStatusEnum.DELETED_NO.getValue()); -// return roleResource; -// }).collect(Collectors.toList()); -// adminRoleMapper.insertList(adminRoleDOs); -// } -// // TODO 插入操作日志 -// // 返回成功 -// return true; -// } - } diff --git a/system/pom.xml b/system/pom.xml index f6cd2d90a..276682102 100644 --- a/system/pom.xml +++ b/system/pom.xml @@ -14,15 +14,11 @@ pom - system-application - system-rpc-api - system-rpc system-rest system-biz - system-biz-api diff --git a/system/system-application/pom.xml b/system/system-application/pom.xml deleted file mode 100644 index f46f0ed7d..000000000 --- a/system/system-application/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - system - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - system-application - - - - - cn.iocoder.mall - system-rest - 1.0-SNAPSHOT - - - cn.iocoder.mall - system-rpc - 1.0-SNAPSHOT - - - - - diff --git a/system/system-application/src/main/java/cn/iocoder/mall/system/application/SystemApplication.java b/system/system-application/src/main/java/cn/iocoder/mall/system/application/SystemApplication.java deleted file mode 100644 index 0385ef8a3..000000000 --- a/system/system-application/src/main/java/cn/iocoder/mall/system/application/SystemApplication.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.mall.system.application; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.config.ConfigFileApplicationListener; - -@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.system"}) -public class SystemApplication { - - /** - * 设置需要读取的配置文件的名字。 - * 基于 {@link org.springframework.boot.context.config.ConfigFileApplicationListener#CONFIG_NAME_PROPERTY} 实现。 - */ - private static final String CONFIG_NAME_VALUE = "biz,rest,rpc,application"; - - public static void main(String[] args) { - // 设置环境变量 - System.setProperty(ConfigFileApplicationListener.CONFIG_NAME_PROPERTY, CONFIG_NAME_VALUE); - - // 启动 Spring Boot 应用 - SpringApplication.run(SystemApplication.class, args); - } - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/user/UserConvert.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/user/UserConvert.java deleted file mode 100644 index 40e783645..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/user/UserConvert.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.mall.system.biz.convert.user; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.biz.bo.ouath2.OAuth2AuthenticateBO; -import cn.iocoder.mall.system.biz.bo.user.UserAuthenticateBO; -import cn.iocoder.mall.system.biz.bo.user.UserBO; -import cn.iocoder.mall.system.biz.dataobject.admin.AdminDO; -import cn.iocoder.mall.system.biz.dataobject.user.UserDO; -import cn.iocoder.mall.system.biz.dto.user.UserUpdateDTO; -import cn.iocoder.mall.system.biz.dto.user.UserUpdateStatusDTO; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface UserConvert { - - UserConvert INSTANCE = Mappers.getMapper(UserConvert.class); - - UserBO convert(UserDO bean); - - /** - * 用户分页列表 - DOPage转换BO - * @param userDOPage - * @return - */ - @Mapping(source = "records", target = "list") - PageResult convertToPage(IPage userDOPage); - - /** - * 更新用户信息 - DTO转换DO - * @param userUpdateDTO - * @return - */ - UserDO convertToUserDO(UserUpdateDTO userUpdateDTO); - - /** - * 更新用户状态 - DTO转换DO - * @param userUpdateStatusDTO - * @return - */ - UserDO convertToUserDO(UserUpdateStatusDTO userUpdateStatusDTO); - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/user/UserPageDTO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/user/UserPageDTO.java deleted file mode 100644 index 65f23336b..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/user/UserPageDTO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.mall.system.biz.dto.user; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotNull; - -/** - * @Author: jiangweifan - * @Date: 2020/5/12 - * @Description: 用户信息 - 用户分页列表DTO - */ -@Data -@Accessors(chain = true) -public class UserPageDTO { - - /** - * 昵称,模糊匹配 - */ - private String nickname; - - /** - * 状态。1 - 开启;2 - 禁用 - */ - private Integer status; - - /** - * 页码,从 1 开始 - */ - @NotNull(message = "页码不能为空") - private Integer pageNo; - - /** - * 每页条数 - */ - @NotNull(message = "每页条数不能为空") - private Integer pageSize; -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/user/UserService.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/user/UserService.java deleted file mode 100644 index bd74169ad..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/user/UserService.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.mall.system.biz.service.user; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.biz.bo.user.UserBO; -import cn.iocoder.mall.system.biz.dto.user.UserPageDTO; -import cn.iocoder.mall.system.biz.dto.user.UserUpdateDTO; -import cn.iocoder.mall.system.biz.dto.user.UserUpdateStatusDTO; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; - -/** - * 用户 Service 接口 - */ -@Validated -public interface UserService { - - /** - * 根据条件分页获取用户列表 - * @param userPageDTO - * @return - */ - PageResult getUserPage(UserPageDTO userPageDTO); - - /** - * 更新用户信息 - * @param userUpdateDTO - * @return - */ - Boolean updateUserInfo(@Valid UserUpdateDTO userUpdateDTO); - - /** - * 更新用户状态 - * @param userUpdateStatusDTO - * @return - */ - Boolean updateUserStatus(@Valid UserUpdateStatusDTO userUpdateStatusDTO); - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/user/UserServiceImpl.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/user/UserServiceImpl.java deleted file mode 100644 index 6b11acd60..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/user/UserServiceImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.mall.system.biz.service.user; - -import cn.iocoder.common.framework.util.ServiceExceptionUtil; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.biz.bo.ouath2.OAuth2AuthenticateBO; -import cn.iocoder.mall.system.biz.bo.user.UserAuthenticateBO; -import cn.iocoder.mall.system.biz.bo.user.UserBO; -import cn.iocoder.mall.system.biz.convert.user.UserConvert; -import cn.iocoder.mall.system.biz.dao.user.UserMapper; -import cn.iocoder.mall.system.biz.dataobject.user.UserDO; -import cn.iocoder.mall.system.biz.dto.oatuh2.OAuth2MobileCodeAuthenticateDTO; -import cn.iocoder.mall.system.biz.dto.user.UserPageDTO; -import cn.iocoder.mall.system.biz.dto.user.UserUpdateDTO; -import cn.iocoder.mall.system.biz.dto.user.UserUpdateStatusDTO; -import cn.iocoder.mall.system.biz.enums.user.UserStatusEnum; -import cn.iocoder.mall.system.biz.service.oauth2.OAuth2Service; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Arrays; -import static cn.iocoder.mall.system.biz.enums.SystemErrorCodeEnum.*; - -@Service -public class UserServiceImpl implements UserService { - - @Autowired - private UserMapper userMapper; - - /** - * 根据条件分页获取用户列表 - * @param userPageDTO - * @return - */ - @Override - public PageResult getUserPage(UserPageDTO userPageDTO) { - return UserConvert.INSTANCE.convertToPage(userMapper.selectUserPage(userPageDTO)); - } - - /** - * 更新用户信息 - * @param userUpdateDTO - * @return - */ - @Override - public Boolean updateUserInfo(UserUpdateDTO userUpdateDTO) { - // 查询用户是否存在 - UserDO userDO = userMapper.selectById(userUpdateDTO.getId()); - if (null == userDO) { - throw ServiceExceptionUtil.exception(USER_NOT_EXISTS); - } - // 更新用户信息 - UserDO updateDO = UserConvert.INSTANCE.convertToUserDO(userUpdateDTO); - userMapper.updateById(updateDO); - // TODO 伟帆 操作日志 - return true; - } - - - /** - * 更新用户状态 - * @param userUpdateStatusDTO - * @return - */ - @Override - public Boolean updateUserStatus(UserUpdateStatusDTO userUpdateStatusDTO) { - // 查询用户是否存在 - UserDO userDO = userMapper.selectById(userUpdateStatusDTO.getId()); - if (null == userDO) { - throw ServiceExceptionUtil.exception(USER_NOT_EXISTS); - } - // 判断更新状态是否存在 - if (null != userUpdateStatusDTO.getStatus() && - Arrays.stream(UserStatusEnum.ARRAYS).noneMatch(status -> status == userUpdateStatusDTO.getStatus())) { - throw ServiceExceptionUtil.exception(USER_STATUS_NOT_EXISTS); - } - // 如果状态相同,则返回错误 - if (null != userUpdateStatusDTO.getStatus() && userUpdateStatusDTO.getStatus().equals(userDO.getStatus())) { - throw ServiceExceptionUtil.exception(USER_STATUS_EQUALS); - } - // 更新用户信息 - UserDO updateStatusDO = UserConvert.INSTANCE.convertToUserDO(userUpdateStatusDTO); - userMapper.updateById(updateStatusDO); - // TODO 伟帆 操作日志 - return true; - } - -} diff --git a/system/system-application/src/main/resources/application.yaml b/system/system-biz/src/main/resources/application.yaml similarity index 100% rename from system/system-application/src/main/resources/application.yaml rename to system/system-biz/src/main/resources/application.yaml diff --git a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/controller/admin/AdminsUserController.java b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/controller/admin/AdminsUserController.java deleted file mode 100644 index bb27c4c94..000000000 --- a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/controller/admin/AdminsUserController.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.mall.system.rest.controller.admin; - -import cn.iocoder.common.framework.enums.MallConstants; -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.biz.bo.user.UserBO; -import cn.iocoder.mall.system.biz.service.user.UserService; -import cn.iocoder.mall.system.rest.convert.admin.AdminsUserConvert; -import cn.iocoder.mall.system.rest.request.admin.AdminsUserPageRequest; -import cn.iocoder.mall.system.rest.request.admin.AdminsUserUpdateRequest; -import cn.iocoder.mall.system.rest.request.admin.AdminsUserUpdateStatusRequest; -import cn.iocoder.mall.system.rest.response.admin.AdminsUserPageResponse; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -/** - * @Author: jiangweifan - * @Date: 2020/5/12 - * @Description: 管理员 - 用户信息 - */ -@RestController -@RequestMapping(MallConstants.ROOT_PATH_ADMIN + "/user-info") -@Api(tags = "管理员 - 用户信息 API") -public class AdminsUserController { - - @Autowired - private UserService userService; - - @GetMapping("/page") - @ApiOperation(value = "用户分页列表") - public CommonResult> page(AdminsUserPageRequest adminsUserPageRequest) { - PageResult userPage = userService.getUserPage(AdminsUserConvert.INSTANCE.convertToPageDTO(adminsUserPageRequest)); - return success(AdminsUserConvert.INSTANCE.convertToPageResponse(userPage)); - } - - @PostMapping("/update") - @ApiOperation(value = "更新用户基本信息") - public CommonResult update(AdminsUserUpdateRequest adminsUserUpdateRequest) { - return success(userService.updateUserInfo(AdminsUserConvert.INSTANCE.convertToUpdateDTO(adminsUserUpdateRequest))); - } - - @PostMapping("/update_status") - @ApiOperation(value = "更新用户状态") - public CommonResult updateStatus(AdminsUserUpdateStatusRequest adminsUserUpdateStatusRequest) { - return success(userService.updateUserStatus(AdminsUserConvert.INSTANCE.convertToUpdateStatusDTO(adminsUserUpdateStatusRequest))); - } -} diff --git a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/convert/admin/AdminsUserConvert.java b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/convert/admin/AdminsUserConvert.java deleted file mode 100644 index 5dede640f..000000000 --- a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/convert/admin/AdminsUserConvert.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.mall.system.rest.convert.admin; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.biz.bo.user.UserBO; -import cn.iocoder.mall.system.biz.dto.user.UserPageDTO; -import cn.iocoder.mall.system.biz.dto.user.UserUpdateDTO; -import cn.iocoder.mall.system.biz.dto.user.UserUpdateStatusDTO; -import cn.iocoder.mall.system.rest.request.admin.AdminsUserPageRequest; -import cn.iocoder.mall.system.rest.request.admin.AdminsUserUpdateRequest; -import cn.iocoder.mall.system.rest.request.admin.AdminsUserUpdateStatusRequest; -import cn.iocoder.mall.system.rest.response.admin.AdminsUserPageResponse; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * @Author: jiangweifan - * @Date: 2020/5/12 - * @Description: 管理后台 - 用户数据转换 - */ -@Mapper -public interface AdminsUserConvert { - - AdminsUserConvert INSTANCE = Mappers.getMapper(AdminsUserConvert.class); - - /** - * 分页获取用户列表 - Request转DTO - * @param adminsUserPageRequest - * @return - */ - UserPageDTO convertToPageDTO(AdminsUserPageRequest adminsUserPageRequest); - - /** - * 更新用户信息 - Request转DTO - * @param adminsUserUpdateRequest - * @return - */ - UserUpdateDTO convertToUpdateDTO(AdminsUserUpdateRequest adminsUserUpdateRequest); - - /** - * 更新用户状态 - Request转DTO - * @param adminsUserUpdateStatusRequest - * @return - */ - UserUpdateStatusDTO convertToUpdateStatusDTO(AdminsUserUpdateStatusRequest adminsUserUpdateStatusRequest); - - /** - * 分页获取用户列表 - BO转Response - * @param userPage - * @return - */ - PageResult convertToPageResponse(PageResult userPage); -} diff --git a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/convert/systemlog/AccessLogConvert.java b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/convert/systemlog/AccessLogConvert.java deleted file mode 100644 index e5f20cf7b..000000000 --- a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/convert/systemlog/AccessLogConvert.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.mall.system.rest.convert.systemlog; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.biz.bo.systemlog.AccessLogBO; -import cn.iocoder.mall.system.rest.response.systemlog.AccessLogPageResponse; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -/** - * @author:ycjx - * @descriptio - * @create:2019-06-23 17:36 - */ -@Mapper -public interface AccessLogConvert { - - - AccessLogConvert INSTANCE = Mappers.getMapper(AccessLogConvert.class); - - - @Mappings({}) // TODO FROM 芋艿 to 2447007062:注意空行哟;另外,如果不需要专门 mapping,可以不添加该注解,嘿嘿。 - PageResult convert(PageResult result); - - - -} diff --git a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/request/errorcode/ErrorCodeAddRequest.java b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/request/errorcode/ErrorCodeAddRequest.java deleted file mode 100644 index 5a45a3c1b..000000000 --- a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/request/errorcode/ErrorCodeAddRequest.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.mall.system.rest.request.errorcode; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; - -@ApiModel("管理员 - 错误码模块 - 添加错误码 Request") -@Data -@Accessors(chain = true) -public class ErrorCodeAddRequest { - - @ApiModelProperty(value = "错误码信息", required = true, example = "系统管理员") - @NotEmpty(message = "错误码信息不能为空") - private String message; - - @ApiModelProperty(value = "错误码编码", example = "SUPER_ADMIN") - @NotEmpty(message = "错误码编码不能为空") - private Integer code; - - @ApiModelProperty(value = "错误码分组,字典表获取") - @NotEmpty(message = "错误码分组不能为空") - private Integer group; - - @ApiModelProperty(value = "错误码角色,系统内置(枚举)还是自定义") - @NotEmpty(message = "错误码角色不能空") - private Integer type; - -} diff --git a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/request/errorcode/ErrorCodePageRequest.java b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/request/errorcode/ErrorCodePageRequest.java deleted file mode 100644 index 6383207e6..000000000 --- a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/request/errorcode/ErrorCodePageRequest.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.mall.system.rest.request.errorcode; - -import io.swagger.annotations.ApiModel; -import lombok.Data; -import lombok.experimental.Accessors; - - -/** - * @author ding - */ -@ApiModel("管理员 - 错误码模块 - 错误码分页 Request") -@Data -@Accessors(chain = true) -public class ErrorCodePageRequest { - - // TODO FROM 芋艿 to 鱿鱼须:分页参数? - // TODO FROM 芋艿 to 鱿鱼须:对于 rest 的接口,要区分下是给 Admins 管理员还是 Users 用户的 -} diff --git a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/request/errorcode/ErrorCodeUpdateRequest.java b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/request/errorcode/ErrorCodeUpdateRequest.java deleted file mode 100644 index 53e2d5e0d..000000000 --- a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/request/errorcode/ErrorCodeUpdateRequest.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.mall.system.rest.request.errorcode; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 类 描 述:错误码模块 - * @author ding - */ -@ApiModel("管理员 - 错误码模块 - 修改错误码 Request") -@Data -@Accessors(chain = true) -public class ErrorCodeUpdateRequest { - @ApiModelProperty(value = "错误码编号", required = true, example = "1") - @NotNull(message = "错误码不能为空") - private Integer id; - - @ApiModelProperty(value = "错误码信息", required = true, example = "系统管理员") - @NotEmpty(message = "错误码信息不能为空") - private String message; - - @ApiModelProperty(value = "错误码编码", example = "SUPER_ADMIN") - @NotEmpty(message = "错误码编码不能为空") - private Integer code; -} diff --git a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/authorization/AdminsAuthorizationMenuTreeResponse.java b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/authorization/AdminsAuthorizationMenuTreeResponse.java deleted file mode 100644 index a507ed3e9..000000000 --- a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/authorization/AdminsAuthorizationMenuTreeResponse.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.mall.system.rest.response.authorization; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.List; - -@ApiModel(value = "管理员 - 授权模块 - 菜单资源树 Response", description = "一般用于首页菜单树") -@Data -@Accessors(chain = true) -public class AdminsAuthorizationMenuTreeResponse { - - @ApiModelProperty(value = "菜单编号", required = true, example = "1") - private Integer id; - @ApiModelProperty(value = "菜单名", required = true, example = "商品管理") - private String name; - @ApiModelProperty(value = "前端路由", required = true, example = "/order/list") - private String route; - @ApiModelProperty(value = "菜单图标", required = true, example = "user") - private String icon; - /** - * 子节点数组 - */ - private List children; - -} diff --git a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/authorization/AdminsAuthorizationRoleResourceTreeResponse.java b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/authorization/AdminsAuthorizationRoleResourceTreeResponse.java deleted file mode 100644 index e970a5c1c..000000000 --- a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/authorization/AdminsAuthorizationRoleResourceTreeResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.mall.system.rest.response.authorization; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.List; - -@ApiModel(value = "管理员 - 授权模块 - 角色拥有的资源树 Response") -@Data -@Accessors(chain = true) -public class AdminsAuthorizationRoleResourceTreeResponse { - - @ApiModelProperty(value = "菜单编号", required = true, example = "1") - private Integer id; - @ApiModelProperty(value = "菜单名", required = true, example = "商品管理") - private String name; - @ApiModelProperty(value = "是否分配", required = true, notes = "即角色是否拥有该资源") - private Boolean assigned; - /** - * 子节点数组 - */ - private List children; - -} diff --git a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/authorization/AdminsResourceTreeResponse.java b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/authorization/AdminsResourceTreeResponse.java deleted file mode 100644 index efe11a708..000000000 --- a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/authorization/AdminsResourceTreeResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.mall.system.rest.response.authorization; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.List; - -@ApiModel("管理员 - 授权模块 - 菜单资源树 Response") -@Data -@Accessors(chain = true) -public class AdminsResourceTreeResponse { - - @ApiModelProperty(value = "菜单编号", required = true, example = "1") - private Integer id; - @ApiModelProperty(value = "菜单名", required = true, example = "商品管理") - private String name; - @ApiModelProperty(value = "权限标识", example = "/order/list") - private String permission; - @ApiModelProperty(value = "资源类型", required = true, example = "1-菜单;2-按钮") - private Integer type; - @ApiModelProperty(value = "排序", required = true, example = "1") - private Integer sort; - @ApiModelProperty(value = "父菜单编号", required = true, example = "1", notes = "如果无父菜单,则值为 0") - private Integer pid; - @ApiModelProperty(value = "前端路由", example = "/order/list") - private String route; - @ApiModelProperty(value = "菜单图标", example = "user") - private String icon; - /** - * 子节点数组 - */ - private List children; - -} diff --git a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/errorcode/ErrorCodePageResponse.java b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/errorcode/ErrorCodePageResponse.java deleted file mode 100644 index a03097773..000000000 --- a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/errorcode/ErrorCodePageResponse.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.mall.system.rest.response.errorcode; - -import io.swagger.annotations.ApiModel; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.Date; - -/** - * 类 描 述:错误码模块 - * @author ding - */ -@ApiModel("管理员 - 错误码模块 - 查询错误码 Request") -@Data -@Accessors(chain = true) -public class ErrorCodePageResponse { - /** - * 错误码编号 - */ - private Integer id; - /** - * 错误码编码 - */ - private Integer code; - /** - * 错误码错误信息 - */ - private String message; - /** - * 添加时间 - */ - private Date createTime; -} diff --git a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/systemlog/AccessLogPageResponse.java b/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/systemlog/AccessLogPageResponse.java deleted file mode 100644 index 83f5c2368..000000000 --- a/system/system-rest/src/main/java/cn/iocoder/mall/system/rest/response/systemlog/AccessLogPageResponse.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.mall.system.rest.response.systemlog; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.Date; - -/** - * @author mxc - * @date 2020/5/11 22:11 - */ -@ApiModel("访问日志 VO") -@Data -@Accessors(chain = true) -public class AccessLogPageResponse { - - - @ApiModelProperty(value = "链路追踪编号", required = true, example = "1") - private String traceId; - - @ApiModelProperty(value = "账号编号", required = true, example = "1") - private Integer accountId;; - - @ApiModelProperty(value = "应用名", required = true, example = "1") - private String applicationName; - - @ApiModelProperty(value = "访问地址", required = true, example = "1") - private String uri; - - @ApiModelProperty(value = "请求参数", required = true, example = "1") - private String queryString; - - @ApiModelProperty(value = "http 请求方法", required = true, example = "1") - private String method; - - @ApiModelProperty(value = "User-Agent ", required = true, example = "1") - private String userAgent; - - @ApiModelProperty(value = "ip", required = true, example = "1") - private String ip; - - @ApiModelProperty(value = "请求时间", required = true, example = "1") - private Date startTime; - - @ApiModelProperty(value = "响应时长", required = true, example = "1") - private Integer responseTime; - - @ApiModelProperty(value = "错误码", required = true, example = "1") - private Integer errorCode; - -} diff --git a/system/system-rpc-api/pom.xml b/system/system-rpc-api/pom.xml deleted file mode 100644 index 35bdfe646..000000000 --- a/system/system-rpc-api/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - system - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - system-rpc-api - - - - - cn.iocoder.mall - system-biz-api - 1.0-SNAPSHOT - - - - - javax.validation - validation-api - - - org.projectlombok - lombok - - - - - diff --git a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/api/user/UserRPC.java b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/api/user/UserRPC.java deleted file mode 100644 index 1e04551a9..000000000 --- a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/api/user/UserRPC.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.mall.system.rpc.api.user; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.system.rpc.response.user.UserResponse; - -/** - * User RPC 接口 - */ -public interface UserRPC { - -// CommonResult getUser(Integer id); - - CommonResult getUserByAccountId(Integer accountId); - -} diff --git a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/user/UserResponse.java b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/user/UserResponse.java deleted file mode 100644 index 8e3c06688..000000000 --- a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/user/UserResponse.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.mall.system.rpc.response.user; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * User 模块 - User 信息 Response - */ -@Data -@Accessors(chain = true) -public class UserResponse implements Serializable { - - /** - * 用户编号 - */ - private Integer id; - -} diff --git a/system/system-rpc/pom.xml b/system/system-rpc/pom.xml deleted file mode 100644 index 4827a0436..000000000 --- a/system/system-rpc/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - system - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - system-rpc - - - - - cn.iocoder.mall - system-rpc-api - 1.0-SNAPSHOT - - - cn.iocoder.mall - system-biz - 1.0-SNAPSHOT - - - - - com.alibaba.cloud - spring-cloud-starter-dubbo - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - diff --git a/system/system-rpc/src/main/java/cn/iocoder/mall/system/rpc/convert/user/UserConvert.java b/system/system-rpc/src/main/java/cn/iocoder/mall/system/rpc/convert/user/UserConvert.java deleted file mode 100644 index 1afbe42f4..000000000 --- a/system/system-rpc/src/main/java/cn/iocoder/mall/system/rpc/convert/user/UserConvert.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.mall.system.rpc.convert.user; - -import cn.iocoder.mall.system.biz.bo.user.UserBO; -import cn.iocoder.mall.system.rpc.response.user.UserResponse; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface UserConvert { - - UserConvert INSTANCE = Mappers.getMapper(UserConvert.class); - - UserResponse convert(UserBO bean); - -} diff --git a/system/system-rpc/src/main/java/cn/iocoder/mall/system/rpc/rpc/user/UserRPCImpl.java b/system/system-rpc/src/main/java/cn/iocoder/mall/system/rpc/rpc/user/UserRPCImpl.java deleted file mode 100644 index 729932a77..000000000 --- a/system/system-rpc/src/main/java/cn/iocoder/mall/system/rpc/rpc/user/UserRPCImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.mall.system.rpc.rpc.user; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.system.biz.bo.user.UserBO; -import cn.iocoder.mall.system.biz.service.user.UserService; -import cn.iocoder.mall.system.rpc.api.user.UserRPC; -import cn.iocoder.mall.system.rpc.convert.user.UserConvert; -import cn.iocoder.mall.system.rpc.response.user.UserResponse; -import org.apache.dubbo.config.annotation.Service; -import org.springframework.beans.factory.annotation.Autowired; - -@Service(version = "${dubbo.provider.UserRPC.version}", validation = "true") -public class UserRPCImpl implements UserRPC { - - @Autowired - private UserService userService; - - @Override - public CommonResult getUserByAccountId(Integer accountId) { - UserBO userBO = userService.getUserByAccountId(accountId); - return CommonResult.success(UserConvert.INSTANCE.convert(userBO)); - } - -} diff --git a/system/system-rpc/src/main/resources/rpc-local.yaml b/system/system-rpc/src/main/resources/rpc-local.yaml deleted file mode 100644 index 2e9e99973..000000000 --- a/system/system-rpc/src/main/resources/rpc-local.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - # Spring Cloud 配置项 - cloud: - nacos: - # Spring Cloud Nacos Discovery 配置项 - discovery: - server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址 - namespace: local # Nacos 命名空间 - -# Dubbo 配置项 -dubbo: - # Dubbo 注册中心 - registry: - address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址 diff --git a/system/system-rpc/src/main/resources/rpc-test.yaml b/system/system-rpc/src/main/resources/rpc-test.yaml deleted file mode 100644 index d3d0e9e69..000000000 --- a/system/system-rpc/src/main/resources/rpc-test.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - # Spring Cloud 配置项 - cloud: - nacos: - # Spring Cloud Nacos Discovery 配置项 - discovery: - server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址 - namespace: test # Nacos 命名空间 - -# Dubbo 配置项 -dubbo: - # Dubbo 注册中心 - registry: - address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址 diff --git a/system/system-rpc/src/main/resources/rpc.yaml b/system/system-rpc/src/main/resources/rpc.yaml deleted file mode 100644 index c44353e1f..000000000 --- a/system/system-rpc/src/main/resources/rpc.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# Dubbo 配置项 -dubbo: - # Spring Cloud Alibaba Dubbo 专属配置 - cloud: - subscribed-services: '' # 设置订阅的应用列表,默认为 * 订阅所有应用 - # Dubbo 提供者的协议 - protocol: - name: dubbo - port: -1 - # Dubbo 提供服务的扫描基础包 - scan: - base-packages: cn.iocoder.mall.system.rpc.rpc - # Dubbo 服务提供者的配置 - provider: - filter: -exception - SystemLogRPC: - version: 1.0.0 - OAuth2RPC: - version: 1.0.0 - AuthorizationRPC: - version: 1.0.0 - AdminRPC: - version: 1.0.0 - UserRPC: - version: 1.0.0 - UserAddressRPC: - version: 1.0.0 - ErrorCodeRPC: - version: 1.0.0 - - # Dubbo 服务消费者的配置 - consumer: - SystemLogRPC: # 用于 AccessLogInterceptor 等拦截器,记录 HTTP API 请求的访问日志 - version: 1.0.0 - OAuth2RPC: # 用于 AccountAuthInterceptor 拦截器,执行认证 - version: 1.0.0 - AuthorizationRPC: # 用于 AccountAuthInterceptor 拦截器,执行鉴权(权限验证) - version: 1.0.0 - AdminRPC: - version: 1.0.0 - UserRPC: - version: 1.0.0 - ErrorCodeRPC: - version: 1.0.0 diff --git a/user-service-project/pom.xml b/user-service-project/pom.xml index e963aa24a..f21e37c9f 100644 --- a/user-service-project/pom.xml +++ b/user-service-project/pom.xml @@ -34,6 +34,12 @@ 1.0-SNAPSHOT + + cn.iocoder.mall + system-service-api + 1.0-SNAPSHOT + + cn.iocoder.mall diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/enums/UserErrorCodeConstants.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/enums/UserErrorCodeConstants.java index ace35cca4..febb0d14b 100644 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/enums/UserErrorCodeConstants.java +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/enums/UserErrorCodeConstants.java @@ -24,7 +24,7 @@ public interface UserErrorCodeConstants { // ========== 用户信息模块 1004004100 ========== ErrorCode USER_NOT_EXISTS = new ErrorCode(1004004100, "用户不存在"); - ErrorCode USER_STATUS_NOT_EXISTS = new ErrorCode(1004004101, "用户状态不存在"); ErrorCode USER_STATUS_EQUALS = new ErrorCode(1004004101, "用户已经是该状态"); + ErrorCode USER_MOBILE_EXISTS = new ErrorCode(1004004102, "手机号已经存在"); } diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpc.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpc.java index b4d5b5893..c1f7cc4bc 100644 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpc.java +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpc.java @@ -1,16 +1,16 @@ package cn.iocoder.mall.userservice.rpc.sms; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.userservice.rpc.sms.vo.UserSendSmsCodeDTO; -import cn.iocoder.mall.userservice.rpc.sms.vo.UserVerifySmsCodeDTO; +import cn.iocoder.mall.userservice.rpc.sms.dto.UserSendSmsCodeReqDTO; +import cn.iocoder.mall.userservice.rpc.sms.dto.UserVerifySmsCodeReqDTO; /** * 用户短信验证码 Rpc 接口 */ public interface UserSmsCodeRpc { - CommonResult sendSmsCode(UserSendSmsCodeDTO sendSmsCodeDTO); + CommonResult sendSmsCode(UserSendSmsCodeReqDTO sendSmsCodeDTO); - CommonResult verifySmsCode(UserVerifySmsCodeDTO verifySmsCodeDTO); + CommonResult verifySmsCode(UserVerifySmsCodeReqDTO verifySmsCodeDTO); } diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/vo/UserSendSmsCodeDTO.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserSendSmsCodeReqDTO.java similarity index 82% rename from user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/vo/UserSendSmsCodeDTO.java rename to user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserSendSmsCodeReqDTO.java index 1f77484e4..67d1a39fe 100644 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/vo/UserSendSmsCodeDTO.java +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserSendSmsCodeReqDTO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.userservice.rpc.sms.vo; +package cn.iocoder.mall.userservice.rpc.sms.dto; import cn.iocoder.common.framework.validator.InEnum; import cn.iocoder.mall.userservice.enums.sms.UserSmsSceneEnum; @@ -10,12 +10,12 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; /** - * 用户发送短信验证码 DTO + * 用户发送短信验证码 Request DTO */ @Data @Accessors(chain = true) @Builder -public class UserSendSmsCodeDTO implements Serializable { +public class UserSendSmsCodeReqDTO implements Serializable { /** * 手机号码 diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/vo/UserVerifySmsCodeDTO.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserVerifySmsCodeReqDTO.java similarity index 84% rename from user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/vo/UserVerifySmsCodeDTO.java rename to user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserVerifySmsCodeReqDTO.java index 499498785..4eda0bfd2 100644 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/vo/UserVerifySmsCodeDTO.java +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserVerifySmsCodeReqDTO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.userservice.rpc.sms.vo; +package cn.iocoder.mall.userservice.rpc.sms.dto; import cn.iocoder.common.framework.validator.InEnum; import cn.iocoder.mall.userservice.enums.sms.UserSmsSceneEnum; @@ -10,12 +10,12 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; /** - * 用户校验验证码 DTO + * 用户校验验证码 Request DTO */ @Data @Accessors(chain = true) @Builder -public class UserVerifySmsCodeDTO implements Serializable { +public class UserVerifySmsCodeReqDTO implements Serializable { /** * 手机号码 diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpc.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpc.java index 702a87599..6ebff8f2f 100644 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpc.java +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpc.java @@ -1,13 +1,54 @@ package cn.iocoder.mall.userservice.rpc.user; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.userservice.rpc.user.dto.UserCreateDTO; -import cn.iocoder.mall.userservice.rpc.user.vo.UserVO; +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 { - CommonResult getUser(Integer id); + /** + * 获得用户 + * + * @param userId 用户编号 + * @return 用户 + */ + CommonResult getUser(Integer userId); - CommonResult createUserIfAbsent(UserCreateDTO createDTO); + /** + * 基于手机号创建用户。 + * 如果用户已经存在,则直接进行返回 + * + * @param createDTO 创建用户 DTO + * @return 用户信息 + */ + CommonResult createUserIfAbsent(UserCreateReqDTO createDTO); + + /** + * 更新用户 + * + * @param updateDTO 更新用户 DTO + */ + CommonResult updateUser(UserUpdateReqDTO updateDTO); + + /** + * 获得用户列表 + * + * @param userIds 用户编号列表 + * @return 用户列表 + */ + CommonResult> listUsers(List userIds); + + /** + * 获得用户分页 + * + * @param pageDTO 用户分页查询 + * @return 用户分页结果 + */ + CommonResult> pageUser(UserPageReqDTO pageDTO); } diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserCreateDTO.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserCreateReqDTO.java similarity index 88% rename from user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserCreateDTO.java rename to user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserCreateReqDTO.java index 23d3916fc..4f7e0f924 100644 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserCreateDTO.java +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserCreateReqDTO.java @@ -8,11 +8,11 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; /** - * 用户创建 DTO + * 用户创建 Request DTO */ @Data @Accessors(chain = true) -public class UserCreateDTO implements Serializable { +public class UserCreateReqDTO implements Serializable { /** * 手机号 diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserPageReqDTO.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserPageReqDTO.java new file mode 100644 index 000000000..8a6ee3d13 --- /dev/null +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserPageReqDTO.java @@ -0,0 +1,28 @@ +package cn.iocoder.mall.userservice.rpc.user.dto; + +import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.validator.InEnum; +import cn.iocoder.common.framework.vo.PageParam; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** +* 用户分页 Request DTO +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +public class UserPageReqDTO extends PageParam { + + /** + * 昵称,模糊匹配 + */ + private String nickname; + /** + * 状态 + */ + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") + private Integer status; + +} diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/vo/UserVO.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserRespDTO.java similarity index 80% rename from user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/vo/UserVO.java rename to user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserRespDTO.java index 9b439f1e3..f521bf95e 100644 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/vo/UserVO.java +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserRespDTO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.userservice.rpc.user.vo; +package cn.iocoder.mall.userservice.rpc.user.dto; import cn.iocoder.common.framework.enums.CommonStatusEnum; import lombok.Data; @@ -7,11 +7,11 @@ import lombok.experimental.Accessors; import java.io.Serializable; /** - * 用户响应 + * 用户信息 Response DTO */ @Data @Accessors(chain = true) -public class UserVO implements Serializable { +public class UserRespDTO implements Serializable { /** * 用户编号 diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserUpdateReqDTO.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserUpdateReqDTO.java new file mode 100644 index 000000000..a41a0729a --- /dev/null +++ b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/user/dto/UserUpdateReqDTO.java @@ -0,0 +1,47 @@ +package cn.iocoder.mall.userservice.rpc.user.dto; + +import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.validator.InEnum; +import cn.iocoder.common.framework.validator.Mobile; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** +* 用户更新 Request DTO +*/ +@Data +@Accessors(chain = true) +public class UserUpdateReqDTO implements Serializable { + + /** + * 用户编号 + */ + @NotNull(message = "用户编号不能为空") + private Integer id; + /** + * 昵称 + */ + private String nickname; + /** + * 头像 + */ + private String avatar; + /** + * 状态 + */ + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") + private Integer status; + /** + * 手机号 + */ + @Mobile + private String mobile; + /** + * 加密后的密码 + */ + private String password; + +} diff --git a/user-service-project/user-service-app/pom.xml b/user-service-project/user-service-app/pom.xml index 6452806f2..8a4711ff9 100644 --- a/user-service-project/user-service-app/pom.xml +++ b/user-service-project/user-service-app/pom.xml @@ -17,6 +17,12 @@ spring-cloud-starter-dubbo + + + cn.iocoder.mall + system-service-api + + cn.iocoder.mall diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/config/ServiceExceptionConfiguration.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/config/ServiceExceptionConfiguration.java deleted file mode 100644 index beea88703..000000000 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/config/ServiceExceptionConfiguration.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.mall.userservice.config; - -import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil; -import cn.iocoder.mall.userservice.enums.UserErrorCodeConstants; -import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.event.EventListener; - -import java.util.Arrays; - -@Configuration -public class ServiceExceptionConfiguration { - - @EventListener(ApplicationReadyEvent.class) - public void initMessages() { - Arrays.stream(UserErrorCodeConstants.values()).forEach( - item -> ServiceExceptionUtil.put(item.getCode(), item.getMessage())); - } - -} diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/convert/user/UserConvert.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/convert/user/UserConvert.java index da889d885..0a92402f7 100644 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/convert/user/UserConvert.java +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/convert/user/UserConvert.java @@ -1,26 +1,49 @@ package cn.iocoder.mall.userservice.convert.user; -import cn.iocoder.mall.userservice.rpc.user.dto.UserCreateDTO; +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.UserUpdateReqDTO; import cn.iocoder.mall.userservice.service.user.bo.UserBO; import cn.iocoder.mall.userservice.dal.mysql.dataobject.user.UserDO; -import cn.iocoder.mall.userservice.rpc.user.vo.UserVO; +import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; import cn.iocoder.mall.userservice.service.user.bo.UserCreateBO; +import cn.iocoder.mall.userservice.service.user.bo.UserPageBO; +import cn.iocoder.mall.userservice.service.user.bo.UserUpdateBO; +import com.baomidou.mybatisplus.core.metadata.IPage; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +import java.util.List; + @Mapper public interface UserConvert { UserConvert INSTANCE = Mappers.getMapper(UserConvert.class); - UserVO convert(UserBO bean); + UserRespDTO convert(UserBO bean); UserBO convert(UserDO bean); UserDO convert(UserCreateBO bean); @Mapping(source = "ip", target = "createIp") - UserCreateBO convert(UserCreateDTO createDTO); + UserCreateBO convert(UserCreateReqDTO bean); + + UserDO convert(UserUpdateBO bean); + + @Mapping(source = "records", target = "list") + PageResult convertPage(IPage page); + + UserUpdateBO convert(UserUpdateReqDTO bean); + + List convertList(List list); + + UserPageBO convert(UserPageReqDTO bean); + + PageResult convertPage(PageResult page); + + List convertList02(List list); } diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/dal/mysql/mapper/user/UserMapper.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/dal/mysql/mapper/user/UserMapper.java index 7c8e441e7..2ee8c9820 100644 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/dal/mysql/mapper/user/UserMapper.java +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/dal/mysql/mapper/user/UserMapper.java @@ -1,8 +1,12 @@ package cn.iocoder.mall.userservice.dal.mysql.mapper.user; +import cn.iocoder.mall.mybatis.core.query.QueryWrapperX; import cn.iocoder.mall.userservice.dal.mysql.dataobject.user.UserDO; +import cn.iocoder.mall.userservice.service.user.bo.UserPageBO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.stereotype.Repository; @Repository @@ -14,18 +18,10 @@ public interface UserMapper extends BaseMapper { ); } -// /** -// * 根据条件分页查询用户列表 -// * @param userPageDTO -// * @return -// */ -// default IPage selectUserPage(UserPageDTO userPageDTO) { -// // TODO FROM 芋艿 to jwf1173:看下 QueryWrapperX 噢,已经提供判空啦 [DONE] -// return this.selectPage(new Page<>(userPageDTO.getPageNo(), userPageDTO.getPageSize()), -// new QueryWrapperX() -// .eq(StringUtils.isNotBlank(userPageDTO.getNickname()), "nickname", userPageDTO.getNickname()) -// .eq(null != userPageDTO.getStatus(), "status", userPageDTO.getStatus()) -// ); -// } + default IPage selectPage(UserPageBO pageBO) { + return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()), + new QueryWrapperX().likeIfPresent("nickname", pageBO.getNickname()) + .eqIfPresent("status", pageBO.getStatus())); + } } diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/manager/sms/UserSmsCodeManager.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/manager/sms/UserSmsCodeManager.java index e88170d29..76ac53a28 100644 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/manager/sms/UserSmsCodeManager.java +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/manager/sms/UserSmsCodeManager.java @@ -1,7 +1,7 @@ package cn.iocoder.mall.userservice.manager.sms; -import cn.iocoder.mall.userservice.rpc.sms.vo.UserSendSmsCodeDTO; -import cn.iocoder.mall.userservice.rpc.sms.vo.UserVerifySmsCodeDTO; +import cn.iocoder.mall.userservice.rpc.sms.dto.UserSendSmsCodeReqDTO; +import cn.iocoder.mall.userservice.rpc.sms.dto.UserVerifySmsCodeReqDTO; import cn.iocoder.mall.userservice.service.sms.UserSmsCodeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -12,14 +12,14 @@ public class UserSmsCodeManager { @Autowired private UserSmsCodeService userSmsCodeService; - public void sendSmsCode(UserSendSmsCodeDTO sendSmsCodeDTO) { + public void sendSmsCode(UserSendSmsCodeReqDTO sendSmsCodeDTO) { // 生成短信验证码 String smsCode = userSmsCodeService.createSmsCode(sendSmsCodeDTO.getMobile(), sendSmsCodeDTO.getScene(), sendSmsCodeDTO.getIp()); // TODO 调用发送验证码 } - public void verifySmsCode(UserVerifySmsCodeDTO verifySmsCodeDTO) { + public void verifySmsCode(UserVerifySmsCodeReqDTO verifySmsCodeDTO) { userSmsCodeService.verifySmsCode(verifySmsCodeDTO.getMobile(), verifySmsCodeDTO.getCode(), verifySmsCodeDTO.getScene(), verifySmsCodeDTO.getIp()); } diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/manager/user/UserManager.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/manager/user/UserManager.java index 9f0636a6a..3bb87a444 100644 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/manager/user/UserManager.java +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/manager/user/UserManager.java @@ -1,25 +1,34 @@ package cn.iocoder.mall.userservice.manager.user; +import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.enums.UserTypeEnum; +import cn.iocoder.common.framework.util.StringUtils; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.systemservice.rpc.oauth.OAuth2Rpc; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO; import cn.iocoder.mall.userservice.convert.user.UserConvert; -import cn.iocoder.mall.userservice.rpc.user.dto.UserCreateDTO; -import cn.iocoder.mall.userservice.rpc.user.vo.UserVO; +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 cn.iocoder.mall.userservice.service.user.UserService; import cn.iocoder.mall.userservice.service.user.bo.UserBO; +import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class UserManager { @Autowired private UserService userService; - public UserVO getUser(Integer id) { - UserBO userBO = userService.getUser(id); - return UserConvert.INSTANCE.convert(userBO); - } + @DubboReference(version = "${dubbo.consumer.OAuth2Rpc.version}") + private OAuth2Rpc oauth2Rpc; - public UserVO createUserIfAbsent(UserCreateDTO createDTO) { + public UserRespDTO createUserIfAbsent(UserCreateReqDTO createDTO) { // 用户已经存在 UserBO userBO = userService.getUser(createDTO.getMobile()); if (userBO != null) { @@ -30,4 +39,53 @@ public class UserManager { return UserConvert.INSTANCE.convert(userBO); } + /** + * 更新用户 + * + * @param updateDTO 更新用户 DTO + */ + public void updateUser(UserUpdateReqDTO updateDTO) { + // 更新管理员信息 + userService.updateUser(UserConvert.INSTANCE.convert(updateDTO)); + // 如果修改密码,或者禁用管理员 + if (StringUtils.hasText(updateDTO.getPassword()) + || CommonStatusEnum.DISABLE.getValue().equals(updateDTO.getStatus())) { + oauth2Rpc.removeToken(new OAuth2RemoveTokenByUserReqDTO().setUserId(updateDTO.getId()) + .setUserType(UserTypeEnum.ADMIN.getValue())); + } + } + + /** + * 获得用户 + * + * @param userId 用户编号 + * @return 用户 + */ + public UserRespDTO getUser(Integer userId) { + UserBO userBO = userService.getUser(userId); + return UserConvert.INSTANCE.convert(userBO); + } + + /** + * 获得用户列表 + * + * @param userIds 用户编号列表 + * @return 用户列表 + */ + public List listUsers(List userIds) { + List userBOs = userService.listUsers(userIds); + return UserConvert.INSTANCE.convertList02(userBOs); + } + + /** + * 获得用户分页 + * + * @param pageDTO 用户分页查询 + * @return 用户分页结果 + */ + public PageResult pageUser(UserPageReqDTO pageDTO) { + PageResult pageResultBO = userService.pageUser(UserConvert.INSTANCE.convert(pageDTO)); + return UserConvert.INSTANCE.convertPage(pageResultBO); + } + } diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpcImpl.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpcImpl.java index 95c56bad1..e54618250 100644 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpcImpl.java +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeRpcImpl.java @@ -2,8 +2,8 @@ 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.vo.UserSendSmsCodeDTO; -import cn.iocoder.mall.userservice.rpc.sms.vo.UserVerifySmsCodeDTO; +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; @@ -14,13 +14,13 @@ public class UserSmsCodeRpcImpl implements UserSmsCodeRpc { private UserSmsCodeManager userSmsCodeManager; @Override - public CommonResult sendSmsCode(UserSendSmsCodeDTO sendSmsCodeDTO) { + public CommonResult sendSmsCode(UserSendSmsCodeReqDTO sendSmsCodeDTO) { userSmsCodeManager.sendSmsCode(sendSmsCodeDTO); return CommonResult.success(true); } @Override - public CommonResult verifySmsCode(UserVerifySmsCodeDTO verifySmsCodeDTO) { + public CommonResult verifySmsCode(UserVerifySmsCodeReqDTO verifySmsCodeDTO) { userSmsCodeManager.verifySmsCode(verifySmsCodeDTO); return CommonResult.success(true); } diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpcImpl.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpcImpl.java index 0f048660b..e251bd652 100644 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpcImpl.java +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/rpc/user/UserRpcImpl.java @@ -1,12 +1,17 @@ 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.manager.user.UserManager; -import cn.iocoder.mall.userservice.rpc.user.dto.UserCreateDTO; -import cn.iocoder.mall.userservice.rpc.user.vo.UserVO; +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 java.util.List; + import static cn.iocoder.common.framework.vo.CommonResult.success; @Service(version = "${dubbo.provider.UserRpc.version}", validation = "false") @@ -16,13 +21,29 @@ public class UserRpcImpl implements UserRpc { private UserManager userManager; @Override - public CommonResult getUser(Integer id) { + public CommonResult getUser(Integer id) { return success(userManager.getUser(id)); } @Override - public CommonResult createUserIfAbsent(UserCreateDTO createDTO) { + public CommonResult> listUsers(List userIds) { + return success(userManager.listUsers(userIds)); + } + + @Override + public CommonResult createUserIfAbsent(UserCreateReqDTO createDTO) { return success(userManager.createUserIfAbsent(createDTO)); } + @Override + public CommonResult updateUser(UserUpdateReqDTO updateDTO) { + userManager.updateUser(updateDTO); + return success(true); + } + + @Override + public CommonResult> pageUser(UserPageReqDTO pageDTO) { + return success(userManager.pageUser(pageDTO)); + } + } diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/UserService.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/UserService.java index c8da0629b..2e326e5fd 100644 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/UserService.java +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/UserService.java @@ -1,16 +1,25 @@ package cn.iocoder.mall.userservice.service.user; import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil; import cn.iocoder.common.framework.util.DigestUtils; import cn.iocoder.common.framework.util.StringUtils; +import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.mall.userservice.convert.user.UserConvert; import cn.iocoder.mall.userservice.dal.mysql.dataobject.user.UserDO; import cn.iocoder.mall.userservice.dal.mysql.mapper.user.UserMapper; import cn.iocoder.mall.userservice.service.user.bo.UserBO; import cn.iocoder.mall.userservice.service.user.bo.UserCreateBO; +import cn.iocoder.mall.userservice.service.user.bo.UserPageBO; +import cn.iocoder.mall.userservice.service.user.bo.UserUpdateBO; +import com.baomidou.mybatisplus.core.metadata.IPage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + +import static cn.iocoder.mall.userservice.enums.UserErrorCodeConstants.*; + @Service public class UserService { @@ -22,6 +31,17 @@ public class UserService { return UserConvert.INSTANCE.convert(userDO); } + /** + * 获得用户列表 + * + * @param userIds 用户编号列表 + * @return 用户列表 + */ + public List listUsers(List userIds) { + List userDOs = userMapper.selectBatchIds(userIds); + return UserConvert.INSTANCE.convertList(userDOs); + } + public UserBO getUser(String mobile) { UserDO userDO = userMapper.selectByMobile(mobile); return UserConvert.INSTANCE.convert(userDO); @@ -43,6 +63,45 @@ public class UserService { return UserConvert.INSTANCE.convert(userDO); } + public void updateUser(UserUpdateBO updateBO) { + // 校验用户存在 + UserDO userDO = userMapper.selectById(updateBO.getId()); + if (userDO == null) { + throw ServiceExceptionUtil.exception(USER_NOT_EXISTS); + } + // 校验手机唯一 + if (StringUtils.hasText(updateBO.getMobile())) { + UserDO mobileAdmin = userMapper.selectByMobile(updateBO.getMobile()); + if (mobileAdmin != null && !mobileAdmin.getId().equals(updateBO.getId())) { + throw ServiceExceptionUtil.exception(USER_MOBILE_EXISTS); + } + } + // 如果有更新状态,则校验是否已经是该状态 + if (updateBO.getStatus() != null && updateBO.getStatus().equals(userDO.getStatus())) { + throw ServiceExceptionUtil.exception(USER_STATUS_EQUALS); + } + // 更新到数据库 + UserDO updateUser = UserConvert.INSTANCE.convert(updateBO); + // 如果更新密码,需要特殊加密 + if (StringUtils.hasText(updateBO.getPassword())) { + String passwordSalt = genPasswordSalt(); + String password = encodePassword(updateBO.getPassword(), passwordSalt); + updateUser.setPassword(password).setPasswordSalt(passwordSalt); + } + userMapper.updateById(updateUser); + } + + /** + * 获得用户分页 + * + * @param pageBO 用户分页查询 + * @return 用户分页结果 + */ + public PageResult pageUser(UserPageBO pageBO) { + IPage userDOPage = userMapper.selectPage(pageBO); + return UserConvert.INSTANCE.convertPage(userDOPage); + } + private String genPasswordSalt() { return DigestUtils.genBcryptSalt(); } diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserCreateBO.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserCreateBO.java index 2ad73a31b..6771d4d5d 100644 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserCreateBO.java +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserCreateBO.java @@ -1,5 +1,6 @@ package cn.iocoder.mall.userservice.service.user.bo; +import cn.iocoder.common.framework.validator.Mobile; import lombok.Data; import lombok.experimental.Accessors; @@ -24,6 +25,7 @@ public class UserCreateBO { * 手机 */ @NotNull(message = "手机号不能为空") + @Mobile private String mobile; /** * 原始密码,允许空 diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserPageBO.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserPageBO.java new file mode 100644 index 000000000..ad244cc9f --- /dev/null +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserPageBO.java @@ -0,0 +1,30 @@ +package cn.iocoder.mall.userservice.service.user.bo; + +import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.validator.InEnum; +import cn.iocoder.common.framework.vo.PageParam; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** +* 用户分页 BO +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +public class UserPageBO extends PageParam { + + /** + * 昵称 + * + * 模糊 + */ + private String nickname; + /** + * 状态 + */ + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") + private Integer status; + +} diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserUpdateBO.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserUpdateBO.java new file mode 100644 index 000000000..2480ebdb7 --- /dev/null +++ b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/service/user/bo/UserUpdateBO.java @@ -0,0 +1,46 @@ +package cn.iocoder.mall.userservice.service.user.bo; + +import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.validator.InEnum; +import cn.iocoder.common.framework.validator.Mobile; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** +* 用户更新 BO +*/ +@Data +@Accessors(chain = true) +public class UserUpdateBO { + + /** + * 用户编号 + */ + @NotNull(message = "用户编号不能为空") + private Integer id; + /** + * 昵称 + */ + private String nickname; + /** + * 头像 + */ + private String avatar; + /** + * 状态 + */ + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") + private Integer status; + /** + * 手机号 + */ + @Mobile + private String mobile; + /** + * 密码 + */ + private String password; + +} diff --git a/user-service-project/user-service-app/src/main/resources/application.yaml b/user-service-project/user-service-app/src/main/resources/application.yaml index 7ec437ce3..dcb6a7079 100644 --- a/user-service-project/user-service-app/src/main/resources/application.yaml +++ b/user-service-project/user-service-app/src/main/resources/application.yaml @@ -38,3 +38,7 @@ dubbo: version: 1.0.0 UserSmsCodeRpc: version: 1.0.0 + # Dubbo 服务消费者的配置 + consumer: + OAuth2Rpc: + versoin: 1.0.0 diff --git a/user-web-app/src/main/java/cn/iocoder/mall/userweb/convert/passport/UserPassportConvert.java b/user-web-app/src/main/java/cn/iocoder/mall/userweb/convert/passport/UserPassportConvert.java index 8a7dd6033..a4ab405a4 100644 --- a/user-web-app/src/main/java/cn/iocoder/mall/userweb/convert/passport/UserPassportConvert.java +++ b/user-web-app/src/main/java/cn/iocoder/mall/userweb/convert/passport/UserPassportConvert.java @@ -1,10 +1,10 @@ package cn.iocoder.mall.userweb.convert.passport; -import cn.iocoder.mall.systemservice.rpc.oauth.vo.OAuth2AccessTokenVO; -import cn.iocoder.mall.userservice.rpc.sms.vo.UserSendSmsCodeDTO; -import cn.iocoder.mall.userservice.rpc.sms.vo.UserVerifySmsCodeDTO; -import cn.iocoder.mall.userservice.rpc.user.dto.UserCreateDTO; -import cn.iocoder.mall.userservice.rpc.user.vo.UserVO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; +import cn.iocoder.mall.userservice.rpc.sms.dto.UserSendSmsCodeReqDTO; +import cn.iocoder.mall.userservice.rpc.sms.dto.UserVerifySmsCodeReqDTO; +import cn.iocoder.mall.userservice.rpc.user.dto.UserCreateReqDTO; +import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; import cn.iocoder.mall.userweb.controller.passport.dto.UserPassportLoginBySmsDTO; import cn.iocoder.mall.userweb.controller.passport.dto.UserPassportSendSmsCodeDTO; import cn.iocoder.mall.userweb.controller.passport.vo.UserPassportVO; @@ -16,15 +16,15 @@ public interface UserPassportConvert { UserPassportConvert INSTANCE = Mappers.getMapper(UserPassportConvert.class); - UserVerifySmsCodeDTO convert(UserPassportLoginBySmsDTO bean); - UserCreateDTO convert02(UserPassportLoginBySmsDTO bean); + UserVerifySmsCodeReqDTO convert(UserPassportLoginBySmsDTO bean); + UserCreateReqDTO convert02(UserPassportLoginBySmsDTO bean); - default UserPassportVO convert(UserVO userVO, OAuth2AccessTokenVO accessTokenVO) { + default UserPassportVO convert(UserRespDTO userVO, OAuth2AccessTokenRespDTO accessTokenVO) { return new UserPassportVO().setUser(convert(userVO)).setAuthorization(convert(accessTokenVO)); } - UserPassportVO.User convert(UserVO userVO); - UserPassportVO.Authentication convert(OAuth2AccessTokenVO accessTokenVO); + UserPassportVO.User convert(UserRespDTO userVO); + UserPassportVO.Authentication convert(OAuth2AccessTokenRespDTO accessTokenVO); - UserSendSmsCodeDTO convert(UserPassportSendSmsCodeDTO bean); + UserSendSmsCodeReqDTO convert(UserPassportSendSmsCodeDTO bean); } diff --git a/user-web-app/src/main/java/cn/iocoder/mall/userweb/convert/user/UserConvert.java b/user-web-app/src/main/java/cn/iocoder/mall/userweb/convert/user/UserConvert.java index 4036396fc..e2b8f622f 100644 --- a/user-web-app/src/main/java/cn/iocoder/mall/userweb/convert/user/UserConvert.java +++ b/user-web-app/src/main/java/cn/iocoder/mall/userweb/convert/user/UserConvert.java @@ -1,6 +1,6 @@ package cn.iocoder.mall.userweb.convert.user; -import cn.iocoder.mall.userservice.rpc.user.vo.UserVO; +import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; import cn.iocoder.mall.userweb.controller.user.vo.UserInfoVO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -10,6 +10,6 @@ public interface UserConvert { UserConvert INSTANCE = Mappers.getMapper(UserConvert.class); - UserInfoVO convert(UserVO bean); + UserInfoVO convert(UserRespDTO bean); } diff --git a/user-web-app/src/main/java/cn/iocoder/mall/userweb/manager/passport/UserPassportManager.java b/user-web-app/src/main/java/cn/iocoder/mall/userweb/manager/passport/UserPassportManager.java index 8e88a2f06..18f13674a 100644 --- a/user-web-app/src/main/java/cn/iocoder/mall/userweb/manager/passport/UserPassportManager.java +++ b/user-web-app/src/main/java/cn/iocoder/mall/userweb/manager/passport/UserPassportManager.java @@ -3,12 +3,12 @@ package cn.iocoder.mall.userweb.manager.passport; import cn.iocoder.common.framework.enums.UserTypeEnum; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.systemservice.rpc.oauth.OAuth2Rpc; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenDTO; -import cn.iocoder.mall.systemservice.rpc.oauth.vo.OAuth2AccessTokenVO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; 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.user.vo.UserVO; +import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; import cn.iocoder.mall.userweb.controller.passport.dto.UserPassportLoginBySmsDTO; import cn.iocoder.mall.userweb.controller.passport.dto.UserPassportSendSmsCodeDTO; import cn.iocoder.mall.userweb.controller.passport.vo.UserPassportVO; @@ -32,12 +32,12 @@ public class UserPassportManager { UserPassportConvert.INSTANCE.convert(loginBySmsDTO).setScene(UserSmsSceneEnum.LOGIN_BY_SMS.getValue()).setIp(ip)); verifySmsCodeResult.checkError(); // 获得用户 - CommonResult createUserResult = userRpc.createUserIfAbsent( + CommonResult createUserResult = userRpc.createUserIfAbsent( UserPassportConvert.INSTANCE.convert02(loginBySmsDTO).setIp(ip)); createUserResult.checkError(); // 创建访问令牌 - CommonResult createAccessTokenResult = oauth2Rpc.createAccessToken( - new OAuth2CreateAccessTokenDTO().setUserId(createUserResult.getData().getId()) + CommonResult createAccessTokenResult = oauth2Rpc.createAccessToken( + new OAuth2CreateAccessTokenReqDTO().setUserId(createUserResult.getData().getId()) .setUserType(UserTypeEnum.USER.getValue()).setCreateIp(ip)); createAccessTokenResult.checkError(); // 返回 diff --git a/user-web-app/src/main/java/cn/iocoder/mall/userweb/manager/user/UserManager.java b/user-web-app/src/main/java/cn/iocoder/mall/userweb/manager/user/UserManager.java index 939b16f56..4634d3603 100644 --- a/user-web-app/src/main/java/cn/iocoder/mall/userweb/manager/user/UserManager.java +++ b/user-web-app/src/main/java/cn/iocoder/mall/userweb/manager/user/UserManager.java @@ -2,7 +2,7 @@ package cn.iocoder.mall.userweb.manager.user; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.userservice.rpc.user.UserRpc; -import cn.iocoder.mall.userservice.rpc.user.vo.UserVO; +import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; import cn.iocoder.mall.userweb.controller.user.vo.UserInfoVO; import cn.iocoder.mall.userweb.convert.user.UserConvert; import org.apache.dubbo.config.annotation.Reference; @@ -15,7 +15,7 @@ public class UserManager { private UserRpc userRpc; public UserInfoVO getUser(Integer id) { - CommonResult userResult = userRpc.getUser(id); + CommonResult userResult = userRpc.getUser(id); userResult.checkError(); return UserConvert.INSTANCE.convert(userResult.getData()); } diff --git a/user/pom.xml b/user/pom.xml index a4d6449cd..2357ddc73 100644 --- a/user/pom.xml +++ b/user/pom.xml @@ -18,7 +18,6 @@ user-rest user-rpc user-rpc-api - user-biz-api user-biz diff --git a/user/user-biz-api/pom.xml b/user/user-biz-api/pom.xml deleted file mode 100644 index fec19c094..000000000 --- a/user/user-biz-api/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - user - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - user-biz-api - - - - - cn.iocoder.mall - common-framework - 1.0-SNAPSHOT - - - \ No newline at end of file diff --git a/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/bo/package-info.java b/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/bo/package-info.java deleted file mode 100644 index d4260b548..000000000 --- a/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/bo/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * author: sin - * time: 2020/5/3 8:31 下午 - */ -package cn.iocoder.mall.user.biz.bo; \ No newline at end of file diff --git a/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/convert/package-info.java b/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/convert/package-info.java deleted file mode 100644 index 05c3a5f0d..000000000 --- a/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/convert/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * author: sin - * time: 2020/5/3 8:31 下午 - */ -package cn.iocoder.mall.user.biz.convert; \ No newline at end of file diff --git a/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/dao/package-info.java b/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/dao/package-info.java deleted file mode 100644 index f48f317d3..000000000 --- a/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/dao/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * author: sin - * time: 2020/5/3 8:28 下午 - */ -package cn.iocoder.mall.user.biz.dao; \ No newline at end of file diff --git a/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/dataobject/package-info.java b/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/dataobject/package-info.java deleted file mode 100644 index 8d97d97b4..000000000 --- a/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/dataobject/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * author: sin - * time: 2020/5/3 8:27 下午 - */ -package cn.iocoder.mall.user.biz.dataobject; \ No newline at end of file diff --git a/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/dto/package-info.java b/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/dto/package-info.java deleted file mode 100644 index 0a7a48c4f..000000000 --- a/user/user-biz/src/main/java/cn/iocoder/mall/user/biz/dto/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * author: sin - * time: 2020/5/3 8:29 下午 - */ -package cn.iocoder.mall.user.biz.dto; \ No newline at end of file diff --git a/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/bo/user/UserAuthenticationBO.java b/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/bo/user/UserAuthenticationBO.java deleted file mode 100644 index 50b942051..000000000 --- a/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/bo/user/UserAuthenticationBO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.mall.user.api.bo.user; - -import cn.iocoder.mall.system.api.bo.oauth2.OAuth2AccessTokenBO; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -@ApiModel("用户认证 BO") -@Data -@Accessors(chain = true) -public class UserAuthenticationBO { - - @ApiModelProperty(value = "用户编号", required = true, example = "1") - private Integer id; - - @ApiModelProperty(value = "昵称", required = true, example = "小王") - private String nickname; - - private OAuth2AccessTokenBO token; - -} diff --git a/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/dto/user/UserAuthenticationByMobileCodeDTO.java b/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/dto/user/UserAuthenticationByMobileCodeDTO.java deleted file mode 100644 index c63ca07ed..000000000 --- a/user/user-service-api/src/main/java/cn/iocoder/mall/user/api/dto/user/UserAuthenticationByMobileCodeDTO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.mall.user.api.dto.user; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; - -@ApiModel("用户认证 DTO") -@Data -@Accessors(chain = true) -public class UserAuthenticationByMobileCodeDTO { - - @ApiModelProperty(value = "手机号", required = true, example = "15601691300") - @NotEmpty(message = "手机号不能为空") - @Length(min = 11, max = 11, message = "账号长度为 11 位") - @Pattern(regexp = "^[0-9]+$", message = "手机号必须都是数字") - private String mobile; - - @ApiModelProperty(value = "手机验证码", required = true, example = "1024") - @NotEmpty(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - -} diff --git a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/convert/UserConvert.java b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/convert/UserConvert.java deleted file mode 100644 index ea9bb8dff..000000000 --- a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/convert/UserConvert.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.mall.user.biz.convert; - -import cn.iocoder.mall.user.api.bo.user.UserAuthenticationBO; -import cn.iocoder.mall.user.api.bo.UserBO; -import cn.iocoder.mall.user.api.dto.UserUpdateDTO; -import cn.iocoder.mall.user.biz.dataobject.UserDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface UserConvert { - - UserConvert INSTANCE = Mappers.getMapper(UserConvert.class); - - @Mappings({}) - UserBO convert(UserDO userDO); - - @Mappings({}) - UserAuthenticationBO convert2(UserDO userDO); - - @Mappings({}) - UserDO convert(UserUpdateDTO userUpdateDTO); - - @Mappings({}) - List convert(List userDOs); - -} diff --git a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/UserMapper.java b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/UserMapper.java deleted file mode 100644 index 62c21b83d..000000000 --- a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/UserMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.mall.user.biz.dao; - -import cn.iocoder.mall.user.biz.dataobject.UserDO; -import org.apache.ibatis.annotations.Param; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface UserMapper { - - void insert(UserDO entity); - - int update(UserDO entity); - - UserDO selectByMobile(@Param("mobile") String mobile); - - UserDO selectById(@Param("id") Integer id); - - List selectListByNicknameLike(@Param("nickname") String nickname, - @Param("status") Integer status, - @Param("offset") Integer offset, - @Param("limit") Integer limit); - - Integer selectCountByNicknameLike(@Param("nickname") String nickname, - @Param("status") Integer status); - -} diff --git a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/UserRegisterMapper.java b/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/UserRegisterMapper.java deleted file mode 100644 index 633e822e9..000000000 --- a/user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/dao/UserRegisterMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.mall.user.biz.dao; - -import cn.iocoder.mall.user.biz.dataobject.UserRegisterDO; -import org.springframework.stereotype.Repository; - -@Repository -public interface UserRegisterMapper { - - void insert(UserRegisterDO entity); - -} \ No newline at end of file diff --git a/user/user-start/src/main/java/cn/iocoder/mall/user/application/controller/admins/AdminsUserController.java b/user/user-start/src/main/java/cn/iocoder/mall/user/application/controller/admins/AdminsUserController.java deleted file mode 100644 index 483af9637..000000000 --- a/user/user-start/src/main/java/cn/iocoder/mall/user/application/controller/admins/AdminsUserController.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.mall.user.application.controller.admins; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.user.api.UserService; -import cn.iocoder.mall.user.api.bo.UserPageBO; -import cn.iocoder.mall.user.api.dto.UserPageDTO; -import cn.iocoder.mall.user.api.dto.UserUpdateDTO; -import cn.iocoder.mall.user.application.convert.UserConvert; -import cn.iocoder.mall.user.application.vo.admins.AdminsUserPageVO; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import org.apache.dubbo.config.annotation.Reference; -import org.springframework.web.bind.annotation.*; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -@RestController -@RequestMapping("/admins/user") -@Api("用户模块") -public class AdminsUserController { - - @Reference(validation = "true", version = "${dubbo.provider.UserService.version}") - private UserService userService; - - // 分页 - @GetMapping("/page") - @ApiOperation(value = "用户分页") - @ApiImplicitParams({ - @ApiImplicitParam(name = "nickname", value = "昵称,模糊匹配", example = "小王"), - @ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"), - @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"), - }) - public CommonResult page(@RequestParam(value = "nickname", required = false) String nickname, - @RequestParam(value = "status", required = false) Integer status, - @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { - UserPageDTO userPageDTO = new UserPageDTO().setNickname(nickname).setStatus(status) - .setPageNo(pageNo).setPageSize(pageSize); - // 查询分页 - UserPageBO result = userService.getUserPage(userPageDTO); - // 转换结果 - return success(UserConvert.INSTANCE.convert(result)); - } - - @PostMapping("/update") - @ApiOperation(value = "更新用户基本信息") - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "用户编号", required = true, example = "1"), - @ApiImplicitParam(name = "nickname", value = "昵称", required = true, example = "小王"), - @ApiImplicitParam(name = "avatar", value = "头像", required = true, example = "http://www.iocoder.cn/xxx.jpg"), - }) - public CommonResult update(@RequestParam("id") Integer id, - @RequestParam("nickname") String nickname, - @RequestParam("avatar") String avatar) { - UserUpdateDTO userUpdateDTO = new UserUpdateDTO().setId(id).setNickname(nickname).setNickname(nickname).setAvatar(avatar); - // 更新 - return success(userService.updateUser(userUpdateDTO)); - } - - @PostMapping("/update_status") - @ApiOperation(value = "更新用户状态") - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "用户编号", required = true, example = "1"), - @ApiImplicitParam(name = "status", value = "状态。1 - 开启;2 - 禁用", required = true, example = "1"), - }) - public CommonResult updateStatus(@RequestParam("id") Integer id, - @RequestParam("status") Integer status) { - return success(userService.updateUserStatus(id, status)); - } - -} diff --git a/user/user-start/src/main/java/cn/iocoder/mall/user/application/convert/UserAddressConvert.java b/user/user-start/src/main/java/cn/iocoder/mall/user/application/convert/UserAddressConvert.java deleted file mode 100644 index 84fe3fb12..000000000 --- a/user/user-start/src/main/java/cn/iocoder/mall/user/application/convert/UserAddressConvert.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.mall.user.application.convert; - -import cn.iocoder.mall.user.application.po.UserAddressAddPO; -import cn.iocoder.mall.user.application.po.UserAddressUpdatePO; -import cn.iocoder.mall.user.api.dto.UserAddressAddDTO; -import cn.iocoder.mall.user.api.dto.UserAddressUpdateDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -/** - * @author Sin - * @time 2019-04-06 14:19 - */ -@Mapper -public interface UserAddressConvert { - - UserAddressConvert INSTANCE = Mappers.getMapper(UserAddressConvert.class); - - @Mappings({}) - UserAddressAddDTO convert(UserAddressAddPO userAddressAddPO); - - @Mappings({}) - UserAddressUpdateDTO convert(UserAddressUpdatePO userAddressUpdatePO); -} diff --git a/user/user-start/src/main/java/cn/iocoder/mall/user/application/vo/admins/AdminsUserPageVO.java b/user/user-start/src/main/java/cn/iocoder/mall/user/application/vo/admins/AdminsUserPageVO.java deleted file mode 100644 index 4d016299c..000000000 --- a/user/user-start/src/main/java/cn/iocoder/mall/user/application/vo/admins/AdminsUserPageVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.mall.user.application.vo.admins; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.List; - -@ApiModel("用户分页 VO") -@Data -@Accessors(chain = true) -public class AdminsUserPageVO { - - @ApiModelProperty(value = "用户数组") - private List list; - @ApiModelProperty(value = "用户总数") - private Integer total; - -} diff --git a/user/user-start/src/main/java/cn/iocoder/mall/user/application/vo/admins/AdminsUserVO.java b/user/user-start/src/main/java/cn/iocoder/mall/user/application/vo/admins/AdminsUserVO.java deleted file mode 100644 index 04f1af62c..000000000 --- a/user/user-start/src/main/java/cn/iocoder/mall/user/application/vo/admins/AdminsUserVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.mall.user.application.vo.admins; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.Date; - -@ApiModel("用户 VO") -@Data -@Accessors(chain = true) -public class AdminsUserVO { - - @ApiModelProperty(value = "用户编号", required = true, example = "1") - private Integer id; - @ApiModelProperty(value = "手机号", required = true, example = "15601691300") - private String mobile; - @ApiModelProperty(value = "昵称", required = true, example = "小王") - private String nickname; - @ApiModelProperty(value = "头像", required = true, example = "http://www.iocoder.cn/xxx.jpg") - private String avatar; - @ApiModelProperty(value = "账号状态", required = true, example = "1") - private Integer status; - @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") - private Date createTime; - -}