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

import com.bonus.boot.manager.basic.dao.PackageTypeDao;
import com.bonus.boot.manager.basic.entity.BaseTypePackageBean;
import com.bonus.boot.manager.basic.service.PackageTypeService;
import com.bonus.boot.manager.manager.dao.UtilDao;
import org.springframework.stereotype.Service;

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

/**
 * 包名称：com.bonus.boot.manager.basic.service.impl
 * 类名称：PackageTypeServiceImpl
 * 类描述：
 * 创建人：@author xxxxxx
 * 创建时间：2023年05月31日 16:04
 */

@Service("packageTypeService")
public class PackageTypeServiceImpl implements PackageTypeService {

    @Resource
    private PackageTypeDao dao;
    @Resource
    private UtilDao utilDao;

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

    @Override
    public int addInfo(BaseTypePackageBean bean) {
        int num = utilDao.determineIfExists("pm_base_type_package","type_name",bean.getTypeName(),"");
        if(num > 0){
            num = 3;
        }else {
            num = dao.addInfo(bean);
        }
        return num;
    }

    @Override
    public int updateInfo(BaseTypePackageBean bean) {
        int num = utilDao.determineIfExists("pm_base_type_package","type_name",bean.getTypeName(),bean.getId()+"");
        if(num > 0){
            num = 3;
        }else {
            num = dao.updateInfo(bean);
        }
        return num;
    }

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

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