对委托项目名称、标段名称、标段编号增加新的非法字符校验

This commit is contained in:
zhangqinbin
2022-05-18 10:23:32 +08:00
parent dfd3a18175
commit 8b5ca5f037
6 changed files with 24 additions and 22 deletions

View File

@ -10,6 +10,7 @@ import com.chinaunicom.mall.ebtp.project.projectrecord.entity.ProjectRecord;
import com.chinaunicom.mall.ebtp.project.projectsection.entity.ProjectSection;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
@ -21,11 +22,12 @@ import java.util.Map;
@Service
public class CheckUtil {
@Value("${check.porject.value}")
private static String checkValue[];//"= {"\t","\n","\r","<",">","|","\\","?",":","*","\""}
private String checkValue[];//"= {"\t","\n","\r","<",">","|","\\","?",":","*","\""}
@Value("${check.porject.length}") // = 200;
private static int checkLengh;
private int checkLengh;
//zhqbin 20220428 update 增加对委托项目名称\t\r\n字符校验
public static void checkEntrust(PurpImplementSendVO implementSendVO) {
public void checkEntrust(PurpImplementSendVO implementSendVO) {
log.error("---------对"+Arrays.toString(checkValue)+"..等字符---------------校验非法字符----------------------------");
if(implementSendVO.getPurpImplementName()!=null){
log.error("------------------------校验非法字符----------------------------项目名称:"+implementSendVO.getPurpImplementName());
@ -37,14 +39,14 @@ public class CheckUtil {
sectionList.forEach(s->{
log.error("------------------------校验非法字符----------------------------标段名称:"+s.getPurpName());
log.error("------------------------校验非法字符----------------------------标段编号:"+s.getPurpNo());
CheckUtil.check(s.getPurpName());
CheckUtil.check(s.getPurpNo());
CheckUtil.checkBdNameLengh("标段名称+标段编号",s.getPurpName()+s.getPurpNo());
this.check(s.getPurpName());
this.check(s.getPurpNo());
this.checkBdNameLengh("标段名称+标段编号",s.getPurpName()+s.getPurpNo());
});
}
}
//zhqbin 20220428 update 增加对委托项目名称\t\r\n字符校验
public static void checkInquiryVO(Map<String,Object> map) {
public void checkInquiryVO(Map<String,Object> map) {
log.error("------------------------校验非法字符----------------------------");
if(map.get("projectRecord")!=null){
ProjectRecord record = (ProjectRecord)map.get("projectRecord");
@ -57,14 +59,14 @@ public class CheckUtil {
sectionList.forEach(s->{
log.error("------------------------校验非法字符----------------------------标段名称:"+s.getBidSectName());
log.error("------------------------校验非法字符----------------------------标段编号:"+s.getBidSectBizNum());
CheckUtil.check(s.getBidSectName());
CheckUtil.check(s.getBidSectBizNum());
CheckUtil.checkBdNameLengh("标段名称+标段编号",s.getBidSectName()+s.getBidSectBizNum());
this.check(s.getBidSectName());
this.check(s.getBidSectBizNum());
this.checkBdNameLengh("标段名称+标段编号",s.getBidSectName()+s.getBidSectBizNum());
});
}
}
public static void check(String s) {
public void check(String s) {
//< > | \ / ? : * "
if (s!=null&&s instanceof String) {
log.info("----------校验参数--------"+s);
@ -75,7 +77,7 @@ public class CheckUtil {
}
}
public static void checkBdNameLengh(String name,String value) {
public void checkBdNameLengh(String name,String value) {
log.info("-----长度限制"+checkLengh+"-----对"+name+"进行校验--------");
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("该委托,"+name+"长度过长",
getLength(value)>checkLengh) ;

View File

@ -226,8 +226,8 @@ public class ProjectEntrustInquiryServiceImpl extends BaseServiceImpl<ProjectEnt
private void checkInquiryVO(InquiryVO inquiryVO){
//zhqbin 20220506 inset 校验项目名称非法字符
CheckUtil.check(inquiryVO.getTitle());
CheckUtil.checkBdNameLengh("询价但标题与单号",inquiryVO.getTitle()+inquiryVO.getInquiryNo());
new CheckUtil().check(inquiryVO.getTitle());
new CheckUtil().checkBdNameLengh("询价但标题与单号",inquiryVO.getTitle()+inquiryVO.getInquiryNo());
//询价单ID
if(StringUtils.isEmpty(inquiryVO.getInquiryId())){
ProjectExceptionEnum.FRAME_EXCEPTION_INQUIRY_ID_EMPTY.throwException();

View File

@ -630,7 +630,7 @@ public class ProjectEntrustServiceImpl extends BaseServiceImpl<ProjectEntrustMap
}
//zhqbin 20220506 inset 校验项目名称非法字符
CheckUtil.checkEntrust(implementSendVO);
new CheckUtil().checkEntrust(implementSendVO);
//实施项目ID
if(StringUtils.isEmpty(implementSendVO.getId())){

View File

@ -46,7 +46,7 @@ public class ProjectRecordController{
@PostMapping("")
@PreAuthorize("hasAnyAuthority('ebtp-purchase','ebtp-agency-project-manager')")
public BaseResponse<Boolean> insert(@ApiParam(value = "对象数据", required = true) @RequestBody @Valid ProjectRecordVO projectRecord){
CheckUtil.check(projectRecord.getProjectName());
new CheckUtil().check(projectRecord.getProjectName());
boolean save = projectRecordService.save(projectRecord);
return BaseResponse.success(save);
@ -64,7 +64,7 @@ public class ProjectRecordController{
@PreAuthorize("hasAnyAuthority('ebtp-purchase','ebtp-agency-project-manager')")
public BaseResponse<Boolean> update(
@ApiParam(value = "对象数据", required = true) @RequestBody ProjectRecordVO projectRecord){
CheckUtil.check(projectRecord.getProjectName());
new CheckUtil().check(projectRecord.getProjectName());
return BaseResponse.success(projectRecordService.updateProject(projectRecord));
}

View File

@ -1024,7 +1024,7 @@ public class ProjectRecordServiceImpl extends BaseServiceImpl<ProjectRecordMappe
resultMap.put("materialList", materialList);
resultMap.put("supplierList", supplierList);
//zhqbin 校验非法字符,长度
CheckUtil.checkInquiryVO(resultMap);
new CheckUtil().checkInquiryVO(resultMap);
return resultMap;
}

View File

@ -44,8 +44,8 @@ public class ProjectSectionController{
@PostMapping("")
@PreAuthorize("hasAnyAuthority('ebtp-purchase','ebtp-agency-project-manager')")
public BaseResponse<Boolean> insert(@ApiParam(value = "对象数据", required = true) @RequestBody @Valid ProjectSectionVO projectSection){
CheckUtil.check(projectSection.getBidSectName());
CheckUtil.check(projectSection.getBidSectBizNum());
new CheckUtil().check(projectSection.getBidSectName());
new CheckUtil().check(projectSection.getBidSectBizNum());
boolean save = projectSectionService.save(projectSection);
return BaseResponse.success(save);
@ -62,8 +62,8 @@ public class ProjectSectionController{
@PutMapping("")
@PreAuthorize("hasAnyAuthority('ebtp-purchase','ebtp-agency-project-manager')")
public BaseResponse<Boolean> update(@ApiParam(value = "对象数据", required = true) @RequestBody ProjectSectionVO projectSection){
CheckUtil.check(projectSection.getBidSectName());
CheckUtil.check(projectSection.getBidSectBizNum());
new CheckUtil().check(projectSection.getBidSectName());
new CheckUtil().check(projectSection.getBidSectBizNum());
return BaseResponse.success(projectSectionService.update(projectSection));
}