首页>代码>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日
最近浏览更多
lxy135  LV1 2023年10月10日
dixiu000  LV4 2023年9月25日
卡布琪洛  LV4 2023年6月9日
szf123  LV12 2023年5月30日
陆程江  LV2 2023年5月28日
茫茫人海中的小牛  LV10 2023年4月23日
240598911  LV10 2023年4月16日
duwanfa  LV3 2023年4月15日
做你的景天  LV7 2023年4月12日
sunlzh888888  LV28 2023年3月30日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友