|
@@ -1,5 +1,7 @@
|
|
|
package com.welampiot.utils;
|
|
|
|
|
|
+import com.welampiot.common.BaseResult;
|
|
|
+import com.welampiot.configuration.ResponseConfig;
|
|
|
import com.welampiot.dto.GlobalLocationDTO;
|
|
|
import com.welampiot.dto.SectionDTO;
|
|
|
import com.welampiot.dto.UserDTO;
|
|
@@ -21,6 +23,9 @@ public class ToolUtils {
|
|
|
private SectionService sectionService;
|
|
|
@Autowired
|
|
|
private GlobalLocationService globalLocationService;
|
|
|
+ @Autowired
|
|
|
+ private ResponseConfig responseConfig;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取用户所有路段 id
|
|
@@ -113,4 +118,41 @@ public class ToolUtils {
|
|
|
public UserDTO getUser() {
|
|
|
return user;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 返回接口信息,不带数据
|
|
|
+ * @param code 状态码
|
|
|
+ * @param version 语言类型 0 中文,1 英文,2 俄语
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public BaseResult response(String code,Integer version){
|
|
|
+ String msg;
|
|
|
+ if (version == 0){
|
|
|
+ msg = responseConfig.getMsgCN().containsKey(code) ? responseConfig.getMsgCN().get(code) : "";
|
|
|
+ } else if (version == 1) {
|
|
|
+ msg = responseConfig.getMsgEN().containsKey(code) ? responseConfig.getMsgEN().get(code) : "";
|
|
|
+ }else {
|
|
|
+ msg = responseConfig.getMsgRU().containsKey(code) ? responseConfig.getMsgRU().get(code) : "";
|
|
|
+ }
|
|
|
+ return new BaseResult<>(code,msg,new Object());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 返回接口信息,带数据
|
|
|
+ * @param code 状态码
|
|
|
+ * @param version 语言类型 0 中文,1 英文,2 俄语
|
|
|
+ * @param obj 返回数据内容
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public BaseResult response(String code,Integer version,Object obj){
|
|
|
+ String msg;
|
|
|
+ if (version == 0){
|
|
|
+ msg = responseConfig.getMsgCN().containsKey(code) ? responseConfig.getMsgCN().get(code) : "";
|
|
|
+ } else if (version == 1) {
|
|
|
+ msg = responseConfig.getMsgEN().containsKey(code) ? responseConfig.getMsgEN().get(code) : "";
|
|
|
+ }else {
|
|
|
+ msg = responseConfig.getMsgRU().containsKey(code) ? responseConfig.getMsgRU().get(code) : "";
|
|
|
+ }
|
|
|
+ return new BaseResult<>(code,msg,obj);
|
|
|
+ }
|
|
|
}
|