Просмотр исходного кода

查询方案异常处理修改

luhg 7 лет назад
Родитель
Сommit
7be8bc3cbc

+ 6 - 1
src/main/java/com/uas/eis/entity/ErrorMsg.java

@@ -10,7 +10,12 @@ public enum ErrorMsg {
     EXPIRED_TOKEN(10003,"expired token","token已过期,请重新申请token"),
     INVALID_USER(10003,"invalid user","无效用户"),
     PERMISSION_DENIED_REQUEST(10004,"request permission denied","受限的接口请求"),
-    BAD_USERINFO(10005,"bad userinfo","账户名或密码错误");
+    BAD_USERINFO(10005,"bad userinfo","账户名或密码错误"),
+    NULL_QUERY_CODE(10006,"query code not found","查询方案编号不能为空"),
+    PARAM_AMOUNT_ERROR(10007,"param amount error","查询方案编号不能为空"),
+    PARAM_NAME_ERROR(10007,"param name error","查询方案编号不能为空"),
+    PARAM_FORMAT_ERROR(10008,"param format error","参数格式不正确");
+
 
 
     private int errCode;

+ 7 - 5
src/main/java/com/uas/eis/serviceImpl/QueryServiceImpl.java

@@ -9,6 +9,8 @@ import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import com.uas.eis.entity.ErrorMsg;
+import com.uas.eis.exception.SystemException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
@@ -223,24 +225,24 @@ public class QueryServiceImpl implements QueryService {
 	private void checkParam(String code, String param){
 		com.alibaba.fastjson.JSONObject json = JSON.parseObject(param);
 		if(StringUtils.isEmpty(code)){
-			BaseUtil.showError("查询方案编号不能为空", "NULL_QUERY_CODE");
+			throw new SystemException(ErrorMsg.NULL_QUERY_CODE);
 		}
 		if(json == null){
-			BaseUtil.showError("传入的参数个数不正确", "PARAM_AMOUNT_ERROR");
+			throw new SystemException(ErrorMsg.PARAM_AMOUNT_ERROR);
 		}
 		String getInParamsSql = "select * from queryArgs where qa_qccode = ? and qa_relation is null";
 		List<QueryArgs> inParamList = baseDao.query(getInParamsSql,  QueryArgs.class, code);
 		if(inParamList.size() != json.size()){
-			BaseUtil.showError("传入的参数个数不正确", "PARAM_AMOUNT_ERROR");
+			throw new SystemException(ErrorMsg.PARAM_AMOUNT_ERROR);
 		}else{
 			 for(QueryArgs queryArgs : inParamList){
 				 if(json.getString(queryArgs.getQa_param()) == null){
-					 BaseUtil.showError("传入的参数名不正确", "PARAM_NAME_ERROR");
+					 throw new SystemException(ErrorMsg.PARAM_NAME_ERROR);
 				 }else{
 					 if("array".equals(queryArgs.getQa_paramtype())){
 						 String stringArray = json.getString(queryArgs.getQa_param());
 						 if(!(stringArray.contains("[") && stringArray.contains("]"))){
-							 BaseUtil.showError("传入的参数:"+queryArgs.getQa_param()+"格式不正确", "PARAM_FORMAT_ERROR");
+							 throw new SystemException(ErrorMsg.PARAM_FORMAT_ERROR);
 						 }
 					 }
 				 }