Ver Fonte

修复初始化数据源和重新加载账套的BUG。

yangzhijie há 4 anos atrás
pai
commit
544b390515

+ 69 - 0
src/main/java/com/leanwo/gateway/dto/BaseResponse.java

@@ -0,0 +1,69 @@
+package com.leanwo.gateway.dto;
+
+/**
+ * HTTP 响应基类.
+ *
+ * @author YangZhiJie 2021-09-09
+ */
+public class BaseResponse {
+	
+	/**  错误码,0:正常,<0:异常, >0: 异常. */
+	private int errorCode;
+	
+	/**  错误消息,OK:正常,其他:异常消息. */
+	private String errorMessage;
+
+	public BaseResponse() {
+		
+	}
+	
+	public BaseResponse(int errorCode, String errorMessage) {
+		this.errorCode = errorCode;
+		this.errorMessage = errorMessage;
+	}
+	
+	/**
+	 * Gets the 错误码,0:正常,<0:异常, >0: 异常.
+	 *
+	 * @return the 错误码,0:正常,<0:异常, >0: 异常
+	 */
+	public int getErrorCode() {
+		return errorCode;
+	}
+
+	/**
+	 * Sets the 错误码,0:正常,<0:异常, >0: 异常.
+	 *
+	 * @param errorCode the new 错误码,0:正常,<0:异常, >0: 异常
+	 */
+	public void setErrorCode(int errorCode) {
+		this.errorCode = errorCode;
+	}
+
+	/**
+	 * Gets the 错误消息,OK:正常,其他:异常消息.
+	 *
+	 * @return the 错误消息,OK:正常,其他:异常消息
+	 */
+	public String getErrorMessage() {
+		return errorMessage;
+	}
+
+	/**
+	 * Sets the 错误消息,OK:正常,其他:异常消息.
+	 *
+	 * @param errorMessage the new 错误消息,OK:正常,其他:异常消息
+	 */
+	public void setErrorMessage(String errorMessage) {
+		this.errorMessage = errorMessage;
+	}
+	
+	/**
+	 * 复制BaseResponse
+	 * @param baseResponse
+	 */
+	public void copy(BaseResponse baseResponse) {
+		this.setErrorCode(baseResponse.getErrorCode());
+		this.setErrorMessage(baseResponse.getErrorMessage());
+	}
+}

+ 51 - 0
src/main/java/com/leanwo/gateway/rest/AccountManagementResource.java

@@ -0,0 +1,51 @@
+ package com.leanwo.gateway.rest;
+
+import javax.inject.Inject;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.leanwo.gateway.dto.BaseResponse;
+import com.leanwo.gateway.service.AccountManagementService;
+
+
+
+/**
+ * @author YangZhiJie
+ * @date 2022/05/29
+ */
+
+@RestController
+@RequestMapping("/AccountManagementResource")
+public class AccountManagementResource {
+
+    private static Logger logger = LoggerFactory.getLogger(AccountManagementResource.class);
+
+    @Inject
+    private AccountManagementService accountManagementService; 
+    
+    
+    /**
+     * 重新加载账套
+     * @param accountId
+     * @return
+     */
+    @RequestMapping(value = "/reloadAccountManagement", method = RequestMethod.GET)
+    @ResponseBody
+    public BaseResponse reloadAccountManagement() {
+        BaseResponse baseResponse = new BaseResponse();
+        try {
+            accountManagementService.loadAccountManagement(true);
+            baseResponse.setErrorCode(0);
+        }catch(Exception ex) {
+            logger.error("重新加载账套信息失败。", ex);
+            baseResponse.setErrorCode(1);
+            baseResponse.setErrorMessage(ex.getMessage());
+        }
+        return baseResponse;
+    }
+}