From eb9e1e3f7da200f3edaa7db7a27abad38a7d38bb Mon Sep 17 00:00:00 2001 From: duhui Date: Mon, 21 Jun 2021 16:49:32 +0800 Subject: [PATCH 1/9] =?UTF-8?q?gm,=20=E7=A4=BC=E5=8C=85=E7=A0=81=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jmfy/controller/CdkInfoController.java | 103 ++++++++++++++---- src/main/java/com/jmfy/dao/CdkInfoDao.java | 4 + .../com/jmfy/dao/impl/CdkInfoDaoImpl.java | 18 ++- src/main/java/com/jmfy/model/CdkUseInfo.java | 6 +- .../java/com/jmfy/model/vo/UseCDKInfoVo.java | 70 ++++++++++-- .../resources/static/html/findCDKInfo.html | 63 ++++++----- .../templates/queryCdkInfoByUser.html | 74 +++++++++++++ ...seCDKinfo.html => queryUserInfoByCdk.html} | 12 +- src/main/resources/templates/welcome.html | 6 +- 9 files changed, 283 insertions(+), 73 deletions(-) create mode 100644 src/main/resources/templates/queryCdkInfoByUser.html rename src/main/resources/templates/{useCDKinfo.html => queryUserInfoByCdk.html} (89%) diff --git a/src/main/java/com/jmfy/controller/CdkInfoController.java b/src/main/java/com/jmfy/controller/CdkInfoController.java index 5390d6e..d3796bf 100644 --- a/src/main/java/com/jmfy/controller/CdkInfoController.java +++ b/src/main/java/com/jmfy/controller/CdkInfoController.java @@ -96,34 +96,91 @@ public class CdkInfoController { return cdkInfoDao.deleteCdk(goodsId); } +// public String findCdkInfosssss (ModelMap map , HttpServletRequest request) throws Exception { +// HashMap parameterMap = JsonUtil.getInstence().getParameterMap(request); +// int serverId = Integer.parseInt(parameterMap.get("serverId")); +// String cdkNum = parameterMap.get("cdkNum"); +// CdkInfo cdkInfo = cdkInfoDao.findCdkInfoBuyId(cdkNum); +// if (cdkInfo == null){ +// return "useCDKinfo"; +// } +// SCdkInfo scdkInfo = cdkInfoDao.getScdkInfo(cdkInfo.getGoodsId()); +// if (scdkInfo == null){ +// return "useCDKinfo"; +// } +// List cdkUseInfoList = cdkInfoDao.findCdkUseInfoById(serverId,cdkNum); +// List useCDKInfoVoList = new ArrayList<>(); +// for (CdkUseInfo cdkUseInfo : cdkUseInfoList) { +// UseCDKInfoVo useCDKInfoVo = new UseCDKInfoVo(); +// useCDKInfoVo.setUserId(cdkUseInfo.getUid()); +// GSUser gsUser = gsUserDao.findUserInfo(cdkUseInfo.getServerId(), cdkUseInfo.getUid()); +// useCDKInfoVo.setUserName(gsUser.getPlayerManager().getNickName()); +// useCDKInfoVo.setOpenId(gsUser.getPlayerManager().getOpenId()); +// useCDKInfoVo.setGoodsName(scdkInfo.getGoodsName()); +// useCDKInfoVo.setUseTime(JsonUtil.timeStamp2Date(String.valueOf(cdkUseInfo.getCreateTime()))); +// useCDKInfoVoList.add(useCDKInfoVo); +// } +// map.put("useCDKinfo",useCDKInfoVoList); +// return "useCDKinfo"; +// } + @RequestMapping(value = "/findCdkInfo", method = {RequestMethod.POST, RequestMethod.GET}) - public String findCdkInfo (ModelMap map , HttpServletRequest request) throws Exception { + public String findCdkInfo (ModelMap map, HttpServletRequest request) throws Exception { + String path; HashMap parameterMap = JsonUtil.getInstence().getParameterMap(request); - int serverId = Integer.parseInt(parameterMap.get("serverId")); - String cdkNum = parameterMap.get("cdkNum"); - CdkInfo cdkInfo = cdkInfoDao.findCdkInfoBuyId(cdkNum); - if (cdkInfo == null){ - return "useCDKinfo"; + int type = Integer.valueOf(parameterMap.get("type")); + List cdkUseInfo; + if (type == 1){ + path = "queryUserInfoByCdk"; + String cdkId = parameterMap.get("cdkId"); + cdkUseInfo = cdkInfoDao.findCdkUseInfo(cdkId); } - SCdkInfo scdkInfo = cdkInfoDao.getScdkInfo(cdkInfo.getGoodsId()); - if (scdkInfo == null){ - return "useCDKinfo"; + else if (type == 2){ + path = "queryCdkInfoByUser"; + String userId = parameterMap.get("userId"); + cdkUseInfo = cdkInfoDao.findCdkUseInfoByUId(Integer.valueOf(userId)); } - List cdkUseInfoList = cdkInfoDao.findCdkUseInfoById(serverId,cdkNum); - List useCDKInfoVoList = new ArrayList<>(); - for (CdkUseInfo cdkUseInfo : cdkUseInfoList) { - UseCDKInfoVo useCDKInfoVo = new UseCDKInfoVo(); - useCDKInfoVo.setIsData(1); - useCDKInfoVo.setUserId(cdkUseInfo.getUid()); - GSUser gsUser = gsUserDao.findUserInfo(cdkUseInfo.getServerId(), cdkUseInfo.getUid()); - useCDKInfoVo.setUserName(gsUser.getPlayerManager().getNickName()); - useCDKInfoVo.setOpenId(gsUser.getPlayerManager().getOpenId()); - useCDKInfoVo.setGoodsName(scdkInfo.getGoodsName()); - useCDKInfoVo.setUseTime(JsonUtil.timeStamp2Date(String.valueOf(cdkUseInfo.getCreateTime()))); - useCDKInfoVoList.add(useCDKInfoVo); + else { + throw new Exception("type is error !!!"); } - map.put("useCDKinfo",useCDKInfoVoList); - return "useCDKinfo"; + List vos = new ArrayList<>(voToCdk(cdkUseInfo)); + map.put("useCdkInfo",vos); + return path; + } + + /** + * 转vo对象 + * @param useInfos + * @return + */ + private List voToCdk(List useInfos){ + List list = new ArrayList<>(); + useInfos.forEach(v->{ + UseCDKInfoVo infoVo = new UseCDKInfoVo(); + try { + // 礼包信息 + infoVo.setCdkId(v.getCdk()); + infoVo.setUseTime(DateUtil.stampToTime(v.getCreateTime())); + // 玩家信息 + GSUser gsUser = gsUserDao.findUserInfo(v.getServerId(), v.getUid()); + infoVo.setUserId(v.getUid()); + infoVo.setUserName(gsUser.getPlayerManager().getNickName()); + infoVo.setOpenId(gsUser.getPlayerManager().getOpenId()); + // 服务器信息 + ServerInfo serverinfo = serverInfoDao.getServerinfo(String.valueOf(v.getServerId())); + infoVo.setServerId(v.getServerId()); + infoVo.setServerName(v.getServerId()+"-"+serverinfo.getName()); + // 礼包码信息 + CdkInfo cdkInfo = cdkInfoDao.findCdkInfoBuyId(v.getCdk()); + SCdkInfo scdkInfo = cdkInfoDao.getScdkInfo(cdkInfo.getGoodsId()); + infoVo.setGoodsId(scdkInfo.getId()); + infoVo.setGoodsName(scdkInfo.getGoodsName()); + } catch (Exception e) { + e.printStackTrace(); + } + list.add(infoVo); + }); + return list; } /** diff --git a/src/main/java/com/jmfy/dao/CdkInfoDao.java b/src/main/java/com/jmfy/dao/CdkInfoDao.java index 1bb5f53..3fe575d 100644 --- a/src/main/java/com/jmfy/dao/CdkInfoDao.java +++ b/src/main/java/com/jmfy/dao/CdkInfoDao.java @@ -14,6 +14,10 @@ public interface CdkInfoDao { List findCdkUseInfoById(int serverId, String cdkNum) throws Exception; + List findCdkUseInfo(String cdkNum) throws Exception; + + List findCdkUseInfoByUId(int userId) throws Exception; + // long getCdkNumByGoodsId(int id) throws Exception; long getUseCdkNumByGoodsId(int id) 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 ad34212..9e7d890 100644 --- a/src/main/java/com/jmfy/dao/impl/CdkInfoDaoImpl.java +++ b/src/main/java/com/jmfy/dao/impl/CdkInfoDaoImpl.java @@ -40,11 +40,24 @@ public class CdkInfoDaoImpl implements CdkInfoDao { Query query = new Query(); Criteria cr = new Criteria(); cr.andOperator(Criteria.where("cdk_num").is(cdkNum), Criteria.where("serverId").is(serverId)); -// cr.andOperator(Criteria.where("goodsId").is(cdkNum)); query.addCriteria(cr); return mongoTemplate.find(query, CdkUseInfo.class); - } + + @Override + public List findCdkUseInfo(String cdkNum) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + Query query = new Query(Criteria.where("cdk_num").is(cdkNum)); + return mongoTemplate.find(query, CdkUseInfo.class); + } + + @Override + public List findCdkUseInfoByUId(int userId) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + Query query = new Query(Criteria.where("uid").is(userId)); + return mongoTemplate.find(query, CdkUseInfo.class); + } + // // @Override // public long getCdkNumByGoodsId(int id) throws Exception { @@ -73,7 +86,6 @@ public class CdkInfoDaoImpl implements CdkInfoDao { Query query = new Query(); Criteria cr = new Criteria(); cr.andOperator(Criteria.where("goodsId").is(goodsId)); -// cr.andOperator(Criteria.where("goodsId").is(goodsId),Criteria.where("status").is(0)); query.addCriteria(cr); return mongoTemplate.find(query,CdkInfo.class); } diff --git a/src/main/java/com/jmfy/model/CdkUseInfo.java b/src/main/java/com/jmfy/model/CdkUseInfo.java index 78eee75..fb761b1 100644 --- a/src/main/java/com/jmfy/model/CdkUseInfo.java +++ b/src/main/java/com/jmfy/model/CdkUseInfo.java @@ -7,7 +7,11 @@ import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Field; @Document(collection = "cdk_use_info") -@CompoundIndexes({@CompoundIndex(name = "cdk_num_serverId_index", def = "{'cdk_num': 1, 'serverId': 1}")}) +@CompoundIndexes({ + @CompoundIndex(name = "cdk_num_serverId_index", def = "{'cdk_num': 1, 'serverId': 1}"), + @CompoundIndex(name = "cdk_num_index", def = "{'cdk_num': 1}"), + @CompoundIndex(name = "uid_index", def = "{'uid': 1}") +}) public class CdkUseInfo { @Id diff --git a/src/main/java/com/jmfy/model/vo/UseCDKInfoVo.java b/src/main/java/com/jmfy/model/vo/UseCDKInfoVo.java index 2cd7e03..c32fd8a 100644 --- a/src/main/java/com/jmfy/model/vo/UseCDKInfoVo.java +++ b/src/main/java/com/jmfy/model/vo/UseCDKInfoVo.java @@ -2,38 +2,92 @@ package com.jmfy.model.vo; public class UseCDKInfoVo implements java.io.Serializable { - public int isData; // 是否有数据 0:没有 1: 有 + private String cdkId; - public int userId; + private int userId; - public String openId; + private String userName; - public String userName; + private int serverId; - public String goodsName; //礼包名字 + private String serverName; - public String useTime; + private String openId; - public void setIsData(int isData) { - this.isData = isData; + private int goodsId; + + private String goodsName; + + private String useTime; + + public String getCdkId() { + return cdkId; + } + + public void setCdkId(String cdkId) { + this.cdkId = cdkId; + } + + public int getUserId() { + return userId; } public void setUserId(int userId) { this.userId = userId; } + public int getServerId() { + return serverId; + } + + public void setServerId(int serverId) { + this.serverId = serverId; + } + + public String getServerName() { + return serverName; + } + + public void setServerName(String serverName) { + this.serverName = serverName; + } + + public String getOpenId() { + return openId; + } + public void setOpenId(String openId) { this.openId = openId; } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { this.userName = userName; } + public int getGoodsId() { + return goodsId; + } + + public void setGoodsId(int goodsId) { + this.goodsId = goodsId; + } + + public String getGoodsName() { + return goodsName; + } + public void setGoodsName(String goodsName) { this.goodsName = goodsName; } + public String getUseTime() { + return useTime; + } + public void setUseTime(String useTime) { this.useTime = useTime; } diff --git a/src/main/resources/static/html/findCDKInfo.html b/src/main/resources/static/html/findCDKInfo.html index cedbb81..dd2c676 100644 --- a/src/main/resources/static/html/findCDKInfo.html +++ b/src/main/resources/static/html/findCDKInfo.html @@ -20,23 +20,27 @@ -序列號查询 +序列号查询 - +
-

