修改了用户完善信息的功能模块

This commit is contained in:
XinYi Song 2021-12-21 15:09:01 +08:00
parent e7cd3b4159
commit b8007ec079
4 changed files with 16 additions and 16 deletions

View File

@ -229,22 +229,22 @@ public class SysUserController {
/** /**
* 用户完善信息 * 用户完善信息
* @param files * @param files
* @param userUpdate * @param
* @param token * @param token
* @return * @return
*/ */
@PostMapping("/updateUserByUserId") @PostMapping("/updateUserByUserId")
public String updateUserByUserId(@RequestParam("file") MultipartFile files, UserUpdate userUpdate, @RequestHeader(value="Authorization") String token) throws IOException { public String updateUserByUserId(@RequestParam("file") MultipartFile files, String nickName, @RequestHeader(value="Authorization") String token) throws IOException {
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
if(userUpdate.getNickName() != null){ if(nickName != null){
SysUserEntity byNickName = sysUserDao.findByNickName(userUpdate.getNickName()); SysUserEntity byNickName = sysUserDao.findByNickName(nickName);
if(byNickName != null){ if(byNickName != null){
return outputEncapsulationObject(PromptMessageEnum.FILE_EXISTS,"该昵称已存在!",locale); return outputEncapsulationObject(PromptMessageEnum.FILE_EXISTS,"该昵称已存在!",locale);
} }
} }
String tokenUserName = TokenUtil.getTokenUserName(token); String tokenUserName = TokenUtil.getTokenUserName(token);
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
return sysUserService.updateUserByUserId(files,userUpdate,sysUserEntity.getId()); return sysUserService.updateUserByUserId(files,nickName,sysUserEntity.getId());
} }
/** /**

View File

@ -110,13 +110,13 @@ public interface SysUserDao extends JpaRepository<SysUserEntity,Integer> {
* @param userId * @param userId
* @param nickName * @param nickName
* @param avatar * @param avatar
* @param province * @param
* @param city * @param
* @param county * @param
*/ */
@Modifying(clearAutomatically=true) @Modifying(clearAutomatically=true)
@Query(value = "update sys_user set nick_name = ?2,avatar = ?3,province = ?4,city = ?5,county = ?6 where id = ?1",nativeQuery = true) @Query(value = "update sys_user set nick_name = ?2,avatar = ?3 where id = ?1",nativeQuery = true)
void updateUserByUserId(Integer userId,String nickName,String avatar,String province,String city,String county); void updateUserByUserId(Integer userId,String nickName,String avatar);
/** /**
* 通过用户昵称查询用户信息 * 通过用户昵称查询用户信息

View File

@ -88,11 +88,11 @@ public interface SysUserService {
/** /**
* 用户完善个人信息 * 用户完善个人信息
* @param files * @param files
* @param userUpdate * @param
* @param userId * @param userId
* @return * @return
*/ */
String updateUserByUserId(MultipartFile files, UserUpdate userUpdate, Integer userId) throws IOException; String updateUserByUserId(MultipartFile files, String nickName, Integer userId) throws IOException;
/** /**
* 启用 * 启用

View File

@ -234,21 +234,21 @@ public class SysUserServiceImpl implements SysUserService {
/** /**
* 用户完善个人信息 * 用户完善个人信息
* @param files * @param files
* @param userUpdate * @param
* @param userId * @param userId
* @return * @return
*/ */
@Transactional(rollbackFor=Exception.class) @Transactional(rollbackFor=Exception.class)
@Override @Override
public String updateUserByUserId(MultipartFile files, UserUpdate userUpdate, Integer userId) throws IOException { public String updateUserByUserId(MultipartFile files, String nickName, Integer userId) throws IOException {
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
if(files == null){ if(files == null){
String uploadAvatar = ""; String uploadAvatar = "";
sysUserDao.updateUserByUserId(userId,userUpdate.getNickName(),uploadAvatar,userUpdate.getProvince(),userUpdate.getCity(),userUpdate.getCounty()); sysUserDao.updateUserByUserId(userId,nickName,uploadAvatar);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"提交成功!",locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"提交成功!",locale);
} }
String memoryPhoto = PhotoUtil.memoryPhoto(files); String memoryPhoto = PhotoUtil.memoryPhoto(files);
sysUserDao.updateUserByUserId(userId,userUpdate.getNickName(),memoryPhoto,userUpdate.getProvince(),userUpdate.getCity(),userUpdate.getCounty()); sysUserDao.updateUserByUserId(userId,nickName,memoryPhoto);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"提交成功!",locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"提交成功!",locale);
} }