mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
[update]更新代码规范
This commit is contained in:
parent
c06d6e53f6
commit
79da36ac04
@ -1,12 +1,12 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.infra.controller.file;
|
package cn.iocoder.yudao.adminserver.modules.infra.controller.file;
|
||||||
|
|
||||||
import cn.hutool.core.io.IoUtil;
|
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.coreservice.modules.infra.controller.file.vo.InfFileRespVO;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.service.file.InfFileCoreService;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.file.vo.InfFilePageReqVO;
|
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.file.vo.InfFileRespVO;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.infra.convert.file.InfFileConvert;
|
import cn.iocoder.yudao.adminserver.modules.infra.convert.file.InfFileConvert;
|
||||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@ -35,7 +35,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||||||
public class InfFileController {
|
public class InfFileController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private InfFileCoreService fileService;
|
private InfFileService fileService;
|
||||||
|
|
||||||
@PostMapping("/upload")
|
@PostMapping("/upload")
|
||||||
@ApiOperation("上传文件")
|
@ApiOperation("上传文件")
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.infra.convert.file;
|
package cn.iocoder.yudao.adminserver.modules.infra.convert.file;
|
||||||
|
|
||||||
|
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.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.file.vo.InfFileRespVO;
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
package cn.iocoder.yudao.adminserver.modules.infra.service.file;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.coreservice.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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface InfFileService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存文件,并返回文件的访问路径
|
||||||
|
*
|
||||||
|
* @param path 文件路径
|
||||||
|
* @param content 文件内容
|
||||||
|
* @return 文件路径
|
||||||
|
*/
|
||||||
|
String createFile(String path, byte[] content);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文件
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteFile(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得文件
|
||||||
|
*
|
||||||
|
* @param path 文件路径
|
||||||
|
* @return 文件
|
||||||
|
*/
|
||||||
|
InfFileDO getFile(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得文件分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 文件分页
|
||||||
|
*/
|
||||||
|
PageResult<InfFileDO> getFilePage(InfFilePageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package cn.iocoder.yudao.adminserver.modules.infra.service.file.impl;
|
||||||
|
|
||||||
|
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.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;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class InfFileServiceImpl implements InfFileService {
|
||||||
|
@Resource
|
||||||
|
private InfFileCoreMapper fileCoreMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private InfFileCoreService fileCoreService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String createFile(String path, byte[] content) {
|
||||||
|
return fileCoreService.createFile(path,content);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteFile(String id) {
|
||||||
|
fileCoreService.deleteFile(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InfFileDO getFile(String path) {
|
||||||
|
return fileCoreService.getFile(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<InfFileDO> getFilePage(InfFilePageReqVO pageReqVO) {
|
||||||
|
return fileCoreMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,12 +2,12 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.file;
|
|||||||
|
|
||||||
import cn.hutool.core.io.resource.ResourceUtil;
|
import cn.hutool.core.io.resource.ResourceUtil;
|
||||||
import cn.iocoder.yudao.adminserver.BaseDbUnitTest;
|
import cn.iocoder.yudao.adminserver.BaseDbUnitTest;
|
||||||
|
import cn.iocoder.yudao.coreservice.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.dataobject.file.InfFileDO;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.file.InfFileCoreMapper;
|
import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.file.InfFileCoreMapper;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.service.file.impl.InfFileCoreServiceImpl;
|
import cn.iocoder.yudao.coreservice.modules.infra.service.file.impl.InfFileCoreServiceImpl;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.framework.file.config.FileProperties;
|
import cn.iocoder.yudao.coreservice.modules.infra.framework.file.config.FileProperties;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.file.vo.InfFilePageReqVO;
|
|
||||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
public class InfFileServiceTest extends BaseDbUnitTest {
|
public class InfFileServiceTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private InfFileCoreServiceImpl fileService;
|
private InfFileService fileService;
|
||||||
|
|
||||||
@MockBean
|
@MockBean
|
||||||
private FileProperties fileProperties;
|
private FileProperties fileProperties;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.coreservice.modules.infra.file.vo;
|
package cn.iocoder.yudao.coreservice.modules.infra.controller.file.vo;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.coreservice.modules.infra.file.vo;
|
package cn.iocoder.yudao.coreservice.modules.infra.controller.file.vo;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
@ -1,6 +1,6 @@
|
|||||||
package cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.file;
|
package cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.file;
|
||||||
|
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.file.vo.InfFilePageReqVO;
|
import cn.iocoder.yudao.coreservice.modules.infra.controller.file.vo.InfFilePageReqVO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
package cn.iocoder.yudao.coreservice.modules.infra.service.file;
|
package cn.iocoder.yudao.coreservice.modules.infra.service.file;
|
||||||
|
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.file.vo.InfFilePageReqVO;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Class:ruoyi-vue-pro.cn.iocoder.yudao.coreservice.modules.infra.service.file.InfFileCoreService
|
* core service 文件接口
|
||||||
* @Descript: 文件 core Service 接口
|
*
|
||||||
* @Author:宋天
|
* @author 宋天
|
||||||
* @Date:2021/10/19
|
|
||||||
*/
|
*/
|
||||||
public interface InfFileCoreService {
|
public interface InfFileCoreService {
|
||||||
|
|
||||||
@ -36,12 +33,4 @@ public interface InfFileCoreService {
|
|||||||
* @return 文件
|
* @return 文件
|
||||||
*/
|
*/
|
||||||
InfFileDO getFile(String path);
|
InfFileDO getFile(String path);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得文件分页
|
|
||||||
*
|
|
||||||
* @param pageReqVO 分页查询
|
|
||||||
* @return 文件分页
|
|
||||||
*/
|
|
||||||
PageResult<InfFileDO> getFilePage(InfFilePageReqVO pageReqVO);
|
|
||||||
}
|
}
|
||||||
|
@ -3,24 +3,20 @@ package cn.iocoder.yudao.coreservice.modules.infra.service.file.impl;
|
|||||||
import cn.hutool.core.io.FileTypeUtil;
|
import cn.hutool.core.io.FileTypeUtil;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
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.dal.mysql.file.InfFileCoreMapper;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.file.vo.InfFilePageReqVO;
|
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.framework.file.config.FileProperties;
|
import cn.iocoder.yudao.coreservice.modules.infra.framework.file.config.FileProperties;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.service.file.InfFileCoreService;
|
import cn.iocoder.yudao.coreservice.modules.infra.service.file.InfFileCoreService;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.FILE_NOT_EXISTS;
|
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.*;
|
||||||
import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.FILE_PATH_EXISTS;
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Class:ruoyi-vue-pro.cn.iocoder.yudao.coreservice.modules.infra.service.file.impl.InfFileCoreServiceImpl
|
* core service 文件实现类
|
||||||
* @Descript: core service 文件实现类
|
*
|
||||||
* @Author:宋天
|
* @author 宋天
|
||||||
* @Date:2021/10/19
|
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class InfFileCoreServiceImpl implements InfFileCoreService {
|
public class InfFileCoreServiceImpl implements InfFileCoreService {
|
||||||
@ -65,9 +61,4 @@ public class InfFileCoreServiceImpl implements InfFileCoreService {
|
|||||||
return fileMapper.selectById(path);
|
return fileMapper.selectById(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResult<InfFileDO> getFilePage(InfFilePageReqVO pageReqVO) {
|
|
||||||
return fileMapper.selectPage(pageReqVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ GET {{userServerUrl}}/system/user/profile/get
|
|||||||
Authorization: Bearer test245
|
Authorization: Bearer test245
|
||||||
|
|
||||||
### 请求 /system/user/profile/revise-nickname 接口 成功
|
### 请求 /system/user/profile/revise-nickname 接口 成功
|
||||||
PUT http://localhost:28080/api/system/user/profile/revise-nickname?nickName=yunai111
|
PUT http://localhost:28080/api/system/user/profile/update-nickname?nickName=yunai222
|
||||||
Authorization: Bearer test245
|
Authorization: Bearer test245
|
||||||
|
|
||||||
### 请求 /system/user/profile/get-user-info 接口 成功
|
### 请求 /system/user/profile/get-user-info 接口 成功
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package cn.iocoder.yudao.userserver.modules.member.controller.user;
|
package cn.iocoder.yudao.userserver.modules.member.controller.user;
|
||||||
|
|
||||||
import cn.iocoder.yudao.coreservice.modules.system.controller.user.vo.SysUserCoreProfileRespVo;
|
import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.SysUserInfoRespVO;
|
||||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||||
@ -37,15 +37,17 @@ public class SysUserProfileController {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/revise-nickname")
|
@PutMapping("/update-nickname")
|
||||||
@ApiOperation("修改用户昵称")
|
@ApiOperation("修改用户昵称")
|
||||||
public CommonResult<Boolean> reviseNickname(@RequestParam("nickName") String nickName) {
|
@PreAuthenticated
|
||||||
userService.reviseNickname(getLoginUserId(), nickName);
|
public CommonResult<Boolean> updateNickname(@RequestParam("nickName") String nickName) {
|
||||||
|
userService.updateNickname(getLoginUserId(), nickName);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/revise-avatar")
|
@PutMapping("/revise-avatar")
|
||||||
@ApiOperation("修改用户头像")
|
@ApiOperation("修改用户头像")
|
||||||
|
@PreAuthenticated
|
||||||
public CommonResult<String> reviseAvatar(@RequestParam("avatarFile") MultipartFile file) throws IOException {
|
public CommonResult<String> reviseAvatar(@RequestParam("avatarFile") MultipartFile file) throws IOException {
|
||||||
if (file.isEmpty()) {
|
if (file.isEmpty()) {
|
||||||
throw ServiceExceptionUtil.exception(FILE_IS_EMPTY);
|
throw ServiceExceptionUtil.exception(FILE_IS_EMPTY);
|
||||||
@ -56,8 +58,9 @@ public class SysUserProfileController {
|
|||||||
|
|
||||||
@GetMapping("/get-user-info")
|
@GetMapping("/get-user-info")
|
||||||
@ApiOperation("获取用户头像与昵称")
|
@ApiOperation("获取用户头像与昵称")
|
||||||
public CommonResult<SysUserCoreProfileRespVo> getUserInfo(@RequestParam("id") Long id) {
|
@PreAuthenticated
|
||||||
return success(userService.getUserInfo(id));
|
public CommonResult<SysUserInfoRespVO> getUserInfo() {
|
||||||
|
return success(userService.getUserInfo(getLoginUserId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.coreservice.modules.system.controller.user.vo;
|
package cn.iocoder.yudao.userserver.modules.member.controller.user.vo;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -6,11 +6,11 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@ApiModel("用户个人信息 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ApiModel("用户个人中心信息 Response VO")
|
public class SysUserInfoRespVO {
|
||||||
public class SysUserCoreProfileRespVo {
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "用户昵称", required = true, example = "芋艿")
|
@ApiModelProperty(value = "用户昵称", required = true, example = "芋艿")
|
||||||
private String nickName;
|
private String nickName;
|
@ -9,9 +9,9 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
|||||||
*/
|
*/
|
||||||
public interface MbrErrorCodeConstants {
|
public interface MbrErrorCodeConstants {
|
||||||
|
|
||||||
// 用户相关
|
// ==========用户相关============
|
||||||
ErrorCode USER_NOT_EXISTS = new ErrorCode(1004000000, "用户不存在");
|
ErrorCode USER_NOT_EXISTS = new ErrorCode(1004001000, "用户不存在");
|
||||||
|
|
||||||
// 文件相关
|
// ==========文件相关 ===========
|
||||||
ErrorCode FILE_IS_EMPTY = new ErrorCode(1004000000, "用户不存在");
|
ErrorCode FILE_IS_EMPTY = new ErrorCode(1004002000, "文件不存在");
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.yudao.userserver.modules.member.service.user;
|
package cn.iocoder.yudao.userserver.modules.member.service.user;
|
||||||
|
|
||||||
import cn.iocoder.yudao.coreservice.modules.member.dal.dataobject.user.MbrUserDO;
|
import cn.iocoder.yudao.coreservice.modules.member.dal.dataobject.user.MbrUserDO;
|
||||||
import cn.iocoder.yudao.coreservice.modules.system.controller.user.vo.SysUserCoreProfileRespVo;
|
import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.SysUserInfoRespVO;
|
||||||
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -49,24 +49,24 @@ public interface MbrUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户昵称
|
* 修改用户昵称
|
||||||
* @param loginUserId 登录用户id
|
* @param userId 用户id
|
||||||
* @param nickName 用户新昵称
|
* @param nickName 用户新昵称
|
||||||
*/
|
*/
|
||||||
void reviseNickname(Long loginUserId, String nickName);
|
void updateNickname(Long userId, String nickName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户头像
|
* 修改用户头像
|
||||||
* @param loginUserId 登录用户id
|
* @param userId 用户id
|
||||||
* @param inputStream 头像文件
|
* @param inputStream 头像文件
|
||||||
* @return 头像url
|
* @return 头像url
|
||||||
*/
|
*/
|
||||||
String reviseAvatar(Long loginUserId, InputStream inputStream);
|
String reviseAvatar(Long userId, InputStream inputStream);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户id,获取用户头像与昵称
|
* 根据用户id,获取用户头像与昵称
|
||||||
* @param loginUserId 登录用户id
|
* @param userId 用户id
|
||||||
* @return 用户响应实体类
|
* @return 用户响应实体类
|
||||||
*/
|
*/
|
||||||
SysUserCoreProfileRespVo getUserInfo(Long loginUserId);
|
SysUserInfoRespVO getUserInfo(Long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,7 @@ import cn.hutool.core.io.IoUtil;
|
|||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.iocoder.yudao.coreservice.modules.infra.service.file.InfFileCoreService;
|
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.member.dal.dataobject.user.MbrUserDO;
|
||||||
import cn.iocoder.yudao.coreservice.modules.system.controller.user.vo.SysUserCoreProfileRespVo;
|
import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.SysUserInfoRespVO;
|
||||||
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.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.userserver.modules.member.dal.mysql.user.MbrUserMapper;
|
import cn.iocoder.yudao.userserver.modules.member.dal.mysql.user.MbrUserMapper;
|
||||||
import cn.iocoder.yudao.userserver.modules.member.service.user.MbrUserService;
|
import cn.iocoder.yudao.userserver.modules.member.service.user.MbrUserService;
|
||||||
@ -81,52 +80,51 @@ public class MbrUserServiceImpl implements MbrUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reviseNickname(Long loginUserId, String nickName) {
|
public void updateNickname(Long userId, String nickName) {
|
||||||
MbrUserDO mbrUserDO = userMapper.selectById(loginUserId);
|
MbrUserDO user = this.checkUserExists(userId);
|
||||||
// 仅当新昵称不等于旧昵称时进行修改
|
// 仅当新昵称不等于旧昵称时进行修改
|
||||||
if (!nickName.equals(mbrUserDO.getNickname())){
|
if (nickName.equals(user.getNickname())){
|
||||||
MbrUserDO user = new MbrUserDO();
|
return;
|
||||||
user.setId(mbrUserDO.getId());
|
|
||||||
user.setNickname(nickName);
|
|
||||||
userMapper.updateById(user);
|
|
||||||
}
|
}
|
||||||
|
MbrUserDO userDO = new MbrUserDO();
|
||||||
|
userDO.setId(user.getId());
|
||||||
|
userDO.setNickname(nickName);
|
||||||
|
userMapper.updateById(userDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String reviseAvatar(Long loginUserId, InputStream avatarFile) {
|
public String reviseAvatar(Long userId, InputStream avatarFile) {
|
||||||
this.checkUserExists(loginUserId);
|
this.checkUserExists(userId);
|
||||||
// 创建文件
|
// 创建文件
|
||||||
String avatar = fileCoreService.createFile(IdUtil.fastUUID(), IoUtil.readBytes(avatarFile));
|
String avatar = fileCoreService.createFile(IdUtil.fastUUID(), IoUtil.readBytes(avatarFile));
|
||||||
// 更新头像路径
|
// 更新头像路径
|
||||||
MbrUserDO userDO = new MbrUserDO();
|
MbrUserDO userDO = MbrUserDO.builder()
|
||||||
userDO.setId(loginUserId);
|
.id(userId)
|
||||||
userDO.setAvatar(avatar);
|
.avatar(avatar)
|
||||||
|
.build();
|
||||||
userMapper.updateById(userDO);
|
userMapper.updateById(userDO);
|
||||||
return avatar;
|
return avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysUserCoreProfileRespVo getUserInfo(Long loginUserId) {
|
public SysUserInfoRespVO getUserInfo(Long userId) {
|
||||||
MbrUserDO mbrUserDO = userMapper.selectById(loginUserId);
|
MbrUserDO user = this.checkUserExists(userId);
|
||||||
if (mbrUserDO == null){
|
SysUserInfoRespVO userResp = new SysUserInfoRespVO();
|
||||||
log.error("用户不存在:{}",loginUserId);
|
userResp.setNickName(user.getNickname());
|
||||||
throw exception(USER_NOT_EXISTS);
|
userResp.setAvatar(user.getAvatar());
|
||||||
}
|
return userResp;
|
||||||
|
|
||||||
SysUserCoreProfileRespVo userRes = new SysUserCoreProfileRespVo();
|
|
||||||
userRes.setNickName(mbrUserDO.getNickname());
|
|
||||||
userRes.setAvatar(mbrUserDO.getAvatar());
|
|
||||||
return userRes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void checkUserExists(Long id) {
|
public MbrUserDO checkUserExists(Long id) {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
MbrUserDO user = userMapper.selectById(id);
|
MbrUserDO user = userMapper.selectById(id);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw exception(USER_NOT_EXISTS);
|
throw exception(USER_NOT_EXISTS);
|
||||||
|
}else{
|
||||||
|
return user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user