diff --git a/src/main/java/com/Application.java b/src/main/java/com/Application.java index 37930bf..98195d6 100644 --- a/src/main/java/com/Application.java +++ b/src/main/java/com/Application.java @@ -47,6 +47,7 @@ public class Application extends SpringBootServletInitializer { ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); MinuteTask minuteTask = configurableApplicationContext.getBean(MinuteTask.class); scheduledExecutorService.scheduleWithFixedDelay(minuteTask,30,10, TimeUnit.SECONDS); + FileCacheUtils.initData(); // FileCacheUtils.initData(); } diff --git a/src/main/java/com/jmfy/controller/CdkInfoController.java b/src/main/java/com/jmfy/controller/CdkInfoController.java index c0e61d0..a5af591 100644 --- a/src/main/java/com/jmfy/controller/CdkInfoController.java +++ b/src/main/java/com/jmfy/controller/CdkInfoController.java @@ -37,9 +37,11 @@ public class CdkInfoController { @RequestMapping(value = "/toAddCDKGoodsPage",method = RequestMethod.GET) public String toAddCDKGoodsPage(ModelMap map){ + Map itemNameMap = FileCacheUtils.itemNameMap; try { List allServerInfo = serverInfoDao.getAllServerInfo(); map.addAttribute("serverInfo",allServerInfo); + map.addAttribute("itemNameMap",itemNameMap); } catch (Exception e) { e.printStackTrace(); } @@ -79,6 +81,10 @@ public class CdkInfoController { return 0; } + @RequestMapping(value = "deleteCdkNumber",method = {RequestMethod.POST}) + public @ResponseBody int deleteCdkNumber(ModelMap map,int goodsId) throws Exception { + return cdkInfoDao.deleteCdk(goodsId); + } @RequestMapping(value = "/findCdkInfo", method = {RequestMethod.POST, RequestMethod.GET}) public String findCdkInfo (HttpSession session, ModelMap map , HttpServletRequest request) throws Exception { HashMap parameterMap = JsonUtil.getInstence().getParameterMap(request); diff --git a/src/main/java/com/jmfy/controller/MailController.java b/src/main/java/com/jmfy/controller/MailController.java index ce7bfa2..a51f02c 100644 --- a/src/main/java/com/jmfy/controller/MailController.java +++ b/src/main/java/com/jmfy/controller/MailController.java @@ -9,6 +9,7 @@ import com.jmfy.model.ServerInfo; import com.jmfy.model.ServerMail; import com.jmfy.model.vo.ServerMailVo; import com.jmfy.model.vo.ServerPMailVo; +import com.jmfy.utils.FileCacheUtils; import com.jmfy.utils.JsonUtil; import com.jmfy.utils.SeqUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -20,10 +21,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; +import java.util.*; @Controller public class MailController { @@ -40,9 +38,11 @@ public class MailController { @RequestMapping(value = "/toMailPage",method = RequestMethod.GET) public String toMailPage(ModelMap map,Integer type){ + Map itemNameMap = FileCacheUtils.itemNameMap; try { List allServerInfo = serverInfoDao.getAllServerInfo(); map.addAttribute("serverInfo",allServerInfo); + map.addAttribute("itemNameMap",itemNameMap); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/com/jmfy/dao/CdkInfoDao.java b/src/main/java/com/jmfy/dao/CdkInfoDao.java index 012df23..1bb5f53 100644 --- a/src/main/java/com/jmfy/dao/CdkInfoDao.java +++ b/src/main/java/com/jmfy/dao/CdkInfoDao.java @@ -27,4 +27,6 @@ public interface CdkInfoDao { SCdkInfo getScdkInfo(int goodsId) throws Exception; void updateCdkGoodsInfo(SCdkInfo scdkInfo,int goodsId) throws Exception; + + int deleteCdk(int goodsId) throws Exception; } diff --git a/src/main/java/com/jmfy/dao/impl/CdkInfoDaoImpl.java b/src/main/java/com/jmfy/dao/impl/CdkInfoDaoImpl.java index cc5790c..ad34212 100644 --- a/src/main/java/com/jmfy/dao/impl/CdkInfoDaoImpl.java +++ b/src/main/java/com/jmfy/dao/impl/CdkInfoDaoImpl.java @@ -3,6 +3,7 @@ package com.jmfy.dao.impl; import com.jmfy.dao.CdkInfoDao; import com.jmfy.model.*; import com.jmfy.utils.Connect; +import com.mongodb.WriteResult; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; @@ -109,4 +110,15 @@ public class CdkInfoDaoImpl implements CdkInfoDao { // Query query = new Query(Criteria.where("_id").is(goodsId)); // mongoTemplate.updateMulti(query, update, SCdkInfo.class); } + @Override + public int deleteCdk(int goodsId) throws Exception{ + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + Query query = new Query(); + Criteria cr = new Criteria(); + cr.andOperator(Criteria.where("_id").is(goodsId)); + query.addCriteria(cr); + mongoTemplate.remove(query,SCdkInfo.class); + return 1; + } + } diff --git a/src/main/resources/templates/CDKBuild.html b/src/main/resources/templates/CDKBuild.html index 66ffe99..ce7db80 100644 --- a/src/main/resources/templates/CDKBuild.html +++ b/src/main/resources/templates/CDKBuild.html @@ -25,7 +25,7 @@
-

