package thyyxxk.webserver.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.entity.login.UserInfo;
import thyyxxk.webserver.service.LoginService;

import java.util.List;
import java.util.Map;

/**
 * @author dj
 */
@RestController
@RequestMapping("/login")
public class LoginController {
    private final LoginService service;

    @Autowired
    public LoginController(LoginService service) {
        this.service = service;
    }

    @PassToken
    @PostMapping("/login")
    public ResultVo<UserInfo> login(@RequestBody UserInfo userInfo) {
        return service.login(userInfo);
    }

    @GetMapping("/getWards")
    public ResultVo<List<CodeName>> getWards() {
        return service.getWards();
    }

    @GetMapping("/fetchVueMenus")
    public ResultVo<Map<String, Object>> fetchVueMenus() {
        return service.fetchVueMenus();
    }
}
