diff --git a/src/main/java/com/greenorange/promotion/controller/userInfo/AdvancementApplyController.java b/src/main/java/com/greenorange/promotion/controller/userInfo/AdvancementApplyController.java index 179f94b..04de9bf 100644 --- a/src/main/java/com/greenorange/promotion/controller/userInfo/AdvancementApplyController.java +++ b/src/main/java/com/greenorange/promotion/controller/userInfo/AdvancementApplyController.java @@ -37,7 +37,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; -import java.util.UUID; + /** diff --git a/src/main/java/com/greenorange/promotion/controller/userInfo/UserInfoController.java b/src/main/java/com/greenorange/promotion/controller/userInfo/UserInfoController.java index 1a5d617..09a2090 100644 --- a/src/main/java/com/greenorange/promotion/controller/userInfo/UserInfoController.java +++ b/src/main/java/com/greenorange/promotion/controller/userInfo/UserInfoController.java @@ -5,6 +5,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaQrcode; import com.auth0.jwt.interfaces.DecodedJWT; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.greenorange.promotion.annotation.RequiresPermission; import com.greenorange.promotion.annotation.SysLog; @@ -97,6 +98,23 @@ public class UserInfoController { // } + /** + * 小程序端用户修改用户头像 + * @param commonStringRequest 头像view值 + * @return 是否修改成功 + */ + @PostMapping("modify/avatar") + @Operation(summary = "小程序端用户修改用户头像", description = "参数:头像view值,权限:管理员(boss, admin),方法名:modifyUserAvatar") + @RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE) + public BaseResponse modifyUserAvatar(@Valid @RequestBody CommonStringRequest commonStringRequest, HttpServletRequest request) { + Long userId = (Long) request.getAttribute("userId"); + String view = commonStringRequest.getTemplateString(); + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(UserInfo::getId, userId).set(UserInfo::getUserAvatar, view); + userInfoService.update(updateWrapper); + return ResultUtils.success(true); + } + /** diff --git a/src/main/java/com/greenorange/promotion/service/userInfo/impl/UserInfoServiceImpl.java b/src/main/java/com/greenorange/promotion/service/userInfo/impl/UserInfoServiceImpl.java index b696793..3b439f0 100644 --- a/src/main/java/com/greenorange/promotion/service/userInfo/impl/UserInfoServiceImpl.java +++ b/src/main/java/com/greenorange/promotion/service/userInfo/impl/UserInfoServiceImpl.java @@ -348,7 +348,7 @@ public class UserInfoServiceImpl extends ServiceImpl phoneNumberLambdaQueryWrapper.eq(UserInfo::getPhoneNumber, phoneNumber); phoneNumberLambdaQueryWrapper = getQueryWrapperByUserRole(userRoleEnum, phoneNumberLambdaQueryWrapper); UserInfo userInfo = this.getOne(phoneNumberLambdaQueryWrapper); - ThrowUtils.throwIf(userInfo != null, ErrorCode.OPERATION_ERROR, "手机号已注册"); + ThrowUtils.throwIf(userInfo != null, ErrorCode.OPERATION_ERROR, "该手机号为"+ userRoleEnum.getText() +"账号"); } String code = redisTemplate.opsForValue().get(SystemConstant.VERIFICATION_CODE + ":" + verificationCode); ThrowUtils.throwIf(code == null, ErrorCode.OPERATION_ERROR, "验证码已失效");