package com.mortals.xhx.module.matter.service.impl;

import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.matter.model.MatterEntity;
import com.mortals.xhx.module.matter.service.MatterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.matter.dao.MatterFlowlimitDao;
import com.mortals.xhx.module.matter.model.MatterFlowlimitEntity;
import com.mortals.xhx.module.matter.service.MatterFlowlimitService;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
* <p>Title: 事项办理流程</p>
* <p>Description: MatterFlowlimitService service接口 </p>
* <p>Copyright: Copyright &reg;  </p>
* @version 1.0.0
*/
@Service("matterFlowlimitService")
public class MatterFlowlimitServiceImpl extends AbstractCRUDServiceImpl<MatterFlowlimitDao, MatterFlowlimitEntity, Long> implements MatterFlowlimitService {
    @Autowired
    private MatterService matterService;


    @Override
    protected void findAfter(MatterFlowlimitEntity params, PageInfo pageInfo, Context context, List<MatterFlowlimitEntity> list) throws AppException {

        list.stream().peek(item->{
            MatterEntity matterEntity = matterService.get(item.getMatterId());
            if(!ObjectUtils.isEmpty(matterEntity)){
                item.setMatterName(matterEntity.getMatterName());
            }
        }).count();
        super.findAfter(params, pageInfo, context, list);
    }
}