From e1cc0d03fadc2d251d36c0dc3650f75e830d5363 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 07 四月 2022 19:12:42 +0800 Subject: [PATCH] 功能完善 --- app/src/main/java/com/yeshi/makemoney/app/controller/admin/goldcorn/GoldCornGetFrequencyConfigAdminController.java | 71 +++++++++++++++++++++++++---------- 1 files changed, 51 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/yeshi/makemoney/app/controller/admin/goldcorn/GoldCornGetFrequencyConfigAdminController.java b/app/src/main/java/com/yeshi/makemoney/app/controller/admin/goldcorn/GoldCornGetFrequencyConfigAdminController.java index 65f169c..ee39c75 100644 --- a/app/src/main/java/com/yeshi/makemoney/app/controller/admin/goldcorn/GoldCornGetFrequencyConfigAdminController.java +++ b/app/src/main/java/com/yeshi/makemoney/app/controller/admin/goldcorn/GoldCornGetFrequencyConfigAdminController.java @@ -1,6 +1,10 @@ package com.yeshi.makemoney.app.controller.admin.goldcorn; import com.google.gson.*; +import com.yeshi.makemoney.app.aop.AdminApiFilter; +import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetType; +import com.yeshi.makemoney.app.vo.AcceptAdminData; +import com.yeshi.makemoney.app.vo.admin.goldcorn.GoldCornGetFrequencyAdminVO; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.springframework.stereotype.Controller; @@ -15,21 +19,23 @@ import java.lang.reflect.Type; import java.util.Date; import java.util.List; + import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetFrequencyConfig; import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornGetFrequencyConfigService; import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornGetFrequencyConfigQuery; + @Controller -@RequestMapping("admin/api/goldcorn/get/config") +@RequestMapping("admin/api/goldcorn/getfrequency") public class GoldCornGetFrequencyConfigAdminController { @Resource private GoldCornGetFrequencyConfigService goldCornGetFrequencyConfigService; - @ResponseBody + @ResponseBody @RequestMapping("list") - public String list(GoldCornGetFrequencyConfigQuery query, int page, int limit ) { - List<GoldCornGetFrequencyConfig> list = goldCornGetFrequencyConfigService.list(query,page,limit); + public String list(GoldCornGetFrequencyConfigQuery query, int page, int limit) { + List<GoldCornGetFrequencyConfig> list = goldCornGetFrequencyConfigService.list(query, page, limit); long count = goldCornGetFrequencyConfigService.count(query); JSONObject data = new JSONObject(); Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { @@ -37,6 +43,18 @@ @Override public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) { return date == null ? new JsonPrimitive("") : new JsonPrimitive(TimeUtil.getGernalTime(date.getTime(), "yyyy.MM.dd HH:mm")); + } + }).registerTypeAdapter(GoldCornGetType.class, new JsonSerializer<GoldCornGetType>() { + + @Override + public JsonElement serialize(GoldCornGetType date, Type type, JsonSerializationContext jsonSerializationContext) { + return date == null ? new JsonPrimitive("") : new JsonPrimitive(date.getName()); + } + }).registerTypeAdapter(GoldCornGetFrequencyConfig.GoldCornGetFrequencyTimeUnit.class, new JsonSerializer<GoldCornGetFrequencyConfig.GoldCornGetFrequencyTimeUnit>() { + + @Override + public JsonElement serialize(GoldCornGetFrequencyConfig.GoldCornGetFrequencyTimeUnit date, Type type, JsonSerializationContext jsonSerializationContext) { + return date == null ? new JsonPrimitive("") : new JsonPrimitive(date.getName()); } }).create(); @@ -49,21 +67,20 @@ @ResponseBody @RequestMapping("delete") public String delete(String ids) { - Type type = new TypeToken<List<String>>(){}.getType(); - List<String> idList=new Gson().fromJson(ids,type); + Type type = new TypeToken<List<String>>() { + }.getType(); + List<String> idList = new Gson().fromJson(ids, type); goldCornGetFrequencyConfigService.delete(idList); return JsonUtil.loadTrueResult(""); - } @ResponseBody @RequestMapping("add") - public String add(GoldCornGetFrequencyConfig bean, HttpSession session) { - try{ - goldCornGetFrequencyConfigService.add(bean); + public String add(GoldCornGetFrequencyAdminVO vo, AcceptAdminData acceptAdminData) { + try { + goldCornGetFrequencyConfigService.add(vo.toEntity(acceptAdminData.getSystem())); return JsonUtil.loadTrueResult(""); - - }catch(Exception e){ + } catch (Exception e) { return JsonUtil.loadFalseResult(e.getMessage()); } @@ -73,8 +90,8 @@ @RequestMapping("get") public String get(String id, HttpSession session) { GoldCornGetFrequencyConfig entity = goldCornGetFrequencyConfigService.get(id); - if (entity !=null){ - return JsonUtil.loadTrueResult(entity); + if (entity != null) { + return JsonUtil.loadTrueResult(GoldCornGetFrequencyAdminVO.create(entity)); } else { return JsonUtil.loadFalseResult("ID涓嶅瓨鍦�"); @@ -85,14 +102,14 @@ @ResponseBody @RequestMapping("update") - public String update(GoldCornGetFrequencyConfig bean, HttpSession session) { - if (bean.getId() == null) { - return JsonUtil.loadFalseResult("ID涓嶈兘涓虹┖"); + public String update(GoldCornGetFrequencyAdminVO vo, HttpSession session) { + if (vo.getId() == null) { + return JsonUtil.loadFalseResult("ID涓嶈兘涓虹┖"); } - try{ - goldCornGetFrequencyConfigService.update(bean); - }catch(Exception e){ + try { + goldCornGetFrequencyConfigService.update(vo.toEntity(null)); + } catch (Exception e) { return JsonUtil.loadFalseResult(e.getMessage()); } @@ -101,4 +118,18 @@ } + @ResponseBody + @RequestMapping("getTimeUnits") + public String getTimeUnits() { + JSONArray array = new JSONArray(); + for (GoldCornGetFrequencyConfig.GoldCornGetFrequencyTimeUnit unit : GoldCornGetFrequencyConfig.GoldCornGetFrequencyTimeUnit.values()) { + JSONObject data = new JSONObject(); + data.put("key", unit.name()); + data.put("value", unit.getName()); + array.add(data); + } + return JsonUtil.loadTrueResult(array); + } + + } -- Gitblit v1.8.0