序列號查询

-
-
-
-
-
-

-
- - -
-
+

序列号查询

+
+

+ +
+
+
+ +
@@ -47,21 +51,22 @@ \ No newline at end of file diff --git a/src/main/resources/templates/queryCdkInfoByUser.html b/src/main/resources/templates/queryCdkInfoByUser.html new file mode 100644 index 0000000..717c798 --- /dev/null +++ b/src/main/resources/templates/queryCdkInfoByUser.html @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + CDK使用信息 + + + +
+

序列号使用信息

+
+
+ + + + + + + + + + + + + + + + + + +
角色ID角色名玩家区服序列号ID礼包码名称
+
+
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/useCDKinfo.html b/src/main/resources/templates/queryUserInfoByCdk.html similarity index 89% rename from src/main/resources/templates/useCDKinfo.html rename to src/main/resources/templates/queryUserInfoByCdk.html index abe253e..9748c30 100644 --- a/src/main/resources/templates/useCDKinfo.html +++ b/src/main/resources/templates/queryUserInfoByCdk.html @@ -25,7 +25,7 @@ > 序列号查询
-

序列號使用信息

+

序列号使用信息

@@ -33,14 +33,16 @@ - - - + + + + - + + diff --git a/src/main/resources/templates/welcome.html b/src/main/resources/templates/welcome.html index 0657b45..d349ded 100644 --- a/src/main/resources/templates/welcome.html +++ b/src/main/resources/templates/welcome.html @@ -26,10 +26,8 @@

