SSM + Layui实现的后台管理系统

时间:2024-11-17 07:29:54
@Controller @RequestMapping("/user") public class UserController { @Autowired private UserService userService; /* *获取所有用户列表 */ @RequestMapping("getAllUserList") @ResponseBody public ResultUtil getAllUserList(Integer page, Integer limit,UserSearch search) { return userService.getAllUserList(page, limit,search); } /* *增加新用户 */ @RequestMapping("insertUser") @ResponseBody public ResultUtil insUser(User user){ //防止浏览器提交 User user1 = userService.selUserByUsername(user.getUsername()); if(null != user1){ return new ResultUtil(500,"用户名已存在,请重新填写!"); } try { userService.insertUser(user); return ResultUtil.ok(); } catch (Exception e) { return new ResultUtil(502,"网络错误,请检查网络!"); } } /* *检查是否有同名用户,防止用户名重复 */ @RequestMapping("checkUserByUsername/{username}") @ResponseBody public ResultUtil checkUserByUsername(@PathVariable("username")String username){ User user = userService.selUserByUsername(username); if(user!=null){ return new ResultUtil(500,"用户名已存在,请重新填写!"); } return new ResultUtil(0); } /* *更新用户状态 */ @RequestMapping("updateUserStatusById") @ResponseBody public ResultUtil updateUserStatusById(int id, int status) { return userService.updateUserStatusById(id, status); } /* *更新用户信息 */ @RequestMapping("updateUser") @ResponseBody public ResultUtil updateUser(User user) throws ParseException { return userService.updateUser(user); } }