package com.example.demo3.controller;
import com.example.demo3.entity.Login;
import com.example.demo3.mapper.LoginMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RestController
public class LoginController {
@Resource
private LoginMapper loginMapper;
@RequestMapping(path = "/login" ,method = RequestMethod.GET)
public String Login( String username , String password){
Login login = loginMapper.selectLogin(username,password);
if (login==null){
return "[{code:200,mess:登录失败}]";
}
return "[{code:200,mess:登录成功}]";
}
}
```java
package com.example.demo3.entity;
import lombok.Data;
@Data
public class Login {
private Long id;
private String username;
private String password;
}
```java
package com.example.demo3.mapper;
import com.example.demo3.entity.Login;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
public interface LoginMapper {
@Select("select * from login where username = #{username} and password = #{password}")
Login selectLogin(@Param("username") String username, @Param("password") String password);
}