package com.nis.web.service.configuration; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.nis.domain.configuration.AreaIpCfg; import com.nis.domain.configuration.BaseIpCfg; import com.nis.util.Constants; import com.nis.web.dao.configuration.AreaIpCfgDao; 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; @Autowired protected AreaIpCfgDao areaIpCfgDao; /** * * addIpCfg(新增IP类配置) * (继承BaseIpCfg这个类方可使用) * @param baseIpCfg * @return *int * @exception * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int addIpCfg(BaseIpCfg baseIpCfg,List areaIpCfgs){ if(areaIpCfgs!=null&&areaIpCfgs.size()>0){ this.saveIpBatch(areaIpCfgs); } return ipCfgDao.insert(baseIpCfg); } /** * * updateIpCfg(更新IP类配置) * (继承BaseIpCfg这个类方可使用) * @param baseIpCfg * @return *int * @exception * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int updateIpCfg(BaseIpCfg baseIpCfg,List addAreaCfg,List updateAreaCfg,List deleteAreaCfgs){ if(addAreaCfg!=null&&addAreaCfg.size()>0){ this.saveIpBatch(addAreaCfg); } if(updateAreaCfg!=null&&updateAreaCfg.size()>0){ this.updateIpBatch(updateAreaCfg); } if(deleteAreaCfgs!=null&&deleteAreaCfgs.size()>0){ this.deleteIpBatch(deleteAreaCfgs); } return ipCfgDao.updateByPrimaryKeySelective(baseIpCfg); } /** * * auditIpCfg(审核IP类配置) * (继承BaseIpCfg这个类方可使用) * @param baseIpCfg * @return *int * @throws Exception * @exception * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int auditIpCfg(BaseIpCfg sendCfg,BaseIpCfg baseIpCfg) throws Exception{ if(Constants.AUDIT_NOT_YES==baseIpCfg.getIsAudit().intValue()|| Constants.AUDIT_YES==baseIpCfg.getIsAudit().intValue()){//审核通过,取消审核通过需要发到maat if(sendToMaatConvertor(baseIpCfg.getIsAudit(),null,sendCfg)){ return ipCfgDao.audit(baseIpCfg); } }else{ return ipCfgDao.audit(baseIpCfg); } return 0; } /** * * deleteIpCfg(删除IP类配置) * (继承BaseIpCfg这个类方可使用) * @param baseIpCfg * @return *int * @exception * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public int deleteIpCfg(BaseIpCfg baseIpCfg, List areaCfg){ if(areaCfg!=null&&areaCfg.size()>0){ this.deleteIpBatch(areaCfg); } return ipCfgDao.updateValid(baseIpCfg); } /** * * getIpCfg(根据IP与类名获取IP配置) * (继承BaseIpCfg这个类方可使用) * @param clazz * @param id * @return *BaseIpCfg * @exception * @since 1.0.0 */ public BaseIpCfg getIpCfgById(BaseIpCfg baseIpCfg){ return ipCfgDao.getById(baseIpCfg.getTableName(), baseIpCfg.getCfgId()); } public Integer getIsValid(BaseIpCfg baseIpCfg){ return ipCfgDao.getIsValid(baseIpCfg); } public Integer getIsValid(String tableName, long id){ return ipCfgDao.getIsValid(tableName,id); } public Integer getIsAudit(BaseIpCfg baseIpCfg){ return ipCfgDao.getIsAudit(baseIpCfg); } public Integer getIsAudit(String tableName, long id){ return ipCfgDao.getIsAudit(tableName,id); } public List getAreaCfgByCompileId(int compileId){ return areaIpCfgDao.getByCompileId(compileId); } }