| | |
| | | package com.yeshi.fanli.controller.admin.config;
|
| | |
|
| | | 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 com.yeshi.fanli.entity.accept.AdminAcceptData;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.entity.AppVersionInfo;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.entity.system.SystemClientParams;
|
| | | import com.yeshi.fanli.service.inter.config.AppVersionService;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/clientParams")
|
| | | public class SystemClientParamsAdminController {
|
| | |
|
| | | @Resource
|
| | | private SystemClientParamsService systemClientParamsService;
|
| | |
|
| | | @Resource
|
| | | private AppVersionService appVersionService;
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | |
|
| | | /**
|
| | | * 后端查询-新后台
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param key
|
| | | * @param systemId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "query")
|
| | | public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Long systemId,
|
| | | PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | |
|
| | | List<AppVersionInfo> versionList = appVersionService.getAppVersionInfoListByPlatform("android",acceptData.getSystem());
|
| | | Map<Integer, String> androidMapName = new HashMap<>();
|
| | | for (AppVersionInfo version : versionList)
|
| | | androidMapName.put(version.getVersionCode(), version.getVersion());
|
| | |
|
| | | versionList = appVersionService.getAppVersionInfoListByPlatform("ios",acceptData.getSystem());
|
| | | Map<Integer, String> iosMapName = new HashMap<>();
|
| | | for (AppVersionInfo version : versionList)
|
| | | iosMapName.put(version.getVersionCode(), version.getVersion());
|
| | |
|
| | | BusinessSystem businessSystem = businessSystemService.getById(systemId);
|
| | |
|
| | | try {
|
| | |
|
| | | List<SystemClientParams> list = systemClientParamsService.listQuery((pageIndex - 1) * pageSize, pageSize,
|
| | | key, systemId);
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | for (SystemClientParams params : list) {
|
| | | if (businessSystem.getPlatform() == 1)
|
| | | params.setVersion(androidMapName.get(params.getMinVersion()));
|
| | | else
|
| | | params.setVersion(iosMapName.get(params.getMinVersion()));
|
| | | }
|
| | |
|
| | | long count = systemClientParamsService.countQuery(key, systemId);
|
| | |
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", list);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 新增
|
| | | * |
| | | * @param callback
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveAdd")
|
| | | public void saveAdd(String callback, SystemClientParams systemClientParams, String idArray, PrintWriter out) {
|
| | |
|
| | | String key = systemClientParams.getKey();
|
| | | String name = systemClientParams.getName();
|
| | | String value = systemClientParams.getValue();
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(key) || StringUtil.isNullOrEmpty(name) || StringUtil.isNullOrEmpty(value)
|
| | | || StringUtil.isNullOrEmpty(idArray)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("名称、key、value、系统不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | Gson gson = new Gson();
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | systemClientParamsService.saveAdd(systemClientParams, list);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("添加成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 修改
|
| | | * |
| | | * @param callback
|
| | | * @param special
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveModify")
|
| | | public void saveModify(String callback, SystemClientParams systemClientParams, PrintWriter out) {
|
| | |
|
| | | String key = systemClientParams.getKey();
|
| | | String name = systemClientParams.getName();
|
| | | String value = systemClientParams.getValue();
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(key) || StringUtil.isNullOrEmpty(name) || StringUtil.isNullOrEmpty(value)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("名称、key、value不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | SystemClientParams resultObject = systemClientParamsService.selectByPrimaryKey(systemClientParams.getId());
|
| | | if (resultObject == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | systemClientParams.setSystem(resultObject.getSystem());
|
| | | systemClientParams.setUpdatetime(java.lang.System.currentTimeMillis());
|
| | |
|
| | | systemClientParamsService.update(systemClientParams);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除
|
| | | * |
| | | * @param callback
|
| | | * @param idArray
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "delete")
|
| | | public void delete(String callback, String idArray, PrintWriter out) {
|
| | |
|
| | | try {
|
| | | if (StringUtil.isNullOrEmpty(idArray)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | Gson gson = new Gson();
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | systemClientParamsService.deleteBatchByPrimaryKey(list);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("删除成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller.admin.config; |
| | | |
| | | 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 com.yeshi.fanli.entity.accept.AdminAcceptData; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.yeshi.fanli.entity.AppVersionInfo; |
| | | import com.yeshi.fanli.entity.system.BusinessSystem; |
| | | import com.yeshi.fanli.entity.system.SystemClientParams; |
| | | import com.yeshi.fanli.service.inter.config.AppVersionService; |
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService; |
| | | import com.yeshi.fanli.service.inter.config.SystemClientParamsService; |
| | | import com.yeshi.common.entity.PageEntity; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | @RequestMapping("admin/new/api/v1/clientParams") |
| | | public class SystemClientParamsAdminController { |
| | | |
| | | @Resource |
| | | private SystemClientParamsService systemClientParamsService; |
| | | |
| | | @Resource |
| | | private AppVersionService appVersionService; |
| | | |
| | | @Resource |
| | | private BusinessSystemService businessSystemService; |
| | | |
| | | /** |
| | | * 后端查询-新后台 |
| | | * |
| | | * @param callback |
| | | * @param pageIndex |
| | | * @param pageSize |
| | | * @param key |
| | | * @param systemId |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "query") |
| | | public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Long systemId, |
| | | PrintWriter out) { |
| | | |
| | | if (pageIndex == null || pageIndex < 1) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | if (pageSize == null || pageSize < 1) { |
| | | pageSize = Constant.PAGE_SIZE; |
| | | } |
| | | |
| | | List<AppVersionInfo> versionList = appVersionService.getAppVersionInfoListByPlatform("android",acceptData.getSystem()); |
| | | Map<Integer, String> androidMapName = new HashMap<>(); |
| | | for (AppVersionInfo version : versionList) |
| | | androidMapName.put(version.getVersionCode(), version.getVersion()); |
| | | |
| | | versionList = appVersionService.getAppVersionInfoListByPlatform("ios",acceptData.getSystem()); |
| | | Map<Integer, String> iosMapName = new HashMap<>(); |
| | | for (AppVersionInfo version : versionList) |
| | | iosMapName.put(version.getVersionCode(), version.getVersion()); |
| | | |
| | | BusinessSystem businessSystem = businessSystemService.getById(systemId); |
| | | |
| | | try { |
| | | |
| | | List<SystemClientParams> list = systemClientParamsService.listQuery((pageIndex - 1) * pageSize, pageSize, |
| | | key, systemId); |
| | | |
| | | if (list == null || list.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据")); |
| | | return; |
| | | } |
| | | |
| | | for (SystemClientParams params : list) { |
| | | if (businessSystem.getPlatform() == 1) |
| | | params.setVersion(androidMapName.get(params.getMinVersion())); |
| | | else |
| | | params.setVersion(iosMapName.get(params.getMinVersion())); |
| | | } |
| | | |
| | | long count = systemClientParamsService.countQuery(key, systemId); |
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", list); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 新增 |
| | | * |
| | | * @param callback |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveAdd") |
| | | public void saveAdd(AdminAcceptData acceptData,String callback, SystemClientParams systemClientParams, String idArray, PrintWriter out) { |
| | | |
| | | String key = systemClientParams.getKey(); |
| | | String name = systemClientParams.getName(); |
| | | String value = systemClientParams.getValue(); |
| | | |
| | | if (StringUtil.isNullOrEmpty(key) || StringUtil.isNullOrEmpty(name) || StringUtil.isNullOrEmpty(value) |
| | | || StringUtil.isNullOrEmpty(idArray)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("名称、key、value、系统不能为空")); |
| | | return; |
| | | } |
| | | |
| | | Gson gson = new Gson(); |
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() { |
| | | }.getType()); |
| | | if (list == null || list.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统不能为空")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | |
| | | systemClientParamsService.saveAdd(systemClientParams, list); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("添加成功")); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param callback |
| | | * @param special |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveModify") |
| | | public void saveModify(AdminAcceptData acceptData,String callback, SystemClientParams systemClientParams, PrintWriter out) { |
| | | |
| | | String key = systemClientParams.getKey(); |
| | | String name = systemClientParams.getName(); |
| | | String value = systemClientParams.getValue(); |
| | | |
| | | if (StringUtil.isNullOrEmpty(key) || StringUtil.isNullOrEmpty(name) || StringUtil.isNullOrEmpty(value)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("名称、key、value不能为空")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | |
| | | SystemClientParams resultObject = systemClientParamsService.selectByPrimaryKey(systemClientParams.getId()); |
| | | if (resultObject == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在")); |
| | | return; |
| | | } |
| | | |
| | | systemClientParams.setSystem(resultObject.getSystem()); |
| | | systemClientParams.setUpdatetime(java.lang.System.currentTimeMillis()); |
| | | |
| | | systemClientParamsService.update(systemClientParams); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功")); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param callback |
| | | * @param idArray |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "delete") |
| | | public void delete(AdminAcceptData acceptData,String callback, String idArray, PrintWriter out) { |
| | | |
| | | try { |
| | | if (StringUtil.isNullOrEmpty(idArray)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据")); |
| | | return; |
| | | } |
| | | |
| | | Gson gson = new Gson(); |
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() { |
| | | }.getType()); |
| | | |
| | | if (list == null || list.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据")); |
| | | return; |
| | | } |
| | | |
| | | systemClientParamsService.deleteBatchByPrimaryKey(list); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("删除成功")); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |