From 1d8adcc2c2ee0e6a1f65f5c963ea53fda77c95a3 Mon Sep 17 00:00:00 2001 From: shicf <shi_chongfu@163.com> Date: 星期四, 24 四月 2025 12:04:29 +0800 Subject: [PATCH] app管理 --- src/main/java/com/product/mobile/app/service/AppAdminService.java | 56 ++++++++++++++ src/main/java/com/product/mobile/app/controller/AppAdminController.java | 135 +++++++++++++++++++++++++++++++++ 2 files changed, 191 insertions(+), 0 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; + } +} -- Gitblit v1.9.2