|
|
@@ -2,11 +2,16 @@ package com.yhlxj.web.controller.login;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
+import com.cyksj.enums.GatewayApiCode;
|
|
|
+import com.yhlxj.dao.model.dto.Result;
|
|
|
import com.yhlxj.dao.model.entity.WebInfo;
|
|
|
import com.yhlxj.dao.model.entity.WholesaleUser;
|
|
|
+import com.yhlxj.dao.model.enums.GatewayResponse;
|
|
|
+import com.yhlxj.dao.model.request.WholesaleUserReq;
|
|
|
import com.yhlxj.dao.model.view.WebInfoView;
|
|
|
import com.yhlxj.service.wholesale.WebInfoService;
|
|
|
import com.yhlxj.service.wholesale.WholesaleUserService;
|
|
|
@@ -104,4 +109,42 @@ public class WholesaleUserController {
|
|
|
BeanUtil.copyProperties(webInfo, view);
|
|
|
return view;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询用户信息
|
|
|
+ */
|
|
|
+ @GetMapping("/whoami")
|
|
|
+ public WholesaleUser whoami() {
|
|
|
+ long loginIdAsLong = StpUserUtil.getLoginIdAsLong();
|
|
|
+ WholesaleUser wholesaleUser = wholesaleUserService.getById(loginIdAsLong);
|
|
|
+ wholesaleUser.setPassword(null);
|
|
|
+ return wholesaleUser;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改用户信息
|
|
|
+ */
|
|
|
+ @PutMapping("/update/userInfo")
|
|
|
+ public Result<String> updateHeadImg(@RequestBody WholesaleUserReq request) {
|
|
|
+ long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
+ WholesaleUser wholesaleUser = wholesaleUserService.getById(userId);
|
|
|
+ if (wholesaleUser == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
+ Boolean isFlag = false;
|
|
|
+ if (StrUtil.isNotBlank(request.getNickname())) {
|
|
|
+ if (request.getNickname().length() > 32) {
|
|
|
+ throw BusinessRuntimeException.getInstance("名称过长");
|
|
|
+ }
|
|
|
+ wholesaleUser.setNickname(request.getNickname());
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(request.getAvatar())) {
|
|
|
+ wholesaleUser.setAvatar(request.getAvatar());
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ if (isFlag) {
|
|
|
+ wholesaleUserService.updateById(wholesaleUser);
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
}
|