From eb8a211f814360b6aa2da9cefd924d355bbb5972 Mon Sep 17 00:00:00 2001
From: 6c <420680616@qq.com>
Date: 星期三, 07 五月 2025 09:26:35 +0800
Subject: [PATCH] Merge branch 'dev' of http://nonxin.cn:8090/r/product/product-server-mobile-core/V2.0.0 into dev
---
src/main/java/com/product/mobile/core/config/MobileCoreConst.java | 4
src/main/java/com/product/mobile/core/config/MobileCoreCode.java | 1
src/main/java/com/product/mobile/app/service/AppAdminService.java | 56 ++++++++++++++
src/main/java/com/product/mobile/app/controller/AppAdminController.java | 135 +++++++++++++++++++++++++++++++++
4 files changed, 195 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/product/mobile/app/controller/AppAdminController.java b/src/main/java/com/product/mobile/app/controller/AppAdminController.java
new file mode 100644
index 0000000..2cde370
--- /dev/null
+++ b/src/main/java/com/product/mobile/app/controller/AppAdminController.java
@@ -0,0 +1,135 @@
+package com.product.mobile.app.controller;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.alibaba.fastjson.JSONObject;
+import com.product.admin.service.PublicService;
+import com.product.common.lang.StringUtils;
+import com.product.core.config.CoreConst;
+import com.product.core.controller.support.AbstractBaseController;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.entity.RequestParameterEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.mobile.app.service.AppAdminService;
+import com.product.mobile.core.config.MobileCoreCode;
+import com.product.mobile.core.config.MobileCoreConst;
+import com.product.module.sys.version.ApiVersion;
+
+/**
+ * 鎵嬫満绔�氱敤鏌ヨ
+ *
+ * @author shicf
+ */
+@RequestMapping("/api/mobile/app")
+@RestController
+public class AppAdminController extends AbstractBaseController {
+ @Autowired
+ AppAdminService appAdminService;
+ /**
+ * 姝ゆ帴鍙i渶瑕佸姞鍏ョ櫧鍚嶅崟
+ *
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/version-check/{version}", method = RequestMethod.GET)
+ @ApiVersion(2)
+ public String versionCheck2(HttpServletRequest request) {
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(MobileCoreCode.SYSTEM_FORM_NODATA.getValue(),
+ MobileCoreCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(MobileCoreCode.SYSTEM_FORM_NODATA.getValue(),
+ MobileCoreCode.SYSTEM_FORM_NODATA.getText());
+ }
+ String version=fse.getString(MobileCoreConst.APP_VERSION);
+ if(StringUtils.isEmpty(version)) {
+ return this.error(MobileCoreCode.APP_ADMIN_VERSION_CHECK_NOT_CODE);
+ }
+ try {
+
+ FieldSetEntity f=appAdminService.checkVersion(version);
+ if(fse.getObject("type")!=null) {
+ JSONObject result = new JSONObject();
+ result.put("Code", 0);//0浠h〃璇锋眰鎴愬姛锛岄潪0浠h〃澶辫触
+ result.put("UpdateStatus", f.getInteger("upgrade")); //0浠h〃涓嶆洿鏂帮紝1浠h〃鏈夌増鏈洿鏂帮紝涓嶉渶瑕佸己鍒跺崌绾э紝2浠h〃鏈夌増鏈洿鏂帮紝闇�瑕佸己鍒跺崌绾�
+ result.put("VersionCode", f.getInteger("version_code"));
+ result.put("VersionName", f.getString("min_version"));
+ result.put("ModifyContent", f.getString("app_detail"));
+
+ result.put("DownloadUrl", fse.getString("url")+"?uuid="+f.getString("min_version_file")+"&needOnlineView=0");///鐢卞墠绔笂浼犲湴鍧�
+ result.put("ApkSize", 66389);
+// result.put("ApkMd5", "0"); //md5鍊兼病鏈夌殑璇濓紝灏辨棤娉曚繚璇乤pk鏄惁瀹屾暣锛屾瘡娆¢兘浼氶噸鏂颁笅杞姐�傛鏋堕粯璁や娇鐢ㄧ殑鏄痬d5鍔犲瘑銆�
+ System.out.println(result.toJSONString());
+ return result.toJSONString();
+ }else {
+ return this.OK_List(f);
+ }
+ } catch (BaseException e) {
+ return this.error(e);
+ } catch (Exception e) {
+
+ return this.error(MobileCoreCode.GET_DATA_FAIL);
+ }
+ }
+ /**
+ * 姝ゆ帴鍙i渶瑕佸姞鍏ョ櫧鍚嶅崟
+ *
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/version-check/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String versionCheck(HttpServletRequest request) {
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(MobileCoreCode.SYSTEM_FORM_NODATA.getValue(),
+ MobileCoreCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(MobileCoreCode.SYSTEM_FORM_NODATA.getValue(),
+ MobileCoreCode.SYSTEM_FORM_NODATA.getText());
+ }
+ String version=fse.getString(MobileCoreConst.APP_VERSION);
+ if(StringUtils.isEmpty(version)) {
+ return this.error(MobileCoreCode.APP_ADMIN_VERSION_CHECK_NOT_CODE);
+ }
+ try {
+
+ FieldSetEntity f=appAdminService.checkVersion(version);
+ if(fse.getObject("type")!=null) {
+ JSONObject result = new JSONObject();
+ result.put("Code", "0");//0浠h〃璇锋眰鎴愬姛锛岄潪0浠h〃澶辫触
+ result.put("UpdateStatus", f.getInteger("upgrade")); //0浠h〃涓嶆洿鏂帮紝1浠h〃鏈夌増鏈洿鏂帮紝涓嶉渶瑕佸己鍒跺崌绾э紝2浠h〃鏈夌増鏈洿鏂帮紝闇�瑕佸己鍒跺崌绾�
+ result.put("VersionCode", "1");
+ result.put("VersionName", f.getString("min_version"));
+ result.put("ModifyContent", f.getString("app_detail"));
+
+ result.put("DownloadUrl", fse.getString("url")+"&uuid="+f.getString("min_version_file")+"&needOnlineView=0");///鐢卞墠绔笂浼犲湴鍧�
+ result.put("ApkSize", "0");
+ result.put("ApkMd5", "0"); //md5鍊兼病鏈夌殑璇濓紝灏辨棤娉曚繚璇乤pk鏄惁瀹屾暣锛屾瘡娆¢兘浼氶噸鏂颁笅杞姐�傛鏋堕粯璁や娇鐢ㄧ殑鏄痬d5鍔犲瘑銆�
+ return result.toJSONString();
+ }else {
+ return this.OK_List(f);
+ }
+ } catch (BaseException e) {
+ return this.error(e);
+ } catch (Exception e) {
+
+ return this.error(MobileCoreCode.GET_DATA_FAIL);
+ }
+ }
+}
diff --git a/src/main/java/com/product/mobile/app/service/AppAdminService.java b/src/main/java/com/product/mobile/app/service/AppAdminService.java
new file mode 100644
index 0000000..74c3a46
--- /dev/null
+++ b/src/main/java/com/product/mobile/app/service/AppAdminService.java
@@ -0,0 +1,56 @@
+package com.product.mobile.app.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.product.core.dao.BaseDao;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.mobile.core.config.MobileCoreConst;
+import com.product.util.BaseUtil;
+
+/**
+ * 鎵嬫満绔紝鑾峰彇鐢ㄦ埛鎵�鏈夊簲鐢�
+ * @author Administrator
+ *
+ */
+@Component
+public class AppAdminService extends AbstractBaseService{
+ @Autowired
+ public BaseDao baseDao;
+ /**
+ * 鏄惁鏈夋柊鐨勭増鏈彿,杩斿洖涓や釜鐗堟湰鍙凤細鏈�杩戜竴娆$増鏈紝鏈�鏂扮増鏈�
+ * 璁╃敤鎴烽�夋嫨
+ * 鐗堟湰:澶т腑灏忥紝涓変釜鐗堟湰鍙凤紝鍙兘鍦ㄧ浉鍚屽ぇ鐗堝彿鍐呭鏇存柊
+ * 澶х増鏈彿闅忓悗绔殑澶х増鏈彿鍚屾椂鍗囩骇锛屽嵆鍚庣鏈夊ぇ鐗堟湰鍗囩骇锛屽悓鏃剁Щ鍔ㄧ涔熻澶х増鏈崌绾э紝涓増鏈�佸皬鐗堝彿鍙互涓嶄竴鑷�
+ * @return
+ * @throws BaseException
+ */
+ public FieldSetEntity checkVersion(String version) throws BaseException{
+ String filter="version>?";
+ DataTableEntity dt =baseDao.listTable(MobileCoreConst.TABLE_APP_MANAGER, filter, new String[] {version},"version");
+
+ FieldSetEntity fs=new FieldSetEntity();
+ fs.setTableName(MobileCoreConst.TABLE_APP_MANAGER);
+ if(DataTableEntity.isEmpty(dt)) {
+ fs.setValue("upgrade",0);
+ }else {
+
+ fs.setValue("min_version", dt.getString(0,"version"));
+ fs.setValue("min_version_file", dt.getString(0,"file"));
+ fs.setValue("version_code", dt.getString(0,"version_code"));
+ fs.setValue("app_detail", dt.getString(0,"app_detail"));
+// if(dt.getRows()>1) {
+// fs.setValue("max_version", dt.getString(dt.getRows()-1,"version"));
+// fs.setValue("max_version_file", dt.getString(dt.getRows()-1,"file"));
+// }else {
+// fs.setValue("max_version", dt.getString(0,"version"));
+// fs.setValue("max_version_file", dt.getString(0,"file"));
+// }
+ fs.setValue("upgrade",1);
+ }
+ return fs;
+ }
+}
diff --git a/src/main/java/com/product/mobile/core/config/MobileCoreCode.java b/src/main/java/com/product/mobile/core/config/MobileCoreCode.java
index fa2453c..2640d71 100644
--- a/src/main/java/com/product/mobile/core/config/MobileCoreCode.java
+++ b/src/main/java/com/product/mobile/core/config/MobileCoreCode.java
@@ -34,6 +34,7 @@
SIGN_IN_FAIL("鑰冨嫟鎵撳崱澶辫触", "011"),
GET_DATA_FAIL("鑾峰彇鏁版嵁澶辫触", "012"),
GET_MVC_PAGE_INFO_FAIL("鑾峰彇椤甸潰淇℃伅澶辫触", "013"),
+ APP_ADMIN_VERSION_CHECK_NOT_CODE("鏈幏鍙栧埌APP鐗堟湰鍙�", "014"),
;
MobileCoreCode(String text, String code) {
diff --git a/src/main/java/com/product/mobile/core/config/MobileCoreConst.java b/src/main/java/com/product/mobile/core/config/MobileCoreConst.java
index 0bc325f..4db4822 100644
--- a/src/main/java/com/product/mobile/core/config/MobileCoreConst.java
+++ b/src/main/java/com/product/mobile/core/config/MobileCoreConst.java
@@ -30,6 +30,7 @@
public static final String TABLE_PUNCH_RECORD = "product_oa_punch_record";
public static final String TABLE_PUNCH_SITE = "product_oa_punch_site";
public static final String TABLE_PUNCH_TIME = "product_oa_punch_time";
+ public static final String TABLE_APP_MANAGER = "product_sys_app_version";
//鎵撳崱:鎵嬫満鎵撳崱
public static final String FIELD_PUNCH_TYPE = "punch_type";
@@ -44,5 +45,6 @@
public static final String NAV_BAR_NAME = "nav_bar_name";
public static final String NAV_BAR_IMG = "nav_bar_img";
public static final String PATH = "path";
-
+ public static final String APP_VERSION = "version";
+
}
--
Gitblit v1.9.2