戒灵后台管理台

-

更新日志[2021-6-9]

-

1、区服展示改为: 区服id-区服名称

-

2、gm管理添加渠道管理页签,可以添加删除渠道信息

-

2、订单页面管理,添加字段,解决导出报错问题

+

更新日志[2021-6-21]

+

1、序列号查询功能修改优化

From 63e5b1d55bb239d89a04b122d402b590b88b1ee4 Mon Sep 17 00:00:00 2001 From: duhui Date: Tue, 22 Jun 2021 10:17:28 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=88=9D=E7=89=88=E6=9C=AA=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/GamePackInfoController.java | 129 ++++++++++++++++ .../java/com/jmfy/dao/GamePackInfoDao.java | 42 ++++++ .../jmfy/dao/impl/GamePackInfoDaoImpl.java | 50 +++++++ .../java/com/jmfy/model/GamePackInfo.java | 61 ++++++++ .../java/com/jmfy/model/vo/PowersEnum.java | 3 + .../resources/templates/gamePackInfo.html | 141 ++++++++++++++++++ src/main/resources/templates/index.html | 4 +- 7 files changed, 429 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/jmfy/controller/GamePackInfoController.java create mode 100644 src/main/java/com/jmfy/dao/GamePackInfoDao.java create mode 100644 src/main/java/com/jmfy/dao/impl/GamePackInfoDaoImpl.java create mode 100644 src/main/java/com/jmfy/model/GamePackInfo.java create mode 100644 src/main/resources/templates/gamePackInfo.html diff --git a/src/main/java/com/jmfy/controller/GamePackInfoController.java b/src/main/java/com/jmfy/controller/GamePackInfoController.java new file mode 100644 index 0000000..6ffee20 --- /dev/null +++ b/src/main/java/com/jmfy/controller/GamePackInfoController.java @@ -0,0 +1,129 @@ +package com.jmfy.controller; + +import com.jmfy.dao.CUserDao; +import com.jmfy.dao.GamePackInfoDao; +import com.jmfy.model.CAdmin; +import com.jmfy.model.GamePackInfo; +import com.jmfy.model.vo.PowersEnum; +import com.jmfy.utils.JsonUtil; +import com.jmfy.utils.SeqUtils; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +/** + * @Author hj + * @Description 登陆界面 协议http管理 + **/ +@SuppressWarnings("ALL") +@Controller +public class GamePackInfoController { + + @Resource + private GamePackInfoDao gamePackInfoDao; + @Resource + private CUserDao cUserDao; + @Resource + private SeqUtils seqUtils; + + /** + * 获取全部列表 + * @param map + * @return + */ + @RequestMapping(value = "/gamePackInfoList", method = {RequestMethod.POST, RequestMethod.GET}) + public String getGamePackInfoList(ModelMap map){ + try { + List infoList = gamePackInfoDao.getGamePackInfoList(); + map.addAttribute("infoList",infoList); + } catch (Exception e) { + e.printStackTrace(); + } + return "gamePackInfo"; + } + + /** + * 添加 + * @param request + * @return + * @throws Exception + */ + @RequestMapping(value = "/insertGamePackInfo", method = {RequestMethod.POST, RequestMethod.GET}) + public @ResponseBody + int insertGamePackInfo(HttpServletRequest request) throws Exception { + HashMap map = JsonUtil.getInstence().getParameterMap(request); + // 验证权限 + boolean verifyPower = verifyPower(request, PowersEnum.ADD_PACKAGE_NAME); + if (!verifyPower){ + return 2; + } + + String id = map.get("id"); + String instructions = map.get("instructions"); + String privacy = map.get("privacy"); + + // 添加 + gamePackInfoDao.insertGamePackInfo(new GamePackInfo(id,instructions,privacy)); + return 1; + } + + /** + * 删除 + * @param request + * @return + * @throws Exception + */ + @RequestMapping(value = "/deleteGamePackInfo", method = {RequestMethod.POST, RequestMethod.GET}) + public @ResponseBody + int deleteGamePackInfo(HttpServletRequest request) throws Exception { + HashMap map = JsonUtil.getInstence().getParameterMap(request); + // 验证权限 + boolean verifyPower = verifyPower(request, PowersEnum.DELETE_PACKAGE_NAME); + if (!verifyPower){ + return 2; + } + + // 获取id + String id = Optional.ofNullable(map.get("id")).orElse(""); + GamePackInfo byId = gamePackInfoDao.getGamePackInfoById(id); + if (byId == null){ + return 0; + } + // 删除 + gamePackInfoDao.deleteGamePackInfo(byId); + return 1; + } + + /** + * 验证权限 + * @param request + * @param powersEnum + * @return + */ + private boolean verifyPower(HttpServletRequest request, PowersEnum... powersEnum) throws Exception { + String username = (String) request.getSession().getAttribute("username"); + if (username == null){ + return false; + } + CAdmin admin = cUserDao.findAdmin(username); + if (admin == null){ + return false; + } + for (PowersEnum anEnum : powersEnum) { + if (!admin.getPowers().contains(anEnum.getId())){ + return false; + } + } + return true; + } + +} diff --git a/src/main/java/com/jmfy/dao/GamePackInfoDao.java b/src/main/java/com/jmfy/dao/GamePackInfoDao.java new file mode 100644 index 0000000..f8537ec --- /dev/null +++ b/src/main/java/com/jmfy/dao/GamePackInfoDao.java @@ -0,0 +1,42 @@ +package com.jmfy.dao; + +/** + * @Author hj + * @Description //TODO $ + **/ + +import com.jmfy.model.GamePackInfo; + +import java.util.List; + +public interface GamePackInfoDao { + + /** + * 获取全部 + * @return + * @throws Exception + */ + List getGamePackInfoList() throws Exception; + + /** + * 单个查询,id + * @param id + * @return + * @throws Exception + */ + GamePackInfo getGamePackInfoById(String id) throws Exception; + + /** + * 添加 + * @param gamePackInfo + */ + void insertGamePackInfo(GamePackInfo gamePackInfo) throws Exception; + + /** + * 删除 + * @param gamePackInfo + * @throws Exception + */ + void deleteGamePackInfo(GamePackInfo gamePackInfo) throws Exception; + +} diff --git a/src/main/java/com/jmfy/dao/impl/GamePackInfoDaoImpl.java b/src/main/java/com/jmfy/dao/impl/GamePackInfoDaoImpl.java new file mode 100644 index 0000000..e4ebe9e --- /dev/null +++ b/src/main/java/com/jmfy/dao/impl/GamePackInfoDaoImpl.java @@ -0,0 +1,50 @@ +package com.jmfy.dao.impl; + +/** + * @Author hj + * @Description // 游戏登陆界面 协议管理 + **/ +import com.jmfy.dao.GamePackInfoDao; +import com.jmfy.model.Constant; +import com.jmfy.model.GamePackInfo; +import com.jmfy.utils.Connect; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.List; + +@Component +public class GamePackInfoDaoImpl implements GamePackInfoDao { + + @Resource + private Connect connect; + + @Override + public List getGamePackInfoList() throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + Query query = new Query(); + return mongoTemplate.find(query, GamePackInfo.class); + } + + @Override + public GamePackInfo getGamePackInfoById(String id) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + Query query = new Query(Criteria.where("_id").is(id)); + return mongoTemplate.findOne(query, GamePackInfo.class); + } + + @Override + public void insertGamePackInfo(GamePackInfo gamePackInfo) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + mongoTemplate.insert(gamePackInfo); + } + + @Override + public void deleteGamePackInfo(GamePackInfo gamePackInfo) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + mongoTemplate.remove(gamePackInfo); + } +} diff --git a/src/main/java/com/jmfy/model/GamePackInfo.java b/src/main/java/com/jmfy/model/GamePackInfo.java new file mode 100644 index 0000000..ac9ba8b --- /dev/null +++ b/src/main/java/com/jmfy/model/GamePackInfo.java @@ -0,0 +1,61 @@ +package com.jmfy.model; + +import org.springframework.data.annotation.Id; +import org.springframework.data.mongodb.core.index.Indexed; +import org.springframework.data.mongodb.core.mapping.Document; +import org.springframework.data.mongodb.core.mapping.Field; + +/** + * + * @author Administrator + * @date 2015/8/13 + */ + +@Document(collection = "game_pack_info") +public class GamePackInfo { + @Id + private String id; + + @Field("instructions") + private String instructions; + + @Field("privacy") + private String privacy; + + public GamePackInfo(String id, String instructions, String privacy) { + this.id = id; + this.instructions = instructions; + this.privacy = privacy; + } + + public GamePackInfo(String id) { + this.id = id; + } + + public GamePackInfo() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getInstructions() { + return instructions; + } + + public void setInstructions(String instructions) { + this.instructions = instructions; + } + + public String getPrivacy() { + return privacy; + } + + public void setPrivacy(String privacy) { + this.privacy = privacy; + } +} diff --git a/src/main/java/com/jmfy/model/vo/PowersEnum.java b/src/main/java/com/jmfy/model/vo/PowersEnum.java index edbe884..72e41c9 100644 --- a/src/main/java/com/jmfy/model/vo/PowersEnum.java +++ b/src/main/java/com/jmfy/model/vo/PowersEnum.java @@ -44,6 +44,9 @@ public enum PowersEnum { CHANNEL_NAME_MANAGER(415,"渠道管理",400), ADD_CHANNEL_PERMISSIONS(416,"权限: 添加渠道",400), DELETE_CHANNEL_PERMISSIONS(417,"权限: 删除渠道",400), + GAME_PACK_MANAGER(418,"游戏包管理",400), + ADD_GAME_PACK_PERMISSIONS(419,"权限: 添加游戏包",400), + DELETE_GAME_PACK_PERMISSIONS(420,"权限: 删除游戏包",400), // 流水日志管理500-599 BILL_LOG(500,"流水日志管理",500), diff --git a/src/main/resources/templates/gamePackInfo.html b/src/main/resources/templates/gamePackInfo.html new file mode 100644 index 0000000..4bed8cc --- /dev/null +++ b/src/main/resources/templates/gamePackInfo.html @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + 频道管理 + + + +
+

游戏包管理

+
+ + +
+
+
+
角色ID角色账号角色名字礼包名称玩家区服账号ID角色名礼包名 使用时间
+ + + + + + + + + + + + + + + + +
包名使用说明隐私协议
+ +
+
+
+
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 8345432..87f6729 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -134,8 +134,10 @@ href="javascript:;">频道管理
  • 公会列表管理
  • -
  • 渠道管理
  • +
  • 游戏包管理
  • From 7aeeaceb56e2078c6babfdaa1799368e9854ba9c Mon Sep 17 00:00:00 2001 From: duhui Date: Tue, 22 Jun 2021 15:46:16 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E7=AE=A1=E7=90=86,=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ller.java => GameAgreementController.java} | 66 +++++--- .../java/com/jmfy/dao/GameAgreementDao.java | 48 ++++++ .../java/com/jmfy/dao/GamePackInfoDao.java | 42 ----- .../jmfy/dao/impl/GameAgreementDaoImpl.java | 61 ++++++++ .../jmfy/dao/impl/GamePackInfoDaoImpl.java | 50 ------ .../{GamePackInfo.java => GameAgreement.java} | 10 +- .../java/com/jmfy/model/vo/PowersEnum.java | 7 +- .../resources/templates/addGsAccount.html | 2 +- .../{gamePackInfo.html => gameAgreement.html} | 50 ++---- src/main/resources/templates/index.html | 4 +- .../templates/updateGameAgreement.html | 146 ++++++++++++++++++ 11 files changed, 326 insertions(+), 160 deletions(-) rename src/main/java/com/jmfy/controller/{GamePackInfoController.java => GameAgreementController.java} (55%) create mode 100644 src/main/java/com/jmfy/dao/GameAgreementDao.java delete mode 100644 src/main/java/com/jmfy/dao/GamePackInfoDao.java create mode 100644 src/main/java/com/jmfy/dao/impl/GameAgreementDaoImpl.java delete mode 100644 src/main/java/com/jmfy/dao/impl/GamePackInfoDaoImpl.java rename src/main/java/com/jmfy/model/{GamePackInfo.java => GameAgreement.java} (83%) rename src/main/resources/templates/{gamePackInfo.html => gameAgreement.html} (76%) create mode 100644 src/main/resources/templates/updateGameAgreement.html diff --git a/src/main/java/com/jmfy/controller/GamePackInfoController.java b/src/main/java/com/jmfy/controller/GameAgreementController.java similarity index 55% rename from src/main/java/com/jmfy/controller/GamePackInfoController.java rename to src/main/java/com/jmfy/controller/GameAgreementController.java index 6ffee20..501124b 100644 --- a/src/main/java/com/jmfy/controller/GamePackInfoController.java +++ b/src/main/java/com/jmfy/controller/GameAgreementController.java @@ -1,21 +1,23 @@ package com.jmfy.controller; import com.jmfy.dao.CUserDao; -import com.jmfy.dao.GamePackInfoDao; +import com.jmfy.dao.GameAgreementDao; import com.jmfy.model.CAdmin; -import com.jmfy.model.GamePackInfo; +import com.jmfy.model.GameAgreement; import com.jmfy.model.vo.PowersEnum; import com.jmfy.utils.JsonUtil; import com.jmfy.utils.SeqUtils; +import com.sun.javaws.exceptions.ErrorCodeResponseException; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.Arrays; +import javax.swing.text.html.Option; import java.util.HashMap; import java.util.List; import java.util.Optional; @@ -26,10 +28,10 @@ import java.util.Optional; **/ @SuppressWarnings("ALL") @Controller -public class GamePackInfoController { +public class GameAgreementController { @Resource - private GamePackInfoDao gamePackInfoDao; + private GameAgreementDao agreementDao; @Resource private CUserDao cUserDao; @Resource @@ -40,15 +42,36 @@ public class GamePackInfoController { * @param map * @return */ - @RequestMapping(value = "/gamePackInfoList", method = {RequestMethod.POST, RequestMethod.GET}) - public String getGamePackInfoList(ModelMap map){ + @RequestMapping(value = "/gameAgreementList", method = {RequestMethod.POST, RequestMethod.GET}) + public String getGameAgreementList(ModelMap map){ try { - List infoList = gamePackInfoDao.getGamePackInfoList(); + List infoList = agreementDao.getGameAgreementList(); map.addAttribute("infoList",infoList); } catch (Exception e) { e.printStackTrace(); } - return "gamePackInfo"; + return "gameAgreement"; + } + + /** + * 跳转到新增或修改界面 + * @param map + * @param id + * @param request + * @return + * @throws Exception + */ + @RequestMapping(value = "/gameAgreementToUpdate", method = {RequestMethod.POST, RequestMethod.GET}) + public String gameAgreementToUpdate(ModelMap map, String id, HttpServletRequest request) throws Exception { + // 验证权限 + boolean verifyPower = verifyPower(request, PowersEnum.ADD_GAME_AGREEMENT_PERMISSIONS); + if (!verifyPower){ + throw new Exception("not permissions..."); + } + + GameAgreement agreement = Optional.ofNullable(agreementDao.getGameAgreementById(id)).orElse(new GameAgreement()); + map.addAttribute("agreement",agreement); + return "updateGameAgreement"; } /** @@ -57,9 +80,9 @@ public class GamePackInfoController { * @return * @throws Exception */ - @RequestMapping(value = "/insertGamePackInfo", method = {RequestMethod.POST, RequestMethod.GET}) + @RequestMapping(value = "/updateGameAgreement", method = {RequestMethod.POST, RequestMethod.GET}) public @ResponseBody - int insertGamePackInfo(HttpServletRequest request) throws Exception { + int updateGameAgreement(@RequestBody GameAgreement agreement, HttpServletRequest request) throws Exception { HashMap map = JsonUtil.getInstence().getParameterMap(request); // 验证权限 boolean verifyPower = verifyPower(request, PowersEnum.ADD_PACKAGE_NAME); @@ -67,12 +90,12 @@ public class GamePackInfoController { return 2; } - String id = map.get("id"); - String instructions = map.get("instructions"); - String privacy = map.get("privacy"); - - // 添加 - gamePackInfoDao.insertGamePackInfo(new GamePackInfo(id,instructions,privacy)); + GameAgreement gameAgreement = agreementDao.getGameAgreementById(agreement.getId()); + if (gameAgreement == null){ + agreementDao.insert(agreement); + }else { + agreementDao.update(agreement); + } return 1; } @@ -82,24 +105,23 @@ public class GamePackInfoController { * @return * @throws Exception */ - @RequestMapping(value = "/deleteGamePackInfo", method = {RequestMethod.POST, RequestMethod.GET}) + @RequestMapping(value = "/deleteGameAgreement", method = {RequestMethod.POST, RequestMethod.GET}) public @ResponseBody - int deleteGamePackInfo(HttpServletRequest request) throws Exception { + int deleteGameAgreement(HttpServletRequest request) throws Exception { HashMap map = JsonUtil.getInstence().getParameterMap(request); // 验证权限 boolean verifyPower = verifyPower(request, PowersEnum.DELETE_PACKAGE_NAME); if (!verifyPower){ return 2; } - // 获取id String id = Optional.ofNullable(map.get("id")).orElse(""); - GamePackInfo byId = gamePackInfoDao.getGamePackInfoById(id); + GameAgreement byId = agreementDao.getGameAgreementById(id); if (byId == null){ return 0; } // 删除 - gamePackInfoDao.deleteGamePackInfo(byId); + agreementDao.delete(byId); return 1; } diff --git a/src/main/java/com/jmfy/dao/GameAgreementDao.java b/src/main/java/com/jmfy/dao/GameAgreementDao.java new file mode 100644 index 0000000..c682201 --- /dev/null +++ b/src/main/java/com/jmfy/dao/GameAgreementDao.java @@ -0,0 +1,48 @@ +package com.jmfy.dao; + +/** + * @Author hj + * @Description //TODO $ + **/ + +import com.jmfy.model.GameAgreement; + +import java.util.List; + +public interface GameAgreementDao { + + /** + * 获取全部 + * @return + * @throws Exception + */ + List getGameAgreementList() throws Exception; + + /** + * 单个查询,id + * @param id + * @return + * @throws Exception + */ + GameAgreement getGameAgreementById(String id) throws Exception; + + /** + * 添加 + * @param gameAgreement + */ + void insert(GameAgreement gameAgreement) throws Exception; + + /** + * 修改 + * @param gameAgreement + */ + void update(GameAgreement gameAgreement) throws Exception; + + /** + * 删除 + * @param gameAgreement + * @throws Exception + */ + void delete(GameAgreement gameAgreement) throws Exception; + +} diff --git a/src/main/java/com/jmfy/dao/GamePackInfoDao.java b/src/main/java/com/jmfy/dao/GamePackInfoDao.java deleted file mode 100644 index f8537ec..0000000 --- a/src/main/java/com/jmfy/dao/GamePackInfoDao.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.jmfy.dao; - -/** - * @Author hj - * @Description //TODO $ - **/ - -import com.jmfy.model.GamePackInfo; - -import java.util.List; - -public interface GamePackInfoDao { - - /** - * 获取全部 - * @return - * @throws Exception - */ - List getGamePackInfoList() throws Exception; - - /** - * 单个查询,id - * @param id - * @return - * @throws Exception - */ - GamePackInfo getGamePackInfoById(String id) throws Exception; - - /** - * 添加 - * @param gamePackInfo - */ - void insertGamePackInfo(GamePackInfo gamePackInfo) throws Exception; - - /** - * 删除 - * @param gamePackInfo - * @throws Exception - */ - void deleteGamePackInfo(GamePackInfo gamePackInfo) throws Exception; - -} diff --git a/src/main/java/com/jmfy/dao/impl/GameAgreementDaoImpl.java b/src/main/java/com/jmfy/dao/impl/GameAgreementDaoImpl.java new file mode 100644 index 0000000..fe810b5 --- /dev/null +++ b/src/main/java/com/jmfy/dao/impl/GameAgreementDaoImpl.java @@ -0,0 +1,61 @@ +package com.jmfy.dao.impl; + +/** + * @Author hj + * @Description // 游戏登陆界面 协议管理 + **/ +import com.jmfy.dao.GameAgreementDao; +import com.jmfy.model.Constant; +import com.jmfy.model.GameAgreement; +import com.jmfy.utils.Connect; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.data.mongodb.core.query.Update; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.List; + +@Component +public class GameAgreementDaoImpl implements GameAgreementDao { + + @Resource + private Connect connect; + + @Override + public List getGameAgreementList() throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + Query query = new Query(); + return mongoTemplate.find(query, GameAgreement.class); + } + + @Override + public GameAgreement getGameAgreementById(String id) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + Query query = new Query(Criteria.where("_id").is(id)); + return mongoTemplate.findOne(query, GameAgreement.class); + } + + @Override + public void insert(GameAgreement gameAgreement) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + mongoTemplate.insert(gameAgreement); + } + + @Override + public void update(GameAgreement gameAgreement) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + Query query = new Query(Criteria.where("_id").is(gameAgreement.getId())); + Update update = new Update(); + update.set("instructions",gameAgreement.getInstructions()); + update.set("privacy",gameAgreement.getPrivacy()); + mongoTemplate.upsert(query,update,GameAgreement.class); + } + + @Override + public void delete(GameAgreement gameAgreement) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + mongoTemplate.remove(gameAgreement); + } +} diff --git a/src/main/java/com/jmfy/dao/impl/GamePackInfoDaoImpl.java b/src/main/java/com/jmfy/dao/impl/GamePackInfoDaoImpl.java deleted file mode 100644 index e4ebe9e..0000000 --- a/src/main/java/com/jmfy/dao/impl/GamePackInfoDaoImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.jmfy.dao.impl; - -/** - * @Author hj - * @Description // 游戏登陆界面 协议管理 - **/ -import com.jmfy.dao.GamePackInfoDao; -import com.jmfy.model.Constant; -import com.jmfy.model.GamePackInfo; -import com.jmfy.utils.Connect; -import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.data.mongodb.core.query.Criteria; -import org.springframework.data.mongodb.core.query.Query; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -@Component -public class GamePackInfoDaoImpl implements GamePackInfoDao { - - @Resource - private Connect connect; - - @Override - public List getGamePackInfoList() throws Exception { - MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); - Query query = new Query(); - return mongoTemplate.find(query, GamePackInfo.class); - } - - @Override - public GamePackInfo getGamePackInfoById(String id) throws Exception { - MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); - Query query = new Query(Criteria.where("_id").is(id)); - return mongoTemplate.findOne(query, GamePackInfo.class); - } - - @Override - public void insertGamePackInfo(GamePackInfo gamePackInfo) throws Exception { - MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); - mongoTemplate.insert(gamePackInfo); - } - - @Override - public void deleteGamePackInfo(GamePackInfo gamePackInfo) throws Exception { - MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); - mongoTemplate.remove(gamePackInfo); - } -} diff --git a/src/main/java/com/jmfy/model/GamePackInfo.java b/src/main/java/com/jmfy/model/GameAgreement.java similarity index 83% rename from src/main/java/com/jmfy/model/GamePackInfo.java rename to src/main/java/com/jmfy/model/GameAgreement.java index ac9ba8b..24116ba 100644 --- a/src/main/java/com/jmfy/model/GamePackInfo.java +++ b/src/main/java/com/jmfy/model/GameAgreement.java @@ -11,8 +11,8 @@ import org.springframework.data.mongodb.core.mapping.Field; * @date 2015/8/13 */ -@Document(collection = "game_pack_info") -public class GamePackInfo { +@Document(collection = "game_agreement") +public class GameAgreement { @Id private String id; @@ -22,17 +22,17 @@ public class GamePackInfo { @Field("privacy") private String privacy; - public GamePackInfo(String id, String instructions, String privacy) { + public GameAgreement(String id, String instructions, String privacy) { this.id = id; this.instructions = instructions; this.privacy = privacy; } - public GamePackInfo(String id) { + public GameAgreement(String id) { this.id = id; } - public GamePackInfo() { + public GameAgreement() { } public String getId() { diff --git a/src/main/java/com/jmfy/model/vo/PowersEnum.java b/src/main/java/com/jmfy/model/vo/PowersEnum.java index 72e41c9..af34fb1 100644 --- a/src/main/java/com/jmfy/model/vo/PowersEnum.java +++ b/src/main/java/com/jmfy/model/vo/PowersEnum.java @@ -44,9 +44,8 @@ public enum PowersEnum { CHANNEL_NAME_MANAGER(415,"渠道管理",400), ADD_CHANNEL_PERMISSIONS(416,"权限: 添加渠道",400), DELETE_CHANNEL_PERMISSIONS(417,"权限: 删除渠道",400), - GAME_PACK_MANAGER(418,"游戏包管理",400), - ADD_GAME_PACK_PERMISSIONS(419,"权限: 添加游戏包",400), - DELETE_GAME_PACK_PERMISSIONS(420,"权限: 删除游戏包",400), + GAME_AGREEMENT_MANAGER(418,"游戏协议管理",400), + ADD_GAME_AGREEMENT_PERMISSIONS(419,"权限: 操作游戏协议(增,删,改)",400), // 流水日志管理500-599 BILL_LOG(500,"流水日志管理",500), @@ -88,6 +87,8 @@ public enum PowersEnum { SUPPORT_PLAN_SELECT(1104,"扶持进度查看",1100), PASS_SUPPORT_PERMISSIONS(1105,"权限: 通过扶持权限",1100), DELETE_SUPPORT_ACCOUNT_PERMISSIONS(1106,"权限: 删除扶持账号",1100), + + ; private int id; diff --git a/src/main/resources/templates/addGsAccount.html b/src/main/resources/templates/addGsAccount.html index cd5922b..72f2313 100644 --- a/src/main/resources/templates/addGsAccount.html +++ b/src/main/resources/templates/addGsAccount.html @@ -1,6 +1,6 @@  - + diff --git a/src/main/resources/templates/gamePackInfo.html b/src/main/resources/templates/gameAgreement.html similarity index 76% rename from src/main/resources/templates/gamePackInfo.html rename to src/main/resources/templates/gameAgreement.html index 4bed8cc..659336d 100644 --- a/src/main/resources/templates/gamePackInfo.html +++ b/src/main/resources/templates/gameAgreement.html @@ -18,7 +18,7 @@ - 频道管理 + 游戏包管理