package cn.bunny.service.controller;


import cn.bunny.dto.user.LoginDto;
import cn.bunny.result.Result;
import cn.bunny.service.service.UserService;
import cn.bunny.vo.system.login.LoginVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "登录相关接口")
@RestController
@RequestMapping("/admin")
public class LoginController {
    @Autowired
    private UserService userService;

    @Operation(summary = "登录接口", description = "后台用户登录接口")
    @PostMapping("login")
    public Result<LoginVo> login(@RequestBody LoginDto loginDto) {
        LoginVo vo = userService.login(loginDto);
        return Result.success(vo);
    }

    @Operation(summary = "发送邮箱验证码", description = "发送邮箱验证码")
    @PostMapping("noAuth/sendEmail")
    public Result<String> sendEmail(String email) {
        userService.sendEmail(email);
        return Result.success();
    }
}
