删除静控接口

This commit is contained in:
zhangdongxu
2017-12-22 15:35:56 +08:00
parent ed111ec4b8
commit caa9503c86
31 changed files with 0 additions and 3019 deletions

View File

@@ -1,204 +0,0 @@
/**
*@Title: JkDmbCkController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful.jk;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.jk.JkDmbCk;
import com.nis.domain.restful.jk.JkDmbCkSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.jk.JkDmbCkService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: JkDmbCkController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/jk/v1")
public class JkDmbCkController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected JkDmbCkService jkDmbCkService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
/**
* saveDmbCkBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param JkDmbCkSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbCkSources", method = RequestMethod.POST)
@ApiOperation(value = "保存因特网国际出入口", httpMethod = "POST", notes = "保存因特网国际出入口")
public Map saveDmbCkBatch(@RequestBody JkDmbCkSource dmbCkSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dmbCkSource);
super.checkOpAction(thread,System.currentTimeMillis()-start, dmbCkSource.getOpAction(), Constants.OPACTION_POST);
try{
checkData(thread,start,dmbCkSource,Constants.OPACTION_POST);
jkDmbCkService.saveDmbCkBatch(dmbCkSource.getDmbCkList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存因特网国际出入口失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存因特网国际出入口成功",dmbCkSource.getDmbCkList());
}
/**
*
* updateDmbCkBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param JkDmbCkSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbCkSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新因特网国际出入口", httpMethod = "PUT", notes = "更新因特网国际出入口")
public Map updateDmbCkBatch(@RequestBody JkDmbCkSource dmbCkSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dmbCkSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbCkSource.getOpAction(), Constants.OPACTION_PUT);
try{
checkData(thread,start,dmbCkSource,Constants.OPACTION_PUT);
jkDmbCkService.updateDmbCkBatch(dmbCkSource.getDmbCkList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新因特网国际出入口失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新因特网国际出入口成功",dmbCkSource.getDmbCkList());
}
/**
*
* deleteDmbCk(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
// @RequestMapping(value = "/dmbCkSources/{id}", method = RequestMethod.DELETE)
// @ApiOperation(value = "删除因特网国际出入口", httpMethod = "DELETE", notes = "删除因特网国际出入口")
public Map deleteDmbCk(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
jkDmbCkService.removeDmbCk(id);
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除因特网国际出入口失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDmbCk(多条删除)
* (这里描述这个方法适用条件 可选)
* @param JkDmbCkSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
// @RequestMapping(value = "/dmbCkSources", method = RequestMethod.DELETE)
// @ApiOperation(value = "删除因特网国际出入口", httpMethod = "DELETE", notes = "删除因特网国际出入口")
public Map deleteDmbCk(@RequestBody JkDmbCkSource dmbCkSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dmbCkSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbCkSource.getOpAction(), Constants.OPACTION_DELETE);
try{
jkDmbCkService.removeDmbCkBatch(dmbCkSource.getDmbCkList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除因特网国际出入口失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dmbCkSource.getDmbCkList());
}
private void checkData(SaveRequestLogThread thread,long start,JkDmbCkSource dmbCkSource,int opAction){
if(dmbCkSource.getDmbCkList().size()==0){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"因特网国际出入口不能为空", RestBusinessCode.unknow_error.getValue());
}
for(JkDmbCk e:dmbCkSource.getDmbCkList()){
if(opAction==Constants.OPACTION_POST&&e!=null&&e.getSfSx()!=Long.valueOf(Constants.YES)){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"只能新增有效数据", RestBusinessCode.wrong_range.getValue());
}else if(opAction==Constants.OPACTION_PUT&&e!=null&&e.getSfSx()!=Long.valueOf(Constants.NO)){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"只允许将有效数据更改为无效数据", RestBusinessCode.wrong_range.getValue());
}
if(opAction==Constants.OPACTION_POST){
e.setSxFw("0");
}
}
}
}

View File

@@ -1,177 +0,0 @@
package com.nis.web.controller.restful.jk;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.jk.JkFdZb;
import com.nis.domain.restful.jk.JkFdZbSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.jk.JkFdZbService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: JkFdZbController
* @Description: 静态控管封堵/解封
* @author (DDM)
* @date 2016年10月20日 上午10:20:33
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/jk/v1")
@Api(value = "JkFdZbController", description = "静态控管封堵/解封")
public class JkFdZbController extends BaseRestController {
Logger logger = LoggerFactory.getLogger(JkFdZbController.class);
SimpleDateFormat ymdhms=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Autowired
ServicesRequestLogService servicesRequestLogService;
@Autowired
protected JkFdZbService jkFdZbService;
/**
* saveJkFdZbBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param JkFdZbSource
* @param request
* @param response
* @return Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/jkFdZbSources", method = RequestMethod.POST)
@ApiOperation(value = "静态控管封堵", httpMethod = "POST", notes = "save provider info")
public Map saveJkFdZbBatch(@RequestBody JkFdZbSource jkFdZbSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, jkFdZbSource);
super.checkOpAction(thread,System.currentTimeMillis()-start, jkFdZbSource.getOpAction(), Constants.OPACTION_POST);
validJkFdZb(thread,System.currentTimeMillis()-start,jkFdZbSource.getJkFdZbList(),Constants.OPACTION_POST);
try{
Date date=new Date();
if(jkFdZbSource.getJkFdZbList() != null && jkFdZbSource.getJkFdZbList().size() >0){
for (JkFdZb jkFdZb : jkFdZbSource.getJkFdZbList()) {
jkFdZb.setLastUpdate(date);
}
}
jkFdZbService.saveJkFdZbBatch(jkFdZbSource.getJkFdZbList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"静态控管封堵失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"静态控管封堵成功",jkFdZbSource.getJkFdZbList());
}
/**
*
* updateJkFdZbBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param JkFdZbSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/jkFdZbSources", method = RequestMethod.PUT)
@ApiOperation(value = "静态控管解封", httpMethod = "PUT", notes = "update provider info")
public Map updateJkFdZbBatch(@RequestBody JkFdZbSource jkFdZbSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, jkFdZbSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,jkFdZbSource.getOpAction(), Constants.OPACTION_PUT);
validJkFdZb(thread,System.currentTimeMillis()-start,jkFdZbSource.getJkFdZbList(),Constants.OPACTION_PUT);
try{
Date date=new Date();
if(jkFdZbSource.getJkFdZbList() != null && jkFdZbSource.getJkFdZbList().size() >0){
for (JkFdZb jkFdZb : jkFdZbSource.getJkFdZbList()) {
jkFdZb.setLastUpdate(date);
}
}
jkFdZbService.updateJkFdZbBatch(jkFdZbSource.getJkFdZbList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"静态控管解封失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"静态控管解封成功",jkFdZbSource.getJkFdZbList());
}
/**
* 校验是否存在无效数据
*
* @Title: validJkFdZb
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param thread
* @param @param start
* @param @param jkFdZbList
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
public void validJkFdZb(SaveRequestLogThread thread,long start, List<JkFdZb> jkFdZbList,int opAction){
String errorInfo = "";
if (jkFdZbList.size() <= 0) {
errorInfo = "静控封堵记录不能为空";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.missing_args.getValue());
}else{
for (JkFdZb jkFdZb : jkFdZbList) {
if(opAction==Constants.OPACTION_POST&&jkFdZb != null && jkFdZb.getSfFd() !=Long.valueOf(Constants.YES)){
errorInfo = "只能新增有效数据";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.wrong_range.getValue());
}else if(opAction==Constants.OPACTION_PUT && jkFdZb != null && jkFdZb.getSfFd() !=Long.valueOf(Constants.NO)){
errorInfo = "只允许将有效数据更改为无效数据";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.wrong_range.getValue());
}
if(!"".equals(errorInfo)){
break;
}
if(opAction==Constants.OPACTION_POST){
jkFdZb.setSxFw("0");
}
}
}
}
}

View File

@@ -1,134 +0,0 @@
/**
*@Title: JkFfjInfoController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author (zbc)
*@date 2016年10月19日 下午20:04:16
*@version V1.0
*/
package com.nis.web.controller.restful.jk;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.jk.JkFfjInfo;
import com.nis.domain.restful.jk.JkFfjInfoSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.jk.JkFfjInfoService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: JkFfjInfoController.java
* @Description: TODO
* @author (zbc)
* @date 2016年10月19日 下午20:04:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/jk/v1")
@SuppressWarnings("rawtypes")
public class JkFfjInfoController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@Autowired
protected JkFfjInfoService jkFfjService;
@RequestMapping(value = "/jkFfjSources", method = RequestMethod.POST)
@ApiOperation(value = "保存静态控管分发机信息", httpMethod = "POST", notes = "save server info")
public Map saveJkFfjInfoBatch(@RequestBody JkFfjInfoSource jkFfjSource, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request, jkFfjSource);
super.checkOpAction(thread, System.currentTimeMillis() - start, jkFfjSource.getOpAction(), Constants.OPACTION_POST);
validJkFdZb(thread,System.currentTimeMillis()-start,jkFfjSource.getJkffjList(),Constants.OPACTION_POST);
try {
jkFfjService.saveJkFfjBatch(jkFfjSource.getJkffjList());
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存静态控管分发机信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存静态控管分发机信息成功",jkFfjSource.getJkffjList());
}
@RequestMapping(value = "/jkFfjSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新静态控管分发机信息", httpMethod = "PUT", notes = "update server info")
public Map updateJkFfjInfoBatch(@RequestBody JkFfjInfoSource jkFfjSource, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request, jkFfjSource);
super.checkOpAction(thread, System.currentTimeMillis() - start, jkFfjSource.getOpAction(), Constants.OPACTION_PUT);
validJkFdZb(thread,System.currentTimeMillis()-start,jkFfjSource.getJkffjList(),Constants.OPACTION_PUT);
try {
jkFfjService.updateJkFfjBatch(jkFfjSource.getJkffjList());
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info = OracleErrorCodeUtil.getOraCode(e);
if (!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread, System.currentTimeMillis() - start, info);
else
throw new RestServiceException(thread, System.currentTimeMillis() - start, "更新静态控管分发机信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新静态控管分发机信息成功",jkFfjSource.getJkffjList());
}
private void validJkFdZb(SaveRequestLogThread thread, long start, List<JkFfjInfo> jkffjList, int opAction) {
String errorInfo = "";
if (jkffjList.size() <= 0) {
errorInfo = "静控分发机记录不能为空";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.missing_args.getValue());
}else{
for (JkFfjInfo JkFfj : jkffjList) {
if(opAction==Constants.OPACTION_POST&&JkFfj != null && JkFfj.getSfSx() !=Long.valueOf(Constants.YES)){
errorInfo = "只能新增有效数据";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.wrong_range.getValue());
}else if(opAction==Constants.OPACTION_PUT&&JkFfj != null && JkFfj.getSfSx() !=Long.valueOf(Constants.NO)){
errorInfo = "只允许将有效数据更改为无效数据";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.wrong_range.getValue());
}
if(!"".equals(errorInfo)){
break;
}
if(opAction==Constants.OPACTION_POST){
JkFfj.setSxFw("0");
}
}
}
}
}

