package com.mortals.xhx.module.job.service.impl;
import com.mortals.xhx.module.job.model.JobQuery;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.job.dao.JobDao;
import com.mortals.xhx.module.job.model.JobEntity;
import com.mortals.xhx.module.job.service.JobService;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
* JobService
* 职位信息 service实现
*
* @author zxfei
* @date 2023-04-07
*/
@Service("jobService")
public class JobServiceImpl extends AbstractCRUDServiceImpl<JobDao, JobEntity, Long> implements JobService {

    @Override
    protected void findAfter(JobEntity entity, Context context, List<JobEntity> list) throws AppException {
        list.stream().peek(item -> {
            List<JobEntity> childs = this.find(new JobQuery().groupId(item.getId()));
            if (!ObjectUtils.isEmpty(childs)) {
                item.setChildren(childs);
            } else {
                item.setChildren(null);
            }
        }).count();
    }
}