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.MatterQuestionDao;
import com.mortals.xhx.module.matter.model.MatterQuestionEntity;
import com.mortals.xhx.module.matter.service.MatterQuestionService;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
* <p>Title: 事项常见问题</p>
* <p>Description: MatterQuestionService service接口 </p>
* <p>Copyright: Copyright &reg;  </p>
* @version 1.0.0
*/
@Service("matterQuestionService")
public class MatterQuestionServiceImpl extends AbstractCRUDServiceImpl<MatterQuestionDao, MatterQuestionEntity, Long> implements MatterQuestionService {

    @Autowired
    private MatterService matterService;

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