package com.bonus.boot.manager.health.service.Impl;


import com.bonus.boot.manager.health.dao.SpecialJobDao;
import com.bonus.boot.manager.health.entity.SpecialJobBean;
import com.bonus.boot.manager.health.service.SpecialJobService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("specialJobService")
public class SpecialJobServiceImpl implements SpecialJobService {
    @Resource(name = "specialJobDao")
    private SpecialJobDao dao;
    @Override
    public List<SpecialJobBean> getSpecialJobTree() {
        return dao.getSpecialJobTree();
    }

    @Override
    public List<SpecialJobBean> getList(SpecialJobBean o) {
        return dao.getList(o);
    }

    @Override
    public int addInfo(SpecialJobBean bean) {
        try {
            String[] ids = bean.getId().split(",");
            dao.deleteSpecialJob(bean.getSpecialId());
            for (int i = 0; i < ids.length; i++) {
                dao.insert(ids[i], bean.getSpecialId());
            }
        }catch (Exception e){
            return 0;
        }

        return 1;
    }
}
