游戏协议管理,完成

master
duhui 2021-06-22 15:46:16 +08:00
parent 63e5b1d55b
commit 7aeeaceb56
11 changed files with 326 additions and 160 deletions

View File

@ -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<GamePackInfo> infoList = gamePackInfoDao.getGamePackInfoList();
List<GameAgreement> 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<String, String> 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<String, String> 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;
}

View File

@ -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<GameAgreement> 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;
}

View File

@ -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<GamePackInfo> 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;
}

View File

@ -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<GameAgreement> 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);
}
}

View File

@ -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<GamePackInfo> 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);
}
}

View File

@ -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() {

View File

@ -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;

View File

@ -1,6 +1,6 @@
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8"/>
<meta name="renderer" content="webkit|ie-comp|ie-stand"/>

View File

@ -18,7 +18,7 @@
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
<script>DD_belatedPNG.fix('*');</script>
<title>频道管理</title>
<title>游戏包管理</title>
</head>
<body>
<nav class="breadcrumb">
@ -31,9 +31,9 @@
<div class="page-container" style="text-align: center">
<h2><span style="color:red;">游戏包管理</span></h2>
<div style="text-align: left">
<input type="text" name="packageName" id="packageName" placeholder="多个包名用#号分割" value="" class="input-text"
style="width: 300px;"/>
<button class="btn btn-primary" type="button" id="batch" onclick="addGP()">添加游戏包</button>
<button class="btn btn-primary" type="button" id="batch" onclick="updates()">
<i class="Hui-iconfont">&#xe600;</i>新增
</button>
</div>
<div class="text-c">
<div class="mt-20">
@ -49,11 +49,14 @@
<tr th:each="obj:${infoList}">
<!--<td><input type="checkbox" value="" name=""/></td>-->
<td th:text="${obj.id}" style="text-align: center;"></td>
<td th:text="${obj.id}" style="text-align: center;"></td>
<td th:text="${obj.id}" style="text-align: center;"></td>
<td th:text="${obj.instructions}" style="text-align: center;"></td>
<td th:text="${obj.privacy}" style="text-align: center;"></td>
<td style="text-align: center; width: 300px">
<button type="button" th:id="${obj.id}" class="btn btn-primary"
onclick="return deleteGP(this)"><i class="Hui-iconfont"></i> 删除
onclick="return updates(this)"><i class="Hui-iconfont"></i> 编辑
</button>
<button type="button" th:id="${obj.id}" class="btn btn-primary"
onclick="return deletes(this)"><i class="Hui-iconfont"></i> 删除
</button>
</td>
</tr>
@ -84,43 +87,20 @@
});
// 添加
function addGP() {
var name = $("#packageName").val();
if (name === null || name === "") {
alert("添加数据不能为空");
return;
}
$.ajax({
type: "POST",
data: {
"name": name
},
url: "/insertPackageInfo",
success: function (data) {
if (data === 1) {
layer.msg('操作成功!', {icon: 6, time: 1000});
window.location.reload();
}
if (data === 0) {
layer.msg('操作失败,包名已存在', {icon: 6, time: 1000});
}
if (data === 2) {
layer.msg('没有权限', {icon: 6, time: 1000});
}
}
})
function updates(obj) {
var id = $(obj).attr("id");
window.location.href = "/gameAgreementToUpdate?id=" + id;
}
// 单个审核
function deleteGP(obj) {
function deletes(obj) {
var id = $(obj).attr("id");
$.ajax({
type: "POST",
data: {
"id": id
},
url: "/deletePackageInfo",
url: "/deleteGameAgreement",
success: function (data) {
if (data === 1) {
layer.msg('操作成功!', {icon: 6, time: 1000});

View File

@ -136,8 +136,8 @@
href="javascript:;">公会列表管理</a></li>
<li th:if="${#lists.contains(pos.powers,415)} "><a data-href="channelInfoList" data-title="渠道管理"
href="javascript:;">渠道管理</a></li>
<li th:if="${#lists.contains(pos.powers,418)} "><a data-href="gamePackInfoList" data-title="游戏包管理"
href="javascript:;">游戏管理</a></li>
<li th:if="${#lists.contains(pos.powers,418)} "><a data-href="gameAgreementList" data-title="游戏协议管理"
href="javascript:;">游戏协议管理</a></li>
</ul>
</dd>
</dl>

View File

@ -0,0 +1,146 @@
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8"/>
<meta name="renderer" content="webkit|ie-comp|ie-stand"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="../favicon.ico" />
<link rel="Shortcut Icon" href="../favicon.ico" />
<!--[if lt IE 9] -->
<script type="text/javascript" src="../static/lib/html5shiv.js"></script>
<script type="text/javascript" src="../static/lib/respond.min.js"></script>
<link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="../static/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
<link href="../static/searchableSelect/css/jquery.searchableSelect.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../static/lib/DD_belatedPNG_0.0.8a-min.js"></script>
<script>DD_belatedPNG.fix('*');</script>
<title>基本设置</title>
</head>
<body>
<nav class="breadcrumb">
<a href="javascript:;" onclick="history.go(-1)">
<i class="Hui-iconfont">&#xe67f;</i> 首页
</a>
<span class="c-gray en">&gt;</span> 扶持功能
<span class="c-gray en">&gt;</span> 添加游戏内协议
<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
<form class="form form-horizontal" id="form-article-add" action="/register" method="post"target="sendNotice">
<div id="tab-system" class="HuiTab">
<div class="tabBar cl">
<span>添加游戏内协议</span>
</div>
<div class="tabCon">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span> 包名:
</label>
<div class="formControls col-xs-8 col-sm-9">
<label>
<input type="text" name="agreementId" placeholder="不能为空" th:value="${agreement.id}" class="input-text"/>
</label>
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span> 使用说明:
</label>
<div class="formControls col-xs-8 col-sm-9">
<label>
<input type="text" name="instructions" placeholder="可以为空" th:value="${agreement.instructions}" class="input-text"/>
</label>
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span> 隐私条款:
</label>
<div class="formControls col-xs-8 col-sm-9">
<label>
<input type="text" name="privacy" placeholder="可以为空" th:value="${agreement.privacy}" class="input-text"/>
</label>
</div>
</div>
</div>
<div class="tabCon">
</div>
</div>
<div class="row cl" style="text-align: center" >
<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
<button class="btn btn-primary radius" type="button" onclick="adds()" ><i class="Hui-iconfont">&#xe632;</i> 保存</button>
</div>
</div>
</form>
<iframe name='sendNotice' id="hidden_frame" style='display: none'></iframe>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../static/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="../static/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="../static/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="../static/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="../static/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
$(function () {
$('.skin-minimal input').iCheck({
checkboxClass: 'icheckbox-blue',
radioClass: 'iradio-blue',
increaseArea: '20%'
});
$("#tab-system").Huitab({
index: 0
});
// 模糊搜素
$('#InputsWrapper select').searchableSelect();
});
function adds() {
var id = $("input[name='agreementId']").val();
if (id === '' || id == null) {
alert("包名不能为空!!!");
return;
}
var instructions = $("input[name='instructions']").val();
var privacy = $("input[name='privacy']").val();
$.ajax({
type: "POST",
data:
JSON.stringify({
"id": id,
"instructions": instructions,
"privacy": privacy
}),
dataType: "json",
contentType:'application/json',
url: "/updateGameAgreement",
success: function (data) {
if (data === 1) {
layer.msg('成功!', {icon: 6, time: 1000});
window.location.href = '/gameAgreementList'
}
if (data === 0) {
layer.msg('失败!', {icon: 6, time: 1000});
}
}
})
}
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>