controller层
@RequestMapping(value = "/test", method = RequestMethod.GET)
public RestMessage test(@RequestParam String uname,@RequestParam String password) {
return authService.test(uname,password);
}
service层
public RestMessage test(String uname, String password) {
User user = authMapper.selectInject(uname, password);
return new RestMessage().setData(user);
}
dao层使用mybatis
@Select("select * from user where username='${username}' and password='${password}'")
User selectInject(@Param("username") String username,@Param("password") String password);
建表语句
CREATE TABLE `test_user` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`username` VARCHAR(32) DEFAULT NULL,
`password` VARCHAR(16) DEFAULT NULL,
PRIMARY KEY (`id`)
) EN