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.MatterAcceptDao;
import com.mortals.xhx.module.matter.model.MatterAcceptEntity;
import com.mortals.xhx.module.matter.service.MatterAcceptService;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
* <p>Title: 事项受理条件</p>
* <p>Description: MatterAcceptService service接口 </p>
* <p>Copyright: Copyright &reg;  </p>
* @version 1.0.0
*/
@Service("matterAcceptService")
public class MatterAcceptServiceImpl extends AbstractCRUDServiceImpl<MatterAcceptDao, MatterAcceptEntity, Long> implements MatterAcceptService {

    @Autowired
    private MatterService matterService;


    @Override
    protected void findAfter(MatterAcceptEntity params, PageInfo pageInfo, Context context, List<MatterAcceptEntity> 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);
    }
}