首页>代码>springboot+vue+axios全栈项目开发中的跨域解决方案>/spring-boot-cross-domain-demo/src/main/java/com/cxs/controller/LoginController.java
package com.cxs.controller; import com.cxs.dto.LoginDTO; import com.cxs.vo.LoginVO; import org.springframework.beans.BeanUtils; 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; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map; /** * @Project: spring-boot-cross-domain-demo * @Author: cxs2014501@163.com * @Create: 2023/2/9 13:27 * @Description: **/ @RestController @RequestMapping("/auth") public class LoginController { private static final String ACCOUNT = "admin"; private static final String PWD = "admin1234"; @PostMapping("/login") public Map<String, Object> login(@RequestBody LoginDTO dto){ Map<String, Object> map = new HashMap<>(); if (ACCOUNT.equals(dto.getUsername()) && PWD.equals(dto.getPassword())) { LoginVO vo = new LoginVO(); BeanUtils.copyProperties(dto, vo); vo.setLoginTime(LocalDateTime.now()); map.put("data", vo); map.put("msg", "登陆成功"); } else { map.put("msg", "登陆失败,用户名或密码错误"); } return map; } }
最近下载更多
zengxq056 LV2
2023年3月18日
微信网友_6368711690080256 LV3
2023年2月28日
hbsoft2008 LV16
2023年2月22日
最代码官方 LV167
2023年2月12日