package com.nis.web.service.configuration; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.nis.domain.configuration.BaseIpCfg; import com.nis.web.dao.configuration.IpCfgDao; import com.nis.web.service.CrudService; /** * IP相关配置事务类 * @author dell * */ @Service public class IpCfgService extends CrudService { @Autowired protected IpCfgDao ipCfgDao; /** * * addIpCfg(新增IP类配置) * (继承BaseIpCfg这个类方可使用) * @param baseIpCfg * @return *int * @exception * @since 1.0.0 */ public int addIpCfg(BaseIpCfg baseIpCfg){ String tableName=getTableName(baseIpCfg.getClass().getSimpleName()); if(StringUtils.isBlank(tableName)) return 0; baseIpCfg.setTableName(tableName); logger.info("save "+tableName); return ipCfgDao.insert(baseIpCfg); } /** * * updateIpCfg(更新IP类配置) * (继承BaseIpCfg这个类方可使用) * @param baseIpCfg * @return *int * @exception * @since 1.0.0 */ public int updateIpCfg(BaseIpCfg baseIpCfg){ String tableName=getTableName(baseIpCfg.getClass().getSimpleName()); baseIpCfg.setTableName(tableName); logger.info("update "+tableName); return ipCfgDao.updateByPrimaryKeySelective(baseIpCfg); } /** * * getIpCfg(根据IP与类名获取IP配置) * (继承BaseIpCfg这个类方可使用) * @param clazz * @param id * @return *BaseIpCfg * @exception * @since 1.0.0 */ public BaseIpCfg getIpCfgById(Class clazz,long id){ String tableName=getTableName(clazz.getSimpleName()); logger.info("get "+tableName); return ipCfgDao.getById(tableName, id); } /** * * getIpCfg(根据IP与类名获取IP配置) * (继承BaseIpCfg这个类方可使用) * @param clazz * @param id * @return *BaseIpCfg * @exception * @since 1.0.0 */ public BaseIpCfg getIpCfgById(BaseIpCfg baseIpCfg){ String tableName=getTableName(baseIpCfg.getClass().getSimpleName()); baseIpCfg.setTableName(tableName); logger.info("get "+tableName); return ipCfgDao.get(baseIpCfg); } }