序列號生成

+

序列号生成

@@ -63,8 +63,9 @@ @@ -144,6 +145,26 @@ $("body").append(form); form.submit(); } + function deleteCdk(obj, goodsId) { + goodsId = $(obj).attr("id"); + $.ajax({ + type: "POST", + data: {"goodsId": goodsId}, + url: "/deleteCdkNumber", + success: function (data) { + if (data == 1) { + window.location.reload(); //刷新页面 + layer.msg('删除成功!', {icon: 6, time: 1000}); + } + if(data==0){ + layer.error('此礼包不存在,请刷新页面', {icon: 6, time: 1000}); + + } + } + } + ) + + } \ No newline at end of file diff --git a/src/main/resources/templates/sendPersonalMail.html b/src/main/resources/templates/sendPersonalMail.html index 672296e..dcadca7 100644 --- a/src/main/resources/templates/sendPersonalMail.html +++ b/src/main/resources/templates/sendPersonalMail.html @@ -102,13 +102,19 @@ 附件:
-
- 物品id: - 物品数量: - 物品类型: - - + - +
+
+ 物品id: + + + 物品数量: + × + + + +
@@ -171,29 +177,28 @@ }); $(document).ready(function() { - var MaxInputs = 20; - var InputsWrapper = $("#InputsWrapper"); - var AddButton = $("#AddMoreFileBox"); + var MaxInputs = 5; //maximum input boxes allowed + var AddButton = $("#AddMoreFileBox"); //Add button ID - var x = InputsWrapper.length; - var FieldCount=1; + var item = "#item_"; + var x = 2; //initlal text box count - $(AddButton).click(function (e) + $(AddButton).click(function (e) //on add input button click { - if(x <= MaxInputs) + console.log(x); + if(x <= MaxInputs) //max input box allowed { - FieldCount++; - $(InputsWrapper).append('
' + - '物品id: ' + - '物品数量: 物品类型:×
'); + //add input box + $(item+x).css("display","block"); x++; + return true; } return false; }); $("body").on("click",".removeclass", function(e){ //user click on remove text - if( x > 1 ) { - $(this).parent('div').remove(); //remove text box + if( x > 2 ) { x--; //decrement textbox + $(item+x).css("display","none"); //remove text box } return false; }) @@ -213,17 +218,20 @@ var effectTime = $("input[name='effectTime']").val(); var version = $("input[name='version']").val(); var itemIds = []; - $("input[name='itemId']").each(function () { - itemIds.push($(this).val()); + $("select[name='itemId']").each(function () { + if($(this).val()!=='0'){ + itemIds.push($(this).val()); + } }); var itemNums =[]; $("input[name='itemNum']").each(function(){ - itemNums.push($(this).val()); - }); - var itemTypes =[]; - $("input[name='itemType']").each(function(){ - itemTypes.push($(this).val()); + if($(this).val()!=='') { + itemNums.push($(this).val()); + } }); + if(itemNums.length!==itemIds.length){ + erroCode.html('物品id或物品数量不匹配'); + } if (serverId === '' || serverId == null) { erroCode.html('服务器id不能为空!'); return false; @@ -261,7 +269,6 @@ "userId":userId, "itemIds": itemIds, "itemNums": itemNums, - // "itemTypes[]": itemTypes, "sendTime": sendTime, "playerRTime": playerRTime, "effectTime": effectTime, diff --git a/src/main/resources/templates/sendSysMail.html b/src/main/resources/templates/sendSysMail.html index 74bf9ef..90e2022 100644 --- a/src/main/resources/templates/sendSysMail.html +++ b/src/main/resources/templates/sendSysMail.html @@ -93,13 +93,19 @@ 附件:
-
- 物品id: - 物品数量: - 物品类型: - - + - +
+
+ 物品id: + + + 物品数量: + × + + + +
@@ -171,37 +177,35 @@ $(function(){ }); $(document).ready(function() { - var MaxInputs = 20; - var InputsWrapper = $("#InputsWrapper"); - var AddButton = $("#AddMoreFileBox"); + var MaxInputs = 5; //maximum input boxes allowed + var AddButton = $("#AddMoreFileBox"); //Add button ID - var x = InputsWrapper.length; - var FieldCount=1; + var item = "#item_"; + var x = 2; //initlal text box count - $(AddButton).click(function (e) + $(AddButton).click(function (e) //on add input button click { - if(x <= MaxInputs) + console.log(x); + if(x <= MaxInputs) //max input box allowed { - FieldCount++; - $(InputsWrapper).append('
' + - '物品id: ' + - '物品数量: 物品类型:×
'); + //add input box + $(item+x).css("display","block"); x++; + return true; } return false; }); $("body").on("click",".removeclass", function(e){ //user click on remove text - if( x > 1 ) { - $(this).parent('div').remove(); //remove text box + if( x > 2 ) { x--; //decrement textbox + $(item+x).css("display","none"); //remove text box } return false; }) - }); function sendSysMail() { var erroCode = $('.SERVERID'); - var serverId = $("input[name='serverId']").val(); + var serverId = $("#serverId").val(); var mailTitle = $("input[name='mailTitle']").val(); var mailContent = $("textarea[name='mailContent']").val(); var attach = $("input[name='attach']").val(); @@ -211,16 +215,16 @@ function sendSysMail() { var effectTime = $("input[name='effectTime']").val(); var version = $("input[name='version']").val(); var itemIds = []; - $("input[name='itemId']").each(function () { - itemIds.push($(this).val()); + $("select[name='itemId']").each(function () { + if($(this).val()!=='0'){ + itemIds.push($(this).val()); + } }); var itemNums =[]; $("input[name='itemNum']").each(function(){ - itemNums.push($(this).val()); - }); - var itemTypes =[]; - $("input[name='itemType']").each(function(){ - itemTypes.push($(this).val()); + if($(this).val()!=='') { + itemNums.push($(this).val()); + } }); if (serverId === '' || serverId == null) { erroCode.html('服务器id不能为空!'); @@ -258,7 +262,6 @@ function sendSysMail() { "isAttach": isAttach, "itemIds": itemIds, "itemNums": itemNums, - // "itemTypes[]": itemTypes, "sendTime": sendTime, "playerRTime": playerRTime, "effectTime": effectTime, diff --git a/src/main/resources/templates/toAddCDKGoods.html b/src/main/resources/templates/toAddCDKGoods.html index 13df86b..0ab3266 100644 --- a/src/main/resources/templates/toAddCDKGoods.html +++ b/src/main/resources/templates/toAddCDKGoods.html @@ -28,7 +28,7 @@
- - + + +