| | |
| | | package com.ycl.controller.depart; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ycl.annotation.LogSave; |
| | | import com.ycl.api.BasePageDTO; |
| | | import com.ycl.api.BasePageVO; |
| | | import com.ycl.api.CommonResult; |
| | | import com.ycl.controller.BaseController; |
| | | import com.ycl.entity.depart.DepartManager; |
| | | import com.ycl.entity.depart.UmsDepart; |
| | | import com.ycl.entity.user.UmsDepartManage; |
| | | import com.ycl.service.depart.UmsDepartService; |
| | | import com.ycl.service.user.UmsDepartManageService; |
| | | import com.ycl.utils.auth.UserAuthUtil; |
| | | import com.ycl.vo.depart.DepartVO; |
| | | import com.ycl.vo.depart.UmsDepartVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @ApiOperation("添加部门") |
| | | @PostMapping(value = "/create") |
| | | @LogSave(operationType = "部门管理", contain = "添加部门") |
| | | public CommonResult<Void> create(@Validated @RequestBody DepartVO.AddDepartVO addDepartVO) { |
| | | departService.create(addDepartVO); |
| | | return CommonResult.success(null); |
| | |
| | | |
| | | @ApiOperation("编辑部门") |
| | | @PostMapping(value = "/update") |
| | | @LogSave(operationType = "部门管理", contain = "编辑部门") |
| | | public CommonResult<Void> create(@Validated @RequestBody DepartVO.UpdateDepartVO params) { |
| | | departService.update(params); |
| | | return CommonResult.success(null); |
| | |
| | | |
| | | @ApiOperation("删除") |
| | | @PostMapping(value = "/delete") |
| | | @LogSave(operationType = "部门管理", contain = "删除部门") |
| | | public CommonResult<Void> delete(@Validated @RequestBody DepartVO.IdDepartVO params) { |
| | | departService.delete(params.getId()); |
| | | return CommonResult.success(null); |
| | | } |
| | | |
| | | /** |
| | | * @Description batch deletion departments |
| | | * @Param [ids] |
| | | * @return com.ycl.api.CommonResult<java.lang.Void> |
| | | * @Description batch deletion departments |
| | | * @Param [ids] |
| | | **/ |
| | | @ApiOperation("删除") |
| | | @PostMapping(value = "/batch_deletion)") |
| | | public CommonResult<Void> delete(@RequestParam String[] ids) { |
| | | departService.removeBatchByIds(Arrays.asList(ids)); |
| | | return CommonResult.success(null); |
| | | @ApiOperation("批处理-删除") |
| | | @PostMapping(value = "/batch_deletion") |
| | | @LogSave(operationType = "部门管理", contain = "批量删除部门") |
| | | public CommonResult delete(@RequestParam List<Long> ids) { |
| | | if (ids.isEmpty()) { |
| | | return CommonResult.failed("bad request parameter"); |
| | | } |
| | | return CommonResult.success(departService.removeBatchByIds(ids)); |
| | | } |
| | | |
| | | @ApiOperation("详情") |
| | | @PostMapping(value = "/detail") |
| | | @LogSave(operationType = "部门管理", contain = "查看部门") |
| | | public CommonResult<UmsDepart> detail(@Validated @RequestBody DepartVO.IdDepartVO params) { |
| | | UmsDepart sccgDepart = departService.loadDepartById(params.getId()); |
| | | return CommonResult.success(sccgDepart); |
| | |
| | | |
| | | @ApiOperation("查询全部部门") |
| | | @GetMapping(value = "/page") |
| | | public CommonResult<IPage<UmsDepart>> page(DepartVO.PageDepartVO params) { |
| | | IPage<UmsDepart> page = departService.pageDepart(params); |
| | | public CommonResult<IPage<UmsDepartVO>> page(@RequestParam("currentPage") Integer currentPage, @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam(value = "departName", required = false) String departName) { |
| | | IPage<UmsDepartVO> page = new Page<>(currentPage, pageSize); |
| | | departService.pageDepart(departName, page); |
| | | return CommonResult.success(page); |
| | | } |
| | | |
| | | @ApiOperation("查询我的部门") |
| | | @GetMapping(value = "/belongDepart") |
| | | public CommonResult<BasePageDTO> belongDepart(BasePageVO params) { |
| | | BasePageDTO basePageDTO= umsAdminDepartService.belongDepart(fetchOperator(request).getOperatorId(), params.getCurrent(), params.getPageSize()); |
| | | BasePageDTO basePageDTO = umsAdminDepartService.belongDepart(fetchOperator(request).getOperatorId(), params.getCurrent(), params.getPageSize()); |
| | | return CommonResult.success(basePageDTO); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation("用户修改角色") |
| | | @PutMapping(value = "/user_update_Role") |
| | | public CommonResult userUpdateRole(@RequestParam Long id, |
| | | @RequestParam List<Long> roles) { |
| | | umsAdminDepartService.userUpdateRoles(id, roles); |
| | | return CommonResult.success("update success"); |
| | | } |
| | | |
| | | @ApiOperation("用户修改部门") |
| | | @PutMapping(value = "/user_update_depart") |
| | | public CommonResult userUpdateDepart(@RequestParam Long id, |
| | | @RequestParam List<UmsDepartManage> departmentIds) { |
| | | umsAdminDepartService.userUpdateDepart(id, departmentIds); |
| | | return CommonResult.success("update success"); |
| | | } |
| | | |
| | | @ApiOperation("查询顶级部门") |
| | | @GetMapping(value = "/query_father") |
| | | public CommonResult search() { |
| | | Integer fatherId = 0; |
| | | return CommonResult.success(departService |
| | | .list(new LambdaQueryWrapper<UmsDepart>() |
| | | .eq(UmsDepart::getParentId, fatherId))); |
| | | } |
| | | |
| | | @ApiOperation("查询部门二级") |
| | | @GetMapping(value = "/query_father_children") |
| | | public CommonResult search(@RequestParam Integer fatherId) { |
| | | return CommonResult.success(departService |
| | | .list(new LambdaQueryWrapper<UmsDepart>() |
| | | .eq(UmsDepart::getParentId, fatherId))); |
| | | } |
| | | } |