小白学习笔记
(1)在复习过程中,发现mybatis不支持方法重载
(2) 报错如下:
意思是该statement已经存在了
(3)解决方法
使用动态sql拼接
(4)Mapper接口写法
写成一个就好了,隐藏了方法重载功能
(5)Controller层写法
@RestController
public class AdminController {
@Resource
private AdminService adminService;
@GetMapping("login")
public CommonMessage<Admin> login(@RequestParam(required = false) Integer id,@RequestParam(required = false) String username,@RequestParam("userpswd") String userpswd){
Admin loginAdmin = adminService.login(id, username, userpswd);
if (loginAdmin!=null){
return new CommonMessage<>("200","登录成功",loginAdmin);
}else {
return new CommonMessage<>("201","登录失败",loginAdmin);
}
}
}