فهرست منبع

'增加api界面增加版本显示'

o2wwx 5 سال پیش
والد
کامیت
c72507fd39

+ 49 - 0
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/jest/ActionVersion.java

@@ -0,0 +1,49 @@
+package com.x.program.center.jaxrs.jest;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.google.gson.JsonObject;
+import com.x.base.core.project.config.Config;
+import com.x.base.core.project.gson.GsonPropertyObject;
+import com.x.base.core.project.gson.XGsonBuilder;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.tools.BaseTools;
+
+class ActionVersion extends BaseAction {
+	ActionResult<Wo> execute(HttpServletRequest request, String source) throws Exception {
+		ActionResult<Wo> result = new ActionResult<>();
+		Wo wo = new Wo();
+		String text = BaseTools.readString(Config.PATH_VERSION);
+		if (XGsonBuilder.isJsonObject(text)) {
+			JsonObject obj = XGsonBuilder.instance().fromJson(text, JsonObject.class);
+			 wo.setVersion(obj.get("version").getAsString());
+			 wo.setDate(obj.get("date").getAsString());
+		}
+		result.setData(wo);
+		return result;
+	}
+
+	public static class Wo extends GsonPropertyObject {
+		
+		private String version;
+        private String date;
+        
+		public String getVersion() {
+			return version;
+		}
+
+		public void setVersion(String version) {
+			this.version = version;
+		}
+
+		public String getDate() {
+			return date;
+		}
+
+		public void setDate(String date) {
+			this.date = date;
+		}
+
+	}
+
+}

+ 17 - 0
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/jest/JestAction.java

@@ -47,6 +47,23 @@ public class JestAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 
+	@GET
+	@Path("version")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	@JaxrsMethodDescribe(value = "列示服务器版本", action = ActionVersion.class)
+	public void getVersion(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
+		ActionResult<ActionVersion.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionVersion().execute(request, "");
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+	
 	@GET
 	@Path("clear/cache/{source}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)

+ 25 - 1
o2server/x_program_center/src/main/webapp/jest/list.html

@@ -124,7 +124,7 @@
 				if (json.type == 'success') {
 					if (json.data) {
 						var str = '<table border="1" id = "apiTable" >';
-                        str += '<tr><td colspan="3"><center id="title" style="font-size:32px; font-weight:bold;">O2OA Service API URL</center></td></tr>';
+                        str += '<tr><td colspan="3"><center id="title" style="font-size:32px; font-weight:bold;">O2OA Service API URL </center> </td></tr>';
 						$.each(json.data, function(index, o) {
 							str += '<tr>';
 							str += '<td>' + o.name + '</td>';
@@ -145,6 +145,28 @@
 					}
 				}
 			});
+			
+
+		$.ajax({
+			type : 'get',
+			async : false,
+			dataType : 'json',
+			contentType : 'application/json; charset=utf-8',
+			url : '../jaxrs/jest/version',
+			xhrFields : {
+				'withCredentials' : true
+			},
+			crossDomain : true,
+			error : function(e){
+			}
+		}).done(function(json) {
+			if (json.type == 'success') {
+				 if (json.data) {
+					 $('#version').html('<center>version:'+ json.data.version + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;date:" +json.data.date + "</center>");
+				 }
+				}
+			 }
+		);
 		});
 	</script>
 
@@ -155,5 +177,7 @@
 <center id="title" style="font-size:32px; font-weight:bold;"></center>
 <div id="content" style="margin-top:10px;margin-left: 50px;">&nbsp;</div>
 <div id="contentTable" style="margin-top:20px;margin-left: 50px;">&nbsp;</div>
+<div id="version"  >&nbsp;</div>
+<div><center> Copyright © 2020 Zoneland All Rights Reserved. </center></div>
 </body>
 </html>