package self.cases.teams.controller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import self.cases.teams.utils.DateUtils; import self.cases.teams.utils.IDUtils; import self.cases.teams.msg.R; import self.cases.teams.msg.PageData; import self.cases.teams.entity.Users; import self.cases.teams.service.UsersService; /** * 系统请求响应控制器 * 系统用户 */ @Controller @RequestMapping("/users") public class UsersController extends BaseController { protected static final Logger Log = LoggerFactory.getLogger(UsersController.class); @Autowired private UsersService usersService; @RequestMapping("") public String index() { return "pages/Users"; } @GetMapping("/info") @ResponseBody public R getInfo(String id) { Log.info("查找指定系统用户,ID:{}", id); Users users = usersService.getOne(id); return R.successData(users); } @GetMapping("/page") @ResponseBody public R getPageInfos(Long pageIndex, Long pageSize, Users users) { Log.info("分页查找系统用户,当前页码:{}," + "每页数据量:{}, 模糊查询,附加参数:{}", pageIndex, pageSize, users); PageData page = usersService.getPageInfo(pageIndex, pageSize, users); return R.successData(page); } @PostMapping("/add") @ResponseBody public R addInfo(Users users) { if(usersService.getUserByUserName(users.getUserName()) == null){ users.setId(IDUtils.makeIDByCurrent()); users.setCreateTime(DateUtils.getNowDate()); Log.info("添加系统用户,传入参数:{}", users); users
时间: 2024-02-19 17:02:12 浏览: 157
,usersService.add(users); return R.successMsg("添加成功!"); }else{ return R.failMsg("用户名已存在,请重新输入!"); } } @PostMapping("/update") @ResponseBody public R updateInfo(Users users) { Log.info("更新系统用户,传入参数:{}", users); usersService.update(users); return R.successMsg("更新成功!"); } @GetMapping("/delete") @ResponseBody public R deleteInfo(String id) { Log.info("删除系统用户,ID:{}", id); usersService.delete(id); return R.successMsg("删除成功!"); } @ExceptionHandler @ResponseBody public R handleException(Exception e) { Log.error("系统用户请求异常:{}", e.getMessage()); return R.errorMsg("系统异常,请联系管理员!"); } }
请问这段代码是做什么的?
阅读全文