Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjh committed Jul 17, 2022
1 parent 25f84ec commit fc32d37
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.ccs.m3u8sync.downup.down;

public class DownConstant {
private DownConstant(){

}

//因子
public static final float FACTOR = 1.15F;
Expand All @@ -26,7 +29,7 @@ public class DownConstant {
public static final String TS_SOURCE = ".ts";

public static final String M3U8 = ".m3u8";
public static final String M3U8_FFmpeg = ".text";
public static final String M3U8_FF_MPEG = ".text";
public static final String MP4= ".mp4";
public static final String KEY = ".key";
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public class BaseException extends RuntimeException {
*
*/
private static final long serialVersionUID = 1L;
private String resultCode;
private String title = "Error";
private final String resultCode;
private final String title = "Error";


private static final Map<String, String> errorCodeMap;
Expand Down Expand Up @@ -39,15 +39,7 @@ public String getResultCode() {
return resultCode;
}

public void setResultCode(String resultCode) {
this.resultCode = resultCode;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,21 @@ private Map<String, Object> getRequestMap(HttpServletRequest req) {
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public Object handleException(HttpServletRequest request, Exception ex) {
if (ex != null && (ex instanceof HttpRequestMethodNotSupportedException
if(ex==null){
logger.error("---handleException method={} \n request={}", request.getMethod(), this.getRequestMap(request), ex);
return null;
}
if (ex instanceof HttpRequestMethodNotSupportedException
|| ex instanceof HttpMediaTypeNotSupportedException
|| ex instanceof HttpMediaTypeNotAcceptableException)) {
|| ex instanceof HttpMediaTypeNotAcceptableException){
logger.error("---handleException method={} uri={} error={}", request.getMethod(), request.getRequestURI(), ex.getMessage(), ex);
ResultData resultData = ResultData.error(new FailedException());
resultData.setErrorMsg(ex.getMessage());
return resultData;
}


String messageError = ex != null ? ex.getMessage() : null;
String messageError = ex.getMessage();
logger.error("---handleException method={} error={} \n request={}", request.getMethod(), messageError, this.getRequestMap(request), ex);

ResultData resultData = ResultData.error(new UnknownException(ex.getMessage()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public enum ResultCode {
FILE_UNEXIST("100011", "文件不存在"),
FILE_INVALID("100012", "文件无效"),
FILE_NORMAL("100013", "文件正常");
private String code;
private String msg;
private final String code;
private final String msg;

ResultCode(String code, String msg) {
this.code = code;
Expand Down
6 changes: 3 additions & 3 deletions m3u8sync/src/main/java/org/ccs/m3u8sync/utils/CommUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private CommUtils() {
/**
* 取数据前maxLength位
*
* @param str
* @param str string str
* @param maxLength
* @return
*/
Expand Down Expand Up @@ -57,7 +57,7 @@ public static String getString(Object obj) {
}

/**
* @return
* @return isStartWith
*/
public static boolean startWithChar(String str, char ch) {
if (str == null || str.length() < 1) {
Expand All @@ -67,7 +67,7 @@ public static boolean startWithChar(String str, char ch) {
}

/**
* @return
* @return isEndWith
*/
public static boolean endWithChar(String str, char ch) {
if (str == null || str.length() < 1) {
Expand Down

0 comments on commit fc32d37

Please sign in to comment.