From ca8e89d46a92b567aa9af2c32ea2951d1e60ca6c Mon Sep 17 00:00:00 2001
From: peternameyakj <908253177@qq.com>
Date: Thu, 29 Aug 2024 15:47:04 +0800
Subject: [PATCH] 合并ICO

---
 src/main/java/org/example/ssmico/demos/web/controller/IcoNewCurrencyController.java |   56 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/example/ssmico/demos/web/controller/IcoNewCurrencyController.java b/src/main/java/org/example/ssmico/demos/web/controller/IcoNewCurrencyController.java
index 4e17667..8362028 100644
--- a/src/main/java/org/example/ssmico/demos/web/controller/IcoNewCurrencyController.java
+++ b/src/main/java/org/example/ssmico/demos/web/controller/IcoNewCurrencyController.java
@@ -5,24 +5,19 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.example.ssmico.demos.web.entity.IcoNewCurrency;
 import org.example.ssmico.demos.web.service.IcoNewCurrencySerivce;
-import org.example.ssmico.demos.web.service.IcoOrderService;
-import org.example.ssmico.demos.web.util.GoogleTranslateUtil;
-import org.example.ssmico.demos.web.util.PageList;
+import org.example.ssmico.demos.web.util.DateUtils;
 import org.example.ssmico.demos.web.util.ResultObject;
 import org.example.ssmico.demos.web.util.ServerResponse;
+import org.example.ssmico.demos.web.vo.IcoNewCurrencyVo;
+import org.modelmapper.ModelMapper;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.*;
+
+import static cn.hutool.json.XMLTokener.entity;
 
 /**
  * @program: dabao
@@ -39,13 +34,23 @@
 
     /**
      * 新币添加
-     * @param icoNewCurrency
+     * @param icoNewCurrencyVo
      * @return
      */
     @ResponseBody
     @RequestMapping(value = "/add.action", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
-    public ServerResponse add(IcoNewCurrency icoNewCurrency) {
+    public ServerResponse add(@RequestBody IcoNewCurrencyVo icoNewCurrencyVo) {
         try {
+            IcoNewCurrency icoNewCurrency = new ModelMapper().map(icoNewCurrencyVo, IcoNewCurrency.class);
+            if(StringUtils.isNotBlank(icoNewCurrencyVo.getListingTime())){
+                icoNewCurrency.setListingTime(DateUtils.toDateHms(icoNewCurrencyVo.getListingTime()));
+            }
+            if(StringUtils.isNotBlank(icoNewCurrencyVo.getApplicationStartTime())){
+                icoNewCurrency.setApplicationStartTime(DateUtils.toDateHms(icoNewCurrencyVo.getApplicationStartTime()));
+            }
+            if(StringUtils.isNotBlank(icoNewCurrencyVo.getApplicationEndTime())){
+                icoNewCurrency.setApplicationEndTime(DateUtils.toDateHms(icoNewCurrencyVo.getApplicationEndTime()));
+            }
             long count = icoNewCurrencySerivce.count(new LambdaQueryWrapper<IcoNewCurrency>()
                     .eq(IcoNewCurrency::getTokenCode,icoNewCurrency.getTokenCode()).eq(IcoNewCurrency::getType,icoNewCurrency.getType()));
 
@@ -130,13 +135,23 @@
 
     /**
      * 修改ico
-     * @param icoNewCurrency
+     * @param icoNewCurrencyVo
      * @return
      */
     @ResponseBody
     @RequestMapping(value = "/update.action", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
-    public ServerResponse update(IcoNewCurrency icoNewCurrency,HttpServletRequest request) {
+    public ServerResponse update(@RequestBody IcoNewCurrencyVo icoNewCurrencyVo) {
         try {
+            IcoNewCurrency icoNewCurrency = new ModelMapper().map(icoNewCurrencyVo, IcoNewCurrency.class);
+            if(StringUtils.isNotBlank(icoNewCurrencyVo.getListingTime())){
+                icoNewCurrency.setListingTime(DateUtils.toDateHms(icoNewCurrencyVo.getListingTime()));
+            }
+            if(StringUtils.isNotBlank(icoNewCurrencyVo.getApplicationStartTime())){
+                icoNewCurrency.setApplicationStartTime(DateUtils.toDateHms(icoNewCurrencyVo.getApplicationStartTime()));
+            }
+            if(StringUtils.isNotBlank(icoNewCurrencyVo.getApplicationEndTime())){
+                icoNewCurrency.setApplicationEndTime(DateUtils.toDateHms(icoNewCurrencyVo.getApplicationEndTime()));
+            }
             long count = icoNewCurrencySerivce.count(new LambdaQueryWrapper<IcoNewCurrency>()
                     .eq(IcoNewCurrency::getTokenCode,icoNewCurrency.getTokenCode())
                     .ne(IcoNewCurrency::getId, icoNewCurrency.getId())
@@ -152,6 +167,17 @@
     }
 
     /**
+     * 获取ICO
+     * @param id
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping(value = "/getById.action", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
+    public ServerResponse<IcoNewCurrency> getById(String id) {
+        return ServerResponse.createBySuccess(icoNewCurrencySerivce.getById(id));
+    }
+
+    /**
      * 删除ico
      * @param id
      * @return

--
Gitblit v1.9.3