|
@@ -1,5 +1,7 @@
|
|
|
package cn.reghao.tnb.file.app.controller;
|
|
package cn.reghao.tnb.file.app.controller;
|
|
|
|
|
|
|
|
|
|
+import cn.reghao.jutil.jdk.web.result.Result;
|
|
|
|
|
+import cn.reghao.jutil.jdk.web.result.ResultStatus;
|
|
|
import cn.reghao.tnb.common.web.WebResult;
|
|
import cn.reghao.tnb.common.web.WebResult;
|
|
|
import cn.reghao.tnb.file.app.model.dto.AvatarUpdate;
|
|
import cn.reghao.tnb.file.app.model.dto.AvatarUpdate;
|
|
|
import cn.reghao.tnb.file.app.service.AvatarService;
|
|
import cn.reghao.tnb.file.app.service.AvatarService;
|
|
@@ -12,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -31,7 +34,13 @@ public class AvatarController {
|
|
|
@Operation(summary = "更新账号头像", description = "N")
|
|
@Operation(summary = "更新账号头像", description = "N")
|
|
|
@PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public String updateUserAvatar(@RequestBody @Validated AvatarUpdate avatarUpdate) throws Exception {
|
|
public String updateUserAvatar(@RequestBody @Validated AvatarUpdate avatarUpdate) throws Exception {
|
|
|
- String avatarUrl = avatarService.updateAvatar(avatarUpdate);
|
|
|
|
|
- return WebResult.success(Map.of("url", avatarUrl));
|
|
|
|
|
|
|
+ Result result = avatarService.updateAvatar(avatarUpdate);
|
|
|
|
|
+ if (result.getCode() == ResultStatus.FAIL.getCode()) {
|
|
|
|
|
+ return WebResult.result(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String avatarUrl = result.getData();
|
|
|
|
|
+ Map<String, String> map = Map.of("avatarUrl", avatarUrl);
|
|
|
|
|
+ return WebResult.success(map);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|