package com.chuanxia.mcp.controller;

import com.chuanxia.mcp.aop.Login;
import com.chuanxia.mcp.bean.model.SystemUser;
import com.chuanxia.mcp.bean.vo.Result;
import com.chuanxia.mcp.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author liyuntian
 */
@RestController
@Api("用户相关")
@RequestMapping("user")
@RequiredArgsConstructor
public class UserController {
    private final UserService userService;

    @PostMapping("login")
    @ApiOperation("登录")
    public Result login(@RequestBody SystemUser user) {
        return userService.login(user);
    }

    @PostMapping("register")
    @ApiOperation("用户注册")
    public Result register(@RequestBody SystemUser user) {
        return userService.register(user);
    }

    @GetMapping("getUserDetail")
    @ApiOperation("获取当前登录用户信息")
    @Login
    public Result getUserDetail() {
        return Result.success(userService.getLoginUser());
    }
}