Commit 2d140665 authored by 王淑君's avatar 王淑君

修改bug

parent 17f30a85
......@@ -34,7 +34,7 @@ public class BBanner extends IdEntity<BBanner> {
private String title;
@Length(min = 1,max = 128,message = "长度最小为1,最大为256")
@NotBlank
@NotBlank(message="图片不能为空")
@ApiModelProperty(value = "图片地址")
private String imageUrl;
......
......@@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
/**
......@@ -48,10 +49,19 @@ public class BBannerServiceImpl implements BBannerService {
int line = 0;
//外部链接但外部URL为空或长度为0 抛异常
if ("1".equals(model.getIsExternalLink()) && StringUtils.isEmpty(model.getExternalUrl()))
throw new ServiceException(ResultServiceEnums.MUST_NOT_FILLED);
throw new ServiceException(ResultServiceEnums.JUMP_ADDRESS_NULL);
else {
String regex = "^([hH][tT]{2}[pP]:/*|[hH][tT]{2}[pP][sS]:/*|[fF][tT][pP]:/*)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\/])"; // +(\?{0,1}(([A-Za-z0-9-~]+\={0,1})([A-Za-z0-9-~]*)\&{0,1})*)$
Pattern pattern = Pattern.compile(regex);
if (!pattern.matcher(model.getExternalUrl()).matches()) {
// System.out.println("是正确的网址");
throw new ServiceException("非法网址");
}
}
//内部链接但类型或课程ID为空或长度为0 抛异常
if ("0".equals(model.getIsExternalLink()) && (StringUtils.isEmpty(model.getLineType()) || StringUtils.isEmpty(model.getCourseId())))
throw new ServiceException(ResultServiceEnums.MUST_NOT_FILLED);
throw new ServiceException(ResultServiceEnums.JUMP_ADDRESS_NULL);
if (model.getBusinessId() != null) {
//按ID查询Banner个数
if (bBannerRepository.selectCountById(model.getBusinessId()) == 0){
......
......@@ -211,6 +211,7 @@ public enum ResultServiceEnums {
ZX_FAILED(111,"调用智信接口失败"),
MUST_NOT_FILLED(112,"必填未填写"),
JUMP_ADDRESS_NULL(112,"跳转地址不能为空"),
NOT_MORE_COUNT(113,"添加超过规定个数"),
APPOINT_NOT_CLOSE(114,"必修不能退出"),
STATE_NOT_RELEASE(115,"该课程状态不能发布"),
......
......@@ -47,7 +47,8 @@ public class ValidatedMessage implements ResponseMessage {
public String getResponse(){
List<String> list = new ArrayList<String>();
for(Map.Entry<String,String[]> entry : this.validMap.entrySet()){
list.add(entry.getKey() + " 异常 " + entry.getValue()[0]);
list.add(entry.getKey() + entry.getValue()[0]);
// list.add(entry.getKey() + " 异常 " + entry.getValue()[0]);
}
return StringUtils.join(list,";");
}
......
......@@ -61,8 +61,8 @@ public class ValidatedResult implements Serializable{
while(var3.hasNext()) {
FieldError fieldError = (FieldError)var3.next();
this.errorsMap.put(" ",new String[]{fieldError.getDefaultMessage()});
// this.errorsMap.put(fieldError.getField(), new String[]{fieldError.getDefaultMessage(), fieldError.getCode()});
this.errorsMap.put(" ", new String[]{fieldError.getDefaultMessage()});
// this.errorsMap.put(imageUrl.getField(), new String[]{fieldError.getDefaultMessage(), fieldError.getCode()});
}
}
return this.errorsMap;
......@@ -71,4 +71,6 @@ public class ValidatedResult implements Serializable{
public ResponseMessage getValidatedMessage() {
return ValidatedMessage.builder(this.errorsMap);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment