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.MatterDatumDao;
import com.mortals.xhx.module.matter.model.MatterDatumEntity;
import com.mortals.xhx.module.matter.service.MatterDatumService;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
* <p>Title: 事项申请材料</p>
* <p>Description: MatterDatumService service接口 </p>
* <p>Copyright: Copyright &reg;  </p>
* @version 1.0.0
*/
@Service("matterDatumService")
public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumDao, MatterDatumEntity, Long> implements MatterDatumService {

    @Autowired
    private MatterService matterService;


    @Override
    protected void findAfter(MatterDatumEntity params, PageInfo pageInfo, Context context, List<MatterDatumEntity> list) throws AppException {
        list.stream().peek(item->{
            MatterEntity matterEntity = matterService.getCache(item.getMatterId().toString());
            if(!ObjectUtils.isEmpty(matterEntity)){
                item.setMatterName(matterEntity.getMatterName());
            }
        }).count();
        super.findAfter(params, pageInfo, context, list);
    }
}