package com.docus.server.collect.service;

import com.docus.server.collect.infrastructure.dao.ReceiveDeptInfoEntity;
import com.docus.server.collect.infrastructure.mapper.ReceiveDeptInfoMapper;
import com.docus.server.sys.common.pojo.dto.DeptDTO;
import com.docus.server.sys.service.IPowerDeptService;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Component
@Service
public class CollectService {

    @Resource
    private IPowerDeptService deptService;
    @Resource
    private ReceiveDeptInfoMapper receiveDeptInfoMapper;

    public void receiveDept(DeptDTO dept) {

        //判断任务是否存在。
        //保存数据库
        //从dept 解析为数据库对象
        ReceiveDeptInfoEntity receiveDeptInfoEntity = new ReceiveDeptInfoEntity();
        receiveDeptInfoMapper.insert(receiveDeptInfoEntity);

        //异步写入归档系统，失败自动重试。
        deptService.saveOrUpdatePowerDept(dept);

    }


}
