修改了用户完善信息的功能模块
This commit is contained in:
parent
e7cd3b4159
commit
b8007ec079
@ -229,22 +229,22 @@ public class SysUserController {
|
||||
/**
|
||||
* 用户完善信息
|
||||
* @param files
|
||||
* @param userUpdate
|
||||
* @param
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
@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();
|
||||
if(userUpdate.getNickName() != null){
|
||||
SysUserEntity byNickName = sysUserDao.findByNickName(userUpdate.getNickName());
|
||||
if(nickName != null){
|
||||
SysUserEntity byNickName = sysUserDao.findByNickName(nickName);
|
||||
if(byNickName != null){
|
||||
return outputEncapsulationObject(PromptMessageEnum.FILE_EXISTS,"该昵称已存在!",locale);
|
||||
}
|
||||
}
|
||||
String tokenUserName = TokenUtil.getTokenUserName(token);
|
||||
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
|
||||
return sysUserService.updateUserByUserId(files,userUpdate,sysUserEntity.getId());
|
||||
return sysUserService.updateUserByUserId(files,nickName,sysUserEntity.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,13 +110,13 @@ public interface SysUserDao extends JpaRepository<SysUserEntity,Integer> {
|
||||
* @param userId
|
||||
* @param nickName
|
||||
* @param avatar
|
||||
* @param province
|
||||
* @param city
|
||||
* @param county
|
||||
* @param
|
||||
* @param
|
||||
* @param
|
||||
*/
|
||||
@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)
|
||||
void updateUserByUserId(Integer userId,String nickName,String avatar,String province,String city,String county);
|
||||
@Query(value = "update sys_user set nick_name = ?2,avatar = ?3 where id = ?1",nativeQuery = true)
|
||||
void updateUserByUserId(Integer userId,String nickName,String avatar);
|
||||
|
||||
/**
|
||||
* 通过用户昵称查询用户信息
|
||||
|
@ -88,11 +88,11 @@ public interface SysUserService {
|
||||
/**
|
||||
* 用户完善个人信息
|
||||
* @param files
|
||||
* @param userUpdate
|
||||
* @param
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
String updateUserByUserId(MultipartFile files, UserUpdate userUpdate, Integer userId) throws IOException;
|
||||
String updateUserByUserId(MultipartFile files, String nickName, Integer userId) throws IOException;
|
||||
|
||||
/**
|
||||
* 启用
|
||||
|
@ -234,21 +234,21 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
/**
|
||||
* 用户完善个人信息
|
||||
* @param files
|
||||
* @param userUpdate
|
||||
* @param
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
@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();
|
||||
if(files == null){
|
||||
String uploadAvatar = "";
|
||||
sysUserDao.updateUserByUserId(userId,userUpdate.getNickName(),uploadAvatar,userUpdate.getProvince(),userUpdate.getCity(),userUpdate.getCounty());
|
||||
sysUserDao.updateUserByUserId(userId,nickName,uploadAvatar);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"提交成功!",locale);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user