From 15bedcc619b1edb6eb987f9288db7670e5b38c46 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 07 五月 2022 19:42:23 +0800 Subject: [PATCH] bug修复 --- app/src/main/java/com/yeshi/makemoney/app/controller/admin/money/ExtractAdminController.java | 90 ++++++++++++++++++++++++++++++++++++-------- 1 files changed, 73 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/yeshi/makemoney/app/controller/admin/money/ExtractAdminController.java b/app/src/main/java/com/yeshi/makemoney/app/controller/admin/money/ExtractAdminController.java index eed5615..3f05bc1 100644 --- a/app/src/main/java/com/yeshi/makemoney/app/controller/admin/money/ExtractAdminController.java +++ b/app/src/main/java/com/yeshi/makemoney/app/controller/admin/money/ExtractAdminController.java @@ -1,23 +1,36 @@ package com.yeshi.makemoney.app.controller.admin.money; import com.google.gson.*; +import com.yeshi.makemoney.app.aop.AdminApiFilter; +import com.yeshi.makemoney.app.dto.money.ExtractConfig; +import com.yeshi.makemoney.app.entity.config.SystemConfig; +import com.yeshi.makemoney.app.entity.config.SystemConfigKey; +import com.yeshi.makemoney.app.entity.money.ExtractPayType; +import com.yeshi.makemoney.app.service.inter.config.SystemConfigService; +import com.yeshi.makemoney.app.vo.AcceptAdminData; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.yeshi.utils.JsonUtil; +import org.yeshi.utils.StringUtil; import org.yeshi.utils.TimeUtil; import com.google.gson.reflect.TypeToken; import javax.annotation.Resource; import javax.servlet.http.HttpSession; import java.lang.reflect.Type; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Date; import java.util.List; + import com.yeshi.makemoney.app.entity.money.Extract; import com.yeshi.makemoney.app.service.inter.money.ExtractService; import com.yeshi.makemoney.app.service.query.money.ExtractQuery; + @Controller @RequestMapping("admin/api/money/extract") public class ExtractAdminController { @@ -25,11 +38,14 @@ @Resource private ExtractService extractService; + @Resource + private SystemConfigService systemConfigService; - @ResponseBody + + @ResponseBody @RequestMapping("list") - public String list(ExtractQuery query, int page, int limit, String callback ) { - List<Extract> list = extractService.list(query,page,limit); + public String list(ExtractQuery query, int page, int limit, String callback) { + List<Extract> list = extractService.list(query, page, limit); long count = extractService.count(query); JSONObject data = new JSONObject(); Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { @@ -38,21 +54,17 @@ 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(ExtractPayType.class, new JsonSerializer<ExtractPayType>() { + + @Override + public JsonElement serialize(ExtractPayType date, Type type, JsonSerializationContext jsonSerializationContext) { + return date == null ? new JsonPrimitive("") : new JsonPrimitive(date.getName()); + } }).create(); data.put("list", gson.toJson(list)); data.put("count", count); - return JsonUtil.loadJSONP(callback,JsonUtil.loadTrueResult(data)); - - } - - @ResponseBody - @RequestMapping("delete") - public String delete(String ids, String callback) { - Type type = new TypeToken<List<Long>>(){}.getType(); - List<Long> idList=new Gson().fromJson(ids,type); - extractService.delete(idList); - return JsonUtil.loadJSONP(callback,JsonUtil.loadTrueResult("")); + return JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)); } @@ -61,16 +73,60 @@ @RequestMapping("get") public String get(Long id, HttpSession session, String callback) { Extract entity = extractService.get(id); - if (entity !=null){ - return JsonUtil.loadJSONP(callback,JsonUtil.loadTrueResult(entity)); + if (entity != null) { + return JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(entity)); } else { - return JsonUtil.loadJSONP(callback,JsonUtil.loadFalseResult("ID涓嶅瓨鍦�")); + return JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("ID涓嶅瓨鍦�")); } } + @ResponseBody + @RequestMapping("getExtractConfig") + public String getExtractConfig(AcceptAdminData acceptAdminData) { + SystemConfig config = systemConfigService.getByKey(acceptAdminData.getSystem(), SystemConfigKey.extractConfig); + ExtractConfig extractConfig = null; + if (config != null && !StringUtil.isNullOrEmpty(config.getValue())) { + extractConfig = new Gson().fromJson(config.getValue(), ExtractConfig.class); + } + if (extractConfig == null) { + extractConfig = new ExtractConfig(); + extractConfig.setNewerLittleMoneyNum(0); + extractConfig.setMaxMoney(new BigDecimal(0)); + extractConfig.setMaxMoneyPerDay(new BigDecimal(0)); + extractConfig.setMaxNumPerDay(0); + extractConfig.setMinMoney(new BigDecimal(0)); + extractConfig.setExtractMoneyList(new ArrayList<>()); + } + + return JsonUtil.loadTrueResult(extractConfig); + + } + + @ResponseBody + @RequestMapping("updateExtractConfig") + public String updateExtractConfig(@RequestBody ExtractConfig extractConfig, AcceptAdminData acceptAdminData) { + SystemConfig config = systemConfigService.getByKey(acceptAdminData.getSystem(), SystemConfigKey.extractConfig); + if (config == null) { + SystemConfig newConfig = new SystemConfig(); + newConfig.setSystem(acceptAdminData.getSystem()); + newConfig.setKey(SystemConfigKey.extractConfig); + newConfig.setValue(new Gson().toJson(extractConfig)); + try { + systemConfigService.add(newConfig); + } catch (Exception e) { + return JsonUtil.loadFalseResult(e.getMessage()); + } + } else { + SystemConfig newConfig = new SystemConfig(); + newConfig.setId(config.getId()); + newConfig.setValue(new Gson().toJson(extractConfig)); + systemConfigService.update(newConfig); + } + return JsonUtil.loadTrueResult(""); + } } -- Gitblit v1.8.0