This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
k18-ntcs-web-ntc/src/main/java/com/nis/web/service/configuration/IpCfgService.java

191 lines
5.2 KiB
Java
Raw Normal View History

package com.nis.web.service.configuration;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
2018-02-25 18:43:20 +08:00
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
2018-02-25 18:43:20 +08:00
import org.springframework.transaction.annotation.Transactional;
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<IpCfgDao,BaseIpCfg> {
@Autowired
protected IpCfgDao ipCfgDao;
/**
*
* addIpCfg(新增IP类配置)
* (继承BaseIpCfg这个类方可使用)
* @param baseIpCfg
* @return
*int
* @exception
* @since 1.0.0
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int addIpCfg(BaseIpCfg baseIpCfg){
2018-02-25 18:43:20 +08:00
if(!StringUtils.isBlank(baseIpCfg.getTableName())){
return ipCfgDao.insert(baseIpCfg);
}else{
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
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int updateIpCfg(BaseIpCfg baseIpCfg){
2018-02-25 18:43:20 +08:00
if(!StringUtils.isBlank(baseIpCfg.getTableName())){
return ipCfgDao.updateByPrimaryKeySelective(baseIpCfg);
}else{
String tableName=getTableName(baseIpCfg.getClass().getSimpleName());
if(StringUtils.isBlank(tableName))
return 0;
baseIpCfg.setTableName(tableName);
logger.info("update "+tableName);
return ipCfgDao.updateByPrimaryKeySelective(baseIpCfg);
}
}
/**
*
* auditIpCfg(审核IP类配置)
* (继承BaseIpCfg这个类方可使用)
* @param baseIpCfg
* @return
*int
* @exception
* @since 1.0.0
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
2018-02-25 18:43:20 +08:00
public int auditIpCfg(BaseIpCfg baseIpCfg){
if(!StringUtils.isBlank(baseIpCfg.getTableName())){
return ipCfgDao.audit(baseIpCfg);
}else{
String tableName=getTableName(baseIpCfg.getClass().getSimpleName());
if(StringUtils.isBlank(tableName))
return 0;
baseIpCfg.setTableName(tableName);
logger.info("aduit "+tableName);
return ipCfgDao.audit(baseIpCfg);
}
}
/**
*
* deleteIpCfg(删除IP类配置)
* (继承BaseIpCfg这个类方可使用)
* @param baseIpCfg
* @return
*int
* @exception
* @since 1.0.0
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
2018-02-25 18:43:20 +08:00
public int deleteIpCfg(BaseIpCfg baseIpCfg){
if(!StringUtils.isBlank(baseIpCfg.getTableName())){
return ipCfgDao.updateValid(baseIpCfg);
}else{
String tableName=getTableName(baseIpCfg.getClass().getSimpleName());
if(StringUtils.isBlank(tableName))
return 0;
baseIpCfg.setTableName(tableName);
logger.info("delete "+tableName);
return ipCfgDao.updateValid(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());
2018-02-25 18:43:20 +08:00
if(StringUtils.isBlank(tableName))
return null;
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){
2018-02-25 18:43:20 +08:00
if(!StringUtils.isBlank(baseIpCfg.getTableName())){
return ipCfgDao.get(baseIpCfg);
}else{
String tableName=getTableName(baseIpCfg.getClass().getSimpleName());
if(StringUtils.isBlank(tableName))
return null;
baseIpCfg.setTableName(tableName);
logger.info("get "+tableName);
return ipCfgDao.get(baseIpCfg);
}
}
public Integer getIsValid(BaseIpCfg baseIpCfg){
if(!StringUtils.isBlank(baseIpCfg.getTableName())){
return ipCfgDao.getIsValid(baseIpCfg);
}else{
String tableName=getTableName(baseIpCfg.getClass().getSimpleName());
if(StringUtils.isBlank(tableName))
return null;
baseIpCfg.setTableName(tableName);
return ipCfgDao.getIsValid(baseIpCfg);
}
}
public Integer getIsValid(String tableName, long id){
return ipCfgDao.getIsValid(tableName,id);
}
public Integer getIsAudit(BaseIpCfg baseIpCfg){
if(!StringUtils.isBlank(baseIpCfg.getTableName())){
return ipCfgDao.getIsAudit(baseIpCfg);
}else{
String tableName=getTableName(baseIpCfg.getClass().getSimpleName());
if(StringUtils.isBlank(tableName))
return null;
baseIpCfg.setTableName(tableName);
return ipCfgDao.getIsAudit(baseIpCfg);
}
}
public Integer getIsAudit(String tableName, long id){
return ipCfgDao.getIsAudit(tableName,id);
}
}