编号:ZSSAC-585 描述:新增appcode验证

This commit is contained in:
pengren 2024-04-25 15:20:24 +08:00
parent 6ee4325537
commit 7fdeb3f39d
5 changed files with 36 additions and 5 deletions

View File

@ -10,8 +10,13 @@ import javax.servlet.http.HttpServletRequest;
public class RequestUtils {
public static String getHeader(String code){
HttpServletRequest request = null;
try {
RequestAttributes requestAttributes1 = RequestContextHolder.getRequestAttributes();
HttpServletRequest request = ((ServletRequestAttributes) requestAttributes1).getRequest();
request = ((ServletRequestAttributes) requestAttributes1).getRequest();
} catch (Exception e) {
throw new SecurityException("获取header中获取appCode信息");
}
if(StringUtils.isBlank(request.getHeader(code))){
throw new SecurityException("参数异常appCode为空");
}

View File

@ -52,6 +52,9 @@ public class DeploymentApplyEnvironmentController extends BaseController
public TableDataInfo list(DeploymentApplyEnvironment deploymentApplyEnvironment)
{
deploymentApplyEnvironment.setAppCode(RequestUtils.getHeader(RequestHeaderEnums.APP_CODE.getCode()));
if(StringUtils.isEmpty(deploymentApplyEnvironment.getAppCode())){
throw new SecurityException("参数异常header中的appCode为空");
}
startPage();
List<DeploymentApplyEnvironment> list = deploymentApplyEnvironmentService.selectDeploymentApplyEnvironmentList(deploymentApplyEnvironment);
return getDataTable(list);
@ -89,6 +92,9 @@ public class DeploymentApplyEnvironmentController extends BaseController
public AjaxResult add(@RequestBody DeploymentApplyEnvironment deploymentApplyEnvironment)
{
deploymentApplyEnvironment.setAppCode( RequestUtils.getHeader(RequestHeaderEnums.APP_CODE.getCode()));
if(StringUtils.isEmpty(deploymentApplyEnvironment.getAppCode())){
throw new SecurityException("参数异常header中的appCode为空");
}
return toAjax(deploymentApplyEnvironmentService.insertDeploymentApplyEnvironment(deploymentApplyEnvironment));
}

View File

@ -47,6 +47,9 @@ public class DeploymentModuleListController extends BaseController
public TableDataInfo list(DeploymentModuleList deploymentModuleList)
{
deploymentModuleList.setAppCode(RequestUtils.getHeader(RequestHeaderEnums.APP_CODE.getCode()));
if(StringUtils.isEmpty(deploymentModuleList.getAppCode())){
throw new SecurityException("参数异常header中的appCode为空");
}
startPage();
List<DeploymentModuleList> list = deploymentModuleListService.selectDeploymentModuleListList(deploymentModuleList);
return getDataTable(list);
@ -57,11 +60,11 @@ public class DeploymentModuleListController extends BaseController
@GetMapping("/qurey/list")
public AjaxResult queryByCore(ModuleListByCoreRequest request)
{
if(StringUtils.isEmpty(request.getAppCore())){
throw new SecurityException("参数异常appCode为空");
}
DeploymentModuleList deploymentModuleList = new DeploymentModuleList();
deploymentModuleList.setAppCode(RequestUtils.getHeader(RequestHeaderEnums.APP_CODE.getCode()));
if(StringUtils.isEmpty(deploymentModuleList.getAppCode())){
throw new SecurityException("参数异常header中的appCode为空");
}
deploymentModuleList.setSysType(request.getSysType());
List<DeploymentModuleList> list = deploymentModuleListService.selectDeploymentModuleListList(deploymentModuleList);
return success(list);
@ -99,6 +102,9 @@ public class DeploymentModuleListController extends BaseController
public AjaxResult add(@RequestBody DeploymentModuleList deploymentModuleList)
{
deploymentModuleList.setAppCode(RequestUtils.getHeader(RequestHeaderEnums.APP_CODE.getCode()));
if(StringUtils.isEmpty(deploymentModuleList.getAppCode())){
throw new SecurityException("参数异常header中的appCode为空");
}
return toAjax(deploymentModuleListService.insertDeploymentModuleList(deploymentModuleList));
}

View File

@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
import com.sf.common.enums.RequestHeaderEnums;
import com.sf.common.utils.DateUtils;
import com.sf.common.utils.StringUtils;
import com.sf.common.utils.http.RequestUtils;
import com.sf.system.deployment.domain.DeploymentServicePublish;
import com.sf.system.deployment.service.IDeploymentServicePublishService;
@ -47,6 +48,9 @@ public class DeploymentServicePublishController extends BaseController
public TableDataInfo list(DeploymentServicePublish deploymentServicePublish)
{
deploymentServicePublish.setAppCode(RequestUtils.getHeader(RequestHeaderEnums.APP_CODE.getCode()));
if(StringUtils.isEmpty(deploymentServicePublish.getAppCode())){
throw new SecurityException("参数异常header中的appCode为空");
}
startPage();
List<DeploymentServicePublish> list = deploymentServicePublishService.selectDeploymentServicePublishList(deploymentServicePublish);
return getDataTable(list);
@ -84,6 +88,9 @@ public class DeploymentServicePublishController extends BaseController
public AjaxResult add(@RequestBody DeploymentServicePublish deploymentServicePublish)
{
deploymentServicePublish.setAppCode(RequestUtils.getHeader(RequestHeaderEnums.APP_CODE.getCode()));
if(StringUtils.isEmpty(deploymentServicePublish.getAppCode())){
throw new SecurityException("参数异常header中的appCode为空");
}
return toAjax(deploymentServicePublishService.insertDeploymentServicePublish(deploymentServicePublish));
}

View File

@ -6,6 +6,7 @@ import com.sf.common.core.domain.AjaxResult;
import com.sf.common.core.page.TableDataInfo;
import com.sf.common.enums.BusinessType;
import com.sf.common.enums.RequestHeaderEnums;
import com.sf.common.utils.StringUtils;
import com.sf.common.utils.http.RequestUtils;
import com.sf.common.utils.poi.ExcelUtil;
import com.sf.system.deployment.domain.SysApkInfo;
@ -38,6 +39,9 @@ public class SysApkInfoController extends BaseController
public TableDataInfo list(SysApkInfo sysApkInfo)
{
sysApkInfo.setAppCode(RequestUtils.getHeader(RequestHeaderEnums.APP_CODE.getCode()));
if(StringUtils.isEmpty(sysApkInfo.getAppCode())){
throw new SecurityException("参数异常header中的appCode为空");
}
startPage();
List<SysApkInfo> list = sysApkInfoService.selectSysApkInfoList(sysApkInfo);
return getDataTable(list);
@ -75,6 +79,9 @@ public class SysApkInfoController extends BaseController
public AjaxResult add(@RequestBody SysApkInfo sysApkInfo)
{
sysApkInfo.setAppCode(RequestUtils.getHeader(RequestHeaderEnums.APP_CODE.getCode()));
if(StringUtils.isEmpty(sysApkInfo.getAppCode())){
throw new SecurityException("参数异常header中的appCode为空");
}
sysApkInfo.setCreated(getUsername());
sysApkInfo.setModified(getUsername());
return toAjax(sysApkInfoService.insertSysApkInfo(sysApkInfo));