From c9b57fc36c2666de6f9e75b22554a5ab70326451 Mon Sep 17 00:00:00 2001 From: 喻健 <喻健 @Admin> Date: 星期二, 20 十一月 2018 12:20:40 +0800 Subject: [PATCH] 迁移-系统参数+文件上传 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/config/SystemClientParamsAdminController.java | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 170 insertions(+), 1 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/SystemClientParamsAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/config/SystemClientParamsAdminController.java similarity index 68% rename from fanli/src/main/java/com/yeshi/fanli/controller/admin/SystemClientParamsAdminController.java rename to fanli/src/main/java/com/yeshi/fanli/controller/admin/config/SystemClientParamsAdminController.java index 28d1560..ccf8a90 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/SystemClientParamsAdminController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/config/SystemClientParamsAdminController.java @@ -1,7 +1,8 @@ -package com.yeshi.fanli.controller.admin; +package com.yeshi.fanli.controller.admin.config; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -13,7 +14,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.yeshi.fanli.entity.admin.SystemClientParamsAdmin; +import com.yeshi.fanli.entity.bus.help.AppPageNotification; +import com.yeshi.fanli.entity.bus.help.AppPageNotification.AppPageNotificationTypeEnum; import com.yeshi.fanli.entity.system.CustomerContent; import com.yeshi.fanli.entity.system.CustomerName; import com.yeshi.fanli.entity.system.System; @@ -23,7 +28,9 @@ import com.yeshi.fanli.tag.PageEntity; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.GsonUtil; +import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.Utils; + import org.yeshi.utils.JsonUtil; import net.sf.json.JSONObject; @@ -302,5 +309,167 @@ out.print(JsonUtil.loadTrueResult("娣诲姞鎴愬姛")); } + + /** + * 鍚庣鏌ヨ-鏂板悗鍙� + * @param callback + * @param pageIndex + * @param pageSize + * @param key + * @param systemId + * @param out + */ + @RequestMapping(value="query") + public void query(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; + } + + 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; + } + + 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 special + * @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("鍚嶇О銆乲ey銆乿alue銆佺郴缁熶笉鑳戒负绌�")); + 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.addSystemClientParams(systemClientParams, null); + 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("鍚嶇О銆乲ey銆乿alue涓嶈兘涓虹┖")); + return; + } + + try { + + List<SystemClientParams> list = + systemClientParamsService.getSystemClientParamsBySystemId(systemClientParams.getId()); + if (list == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔鏁版嵁宸蹭笉瀛樺湪")); + return; + } + + SystemClientParams resultObject = list.get(0); + + 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(); + } + } + } -- Gitblit v1.8.0