package com.luojia_channel.modules.user.controller;

import com.luojia_channel.common.domain.Result;
import com.luojia_channel.modules.file.dto.UploadFileDTO;
import com.luojia_channel.modules.user.dto.UserChangeInfoDTO;
import com.luojia_channel.modules.user.service.UserInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/user/info")
@RequiredArgsConstructor
public class UserInfoController {
    private final UserInfoService userInfoService;
    @PostMapping("/update")
    public Result<Void> updateInfo(@RequestBody UserChangeInfoDTO userChangeInfoDTO){
        userInfoService.updateInfo(userChangeInfoDTO);
        return Result.success();
    }

    @PostMapping("/password")
    public Result<Void> updatePassword(@RequestParam String password){
        userInfoService.updatePassword(password);
        return Result.success();
    }

    @PostMapping("/avatar")
    public Result<String> uploadAvatar(@RequestParam("file") MultipartFile file) {
        return Result.success(userInfoService.uploadAvatar(file));
    }
}
