From 7aeeaceb56e2078c6babfdaa1799368e9854ba9c Mon Sep 17 00:00:00 2001 From: duhui Date: Tue, 22 Jun 2021 15:46:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=8D=8F=E8=AE=AE=E7=AE=A1?= =?UTF-8?q?=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 @@ - 频道管理 + 游戏包管理