package com.ruoyi.dk.controller.app;

import cn.dev33.satoken.annotation.SaIgnore;
import com.ruoyi.dk.dto.app.req.LoginPhoneBody;
import com.ruoyi.dk.kit.DkLoginKit;
import com.ruoyi.component.core.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

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

@RestController
public class LoginV2Controller {
    @Autowired
    private DkLoginKit dkLoginKit;

    @PostMapping("/app/customer/login")
    @Operation(summary = "用户登陆")
    @SaIgnore
    public R<Map<String, Object>> loginCustomer(@RequestBody LoginPhoneBody loginBody) {
        Map<String, Object> ajax = new HashMap<>();
        String token = dkLoginKit.login(loginBody.getMobile(),loginBody.getPassword());
        ajax.put("token", token);
        return R.ok(ajax);
    }

}
