|  | @@ -17,23 +17,47 @@ import org.springframework.web.bind.annotation.RequestBody;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.RestController;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import java.util.Map;
 | 
	
		
			
				|  |  | +import java.util.stream.Collectors;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  @RequestMapping("/open/subject")
 | 
	
		
			
				|  |  |  @Api(tags = "声部服务")
 | 
	
		
			
				|  |  |  @RestController
 | 
	
		
			
				|  |  |  public class OpenSubjectController extends BaseController {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Autowired
 | 
	
		
			
				|  |  | -	private SubjectService subjectService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SubjectService subjectService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @ApiOperation(value = "根据声部编号查询声部")
 | 
	
		
			
				|  |  | +    @GetMapping("/get/{id}")
 | 
	
		
			
				|  |  | +    public Object get(@ApiParam(value = "声部编号", required = true) @PathVariable("id") Long id) {
 | 
	
		
			
				|  |  | +        return succeed(subjectService.get(id));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @ApiOperation(value = "分页查询声部树状列表")
 | 
	
		
			
				|  |  | +    @PostMapping("/queryPageTree")
 | 
	
		
			
				|  |  | +    public HttpResponseResult<PageInfo<Subject>> queryPageTree(@RequestBody SubjectQueryInfo queryInfo) {
 | 
	
		
			
				|  |  | +        return succeed(subjectService.queryPageTree(queryInfo));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @ApiOperation(value = "分页查询声部列表")
 | 
	
		
			
				|  |  | +    @GetMapping("/queryPage")
 | 
	
		
			
				|  |  | +    public HttpResponseResult<PageInfo<Subject>> queryPage(SubjectQueryInfo queryInfo) {
 | 
	
		
			
				|  |  | +        PageInfo<Subject> pageInfo = subjectService.queryPage(queryInfo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (pageInfo.getRows().size() == 0) {
 | 
	
		
			
				|  |  | +            return succeed(pageInfo);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@ApiOperation(value = "根据声部编号查询声部")
 | 
	
		
			
				|  |  | -	@GetMapping("/get/{id}")
 | 
	
		
			
				|  |  | -	public Object get(@ApiParam(value = "声部编号", required = true) @PathVariable("id") Long id) {
 | 
	
		
			
				|  |  | -		return succeed(subjectService.get(id));
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +        Map<Long, Subject> map =
 | 
	
		
			
				|  |  | +                subjectService.findBySubjectByIdList(pageInfo.getRows().stream().map(Subject::getParentSubjectId).collect(Collectors.toList())).stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(Subject::getId, t -> t));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@ApiOperation(value = "分页查询声部树状列表")
 | 
	
		
			
				|  |  | -	@PostMapping("/queryPageTree")
 | 
	
		
			
				|  |  | -	public HttpResponseResult<PageInfo<Subject>> queryPageTree(@RequestBody SubjectQueryInfo queryInfo) {
 | 
	
		
			
				|  |  | -		return succeed(subjectService.queryPageTree(queryInfo));
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +        pageInfo.getRows().forEach(row -> {
 | 
	
		
			
				|  |  | +            if (row.getParentSubjectId() != null && row.getParentSubjectId() > 0) {
 | 
	
		
			
				|  |  | +                row.setParentSubjectName(map.get(row.getParentSubjectId()).getName());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        return succeed(pageInfo);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |