1、新增 http redirect&block 支持文件作为应答内容
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package com.nis.domain.callback;
|
||||
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
/**
|
||||
* http代理文件策略
|
||||
* @author nanfang
|
||||
*
|
||||
*/
|
||||
public class ProxyFileStrategyCfg extends BaseCfg<ProxyFileStrategyCfg> {
|
||||
private static final long serialVersionUID = 4283944377949702481L;
|
||||
public final static String TABLE_NAME = "PROXY_FILE_STRATEGY_CFG";//对应表名
|
||||
private String fileId;//glaxy返回的文件id
|
||||
private String fileDesc;//文件描述
|
||||
private String url;//文件保存的url
|
||||
private String contentType;//内容类型,如text/html,取字典表contentType
|
||||
private String md5;//文件md5值
|
||||
private Long contentLength;//文件长度
|
||||
|
||||
public ProxyFileStrategyCfg() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getFileId() {
|
||||
return fileId;
|
||||
}
|
||||
public void setFileId(String fileId) {
|
||||
this.fileId = fileId;
|
||||
}
|
||||
public String getFileDesc() {
|
||||
return fileDesc;
|
||||
}
|
||||
public void setFileDesc(String fileDesc) {
|
||||
this.fileDesc = fileDesc;
|
||||
}
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
public Long getContentLength() {
|
||||
return contentLength;
|
||||
}
|
||||
public void setContentLength(Long contentLength) {
|
||||
this.contentLength = contentLength;
|
||||
}
|
||||
public String getMd5() {
|
||||
return md5;
|
||||
}
|
||||
public void setMd5(String md5) {
|
||||
this.md5 = md5;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -478,6 +478,7 @@ public final class Constants {
|
||||
public static final String REDIRECT_RESPONSE_CODE_KEY = Configurations.getStringProperty("redirect_response_code_key","code");
|
||||
public static final String REDIRECT_URL_KEY = Configurations.getStringProperty("redirect_url_key","url");
|
||||
public static final String REDIRECT_CONTENT_KEY = Configurations.getStringProperty("redirect_content_key","content");
|
||||
public static final String CONTENT_FILE_ID_KEY = Configurations.getStringProperty("content_file_id_key","content_file_id");
|
||||
public static final String REDIRECT_RESPONSE_CODE_STARTWITH = Configurations.getStringProperty("redirect_response_code_startwith","30");
|
||||
public static final String REPLACE_ZONE_KEY = Configurations.getStringProperty("replace_zone_key","zone");
|
||||
public static final String REPLACE_SUBSTITUTE_KEY = Configurations.getStringProperty("replace_substitute_key","substitute");
|
||||
|
||||
@@ -81,6 +81,7 @@ import com.nis.web.service.configuration.IpCfgService;
|
||||
import com.nis.web.service.configuration.IpMultiplexPoolCfgService;
|
||||
import com.nis.web.service.configuration.MailCfgService;
|
||||
import com.nis.web.service.configuration.NumCfgService;
|
||||
import com.nis.web.service.configuration.ProxyFileStrategyService;
|
||||
import com.nis.web.service.configuration.RequestInfoService;
|
||||
import com.nis.web.service.configuration.WebsiteCfgService;
|
||||
import com.nis.web.service.configuration.XmppCfgService;
|
||||
@@ -181,6 +182,10 @@ public class BaseController {
|
||||
protected IpMultiplexPoolCfgService ipMultiplexPoolCfgService;
|
||||
@Autowired
|
||||
protected ConfigureStatisticsService configureStatisticsService;
|
||||
@Autowired
|
||||
protected ProxyFileStrategyService proxyFileStrategyService;//代理文件策略service
|
||||
|
||||
|
||||
/**
|
||||
* 管理基础路径
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
*@Title: ControlController.java
|
||||
*@Package com.nis.web.controller.configuration.proxy
|
||||
*@Description TODO
|
||||
*@author dell
|
||||
*@date 2018年6月22日 下午4:35:42
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.controller.configuration.proxy;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.callback.ProxyFileStrategyCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.domain.maat.ToMaatResult.ResponseData;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.FileUtils;
|
||||
import com.nis.util.JsonMapper;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.configuration.CommonController;
|
||||
|
||||
/**
|
||||
* @ClassName: ControlController.java
|
||||
* @Description: TODO
|
||||
* @author (dell)
|
||||
* @date 2018年6月22日 下午4:35:42
|
||||
* @version V1.0
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/proxy/fileStrategy")
|
||||
public class FileStrategyController extends CommonController {
|
||||
|
||||
@RequestMapping(value = {"list"})
|
||||
public String fileStrategyList(ProxyFileStrategyCfg cfg,Model model,HttpServletRequest request,HttpServletResponse response) {
|
||||
Page<ProxyFileStrategyCfg> page = proxyFileStrategyService.findPage(new Page<ProxyFileStrategyCfg>(request, response,"a"), cfg);
|
||||
model.addAttribute("page", page);
|
||||
model.addAttribute("cfg", cfg);
|
||||
initPageCondition(model);
|
||||
return "/cfg/proxy/fileStrategy/list";
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"form"})
|
||||
@RequiresPermissions(value={"proxy:fileStrategy:config"})
|
||||
public String fileform(Model model,HttpServletRequest request
|
||||
,HttpServletResponse response
|
||||
,@ModelAttribute("cfg")ProxyFileStrategyCfg cfg
|
||||
,String ids
|
||||
,RedirectAttributes redirectAttributes) {
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
cfg = proxyFileStrategyService.getCfgById(Long.valueOf(ids));
|
||||
}
|
||||
// initFormCondition(model);
|
||||
initFormCondition(model, cfg);
|
||||
model.addAttribute("_cfg", cfg);
|
||||
return "/cfg/proxy/fileStrategy/form";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存 文件
|
||||
* 1、将文件上传到 service 接口
|
||||
* 2、将文件信息及 1返回的结果 保存到数据库
|
||||
* @param model
|
||||
* @param request
|
||||
* @param response
|
||||
* @param cfgFile
|
||||
* @param cfg
|
||||
* @param redirectAttributes
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions(value={"proxy:fileStrategy:config"})
|
||||
@RequestMapping(value = {"saveOrUpdate"})
|
||||
public String saveOrUpdate(Model model,HttpServletRequest request
|
||||
,HttpServletResponse response,MultipartFile cfgFile,
|
||||
@ModelAttribute("cfg")ProxyFileStrategyCfg cfg,
|
||||
RedirectAttributes redirectAttributes){
|
||||
File file = null;
|
||||
try{
|
||||
if(cfgFile != null) {
|
||||
String filename = cfgFile.getOriginalFilename();
|
||||
String prefix = FileUtils.getPrefix(filename, false);
|
||||
String suffix = FileUtils.getSuffix(filename, false);
|
||||
file = File.createTempFile("file_"+ prefix, suffix);
|
||||
cfgFile.transferTo(file);//复制文件
|
||||
String md5 = FileUtils.getFileMD5(file);
|
||||
Map<String,Object> srcMap = Maps.newHashMap();
|
||||
srcMap.put("filetype", suffix);
|
||||
srcMap.put("datatype", "dbSystem");//源文件存入数据中心
|
||||
srcMap.put("createTime",new Date());
|
||||
srcMap.put("key",prefix);
|
||||
srcMap.put("fileName", filename);
|
||||
srcMap.put("checksum", md5);
|
||||
ToMaatResult result = ConfigServiceUtil.postFileCfg(null, file, JsonMapper.toJsonString(srcMap));
|
||||
logger.info("http 重定向阻断文件上传响应信息:"+JsonMapper.toJsonString(result));
|
||||
String srcAccessUrl = null;
|
||||
if(!StringUtil.isEmpty(result)){
|
||||
ResponseData data = result.getData();
|
||||
srcAccessUrl=data.getAccessUrl();
|
||||
cfg.setUrl(srcAccessUrl);;
|
||||
}
|
||||
cfg.setMd5(md5);//文件md5值
|
||||
cfg.setContentLength(file.length());//文件长度
|
||||
cfg.setFileId(md5);
|
||||
}
|
||||
proxyFileStrategyService.saveOrUpdate(cfg);
|
||||
addMessage(redirectAttributes,"save_success");
|
||||
}catch(Exception e){
|
||||
logger.error("信息保存失败",e);
|
||||
addMessage(redirectAttributes,"save_failed");
|
||||
}finally {
|
||||
if(file != null) {
|
||||
file.delete();//删除临时文件
|
||||
}
|
||||
}
|
||||
return "redirect:" + adminPath +"/proxy/fileStrategy/list?functionId="+cfg.getFunctionId();
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"delete"})
|
||||
@RequiresPermissions(value={"proxy:fileStrategy:config"})
|
||||
public String delete(Integer isAudit,Integer isValid,
|
||||
String ids,
|
||||
Integer functionId,
|
||||
RedirectAttributes redirectAttributes){
|
||||
proxyFileStrategyService.update(isAudit,isValid,ids,functionId);
|
||||
return "redirect:" + adminPath +"/proxy/fileStrategy/list?functionId="+functionId;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = {"audit"})
|
||||
@RequiresPermissions(value={"proxy:fileStrategy:confirm"})
|
||||
public String audit(Integer isAudit,Integer isValid,String ids
|
||||
,Integer functionId, RedirectAttributes redirectAttributes) {
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
proxyFileStrategyService.audit(isAudit, isValid, functionId, ids);
|
||||
}
|
||||
return "redirect:" + adminPath +"/proxy/fileStrategy/list?functionId="+functionId;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.callback.ProxyFileStrategyCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.HttpBodyCfg;
|
||||
import com.nis.domain.configuration.HttpReqHeadCfg;
|
||||
@@ -42,6 +43,9 @@ public class HttpRedirectPolicyController extends BaseController{
|
||||
Page<CfgIndexInfo> page = httpRedirectCfgService.getHttpRedirectList(searchPage, cfg);
|
||||
model.addAttribute("page", page);
|
||||
initPageCondition(model,cfg);
|
||||
//获取所有的响应文件内容,阻断,或重定向时可以选择
|
||||
List<ProxyFileStrategyCfg> allProxyFileStrategys = proxyFileStrategyService.getProxyFileStrategyCfgList(new ProxyFileStrategyCfg());
|
||||
model.addAttribute("allProxyFileStrategys", allProxyFileStrategys);
|
||||
return "/cfg/proxy/control/httpRedirectList";
|
||||
}
|
||||
@RequestMapping(value = {"form"})
|
||||
@@ -136,8 +140,10 @@ public class HttpRedirectPolicyController extends BaseController{
|
||||
entity.setIpPortList(ipPortList);
|
||||
initFormCondition(model,entity);
|
||||
}
|
||||
|
||||
//获取所有的响应文件内容,阻断,或重定向时可以选择
|
||||
List<ProxyFileStrategyCfg> allProxyFileStrategys = proxyFileStrategyService.getProxyFileStrategyCfgList(new ProxyFileStrategyCfg());
|
||||
model.addAttribute("_cfg", entity);
|
||||
model.addAttribute("allProxyFileStrategys", allProxyFileStrategys);
|
||||
return "/cfg/proxy/control/httpRedirectForm";
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.nis.web.dao.configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nis.domain.callback.ProxyFileStrategyCfg;
|
||||
import com.nis.web.dao.MyBatisDao;
|
||||
|
||||
|
||||
/**
|
||||
* 特定协议相关配置数据处理类
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
@MyBatisDao
|
||||
public interface ProxyFileStrategyDao {
|
||||
|
||||
public List<ProxyFileStrategyCfg> findPage(ProxyFileStrategyCfg entity) ;
|
||||
public ProxyFileStrategyCfg getCfgById(@Param("cfgId")Long cfgId);
|
||||
public void insert(ProxyFileStrategyCfg entity);
|
||||
public void update(ProxyFileStrategyCfg entity);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.nis.web.dao.configuration.ProxyFileStrategyDao" >
|
||||
|
||||
<resultMap id="ProxyFileStrategyCfg" type="com.nis.domain.callback.ProxyFileStrategyCfg" >
|
||||
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
|
||||
|
||||
<result column="file_id" property="fileId" jdbcType="VARCHAR" />
|
||||
<result column="file_desc" property="fileDesc" jdbcType="VARCHAR" />
|
||||
<result column="url" property="url" jdbcType="VARCHAR" />
|
||||
<result column="content_type" property="contentType" jdbcType="VARCHAR" />
|
||||
<result column="content_length" property="contentLength" jdbcType="VARCHAR" />
|
||||
<result column="md5" property="md5" jdbcType="VARCHAR" />
|
||||
|
||||
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
|
||||
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
|
||||
<result column="action" property="action" jdbcType="INTEGER" />
|
||||
<result column="level" property="level" jdbcType="INTEGER" />
|
||||
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
|
||||
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
|
||||
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
||||
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
|
||||
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
|
||||
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
|
||||
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
|
||||
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
|
||||
<result column="request_id" property="requestId" jdbcType="INTEGER" />
|
||||
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
|
||||
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
|
||||
<result column="classify" property="classify" jdbcType="VARCHAR" />
|
||||
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
|
||||
<result column="lable" property="lable" jdbcType="VARCHAR" />
|
||||
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
|
||||
<result column="function_id" property="functionId" jdbcType="INTEGER" />
|
||||
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
|
||||
<result column="creator_name" property="creatorName" jdbcType="VARCHAR" />
|
||||
<result column="auditor_name" property="auditorName" jdbcType="VARCHAR" />
|
||||
<result column="editor_name" property="editorName" jdbcType="VARCHAR" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="ProxyFileStrategyCfgColumn" >
|
||||
a.CFG_ID,a.CFG_DESC,a.ACTION,a.IS_VALID,a.IS_AUDIT,
|
||||
a.CREATOR_ID,a.CREATE_TIME,a.EDITOR_ID,a.EDIT_TIME,a.AUDITOR_ID,a.AUDIT_TIME,
|
||||
a.SERVICE_ID,a.REQUEST_ID,a.COMPILE_ID,a.IS_AREA_EFFECTIVE,a.CLASSIFY,
|
||||
a.ATTRIBUTE,a.LABLE,a.AREA_EFFECTIVE_IDS,a.function_id,a.cfg_type,a.cfg_region_code,
|
||||
a.FILE_ID,a.FILE_DESC,a.URL,a.CONTENT_TYPE,a.CONTENT_LENGTH,a.MD5
|
||||
</sql>
|
||||
|
||||
|
||||
<!-- voip条件查询列表信息 -->
|
||||
<select id="findPage" resultMap="ProxyFileStrategyCfg" parameterType="com.nis.domain.callback.ProxyFileStrategyCfg" >
|
||||
SELECT
|
||||
<include refid="ProxyFileStrategyCfgColumn" />
|
||||
<trim prefix="," prefixOverrides=",">
|
||||
, s.name as creator_name,e.name as editor_name,u.name as auditor_name
|
||||
,ri.request_title as requestName
|
||||
</trim>
|
||||
FROM proxy_file_strategy_cfg a
|
||||
left join sys_user s on a.creator_id=s.id
|
||||
left join sys_user e on a.editor_id=e.id
|
||||
left join sys_user u on a.auditor_id=u.id
|
||||
left join request_info ri on a.request_id=ri.id
|
||||
|
||||
<trim prefix="WHERE" prefixOverrides="AND |OR ">
|
||||
<if test="page !=null and page.where != null and page.where != ''">
|
||||
AND ${page.where}
|
||||
</if>
|
||||
<if test="cfgId != null">
|
||||
AND a.CFG_ID=#{cfgId,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="cfgDesc != null and cfgDesc != ''">
|
||||
AND a.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="action != null">
|
||||
AND a.ACTION=#{action,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="isValid != null">
|
||||
AND a.IS_VALID=#{isValid,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="isValid == null">
|
||||
AND a.IS_VALID != -1
|
||||
</if>
|
||||
<if test="isAudit != null">
|
||||
AND a.IS_AUDIT=#{isAudit,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="creatorName != null and creatorName != ''">
|
||||
AND a.CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="editorName != null and editorName != ''">
|
||||
AND a.EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="auditorName != null and auditorName != ''">
|
||||
AND a.AUDITOR_NAME like concat(concat('%',#{auditorName,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="serviceId != null">
|
||||
AND a.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="requestId != null">
|
||||
AND a.REQUEST_ID=#{requestId,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="compileId != null">
|
||||
AND a.COMPILE_ID=#{compileId,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="isAreaEffective != null">
|
||||
AND a.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="classify != null and classify != ''">
|
||||
AND a.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="attribute != null and attribute != ''">
|
||||
AND a.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="lable != null and lable != ''">
|
||||
AND a.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="areaEffectiveIds != null and areaEffectiveIds != ''">
|
||||
AND a.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="functionId != null">
|
||||
AND a.function_id=#{functionId,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="fileDesc != null and fileDesc != ''">
|
||||
AND a.file_desc like concat(concat('%',#{fileDesc,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${sqlMap.dsf}
|
||||
</trim>
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
ORDER BY ${page.orderBy}
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY a.CFG_ID desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<!-- 根据Id获取ProxyFileStrategyCfg信息 -->
|
||||
<select id="getCfgById" resultMap="ProxyFileStrategyCfg">
|
||||
SELECT
|
||||
<include refid="ProxyFileStrategyCfgColumn" />
|
||||
FROM proxy_file_strategy_cfg a
|
||||
<where>
|
||||
<if test="cfgId != null">
|
||||
and a.CFG_ID=#{cfgId,jdbcType=INTEGER}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.nis.domain.callback.ProxyFileStrategyCfg" >
|
||||
insert into proxy_file_strategy_cfg (
|
||||
CFG_DESC,
|
||||
ACTION,
|
||||
IS_VALID,
|
||||
IS_AUDIT,
|
||||
CREATOR_ID,
|
||||
CREATE_TIME,
|
||||
EDITOR_ID,
|
||||
EDIT_TIME,
|
||||
AUDITOR_ID,
|
||||
AUDIT_TIME,
|
||||
SERVICE_ID,
|
||||
REQUEST_ID,
|
||||
COMPILE_ID,
|
||||
IS_AREA_EFFECTIVE,
|
||||
CLASSIFY,
|
||||
ATTRIBUTE,
|
||||
LABLE,
|
||||
AREA_EFFECTIVE_IDS,
|
||||
function_id,
|
||||
cfg_type,
|
||||
cfg_region_code,
|
||||
|
||||
file_id,
|
||||
file_desc,
|
||||
url,
|
||||
content_type,
|
||||
content_length,
|
||||
md5
|
||||
)values (
|
||||
#{cfgDesc,jdbcType=VARCHAR},
|
||||
#{action,jdbcType=INTEGER},
|
||||
0,
|
||||
0,
|
||||
#{creatorId,jdbcType=INTEGER},
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
#{editorId,jdbcType=INTEGER},
|
||||
#{editTime,jdbcType=TIMESTAMP},
|
||||
#{auditorId,jdbcType=INTEGER},
|
||||
#{auditTime,jdbcType=TIMESTAMP},
|
||||
#{serviceId,jdbcType=INTEGER},
|
||||
#{requestId,jdbcType=INTEGER},
|
||||
#{compileId,jdbcType=INTEGER},
|
||||
#{isAreaEffective,jdbcType=INTEGER},
|
||||
#{classify,jdbcType=VARCHAR},
|
||||
#{attribute,jdbcType=VARCHAR},
|
||||
#{lable,jdbcType=VARCHAR},
|
||||
#{areaEffectiveIds,jdbcType=VARCHAR},
|
||||
#{functionId,jdbcType=INTEGER},
|
||||
#{cfgType,jdbcType=VARCHAR},
|
||||
#{cfgRegionCode,jdbcType=INTEGER},
|
||||
|
||||
#{fileId,jdbcType=VARCHAR},
|
||||
#{fileDesc,jdbcType=VARCHAR},
|
||||
#{url,jdbcType=VARCHAR},
|
||||
#{contentType,jdbcType=VARCHAR},
|
||||
#{contentLength,jdbcType=INTEGER},
|
||||
#{md5,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
||||
<update id="update" parameterType="com.nis.domain.callback.ProxyFileStrategyCfg" >
|
||||
update proxy_file_strategy_cfg
|
||||
<set>
|
||||
<if test="cfgDesc != null and cfgDesc != ''" >
|
||||
cfg_desc = #{cfgDesc,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="action != null" >
|
||||
action = #{action,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="isValid != null" >
|
||||
is_valid = #{isValid,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="isAudit != null" >
|
||||
is_audit = #{isAudit,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="creatorId != null" >
|
||||
creator_id = #{creatorId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="createTime != null and createTime != ''" >
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="editorId != null" >
|
||||
editor_id = #{editorId,jdbcType=INTEGER},
|
||||
</if>
|
||||
edit_time = #{editTime,jdbcType=TIMESTAMP},
|
||||
<if test="serviceId != null" >
|
||||
service_id = #{serviceId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="requestId != null" >
|
||||
request_id = #{requestId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="isAreaEffective != null" >
|
||||
is_area_effective = #{isAreaEffective,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="classify != null and classify != ''" >
|
||||
classify = #{classify,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="attribute != null and attribute != ''" >
|
||||
attribute = #{attribute,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="lable != null and lable != ''" >
|
||||
lable = #{lable,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="areaEffectiveIds != null" >
|
||||
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="functionId != null" >
|
||||
function_id = #{functionId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="cfgRegionCode != null" >
|
||||
cfg_region_code = #{cfgRegionCode,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="cfgType != null" >
|
||||
cfg_type = #{cfgType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
|
||||
<if test="fileId != null" >
|
||||
file_id = #{fileId ,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="fileDesc != null" >
|
||||
file_desc = #{fileDesc ,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="url != null" >
|
||||
url = #{url ,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="contentType != null" >
|
||||
content_type = #{contentType ,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="contentLength != null" >
|
||||
content_length = #{contentLength ,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="md5 != null" >
|
||||
md5 = #{md5 ,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where cfg_id = #{cfgId,jdbcType=BIGINT}
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -408,15 +408,25 @@ public class HttpRedirectCfgService extends CrudService<WebsiteCfgDao,CfgIndexIn
|
||||
if(entity.getAction().equals(16)){
|
||||
String userRegion1=StringUtil.isEmpty(entity.getUserRegion1()) ? "":entity.getUserRegion1();
|
||||
userRegion=Constants.REDIRECT_RESPONSE_CODE_KEY+"="+userRegion1;
|
||||
String userRegion2=StringUtil.isEmpty(entity.getUserRegion2()) ? "":entity.getUserRegion2();
|
||||
userRegion=userRegion+";"+Constants.REDIRECT_CONTENT_KEY+"="+userRegion2;
|
||||
String userRegion3=StringUtil.isEmpty(entity.getUserRegion3()) ? "":entity.getUserRegion3();//应答文件
|
||||
if(StringUtils.isNotBlank(userRegion3)) {
|
||||
userRegion=userRegion+";"+Constants.CONTENT_FILE_ID_KEY+"="+userRegion3;
|
||||
}else {//应答内容
|
||||
String userRegion2=StringUtil.isEmpty(entity.getUserRegion2()) ? "":entity.getUserRegion2();
|
||||
userRegion=userRegion+";"+Constants.REDIRECT_CONTENT_KEY+"="+userRegion2;
|
||||
}
|
||||
}
|
||||
//HTTP redirect: response code is not null ;response content is not null(userRegion is not null)
|
||||
if(entity.getAction().equals(48)){
|
||||
String userRegion1=StringUtil.isEmpty(entity.getUserRegion1()) ? "":entity.getUserRegion1();
|
||||
userRegion=Constants.REDIRECT_RESPONSE_CODE_KEY+"="+userRegion1;
|
||||
String userRegion2=StringUtil.isEmpty(entity.getUserRegion2()) ? "":entity.getUserRegion2();
|
||||
userRegion=userRegion+";"+Constants.REDIRECT_URL_KEY+"="+userRegion2;
|
||||
String userRegion3=StringUtil.isEmpty(entity.getUserRegion3()) ? "":entity.getUserRegion3();//应答文件
|
||||
if(StringUtils.isNotBlank(userRegion3)) {
|
||||
userRegion=userRegion+";"+Constants.CONTENT_FILE_ID_KEY+"="+userRegion3;
|
||||
}else {//应答内容
|
||||
String userRegion2=StringUtil.isEmpty(entity.getUserRegion2()) ? "":entity.getUserRegion2();
|
||||
userRegion=userRegion+";"+Constants.REDIRECT_URL_KEY+"="+userRegion2;
|
||||
}
|
||||
}
|
||||
//HTTP replace: replace type is not null ;find is not null;replace with is not null(userRegion is not null)
|
||||
if(entity.getAction().equals(80)){
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.nis.web.service.configuration;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.SysUser;
|
||||
import com.nis.domain.callback.ProxyFileStrategyCfg;
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.HttpBodyCfg;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.FileUtils;
|
||||
import com.nis.util.JsonMapper;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.configuration.ProxyFileStrategyDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.BaseService;
|
||||
|
||||
|
||||
@Service
|
||||
public class ProxyFileStrategyService extends BaseService{
|
||||
@Autowired
|
||||
protected ProxyFileStrategyDao proxyFileDao;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<ProxyFileStrategyCfg> findPage(Page page, ProxyFileStrategyCfg entity) {
|
||||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a"));
|
||||
entity.setPage(page);
|
||||
List<ProxyFileStrategyCfg> list=proxyFileDao.findPage(entity);
|
||||
page.setList(list);
|
||||
return page;
|
||||
}
|
||||
|
||||
public ProxyFileStrategyCfg getCfgById(Long cfgId) {
|
||||
return proxyFileDao.getCfgById(cfgId);
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveOrUpdate(ProxyFileStrategyCfg entity){
|
||||
Date createTime=new Date();
|
||||
//设置区域运营商信息
|
||||
setAreaEffectiveIds(entity);
|
||||
//新增
|
||||
if(entity.getCfgId()==null){
|
||||
entity.setCreatorId(UserUtils.getUser().getId());
|
||||
entity.setCreateTime(createTime);
|
||||
entity.setIsValid(0);
|
||||
entity.setIsAudit(0);
|
||||
|
||||
//修改
|
||||
proxyFileDao.insert(entity);
|
||||
}else{
|
||||
Date editTime=new Date();
|
||||
entity.setIsValid(0);
|
||||
entity.setIsAudit(0);
|
||||
entity.setEditorId(UserUtils.getUser().getId());
|
||||
entity.setEditTime(editTime);
|
||||
proxyFileDao.update(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void update(Integer isAudit,Integer isValid,String ids,Integer functionId){
|
||||
ProxyFileStrategyCfg entity = new ProxyFileStrategyCfg();
|
||||
String[] idArray = ids.split(",");
|
||||
for(String id :idArray){
|
||||
entity.setCfgId(Long.parseLong(id));
|
||||
entity.setFunctionId(functionId);
|
||||
entity.setIsAudit(isAudit);
|
||||
entity.setIsValid(isValid);
|
||||
entity.setEditorId(UserUtils.getUser().getId());
|
||||
entity.setEditTime(new Date());
|
||||
proxyFileDao.update(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void audit(Integer isAudit,Integer isValid,Integer functionId,String id){
|
||||
Date auditTime = new Date();//审核时间
|
||||
ProxyFileStrategyCfg entity = proxyFileDao.getCfgById(Long.parseLong(id));
|
||||
entity.setIsAudit(isAudit);
|
||||
entity.setIsValid(isValid);
|
||||
entity.setAuditorId(UserUtils.getUser().getId());
|
||||
entity.setAuditTime(auditTime);
|
||||
proxyFileDao.update(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的 响应文件 策略
|
||||
* @return
|
||||
*/
|
||||
public List<ProxyFileStrategyCfg> getProxyFileStrategyCfgList(ProxyFileStrategyCfg entity){
|
||||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a"));
|
||||
List<ProxyFileStrategyCfg> list=proxyFileDao.findPage(entity);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user