You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.5 KiB
39 lines
1.5 KiB
|
3 months ago
|
package com.example.web.controller;
|
||
|
|
|
||
|
|
import com.example.web.service.LoginService;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/")
|
||
|
|
public class LoginController {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private LoginService loginService;
|
||
|
|
|
||
|
|
@PostMapping("/logins")
|
||
|
|
public Map<String, Object> login(@RequestParam String projectName,
|
||
|
|
@RequestParam String userName,
|
||
|
|
@RequestParam String password) {
|
||
|
|
|
||
|
|
System.out.println("=== Controller收到登录请求 ===");
|
||
|
|
System.out.println("工位名: " + projectName + ", 用户名: " + userName + ", 密码: " + password);
|
||
|
|
|
||
|
|
Map<String, Object> result = loginService.authenticate(projectName, userName, password);
|
||
|
|
|
||
|
|
System.out.println("Controller返回结果: " + result);
|
||
|
|
System.out.println("成功状态: " + result.get("success"));
|
||
|
|
|
||
|
|
if (result.get("success").equals(true)) {
|
||
|
|
System.out.println("权限等级: " + result.get("root"));
|
||
|
|
System.out.println("Token: " + result.get("token"));
|
||
|
|
System.out.println("系统类型: " + (Boolean.TRUE.equals(result.get("isSupplySide")) ? "采购端" : "销售端"));
|
||
|
|
Map<String, Object> user = (Map<String, Object>) result.get("user");
|
||
|
|
System.out.println("用户信息: " + user);
|
||
|
|
}
|
||
|
|
System.out.println(result.get("user"));
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
}
|