From d07c2dc84de164c285672d91adc1fd05c2db2931 Mon Sep 17 00:00:00 2001 From: XinYi Song <2037158277@qq.com> Date: Thu, 23 Dec 2021 17:24:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84redis=E9=85=8D=E7=BD=AE=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BA=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BF=A1=E6=81=AF=E7=9A=84=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xkrs/controller/SysUserController.java | 8 +++++--- src/main/java/com/xkrs/service/SysUserService.java | 4 ++-- .../com/xkrs/service/impl/SysUserServiceImpl.java | 13 ++++--------- src/main/resources/application.properties | 4 ++-- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java index 835010e..a58e580 100644 --- a/src/main/java/com/xkrs/controller/SysUserController.java +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -228,14 +228,16 @@ public class SysUserController { /** * 用户完善信息 - * @param files + * @param * @param * @param token * @return */ @PostMapping("/updateUserByUserId") - public String updateUserByUserId(@RequestParam("file") MultipartFile files, String nickName, @RequestHeader(value="Authorization") String token) throws IOException { + public String updateUserByUserId(@RequestBody Map map, @RequestHeader(value="Authorization") String token) throws IOException { Locale locale = LocaleContextHolder.getLocale(); + String avatar = (String) map.get("avatar"); + String nickName = (String) map.get("nickName"); if(nickName != null){ SysUserEntity byNickName = sysUserDao.findByNickName(nickName); if(byNickName != null){ @@ -244,7 +246,7 @@ public class SysUserController { } String tokenUserName = TokenUtil.getTokenUserName(token); SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); - return sysUserService.updateUserByUserId(files,nickName,sysUserEntity.getId()); + return sysUserService.updateUserByUserId(avatar,nickName,sysUserEntity.getId()); } /** diff --git a/src/main/java/com/xkrs/service/SysUserService.java b/src/main/java/com/xkrs/service/SysUserService.java index be06548..550d754 100644 --- a/src/main/java/com/xkrs/service/SysUserService.java +++ b/src/main/java/com/xkrs/service/SysUserService.java @@ -87,12 +87,12 @@ public interface SysUserService { /** * 用户完善个人信息 - * @param files + * @param * @param * @param userId * @return */ - String updateUserByUserId(MultipartFile files, String nickName, Integer userId) throws IOException; + String updateUserByUserId(String avatar, String nickName, Integer userId) throws IOException; /** * 启用 diff --git a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java index 19636ed..209f1eb 100644 --- a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java @@ -25,6 +25,7 @@ import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.security.crypto.keygen.KeyGenerators; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; @@ -234,22 +235,16 @@ public class SysUserServiceImpl implements SysUserService { /** * 用户完善个人信息 - * @param files + * @param * @param * @param userId * @return */ @Transactional(rollbackFor=Exception.class) @Override - public String updateUserByUserId(MultipartFile files, String nickName, Integer userId) throws IOException { + public String updateUserByUserId(String avatar, String nickName, Integer userId) throws IOException { Locale locale = LocaleContextHolder.getLocale(); - if(files == null){ - String uploadAvatar = ""; - sysUserDao.updateUserByUserId(userId,nickName,uploadAvatar); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"提交成功!",locale); - } - String memoryPhoto = PhotoUtil.memoryPhoto(files); - sysUserDao.updateUserByUserId(userId,nickName,memoryPhoto); + sysUserDao.updateUserByUserId(userId,nickName,avatar); return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"提交成功!",locale); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ea1d3ed..b4c7ca5 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -45,10 +45,10 @@ spring.jpa.properties.hibernate.order_updates =true ## Redis配置 12 spring.cache.type = redis -spring.redis.database = 12 +spring.redis.database = 8 spring.redis.host = localhost spring.redis.port = 6379 -spring.redis.password=sdust2020 +spring.redis.password=lybABC123 spring.redis.timeout = 10000 spring.redis.lettuce.pool.max-active = 100 spring.redis.lettuce.pool.max-wait = 10000