package cn.com.poc.human_resources.service.impl;	

import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.poc.human_resources.service.HumanResourceResumeNaturalLanguageRetrievalLogService;
import cn.com.poc.human_resources.model.HumanResourceResumeNaturalLanguageRetrievalLogModel;
import cn.com.poc.human_resources.entity.HumanResourceResumeNaturalLanguageRetrievalLogEntity;
import cn.com.poc.human_resources.convert.HumanResourceResumeNaturalLanguageRetrievalLogConvert;
import cn.com.poc.human_resources.repository.HumanResourceResumeNaturalLanguageRetrievalLogRepository;
import cn.com.yict.framemax.data.model.PagingInfo;
import org.springframework.stereotype.Service;

import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.stream.Collectors;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.util.Assert;

@Service
public class HumanResourceResumeNaturalLanguageRetrievalLogServiceImpl extends BaseServiceImpl
 			 implements HumanResourceResumeNaturalLanguageRetrievalLogService {
   
    @Resource
    private HumanResourceResumeNaturalLanguageRetrievalLogRepository repository;
    			 
    public HumanResourceResumeNaturalLanguageRetrievalLogEntity get(java.lang.Long id) throws Exception{
        Assert.notNull(id);
        HumanResourceResumeNaturalLanguageRetrievalLogModel model =  this.repository.get(id);
        if (model == null){
            return null;
        }
        return HumanResourceResumeNaturalLanguageRetrievalLogConvert.modelToEntity(model);
    }


    public List<HumanResourceResumeNaturalLanguageRetrievalLogEntity> findByExample(HumanResourceResumeNaturalLanguageRetrievalLogEntity example,PagingInfo pagingInfo) throws Exception{
        List<HumanResourceResumeNaturalLanguageRetrievalLogEntity> result = new  ArrayList<HumanResourceResumeNaturalLanguageRetrievalLogEntity>();
        HumanResourceResumeNaturalLanguageRetrievalLogModel model = new HumanResourceResumeNaturalLanguageRetrievalLogModel();
        if (example != null){
            model = HumanResourceResumeNaturalLanguageRetrievalLogConvert.entityToModel(example);
        }
        List<HumanResourceResumeNaturalLanguageRetrievalLogModel> models = this.repository.findByExample(model,pagingInfo);
        if (CollectionUtils.isNotEmpty(models)) {
            result = models.stream().map(HumanResourceResumeNaturalLanguageRetrievalLogConvert::modelToEntity).collect(Collectors.toList());
        }
        return result;
    }

    public HumanResourceResumeNaturalLanguageRetrievalLogEntity save(HumanResourceResumeNaturalLanguageRetrievalLogEntity entity) {
        Assert.notNull(entity);
        entity.setId(null);
        HumanResourceResumeNaturalLanguageRetrievalLogModel model = HumanResourceResumeNaturalLanguageRetrievalLogConvert.entityToModel(entity);
        HumanResourceResumeNaturalLanguageRetrievalLogModel saveModel =  this.repository.save(model);
        return HumanResourceResumeNaturalLanguageRetrievalLogConvert.modelToEntity(saveModel);
    }

    public HumanResourceResumeNaturalLanguageRetrievalLogEntity update(HumanResourceResumeNaturalLanguageRetrievalLogEntity entity) throws Exception{
        Assert.notNull(entity);
        Assert.notNull(entity.getId(),"update pk can not be null");
        HumanResourceResumeNaturalLanguageRetrievalLogModel model = this.repository.get(entity.getId());

       if (entity.getPostionId() != null){
        model.setPostionId(entity.getPostionId());
       }
       if (entity.getPositionContent() != null){
        model.setPositionContent(entity.getPositionContent());
       }
       if (entity.getResumeIds() != null){
        model.setResumeIds(entity.getResumeIds());
       }
       if (entity.getRetrievalContent() != null){
        model.setRetrievalContent(entity.getRetrievalContent());
       }
       if (entity.getCreator() != null){
        model.setCreator(entity.getCreator());
       }
       if (entity.getCreatedTime() != null){
        model.setCreatedTime(entity.getCreatedTime());
       }
       if (entity.getModifier() != null){
        model.setModifier(entity.getModifier());
       }
       if (entity.getModifiedTime() != null){
        model.setModifiedTime(entity.getModifiedTime());
       }
       if (entity.getSysVersion() != null){
        model.setSysVersion(entity.getSysVersion());
       }
        HumanResourceResumeNaturalLanguageRetrievalLogModel saveModel =  this.repository.save(model);
        return HumanResourceResumeNaturalLanguageRetrievalLogConvert.modelToEntity(saveModel);
    }

    public void deletedById(java.lang.Long id) throws Exception{
        Assert.notNull(id);
        HumanResourceResumeNaturalLanguageRetrievalLogModel model =  this.repository.get(id);
        if (model != null){
        }
    }
    
}