package com.sonic.bear.controller.api;

import com.sonic.bear.lib.input.CompleteUserInfoInput;
import com.sonic.bear.lib.input.EditUserInfoInput;
import com.sonic.bear.lib.input.UserIdInput;
import com.sonic.bear.service.UserSetService;
import com.sonic.common.rpc.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * API-用户设置
 * @author coder
 */
@Validated
@RestController
public class UserSetApi {

    @Autowired
    private UserSetService userSetService;

    @ApiOperation(value = "补全用户基础信息", tags = {"API-用户设置"})
    @PostMapping("/api/user/complete-user-info")
    public Result<Void> completeUserInfo(@RequestBody @Valid CompleteUserInfoInput input) {
        userSetService.completeUserInfo(input);
        return Result.success();
    }

    @ApiOperation(value = "编辑用户基础信息", tags = {"API-用户设置"})
    @PostMapping("/api/user/edit-user-info")
    public Result<Void> editUserInfo(@RequestBody @Valid EditUserInfoInput input) {
        userSetService.editUserInfo(input);
        return Result.success();
    }

    @ApiOperation(value = "删除账号", tags = {"API-用户设置"})
    @PostMapping("/api/user/del-account")
    public Result<Void> delAccount(@RequestBody @Valid UserIdInput input) {
        userSetService.delAccount(input.getUserId());
        return Result.success();
    }



}
