package com.inkasso.factoring.login.controller;

import com.inkasso.adapter.enums.ClientTypeEnum;
import com.inkasso.adapter.response.ResponseData;
import com.inkasso.factoring.login.model.dto.LoginResultDTO;
import com.inkasso.factoring.login.model.request.PasswordLoginRequest;
import com.inkasso.factoring.login.service.UserLoginService;
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;

/**
 * @author liutao
 * @date 2023/11/13
 */
@RestController
@RequestMapping("login")
public class LoginController {

    @Autowired
    private UserLoginService userLoginService;

    /**
     * 用户登录
     *
     * @param request
     * @return
     */
    @PostMapping("userLogin")
    public ResponseData login(@RequestBody PasswordLoginRequest request) {
        LoginResultDTO login = userLoginService.login(ClientTypeEnum.WEB, request);
        return ResponseData.success(login);
    }
}
