From f4a5a139b5719dbcde750fbb2f97de15bbda10cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E5=A4=A9?= <2982176321@qq.com> Date: Sun, 24 Oct 2021 22:33:32 +0800 Subject: [PATCH] =?UTF-8?q?[update]user=20server=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B5=8B=E8=AF=95=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=8E=A5=E5=8F=A3=E8=A7=84=E8=8C=83=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/file/InfFileController.java | 2 +- .../controller/file/vo/InfFilePageReqVO.java | 2 +- .../infra/dal/mysql/file/InfFileMapper.java | 24 ++++ .../infra/service/file/InfFileService.java | 2 +- .../service/file/impl/InfFileServiceImpl.java | 9 +- .../service/file/InfFileServiceTest.java | 2 +- .../dal/mysql/file/InfFileCoreMapper.java | 12 -- .../system/enums/SysErrorCodeConstants.java | 2 +- .../user/SysUserProfileController.http | 4 +- .../user/SysUserProfileController.java | 17 +-- ...InfoRespVO.java => MbrUserInfoRespVO.java} | 2 +- .../member/enums/MbrErrorCodeConstants.java | 4 +- .../member/service/user/MbrUserService.java | 6 +- .../service/user/impl/MbrUserServiceImpl.java | 8 +- .../yudao/userserver/BaseDbUnitTest.java | 39 +++++++ .../service/MbrUserServiceImplTest.java | 107 ++++++++++++++++++ .../test/resources/application-unit-test.yaml | 44 +++++++ .../src/test/resources/file/erweima.jpg | Bin 0 -> 18385 bytes .../src/test/resources/logback-spring.xml | 4 + .../src/test/resources/sql/clean.sql | 2 + .../src/test/resources/sql/create_tables.sql | 32 ++++++ 21 files changed, 279 insertions(+), 45 deletions(-) rename {yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice => yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver}/modules/infra/controller/file/vo/InfFilePageReqVO.java (94%) create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/file/InfFileMapper.java rename yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/vo/{SysUserInfoRespVO.java => MbrUserInfoRespVO.java} (94%) create mode 100644 yudao-user-server/src/test/java/cn/iocoder/yudao/userserver/BaseDbUnitTest.java create mode 100644 yudao-user-server/src/test/java/cn/iocoder/yudao/userserver/modules/member/service/MbrUserServiceImplTest.java create mode 100644 yudao-user-server/src/test/resources/application-unit-test.yaml create mode 100644 yudao-user-server/src/test/resources/file/erweima.jpg create mode 100644 yudao-user-server/src/test/resources/logback-spring.xml create mode 100644 yudao-user-server/src/test/resources/sql/clean.sql create mode 100644 yudao-user-server/src/test/resources/sql/create_tables.sql diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/file/InfFileController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/file/InfFileController.java index d0f31429a..b2a49d6e1 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/file/InfFileController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/file/InfFileController.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.infra.controller.file; import cn.hutool.core.io.IoUtil; import cn.iocoder.yudao.adminserver.modules.infra.service.file.InfFileService; -import cn.iocoder.yudao.coreservice.modules.infra.controller.file.vo.InfFilePageReqVO; +import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; import cn.iocoder.yudao.coreservice.modules.infra.controller.file.vo.InfFileRespVO; import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; import cn.iocoder.yudao.framework.common.pojo.CommonResult; diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/controller/file/vo/InfFilePageReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/file/vo/InfFilePageReqVO.java similarity index 94% rename from yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/controller/file/vo/InfFilePageReqVO.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/file/vo/InfFilePageReqVO.java index 8e43b6642..152466a19 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/controller/file/vo/InfFilePageReqVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/file/vo/InfFilePageReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.coreservice.modules.infra.controller.file.vo; +package cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.annotations.ApiModel; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/file/InfFileMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/file/InfFileMapper.java new file mode 100644 index 000000000..d3dfcccbb --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/file/InfFileMapper.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.file; + +import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; +import org.apache.ibatis.annotations.Mapper; + +/** + * admin 文件操作 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface InfFileMapper extends BaseMapperX { + default PageResult selectPage(InfFilePageReqVO reqVO) { + return selectPage(reqVO, new QueryWrapperX() + .likeIfPresent("id", reqVO.getId()) + .likeIfPresent("type", reqVO.getType()) + .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) + .orderByDesc("create_time")); + } +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileService.java index 136175112..a98fd16a7 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileService.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.file; -import cn.iocoder.yudao.coreservice.modules.infra.controller.file.vo.InfFilePageReqVO; +import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/impl/InfFileServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/impl/InfFileServiceImpl.java index 9598d0481..69b4cf0db 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/impl/InfFileServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/impl/InfFileServiceImpl.java @@ -1,9 +1,9 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.file.impl; +import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.file.InfFileMapper; import cn.iocoder.yudao.adminserver.modules.infra.service.file.InfFileService; -import cn.iocoder.yudao.coreservice.modules.infra.controller.file.vo.InfFilePageReqVO; +import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; -import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.file.InfFileCoreMapper; import cn.iocoder.yudao.coreservice.modules.infra.service.file.InfFileCoreService; import cn.iocoder.yudao.framework.common.pojo.PageResult; import org.springframework.stereotype.Service; @@ -17,8 +17,9 @@ import javax.annotation.Resource; */ @Service public class InfFileServiceImpl implements InfFileService { + @Resource - private InfFileCoreMapper fileCoreMapper; + private InfFileMapper fileMapper; @Resource private InfFileCoreService fileCoreService; @@ -40,7 +41,7 @@ public class InfFileServiceImpl implements InfFileService { @Override public PageResult getFilePage(InfFilePageReqVO pageReqVO) { - return fileCoreMapper.selectPage(pageReqVO); + return fileMapper.selectPage(pageReqVO); } } diff --git a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileServiceTest.java b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileServiceTest.java index 0b25d4f6e..ca92bc7d9 100644 --- a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileServiceTest.java +++ b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileServiceTest.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.file; import cn.hutool.core.io.resource.ResourceUtil; import cn.iocoder.yudao.adminserver.BaseDbUnitTest; -import cn.iocoder.yudao.coreservice.modules.infra.controller.file.vo.InfFilePageReqVO; +import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.file.InfFileCoreMapper; import cn.iocoder.yudao.coreservice.modules.infra.service.file.impl.InfFileCoreServiceImpl; diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/file/InfFileCoreMapper.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/file/InfFileCoreMapper.java index 775d81eba..88266caae 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/file/InfFileCoreMapper.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/file/InfFileCoreMapper.java @@ -1,10 +1,7 @@ package cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.file; -import cn.iocoder.yudao.coreservice.modules.infra.controller.file.vo.InfFilePageReqVO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import org.apache.ibatis.annotations.Mapper; @Mapper @@ -12,13 +9,4 @@ public interface InfFileCoreMapper extends BaseMapperX { default Integer selectCountById(String id) { return selectCount("id", id); } - - default PageResult selectPage(InfFilePageReqVO reqVO) { - return selectPage(reqVO, new QueryWrapperX() - .likeIfPresent("id", reqVO.getId()) - .likeIfPresent("type", reqVO.getType()) - .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) - .orderByDesc("create_time")); - } - } diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/SysErrorCodeConstants.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/SysErrorCodeConstants.java index 60249398c..09a3e7204 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/SysErrorCodeConstants.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/SysErrorCodeConstants.java @@ -14,7 +14,7 @@ public interface SysErrorCodeConstants { ErrorCode SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS = new ErrorCode(1006000001, "模板参数({})缺失"); ErrorCode SMS_SEND_TEMPLATE_NOT_EXISTS = new ErrorCode(1006000000, "短信模板不存在"); - // 文件相关 + // ========= 文件相关 1006001000================= ErrorCode FILE_PATH_EXISTS = new ErrorCode(1006001000, "文件路径已存在"); ErrorCode FILE_NOT_EXISTS = new ErrorCode(1006001002, "文件不存在"); } diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.http b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.http index d8fd6f8dd..1ce9eea62 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.http +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.http @@ -3,9 +3,9 @@ GET {{userServerUrl}}/system/user/profile/get Authorization: Bearer test245 ### 请求 /system/user/profile/revise-nickname 接口 成功 -PUT http://localhost:28080/api/system/user/profile/update-nickname?nickName=yunai222 +PUT {{userServerUrl}}/system/user/profile/update-nickname?nickName=yunai222 Authorization: Bearer test245 ### 请求 /system/user/profile/get-user-info 接口 成功 -GET http://localhost:28080/api/system/user/profile/get-user-info?id=245 +GET {{userServerUrl}}/system/user/profile/get-user-info?id=245 Authorization: Bearer test245 \ No newline at end of file diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.java index 9619f405f..11c5f706a 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.userserver.modules.member.controller.user; -import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.SysUserInfoRespVO; +import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.MbrUserInfoRespVO; import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; @@ -30,13 +30,6 @@ public class SysUserProfileController { @Resource private MbrUserService userService; - @GetMapping("/get") - @ApiOperation("获得登录用户信息") - @PreAuthenticated - public CommonResult profile() { - return null; - } - @PutMapping("/update-nickname") @ApiOperation("修改用户昵称") @PreAuthenticated @@ -45,21 +38,21 @@ public class SysUserProfileController { return success(true); } - @PutMapping("/revise-avatar") + @PutMapping("/update-avatar") @ApiOperation("修改用户头像") @PreAuthenticated - public CommonResult reviseAvatar(@RequestParam("avatarFile") MultipartFile file) throws IOException { + public CommonResult updateAvatar(@RequestParam("avatarFile") MultipartFile file) throws IOException { if (file.isEmpty()) { throw ServiceExceptionUtil.exception(FILE_IS_EMPTY); } - String avatar = userService.reviseAvatar(getLoginUserId(), file.getInputStream()); + String avatar = userService.updateAvatar(getLoginUserId(), file.getInputStream()); return success(avatar); } @GetMapping("/get-user-info") @ApiOperation("获取用户头像与昵称") @PreAuthenticated - public CommonResult getUserInfo() { + public CommonResult getUserInfo() { return success(userService.getUserInfo(getLoginUserId())); } } diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/vo/SysUserInfoRespVO.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/vo/MbrUserInfoRespVO.java similarity index 94% rename from yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/vo/SysUserInfoRespVO.java rename to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/vo/MbrUserInfoRespVO.java index 0468960bd..e46bd410f 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/vo/SysUserInfoRespVO.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/vo/MbrUserInfoRespVO.java @@ -10,7 +10,7 @@ import lombok.NoArgsConstructor; @Data @NoArgsConstructor @AllArgsConstructor -public class SysUserInfoRespVO { +public class MbrUserInfoRespVO { @ApiModelProperty(value = "用户昵称", required = true, example = "芋艿") private String nickName; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/enums/MbrErrorCodeConstants.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/enums/MbrErrorCodeConstants.java index d6a3c11b2..3794eb09d 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/enums/MbrErrorCodeConstants.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/enums/MbrErrorCodeConstants.java @@ -9,9 +9,9 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; */ public interface MbrErrorCodeConstants { - // ==========用户相关============ + // ==========用户相关 1004001000============ ErrorCode USER_NOT_EXISTS = new ErrorCode(1004001000, "用户不存在"); - // ==========文件相关 =========== + // ==========文件相关 1004002000 =========== ErrorCode FILE_IS_EMPTY = new ErrorCode(1004002000, "文件为空"); } diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/MbrUserService.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/MbrUserService.java index 32073540b..6b6a36a8e 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/MbrUserService.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/MbrUserService.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.userserver.modules.member.service.user; import cn.iocoder.yudao.coreservice.modules.member.dal.dataobject.user.MbrUserDO; -import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.SysUserInfoRespVO; +import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.MbrUserInfoRespVO; import cn.iocoder.yudao.framework.common.validation.Mobile; import java.io.InputStream; @@ -60,13 +60,13 @@ public interface MbrUserService { * @param inputStream 头像文件 * @return 头像url */ - String reviseAvatar(Long userId, InputStream inputStream); + String updateAvatar(Long userId, InputStream inputStream); /** * 根据用户id,获取用户头像与昵称 * @param userId 用户id * @return 用户响应实体类 */ - SysUserInfoRespVO getUserInfo(Long userId); + MbrUserInfoRespVO getUserInfo(Long userId); } diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/impl/MbrUserServiceImpl.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/impl/MbrUserServiceImpl.java index 3f2531067..5bff9d6cb 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/impl/MbrUserServiceImpl.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/impl/MbrUserServiceImpl.java @@ -4,7 +4,7 @@ import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.IdUtil; import cn.iocoder.yudao.coreservice.modules.infra.service.file.InfFileCoreService; import cn.iocoder.yudao.coreservice.modules.member.dal.dataobject.user.MbrUserDO; -import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.SysUserInfoRespVO; +import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.MbrUserInfoRespVO; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.userserver.modules.member.dal.mysql.user.MbrUserMapper; import cn.iocoder.yudao.userserver.modules.member.service.user.MbrUserService; @@ -93,7 +93,7 @@ public class MbrUserServiceImpl implements MbrUserService { } @Override - public String reviseAvatar(Long userId, InputStream avatarFile) { + public String updateAvatar(Long userId, InputStream avatarFile) { this.checkUserExists(userId); // 创建文件 String avatar = fileCoreService.createFile(IdUtil.fastUUID(), IoUtil.readBytes(avatarFile)); @@ -107,9 +107,9 @@ public class MbrUserServiceImpl implements MbrUserService { } @Override - public SysUserInfoRespVO getUserInfo(Long userId) { + public MbrUserInfoRespVO getUserInfo(Long userId) { MbrUserDO user = this.checkUserExists(userId); - SysUserInfoRespVO userResp = new SysUserInfoRespVO(); + MbrUserInfoRespVO userResp = new MbrUserInfoRespVO(); userResp.setNickName(user.getNickname()); userResp.setAvatar(user.getAvatar()); return userResp; diff --git a/yudao-user-server/src/test/java/cn/iocoder/yudao/userserver/BaseDbUnitTest.java b/yudao-user-server/src/test/java/cn/iocoder/yudao/userserver/BaseDbUnitTest.java new file mode 100644 index 000000000..af8d71a0c --- /dev/null +++ b/yudao-user-server/src/test/java/cn/iocoder/yudao/userserver/BaseDbUnitTest.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.userserver; + +import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; +import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; +import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.jdbc.Sql; + +/** + * 依赖内存 DB 的单元测试 + * + * 注意,Service 层同样适用。对于 Service 层的单元测试,我们针对自己模块的 Mapper 走的是 H2 内存数据库,针对别的模块的 Service 走的是 Mock 方法 + * + * @author 芋道源码 + */ +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbUnitTest.Application.class) +@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件 +@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) // 每个单元测试结束后,清理 DB +public class BaseDbUnitTest { + + @Import({ + // DB 配置类 + YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 + DataSourceAutoConfiguration.class, // Spring DB 自动配置类 + DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 + DruidDataSourceAutoConfigure.class, // Druid 自动配置类 + // MyBatis 配置类 + YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 + MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 + }) + public static class Application { + } + +} diff --git a/yudao-user-server/src/test/java/cn/iocoder/yudao/userserver/modules/member/service/MbrUserServiceImplTest.java b/yudao-user-server/src/test/java/cn/iocoder/yudao/userserver/modules/member/service/MbrUserServiceImplTest.java new file mode 100644 index 000000000..3639c25db --- /dev/null +++ b/yudao-user-server/src/test/java/cn/iocoder/yudao/userserver/modules/member/service/MbrUserServiceImplTest.java @@ -0,0 +1,107 @@ +package cn.iocoder.yudao.userserver.modules.member.service; + +import cn.iocoder.yudao.coreservice.modules.infra.service.file.InfFileCoreService; +import cn.iocoder.yudao.coreservice.modules.member.dal.dataobject.user.MbrUserDO; +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; +import cn.iocoder.yudao.userserver.BaseDbUnitTest; +import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.MbrUserInfoRespVO; +import cn.iocoder.yudao.userserver.modules.member.dal.mysql.user.MbrUserMapper; +import cn.iocoder.yudao.userserver.modules.member.service.user.impl.MbrUserServiceImpl; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; +import org.springframework.http.MediaType; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.util.Assert; + +import javax.annotation.Resource; +import java.io.*; +import java.util.function.Consumer; + +import static cn.hutool.core.util.RandomUtil.randomBytes; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static cn.hutool.core.util.RandomUtil.randomEle; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; +import static org.mockito.Mockito.*; +/** + * {@link MbrUserServiceImpl} 的单元测试类 + * + * @author 宋天 + */ +@Import(MbrUserServiceImpl.class) +public class MbrUserServiceImplTest extends BaseDbUnitTest { + + @Resource + private MbrUserServiceImpl mbrUserService; + + @Resource + private MbrUserMapper userMapper; + + @MockBean + private InfFileCoreService fileCoreService; + + @MockBean + private PasswordEncoder passwordEncoder; + + @Test + public void testUpdateNickName_success(){ + // mock 数据 + MbrUserDO userDO = randomMbrUserDO(); + userMapper.insert(userDO); + + // 随机昵称 + String newNickName = randomString(); + + // 调用接口修改昵称 + mbrUserService.updateNickname(userDO.getId(),newNickName); + // 查询新修改后的昵称 + String nickname = mbrUserService.getUser(userDO.getId()).getNickname(); + // 断言 + assertEquals(newNickName,nickname); + } + + @Test + public void testGetUserInfo_success(){ + // mock 数据 + MbrUserDO userDO = randomMbrUserDO(); + userMapper.insert(userDO); + + // 查询用户昵称与头像 + MbrUserInfoRespVO userInfo = mbrUserService.getUserInfo(userDO.getId()); + System.out.println(userInfo); + } + + @Test + public void testUpdateAvatar_success(){ + // mock 数据 + MbrUserDO dbUser = randomMbrUserDO(); + userMapper.insert(dbUser); + + // 准备参数 + Long userId = dbUser.getId(); + byte[] avatarFileBytes = randomBytes(10); + ByteArrayInputStream avatarFile = new ByteArrayInputStream(avatarFileBytes); + // mock 方法 + String avatar = randomString(); + when(fileCoreService.createFile(anyString(), eq(avatarFileBytes))).thenReturn(avatar); + // 调用 + String str = mbrUserService.updateAvatar(userId, avatarFile); + // 断言 + assertEquals(avatar, str); + } + + // ========== 随机对象 ========== + + @SafeVarargs + private static MbrUserDO randomMbrUserDO(Consumer... consumers) { + Consumer consumer = (o) -> { + o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 + }; + return randomPojo(MbrUserDO.class, ArrayUtils.append(consumer, consumers)); + } + +} diff --git a/yudao-user-server/src/test/resources/application-unit-test.yaml b/yudao-user-server/src/test/resources/application-unit-test.yaml new file mode 100644 index 000000000..d306a7af4 --- /dev/null +++ b/yudao-user-server/src/test/resources/application-unit-test.yaml @@ -0,0 +1,44 @@ +spring: + main: + lazy-initialization: true # 开启懒加载,加快速度 + banner-mode: off # 单元测试,禁用 Banner + +--- #################### 数据库相关配置 #################### + +spring: + # 数据源配置项 + datasource: + name: ruoyi-vue-pro + url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 + driver-class-name: org.h2.Driver + username: sa + password: + schema: classpath:sql/create_tables.sql # MySQL 转 H2 的语句,使用 https://www.jooq.org/translate/ 工具 + druid: + async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 + initial-size: 1 # 单元测试,配置为 1,提升启动速度 + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + redis: + host: 127.0.0.1 # 地址 + port: 16379 # 端口(单元测试,使用 16379 端口) + database: 0 # 数据库索引 + +mybatis: + lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 + +--- #################### 定时任务相关配置 #################### + +--- #################### 配置中心相关配置 #################### + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项(单元测试,禁用 Lock4j) + +# Resilience4j 配置项 + +--- #################### 监控相关配置 #################### + +--- #################### 芋道相关配置 #################### + +# 芋道配置项,设置当前项目所有自定义的配置 diff --git a/yudao-user-server/src/test/resources/file/erweima.jpg b/yudao-user-server/src/test/resources/file/erweima.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1447283cdf1b49b51c1204a160e01cb789e957a8 GIT binary patch literal 18385 zcmb7s2Rzm9+yCL%A+xNq$sv0yBYV$7${yL72_=by>^(#Fv7$0Ev!kp?5wb^FWrg_P zpQHMH%lG#@|3|%E9nLwQao^YbdXMYm@crQ@7>SC4vH}bP0|vtYe_)5BFj*KJ6BGIi zzOcYwY&>jiEG%pSTwEMHLIOg<69gwt5D}A+5D}9SpEyBsiiDJ$f|8Pw@Z@Q#Qxs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xu^+(Dx0;X-q zTq>8_S*A7W8(3U)c~eXqzGG$a`R-OiC#P=WSEfxkG&=-_PhOeqmGvKK*CVHjxOBZ@ pEwzL`>i*8R__Kv1*C}gmHZq>QI%40h(qzO + + + diff --git a/yudao-user-server/src/test/resources/sql/clean.sql b/yudao-user-server/src/test/resources/sql/clean.sql new file mode 100644 index 000000000..bedf8d008 --- /dev/null +++ b/yudao-user-server/src/test/resources/sql/clean.sql @@ -0,0 +1,2 @@ +-- mbr 开头的 DB +DELETE FROM "mbr_user"; \ No newline at end of file diff --git a/yudao-user-server/src/test/resources/sql/create_tables.sql b/yudao-user-server/src/test/resources/sql/create_tables.sql new file mode 100644 index 000000000..306900101 --- /dev/null +++ b/yudao-user-server/src/test/resources/sql/create_tables.sql @@ -0,0 +1,32 @@ +-- mbr 开头的 DB +CREATE TABLE IF NOT EXISTS "mbr_user" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '编号', + "nickname" varchar(30) NOT NULL DEFAULT '' COMMENT '用户昵称', + "avatar" varchar(255) NOT NULL DEFAULT '' COMMENT '头像', + "status" tinyint NOT NULL COMMENT '状态', + "mobile" varchar(11) NOT NULL COMMENT '手机号', + "password" varchar(100) NOT NULL DEFAULT '' COMMENT '密码', + "register_ip" varchar(32) NOT NULL COMMENT '注册 IP', + "login_ip" varchar(50) NULL DEFAULT '' COMMENT '最后登录IP', + "login_date" datetime NULL DEFAULT NULL COMMENT '最后登录时间', + "creator" varchar(64) NULL DEFAULT '' COMMENT '创建者', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + "updater" varchar(64) NULL DEFAULT '' COMMENT '更新者', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + "deleted" bit(1) NOT NULL DEFAULT '0' COMMENT '是否删除', + PRIMARY KEY ("id") +) COMMENT '会员表'; + +-- inf 开头的 DB +CREATE TABLE IF NOT EXISTS "inf_file" ( + "id" varchar(188) NOT NULL, + "type" varchar(63) DEFAULT NULL, + "content" blob NOT NULL, + "creator" varchar(64) DEFAULT '', + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '', + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '文件表'; +