| | |
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.ehcache.EhCacheCacheManager;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.AppVersionInfo;
|
| | | import com.yeshi.fanli.entity.common.Config;
|
| | | import com.yeshi.fanli.entity.system.ConfigCategory;
|
| | | import com.yeshi.fanli.entity.system.ConfigCategory.ConfigCategoryEnum;
|
| | | import com.yeshi.fanli.service.inter.config.AppVersionService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigCategoryService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private AppVersionService appVersionService;
|
| | | private AppVersionService appVersionService;
|
| | |
|
| | | @Resource
|
| | | private EhCacheCacheManager ehCacheCacheManager;
|
| | |
|
| | | @Resource
|
| | | private ConfigCategoryService configCategoryService;
|
| | | |
| | |
|
| | | /**
|
| | | * 查询列表 - 新后台
|
| | |
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | List<AppVersionInfo> versionList = appVersionService.getAppVersionInfoListByPlatform("android");
|
| | | Map<Integer, String> androidMapName = new HashMap<>();
|
| | | for (AppVersionInfo version : versionList)
|
| | | androidMapName.put(version.getVersionCode(), version.getVersion());
|
| | |
|
| | | versionList = appVersionService.getAppVersionInfoListByPlatform("ios");
|
| | | Map<Integer, String> iosMapName = new HashMap<>();
|
| | | for (AppVersionInfo version : versionList)
|
| | | iosMapName.put(version.getVersionCode(), version.getVersion());
|
| | |
|
| | | List<Config> list = configService.listObjects(key, pageIndex);
|
| | |
|
| | | for (Config config : list) {
|
| | | config.setMinAndroidVersion(androidMapName.get(config.getMinAndroidVersionCode()));
|
| | | config.setMinIosVersion(iosMapName.get(config.getMinIosVersionCode()));
|
| | | }
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无更多数据"));
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 查询列表 - 新后台
|
| | | * 版本号信息
|
| | | * |
| | | * @param callback
|
| | | * @param key 查询词 名称
|
| | | * @param pageIndex
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getVersionList")
|
| | | public void getVersionList(String callback, String key, Integer pageIndex, PrintWriter out){
|
| | | |
| | | public void getVersionList(String callback, PrintWriter out) {
|
| | |
|
| | | try {
|
| | | AppVersionInfo appVersionInfo = new AppVersionInfo();
|
| | | appVersionInfo.setVersion("全推");
|
| | | |
| | | |
| | |
|
| | | // IOS版本
|
| | | List<AppVersionInfo> list1 = appVersionService.getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_IOS);
|
| | | if (list1 == null) {
|
| | |
| | | List<AppVersionInfo> listIOS = new ArrayList<AppVersionInfo>();
|
| | | listIOS.add(appVersionInfo);
|
| | | listIOS.addAll(list1);
|
| | | |
| | | |
| | |
|
| | | // 安卓版本
|
| | | List<AppVersionInfo> list2 = appVersionService.getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_ANDROID);
|
| | | List<AppVersionInfo> list2 = appVersionService
|
| | | .getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_ANDROID);
|
| | | if (list2 == null) {
|
| | | list2 = new ArrayList<AppVersionInfo>();
|
| | | }
|
| | | List<AppVersionInfo> listAndroid = new ArrayList<AppVersionInfo>();
|
| | | listAndroid.add(appVersionInfo);
|
| | | listAndroid.addAll(list2);
|
| | | |
| | | //小程序版本
|
| | | List<AppVersionInfo> list3 = appVersionService
|
| | | .getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_XCX);
|
| | | if (list3 == null) {
|
| | | list3 = new ArrayList<AppVersionInfo>();
|
| | | }
|
| | | List<AppVersionInfo> listWxmp = new ArrayList<AppVersionInfo>();
|
| | | listWxmp.add(appVersionInfo);
|
| | | listWxmp.addAll(list3);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("android", listAndroid);
|
| | | data.put("ios", listIOS);
|
| | | |
| | | data.put("wxmp", listWxmp);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | |
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("版本查询失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "clearCaches")
|
| | | public void clearCaches(String callback, PrintWriter out) {
|
| | | ehCacheCacheManager.getCacheManager().clearAll();
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(""));
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 根据分类查询
|
| | | * @param callback
|
| | | * @param type
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getByCategory")
|
| | | public void getByCategory(String callback, String type, PrintWriter out) {
|
| | | try {
|
| | | ConfigCategoryEnum categoryEnum = configCategoryService.getCategoryEnum(type);
|
| | | if (categoryEnum == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("版本查询失败"));
|
| | | return;
|
| | | }
|
| | | |
| | | List<Config> list = new ArrayList<>();
|
| | | |
| | | List<ConfigCategory> listCategory = configCategoryService.listByType(categoryEnum);
|
| | | if (listCategory != null) {
|
| | | for (ConfigCategory category: listCategory) {
|
| | | Config config = configService.getConfigBykeyNoCache(category.getKeyEnum().getKey());
|
| | | if (config != null) {
|
| | | list.add(config);
|
| | | }
|
| | | } |
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", list);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|