View File

@@ -1,134 +0,0 @@
/**
*@Title: JkFwqInfoController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author (zbc)
*@date 2016年10月19日 下午20:04:16
*@version V1.0
*/
package com.nis.web.controller.restful.jk;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.jk.JkFfjInfo;
import com.nis.domain.restful.jk.JkFfjInfoSource;
import com.nis.domain.restful.jk.JkFwqInfo;
import com.nis.domain.restful.jk.JkFwqInfoSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.jk.JkFwqInfoService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: JkFwqInfoController.java
* @Description: TODO
* @author (zbc)
* @date 2016年10月19日 下午20:04:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/jk/v1")
public class JkFwqInfoController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected JkFwqInfoService jkFwqInfoService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "/jkFwqSources", method = RequestMethod.POST)
@ApiOperation(value = "保存静态控管服务器信息", httpMethod = "POST", notes = "save server info")
public Map saveJkFfjInfoBatch(@RequestBody JkFwqInfoSource jkFwqSource, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request, jkFwqSource);
super.checkOpAction(thread, System.currentTimeMillis() - start, jkFwqSource.getOpAction(), Constants.OPACTION_POST);
validJkFdZb(thread,System.currentTimeMillis()-start,jkFwqSource.getJkFwqInfoList(),Constants.OPACTION_POST);
try {
jkFwqInfoService.savejkFwqInfoBatch(jkFwqSource.getJkFwqInfoList());
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存静态控管服务器信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存静态控管服务器信息成功",jkFwqSource.getJkFwqInfoList());
}
@RequestMapping(value = "/jkFwqSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新静态控管服务器信息", httpMethod = "PUT", notes = "update server info")
public Map updateJkFfjInfoBatch(@RequestBody JkFwqInfoSource jkFwqSource, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request, jkFwqSource);
super.checkOpAction(thread, System.currentTimeMillis() - start, jkFwqSource.getOpAction(), Constants.OPACTION_PUT);
validJkFdZb(thread,System.currentTimeMillis()-start,jkFwqSource.getJkFwqInfoList(),Constants.OPACTION_PUT);
try {
jkFwqInfoService.updatejkFwqInfoBatch(jkFwqSource.getJkFwqInfoList());
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info = OracleErrorCodeUtil.getOraCode(e);
if (!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread, System.currentTimeMillis() - start, info);
else
throw new RestServiceException(thread, System.currentTimeMillis() - start, "更新静态控管服务器信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新静态控管服务器信息成功",jkFwqSource.getJkFwqInfoList());
}
private void validJkFdZb(SaveRequestLogThread thread, long start, List<JkFwqInfo> jkFwqList, int opAction) {
String errorInfo = "";
if (jkFwqList.size() <= 0) {
errorInfo = "静态控管服务器信息不能为空";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.missing_args.getValue());
}else{
for (JkFwqInfo jkFwq : jkFwqList) {
if(opAction==Constants.OPACTION_POST&&jkFwq != null && jkFwq.getSfSx()!=Long.valueOf(Constants.YES)){
errorInfo = "只能新增有效数据";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.wrong_range.getValue());
}else if(opAction==Constants.OPACTION_PUT&&jkFwq != null && jkFwq.getSfSx() !=Long.valueOf(Constants.NO)){
errorInfo = "只允许将有效数据更改为无效数据";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.wrong_range.getValue());
}
if(!"".equals(errorInfo)){
break;
}
if(opAction==Constants.OPACTION_POST){
jkFwq.setSxFw("0");
}
}
}
}
}

View File

@@ -1,199 +0,0 @@
/**
*@Title: JkLyqController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful.jk;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.jk.JkLyq;
import com.nis.domain.restful.jk.JkLyqSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.jk.JkLyqService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: JkLyqController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/jk/v1")
public class JkLyqController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected JkLyqService jkLyqService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
/**
* saveJkLyqBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param JkLyqSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/jkLyqSources", method = RequestMethod.POST)
@ApiOperation(value = "保存静态控管路由器", httpMethod = "POST", notes = "保存静态控管路由器")
public Map saveJkLyqBatch(@RequestBody JkLyqSource jkLyqSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, jkLyqSource);
super.checkOpAction(thread,System.currentTimeMillis()-start, jkLyqSource.getOpAction(), Constants.OPACTION_POST);
try{
checKData(thread,start,jkLyqSource,Constants.OPACTION_POST);
jkLyqService.saveJkLyqBatch(jkLyqSource.getJkLyqList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存静态控管路由器失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存静态控管路由器成功",jkLyqSource.getJkLyqList());
}
/**
*
* updateJkLyqBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param JkLyqSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/jkLyqSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新静态控管路由器", httpMethod = "PUT", notes = "更新静态控管路由器")
public Map updateJkLyqBatch(@RequestBody JkLyqSource jkLyqSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, jkLyqSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,jkLyqSource.getOpAction(), Constants.OPACTION_PUT);
try{
checKData(thread,start,jkLyqSource,Constants.OPACTION_PUT);
jkLyqService.updateJkLyqBatch(jkLyqSource.getJkLyqList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新静态控管路由器失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新静态控管路由器成功",jkLyqSource.getJkLyqList());
}
/**
*
* deleteJkLyq(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
// @RequestMapping(value = "/jkLyqSources/{id}", method = RequestMethod.DELETE)
// @ApiOperation(value = "删除静态控管路由器", httpMethod = "DELETE", notes = "删除静态控管路由器")
public Map deleteJkLyq(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
jkLyqService.removeJkLyq(id);
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除静态控管路由器失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteJkLyq(多条删除)
* (这里描述这个方法适用条件 可选)
* @param JkLyqSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
// @RequestMapping(value = "/jkLyqSources", method = RequestMethod.DELETE)
// @ApiOperation(value = "删除静态控管路由器", httpMethod = "DELETE", notes = "删除静态控管路由器")
public Map deleteJkLyq(@RequestBody JkLyqSource jkLyqSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, jkLyqSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,jkLyqSource.getOpAction(), Constants.OPACTION_DELETE);
try{
jkLyqService.removeJkLyqBatch(jkLyqSource.getJkLyqList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除静态控管路由器失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",jkLyqSource.getJkLyqList());
}
private void checKData(SaveRequestLogThread thread,long start,JkLyqSource jkLyqSource,int opAction){
if(jkLyqSource.getJkLyqList().size()==0){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"静态控管路由器不能为空", RestBusinessCode.unknow_error.getValue());
}
for(JkLyq entity:jkLyqSource.getJkLyqList()){
if(opAction==Constants.OPACTION_POST&&entity!=null&&entity.getSfSx()!=Long.valueOf(Constants.YES)){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"只能新增有效数据", RestBusinessCode.wrong_range.getValue());
}else if(opAction==Constants.OPACTION_PUT&&entity!=null&&entity.getSfSx()!=Long.valueOf(Constants.NO)){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"只允许将有效数据更改为无效数据", RestBusinessCode.wrong_range.getValue());
}
if(opAction==Constants.OPACTION_POST){
entity.setSxFw("0");
}
}
}
}