package com.bonus.boot.manager.basic.service.impl;


import com.bonus.boot.manager.basic.dao.HospitalDao;
import com.bonus.boot.manager.basic.dao.PhyCombinDao;
import com.bonus.boot.manager.basic.entity.PhyCombinBean;
import com.bonus.boot.manager.basic.service.HospitalService;
import com.bonus.boot.manager.basic.service.PhyCombinService;
import com.bonus.boot.manager.manager.dao.UtilDao;
import com.bonus.boot.manager.manager.utils.StringHelper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service("phyCombinService")
public class PhyCombinServiceImpl implements PhyCombinService {
    @Resource
    private PhyCombinDao dao;
    @Resource
    private UtilDao utilDao;
    @Override
    public List<PhyCombinBean> getList(PhyCombinBean o) {
        return dao.getList(o);
    }

    @Override
    public int addInfo(PhyCombinBean bean) {
        int num = dao.determineIfExists(bean.getCombinName(),bean.getCombinType(), "");
        if(num > 0){
            num = 3;
        }else {
            num = dao.addInfo(bean);
        }
        return num;
    }

    @Override
    public int updateInfo(PhyCombinBean bean) {
        int num = dao.determineIfExists(bean.getCombinName(),bean.getCombinType(),bean.getId()+"");
        if(num > 0){
            num = 3;
        }else {
            num = dao.updateInfo(bean);
        }
        return num;
    }

    @Override
    public PhyCombinBean getListById(String id) {
        return dao.getListById(id);
    }

    @Override
    @Transactional
    public int delById(PhyCombinBean bean) {
        return dao.delById(bean);
    }
}
