|
|
|
|
package com.youlai.boot.mini.controller;
|
|
|
|
|
|
|
|
|
|
import com.youlai.boot.common.annotation.Log;
|
|
|
|
|
import com.youlai.boot.common.annotation.RepeatSubmit;
|
|
|
|
|
import com.youlai.boot.common.enums.ActionTypeEnum;
|
|
|
|
|
import com.youlai.boot.common.enums.LogModuleEnum;
|
|
|
|
|
import com.youlai.boot.common.result.Result;
|
|
|
|
|
import com.youlai.boot.framework.security.util.SecurityUtils;
|
|
|
|
|
import com.youlai.boot.mini.model.form.MiniUserUpdateForm;
|
|
|
|
|
import com.youlai.boot.mini.model.vo.MiniUserInfoVO;
|
|
|
|
|
import com.youlai.boot.mini.service.MiniUserService;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import jakarta.validation.Valid;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* C端用户信息接口
|
|
|
|
|
*
|
|
|
|
|
* @author youlai
|
|
|
|
|
* @since 2024
|
|
|
|
|
*/
|
|
|
|
|
@Tag(name = "C端用户信息接口")
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/v1/mini/user")
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@Valid
|
|
|
|
|
public class MiniUserController {
|
|
|
|
|
|
|
|
|
|
private final MiniUserService miniUserService;
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "获取当前登录用户基本信息")
|
|
|
|
|
@GetMapping("/info")
|
|
|
|
|
@Log(module = LogModuleEnum.USER, value = ActionTypeEnum.LIST)
|
|
|
|
|
public Result<MiniUserInfoVO> getCurrentUserInfo() {
|
|
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
|
|
MiniUserInfoVO userInfo = miniUserService.getCurrentUserInfo(userId);
|
|
|
|
|
return Result.success(userInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "修改当前登录用户基本信息")
|
|
|
|
|
@PostMapping(value = "/updateInfo")
|
|
|
|
|
@Log(module = LogModuleEnum.USER, value = ActionTypeEnum.UPDATE)
|
|
|
|
|
public Result<Void> updateCurrentUserInfo(@Valid MiniUserUpdateForm form) {
|
|
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
|
|
miniUserService.updateCurrentUserInfo(userId, form);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "上传用户头像")
|
|
|
|
|
@PostMapping(value = "save/avatar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
|
|
@RepeatSubmit
|
|
|
|
|
@Log(module = LogModuleEnum.USER, value = ActionTypeEnum.UPDATE)
|
|
|
|
|
public Result<?> saveFile(
|
|
|
|
|
@RequestPart(name = "image", required = true) MultipartFile image
|
|
|
|
|
) {
|
|
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
|
|
miniUserService.saveFile(userId, image);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|