package com.trs.project.spider;

import com.trs.project.entity.EmpPolicy;
import com.trs.project.service.EmpPolicyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

import java.time.LocalDateTime;

@Component
public class EmpPolicyPipeline implements Pipeline {

    @Autowired
    private EmpPolicyService empPolicyService;

    @Override
    public void process(ResultItems resultItems, Task task) {
        EmpPolicy empPolicy  = resultItems.get("empPolicy");

        empPolicy.setSavetime(LocalDateTime.now());
        empPolicyService.saveOrUpdate(empPolicy);
    }
}
