| | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.mindskip.xzs.base.BaseApiController; |
| | | import com.mindskip.xzs.base.RestResponse; |
| | | import com.mindskip.xzs.domain.Department; |
| | | import com.mindskip.xzs.domain.User; |
| | | import com.mindskip.xzs.service.DepartmentService; |
| | | import com.mindskip.xzs.utility.PageInfoHelper; |
| | | import com.mindskip.xzs.viewmodel.admin.department.DepartmentResponseVM; |
| | | import com.mindskip.xzs.viewmodel.admin.user.UserPageRequestVM; |
| | | import com.mindskip.xzs.viewmodel.admin.user.UserResponseVM; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | |
| | | |
| | | @RestController("AdminDepartmentController") |
| | | @RequestMapping("/api/admin/department") |
| | |
| | | this.departmentService = departmentService; |
| | | } |
| | | |
| | | // @RequestMapping(value = "/page/list", method = RequestMethod.POST) |
| | | // public RestResponse<PageInfo<UserResponseVM>> pageList(@RequestBody UserPageRequestVM model) { |
| | | // PageInfo<User> pageInfo = userService.userPage(model); |
| | | // PageInfo<UserResponseVM> page = PageInfoHelper.copyMap(pageInfo, d -> UserResponseVM.from(d)); |
| | | // return RestResponse.ok(page); |
| | | // } |
| | | |
| | | @RequestMapping(value = "/page/list", method = RequestMethod.POST) |
| | | public RestResponse<PageInfo<DepartmentResponseVM>> pageList(@RequestBody DepartmentResponseVM model) { |
| | | PageInfo<Department> pageInfo = departmentService.gets(model); |
| | | PageInfo<DepartmentResponseVM> page = PageInfoHelper.copyMap(pageInfo, q -> { |
| | | DepartmentResponseVM vm = modelMapper.map(q,DepartmentResponseVM.class); |
| | | return vm; |
| | | }); |
| | | return RestResponse.ok(page); |
| | | } |
| | | |
| | | @RequestMapping(value = "/add", method = RequestMethod.POST) |
| | | public RestResponse add(@RequestBody @Valid String name) { |
| | | return RestResponse.ok(departmentService.add(name)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/update", method = RequestMethod.POST) |
| | | public RestResponse update(@RequestBody @Valid Department model) { |
| | | return RestResponse.ok(departmentService.update(model)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/get/{id}", method = RequestMethod.POST) |
| | | public RestResponse update(@PathVariable Integer id) { |
| | | return RestResponse.ok(departmentService.getById(id)); |
| | | } |
| | | } |