package com.ywt.controllers.mg;

import com.ywt.core.BaseResponse;
import com.ywt.core.DataResponse;
import com.ywt.core.MGRight;
import com.ywt.service.AuthService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping({"/mg/auth"})
@MGRight(need = false)
public class AuthController {

    private static final Logger logger = LoggerFactory.getLogger(AuthController.class);

    @Autowired
    private AuthService authService;


    /**
     * 登录方法--POST方式
     *
     * @param data 传入数据
     * @return {@link DataResponse}
     */
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public BaseResponse postLogin(@RequestBody Map<String, Object> data) {
        String username = (String) data.getOrDefault("username", "");
        String password = (String) data.getOrDefault("password", "");
        DataResponse<Object> response = new DataResponse<>();
        Map map = new HashMap();
        map.put("username", username);
        map.put("password", password);
        response.setData(map);
        return response.succeed();
    }


}
