package org.example.controller;

import org.example.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 登录控制器
 */
@RestController
@RequestMapping("/api")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 用户登录
     */
    @PostMapping("/login/user")
    public Map<String, Object> userLogin(@RequestBody Map<String, String> params) {
        String username = params.get("username");
        String password = params.get("password");
        return loginService.userLogin(username, password);
    }

    /**
     * 管理员登录
     */
    @PostMapping("/login/admin")
    public Map<String, Object> adminLogin(@RequestBody Map<String, String> params) {
        String username = params.get("username");
        String password = params.get("password");
        return loginService.adminLogin(username, password);
    }
}
