| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.system.dto.DeptDTO; |
| | | import com.ruoyi.system.dto.ProjectDeptDTO; |
| | | import com.ruoyi.system.model.TDept; |
| | | import com.ruoyi.system.model.TLocationType; |
| | | import com.ruoyi.system.model.TProjectDept; |
| | | import com.ruoyi.system.query.DeptListQuery; |
| | | import com.ruoyi.system.query.ProjectDeptListQuery; |
| | | import com.ruoyi.system.service.TDeptService; |
| | | import com.ruoyi.system.service.TProjectDeptService; |
| | | import com.ruoyi.system.vo.system.DeptListVO; |
| | | import com.ruoyi.system.vo.system.ProjectDeptListNoLimitVO; |
| | | import com.ruoyi.system.vo.system.ProjectDeptListVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | @ApiOperation(value = "项目部分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<ProjectDeptListVO>> pageList(@RequestBody ProjectDeptListQuery query) { |
| | | public R<PageInfo<ProjectDeptListVO>> pageList(@RequestBody DeptListQuery query) { |
| | | return R.ok(deptService.pageList(query)); |
| | | } |
| | | @ApiOperation(value = "选择项目部/片区不分页列表") |
| | |
| | | BeanUtils.copyProperties(projectDept,projectDeptListNoLimitVO1); |
| | | projectDeptListNoLimitVOS1.add(projectDeptListNoLimitVO1); |
| | | } |
| | | projectDeptListNoLimitVO.setChildren(projectDeptListNoLimitVOS1); |
| | | projectDeptListNoLimitVO.setChildrenList(projectDeptListNoLimitVOS1); |
| | | projectDeptListNoLimitVOS.add(projectDeptListNoLimitVO); |
| | | } |
| | | return R.ok(projectDeptListNoLimitVOS); |
| | |
| | | @ApiOperation(value = "新增项目部") |
| | | @PostMapping(value = "/add") |
| | | public R<Boolean> add(@RequestBody ProjectDeptDTO dto) { |
| | | if (!StringUtils.hasLength(dto.getParentId())){ |
| | | dto.setParentId("0"); |
| | | } |
| | | |
| | | deptService.save(dto); |
| | | return R.ok(); |
| | | } |
| | |
| | | @ApiOperation(value = "编辑项目部") |
| | | @PostMapping(value = "/edit") |
| | | public R<Boolean> edit(@RequestBody ProjectDeptDTO dto) { |
| | | if (!StringUtils.hasLength(dto.getParentId())){ |
| | | dto.setParentId("0"); |
| | | } |
| | | deptService.updateById(dto); |
| | | return R.ok(); |
| | | } |
| | |
| | | } |
| | | @Log(title = "启用/禁用项目部", businessType = BusinessType.OTHER) |
| | | @ApiOperation(value = "启用/禁用项目部") |
| | | @DeleteMapping(value = "/editStatus") |
| | | @GetMapping(value = "/editStatus") |
| | | public R<Boolean> editStatus(@RequestParam String id) { |
| | | TProjectDept byId = deptService.getById(id); |
| | | if (byId.getParentId().equals("0")){ |
| | | // 禁用上级 下级一起禁用 |
| | | List<TProjectDept> list = deptService.lambdaQuery().eq(TProjectDept::getParentId, byId.getId()).list(); |
| | | for (TProjectDept tProjectDept : list) { |
| | | tProjectDept.setStatus(2); |
| | | } |
| | | deptService.updateBatchById(list); |
| | | } |
| | | if (byId.getStatus()==1){ |
| | | byId.setStatus(2); |
| | | }else{ |