|
@@ -0,0 +1,118 @@
|
|
|
|
+package com.jeeplus.test.program.configuration.typeDict.controller;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.jeeplus.aop.logging.annotation.ApiLog;
|
|
|
|
+import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
|
|
+import com.jeeplus.sys.constant.enums.LogTypeEnum;
|
|
|
|
+import com.jeeplus.sys.utils.StringUtils;
|
|
|
|
+import com.jeeplus.test.program.configuration.typeDict.domain.ProgramTypeDict;
|
|
|
|
+import com.jeeplus.test.program.configuration.typeDict.service.ProgramTypeDictService;
|
|
|
|
+import com.jeeplus.test.program.configuration.typeDict.service.dto.ProgramTypeDictDTO;
|
|
|
|
+import com.jeeplus.test.program.configuration.typeDict.service.mapstruct.ProgramTypeDictWrapper;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+@Api("项目配置管理-项目类型管理")
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping(value = "/program/configuration/type")
|
|
|
|
+public class ProgramTypeDictController {
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private ProgramTypeDictService programTypeDictService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询项目类型管理列表
|
|
|
|
+ * @param programTypeDictDTO
|
|
|
|
+ * @param page
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @ApiLog("查询项目类型管理列表")
|
|
|
|
+ @PreAuthorize("hasAuthority('program:configuration:type:list')")
|
|
|
|
+ @GetMapping("list")
|
|
|
|
+ public ResponseEntity<IPage<ProgramTypeDictDTO>> data(ProgramTypeDictDTO programTypeDictDTO, Page<ProgramTypeDictDTO> page) throws Exception {
|
|
|
|
+ IPage<ProgramTypeDictDTO> result = new Page<ProgramTypeDictDTO>();
|
|
|
|
+ if(ObjectUtil.isNotEmpty(programTypeDictDTO)){
|
|
|
|
+ if(StringUtils.isNotBlank(programTypeDictDTO.getType())){
|
|
|
|
+ List<ProgramTypeDict> programTypeDictList = programTypeDictService.list(new QueryWrapper<ProgramTypeDict>().lambda()
|
|
|
|
+ .like(StringUtils.isNotBlank(programTypeDictDTO.getType()), ProgramTypeDict::getType, programTypeDictDTO.getType())
|
|
|
|
+ );
|
|
|
|
+ List<String> pIdList = programTypeDictList.stream().distinct().filter(item->{
|
|
|
|
+ if(!"0".equals(item.getParentId())){
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }).map(ProgramTypeDict::getParentId).collect(Collectors.toList());
|
|
|
|
+ List<String> IdList = programTypeDictList.stream().distinct().filter(item->{
|
|
|
|
+ if("0".equals(item.getParentId())){
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }).map(ProgramTypeDict::getId).collect(Collectors.toList());
|
|
|
|
+ pIdList.addAll(IdList);
|
|
|
|
+ List<String> collect = pIdList.stream().distinct().collect(Collectors.toList());
|
|
|
|
+ if(CollectionUtil.isNotEmpty(collect)){
|
|
|
|
+ QueryWrapper<ProgramTypeDict> wrapper = new QueryWrapper<ProgramTypeDict>()
|
|
|
|
+ .in("ptd.id",collect)
|
|
|
|
+ .or()
|
|
|
|
+ .in("ptd.parent_id",collect);
|
|
|
|
+ result = programTypeDictService.findList (page,wrapper);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ result = programTypeDictService.findList (page,new QueryWrapper<ProgramTypeDict>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return ResponseEntity.ok (result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询项目类型管理数据
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ApiLog("查询项目类型管理详情")
|
|
|
|
+ @PreAuthorize ("hasAnyAuthority('program:configuration:type:view','program:configuration:type:add','program:configuration:type:edit')")
|
|
|
|
+ @GetMapping("queryById")
|
|
|
|
+ public ResponseEntity queryById(@RequestParam("id") String id) {
|
|
|
|
+ ProgramTypeDictDTO programTypeDictDTO = programTypeDictService.queryById ( id );
|
|
|
|
+ return ResponseEntity.ok (programTypeDictDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存项目类型
|
|
|
|
+ * @param programTypeDictDTO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ApiLog(value = "修改/新增项目类型", type = LogTypeEnum.SAVE)
|
|
|
|
+ @PreAuthorize("hasAnyAuthority('program:configuration:type:save','program:configuration:type:edit')")
|
|
|
|
+ @PostMapping("save")
|
|
|
|
+ public ResponseEntity save(@Valid @RequestBody ProgramTypeDictDTO programTypeDictDTO) {
|
|
|
|
+ programTypeDictService.saveType(programTypeDictDTO);
|
|
|
|
+ return ResponseEntity.ok ("操作成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除项目类型
|
|
|
|
+ * @param ids
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ApiLog(value = "删除项目类型", type = LogTypeEnum.SAVE)
|
|
|
|
+ @PreAuthorize ("hasAuthority('program:configuration:type:del')")
|
|
|
|
+ @DeleteMapping("delete")
|
|
|
|
+ public ResponseEntity delete(String ids) {
|
|
|
|
+ return programTypeDictService.deleteByIds(ids);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|