@@ -1,20 +1,44 @@ | |||
package com.ningdatech.pmapi.organization.controller; | |||
import com.ningdatech.pmapi.organization.manage.GovBusinessStripManage; | |||
import com.ningdatech.pmapi.organization.model.vo.GovBusinessStripTreeVO; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Controller; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RequestParam; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import org.springframework.stereotype.Controller; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 前端控制器 | |||
* 前端控制器 | |||
* </p> | |||
* | |||
* @author Liuxinxin | |||
* @since 2023-03-08 | |||
*/ | |||
@Controller | |||
@RequestMapping("/pmapi.organization/gov-business-strip") | |||
@Slf4j | |||
@Validated | |||
@RestController | |||
@RequiredArgsConstructor | |||
@Api(value = "GovBusinessStripController", tags = "条线管理") | |||
@RequestMapping("/api/v1/gov-business-strip") | |||
public class GovBusinessStripController { | |||
private final GovBusinessStripManage govBusinessStripManage; | |||
@GetMapping("/get-child-list") | |||
@ApiOperation("获取条线标签的的树状结构") | |||
public List<GovBusinessStripTreeVO> getChildOrganizationList(@RequestParam(value = "parentCode", required = false) String parentCode) { | |||
return govBusinessStripManage.getChildOrganizationList(parentCode); | |||
} | |||
} |
@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModel; | |||
import lombok.Data; | |||
import java.io.Serializable; | |||
import java.time.LocalDateTime; | |||
/** | |||
* <p> | |||
@@ -24,14 +23,6 @@ public class GovBusinessStrip implements Serializable { | |||
private Long id; | |||
private LocalDateTime createOn; | |||
private LocalDateTime updateOn; | |||
private Long createBy; | |||
private Long updateBy; | |||
/** | |||
* 条线code | |||
*/ | |||
@@ -41,4 +32,14 @@ public class GovBusinessStrip implements Serializable { | |||
* 条线名称 | |||
*/ | |||
private String businessStripName; | |||
/** | |||
* 父级条线code | |||
*/ | |||
private String parentCode; | |||
/** | |||
* 父级条线名称 | |||
*/ | |||
private String parentName; | |||
} |
@@ -0,0 +1,42 @@ | |||
package com.ningdatech.pmapi.organization.manage; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.pmapi.organization.entity.GovBusinessStrip; | |||
import com.ningdatech.pmapi.organization.model.vo.GovBusinessStripTreeVO; | |||
import com.ningdatech.pmapi.organization.service.IGovBusinessStripService; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.stereotype.Component; | |||
import java.util.List; | |||
import java.util.Objects; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @author liuxinxin | |||
* @date 2023/3/14 下午4:48 | |||
*/ | |||
@Component | |||
@RequiredArgsConstructor | |||
public class GovBusinessStripManage { | |||
private final IGovBusinessStripService iGovBusinessStripService; | |||
public List<GovBusinessStripTreeVO> getChildOrganizationList(String parentCode) { | |||
if (Objects.isNull(parentCode)) { | |||
parentCode = "-1"; | |||
} | |||
List<GovBusinessStrip> govBusinessStripList = iGovBusinessStripService.list(Wrappers.lambdaQuery(GovBusinessStrip.class) | |||
.eq(GovBusinessStrip::getParentCode, parentCode)); | |||
return govBusinessStripList.stream().map(r -> { | |||
GovBusinessStripTreeVO govBusinessStripTreeVO = new GovBusinessStripTreeVO(); | |||
govBusinessStripTreeVO.setBusinessStripCode(r.getBusinessStripCode()); | |||
govBusinessStripTreeVO.setBusinessStripName(r.getBusinessStripName()); | |||
govBusinessStripTreeVO.setParentCode(r.getParentCode()); | |||
govBusinessStripTreeVO.setParentName(r.getParentName()); | |||
return govBusinessStripTreeVO; | |||
}).collect(Collectors.toList()); | |||
} | |||
} |
@@ -0,0 +1,28 @@ | |||
package com.ningdatech.pmapi.organization.model.vo; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
/** | |||
* @author Liuxinxin | |||
* @since 2023-03-08 | |||
*/ | |||
@Data | |||
@ApiModel(value = "条线树形 responseVO", description = "") | |||
public class GovBusinessStripTreeVO { | |||
private Long id; | |||
@ApiModelProperty("条线code") | |||
private String businessStripCode; | |||
@ApiModelProperty("条线名称") | |||
private String businessStripName; | |||
@ApiModelProperty("父级条线code") | |||
private String parentCode; | |||
@ApiModelProperty("父级条线名称") | |||
private String parentName; | |||
} |