import com.example.entity.Department;
import com.example.entity.IndexPattern;
import com.example.mapper.DepartmentMapper;
import com.example.service.IndexPatternService;
import com.example.request.QueryIndexPatternRequest;
import com.example.response.QueryIndexPatternResponse;
import com.example.exception.BaseBizException;
import com.example.enums.HadesErrCodeEnum;
import com.example.utils.RespUtils;
import java.util.List;
import java.util.stream.Collectors;
public class DepartmentServiceImpl {
private final DepartmentMapper departmentMapper;
private final IndexPatternService indexPatternService;
public DepartmentServiceImpl(DepartmentMapper departmentMapper, IndexPatternService indexPatternService) {
this.departmentMapper = departmentMapper;
this.indexPatternService = indexPatternService;
}
@Override
public QueryIndexPatternResponse queryIndexPatternByDepartmentId(QueryIndexPatternRequest request) {
QueryDepartmentIndexPatternResponse response = new QueryDepartmentIndexPatternResponse();
if (StringUtils.isEmpty(departmentId)) {
throw new TitanException("所传参数为空");
}
Department department = departmentMapper.selectOneByExample(departmentId);
if (department == null) {
QueryIndexPatternResponse response = new QueryIndexPatternResponse();
RespUtils.setError(HadesErrCodeEnum.DEPARTMENT_NOT_FOUND, response);
return response;
}
List<IndexPattern> indexPatterns = indexPatternService.getIndexPatternByDepartmentId(departmentId);
List<String> indexPatternNames = indexPatterns.stream()
.map(IndexPattern::getName)
.collect(Collectors.toList());
QueryIndexPatternResponse response = new QueryIndexPatternResponse();
response.setIndexPatternNames(indexPatternNames);
RespUtils.setSuccess(response);
return response;
}
}
标签:departmentMapper,QueryIndexPatternResponse,最后,example,import,com,response From: https://www.cnblogs.com/lmzzr24/p/18546737