| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.api.R; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.Dept; |
| | | import com.whyc.pojo.Job; |
| | | import com.whyc.pojo.User; |
| | | import com.whyc.service.DeptService; |
| | | import com.whyc.service.JobService; |
| | | import com.whyc.service.LoginService; |
| | | import com.whyc.service.UserService; |
| | | import io.swagger.annotations.*; |
| | |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | @Resource |
| | | private DeptService deptService; |
| | | |
| | | @Resource |
| | | private JobService jobService; |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加") |
| | | @ApiOperation(value = "添加用户") |
| | | public Response add(@RequestBody User user){ |
| | | return userService.add(user); |
| | | } |
| | | |
| | | @GetMapping |
| | | @ApiOperation(value = "查询byId") |
| | | public User getById(@RequestParam int id){ |
| | | return userService.getById(id); |
| | | @ApiOperation(value = "查询用户byId") |
| | | public Response getById(@RequestParam int id){ |
| | | User user = userService.getById(id); |
| | | if (user==null){ |
| | | return new Response().set(0,null,"此用户不存在"); |
| | | } |
| | | return new Response().set(1,user); |
| | | } |
| | | |
| | | @GetMapping("/all") |
| | | @ApiOperation(value = "查询所有") |
| | | @ApiOperation(value = "查询所有用户") |
| | | public List<User> getAll(){ |
| | | return userService.getAll(); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @ApiOperation(value = "查询分页") |
| | | public IPage<User> getPage(@RequestParam int pageNum,int pageSize){ |
| | | @ApiOperation(value = "查询用户分页") |
| | | public IPage<User> getPage(@RequestParam int pageNum,@RequestParam int pageSize){ |
| | | Page<Object> page = new Page<>(pageNum, pageSize); |
| | | return userService.getAllWithPage(page); |
| | | } |
| | | @GetMapping("/search") |
| | | @ApiOperation(value = "查询用户分页-根据筛选条件") |
| | | public Response<IPage<User>> getPageByCondition(@RequestParam int pageNum,@RequestParam int pageSize,@RequestBody User user){ |
| | | return userService.getPageByCondition(pageNum,pageSize,user); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "编辑") |
| | | public boolean update(@RequestBody User user){ |
| | | @ApiOperation(value = "编辑用户") |
| | | public Response update(@RequestBody User user){ |
| | | return userService.update(user); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @ApiOperation(value = "删除") |
| | | public boolean delete(@RequestParam int id){ |
| | | return userService.delete(id); |
| | | @PutMapping("freezeUser") |
| | | @ApiOperation(value = "冻结用户") |
| | | public Response updateUserFreeze(@RequestParam int id){ |
| | | return userService.updateUserFreeze(id); |
| | | } |
| | | |
| | | @PutMapping("deleteUser") |
| | | @ApiOperation(value = "删除用户") |
| | | public Response delete(@RequestParam int id){ |
| | | return userService.deleteUser(id); |
| | | } |
| | | |
| | | /** |
| | |
| | | return userService.loginCheck(request); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/getDepts") |
| | | @ApiOperation(value = "获取部门") |
| | | public List<Dept> getDepts(){ |
| | | return deptService.getAll(); |
| | | } |
| | | @PostMapping("addDept") |
| | | @ApiOperation(value = "添加部门") |
| | | public Response addDept(@RequestBody Dept dept){ |
| | | return deptService.add(dept); |
| | | } |
| | | @PutMapping("updateDept") |
| | | @ApiOperation(value = "编辑部门") |
| | | public Response update(@RequestBody Dept dept){ |
| | | return deptService.update(dept); |
| | | } |
| | | |
| | | @DeleteMapping("deleteDept") |
| | | @ApiOperation(value = "删除部门") |
| | | public Response deleteDept(@RequestParam int id){ |
| | | return deptService.delete(id); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getJobs") |
| | | @ApiOperation(value = "获取职务") |
| | | public List<Job> getJobs(){ |
| | | return jobService.getAll(); |
| | | } |
| | | |
| | | @PostMapping("addJob") |
| | | @ApiOperation(value = "添加职务") |
| | | public Response addJob(@RequestBody Job job){ |
| | | return jobService.add(job); |
| | | } |
| | | @PutMapping("updateJob") |
| | | @ApiOperation(value = "编辑职务") |
| | | public Response update(@RequestBody Job job){ |
| | | return jobService.update(job); |
| | | } |
| | | |
| | | @DeleteMapping("deleteJob") |
| | | @ApiOperation(value = "删除职务") |
| | | public Response deleteJob(@RequestParam int id){ |
| | | return jobService.delete(id); |
| | | } |
| | | |
| | | } |