Commit ef475f9d authored by zhangqingle's avatar zhangqingle

Merge remote-tracking branch 'origin/meiteng' into meiteng

parents a1b3409d 709fe615
......@@ -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){
......
......@@ -409,12 +409,13 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
// int insertBChapter(BChapter model);
@Select("<script>" +
"SELECT bc.*, brc.current_location as currentLocation " +
"SELECT bc.*, brc.current_location as currentLocation, bf.video_url as videoUrl " +
"FROM " +
" b_lesson_person bp " +
" LEFT JOIN b_lesson b ON bp.lesson_id = b.business_id " +
" LEFT JOIN b_chapter bc ON bc.business_id = bp.chapter_id " +
"left join b_r_student_chapter brc on brc.chapter_id = bc.business_id " +
"left join b_file bf on bf.chapter_id = bc.business_id " +
"WHERE " +
" bp.chapter_id IS NOT NULL " +
" AND bp.chapter_id != '' " +
......
......@@ -73,6 +73,7 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
public void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
exceptionResolvers.add((HttpServletRequest request, HttpServletResponse response, Object handler, Exception e) -> {
Result result = new Result();
String message = e.getMessage();
if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler;
if(e instanceof SystemException){
......@@ -87,7 +88,7 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
if (e instanceof ServiceException) {//业务失败的异常,如“账号或密码错误”
result.setCode(ResultCode.FAIL).setMessage(e.getMessage());
}else {
String message = String.format("接口 [%s] 出现异常,方法:%s.%s,异常摘要:%s",
message = String.format("接口 [%s] 出现异常,方法:%s.%s,异常摘要:%s",
request.getRequestURI(),
handlerMethod.getBean().getClass().getName(),
handlerMethod.getMethod().getName(),
......@@ -101,7 +102,7 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
result.setCode(ResultCode.ERROR).setMessage(e.getMessage());
}
}
log.error(e.getMessage());
log.error(message);
ResponseUtil.responseResult(response, result);
return new ModelAndView();
}
......
......@@ -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