generated from root/miduo_server
白名单
parent
952f1b85f9
commit
cb3ba613c9
|
|
@ -11,6 +11,7 @@ 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;
|
||||
|
|
@ -119,4 +120,39 @@ public class UserInfoController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/addWhiteList", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public @ResponseBody
|
||||
int addWhiteList(HttpSession session, HttpServletRequest request) throws Exception {
|
||||
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
|
||||
String userIds = parameterMap.get("userIds");
|
||||
int type = Integer.parseInt(parameterMap.get("type"));
|
||||
String[] split = userIds.split("#");
|
||||
for (String uid : split){
|
||||
CUserInfo cUserInfo = userInfoDao.findUserInfoByUserId(Integer.parseInt(uid));
|
||||
if (cUserInfo == null){
|
||||
System.out.println("addWhiteList== uid={},cUserInfo is null"+uid);
|
||||
continue;
|
||||
}
|
||||
if (type == 0){
|
||||
WhiteList whiteList = userInfoDao.findWhiteListInfo(cUserInfo.getOpenId());
|
||||
if (whiteList != null){
|
||||
continue;
|
||||
}
|
||||
whiteList = new WhiteList();
|
||||
whiteList.setWhite_openid(cUserInfo.getOpenId());
|
||||
whiteList.setServerid(0);
|
||||
userInfoDao.addWhiteList(whiteList);
|
||||
}else{
|
||||
WhiteList whiteList = userInfoDao.findWhiteListInfo(cUserInfo.getOpenId());
|
||||
if (whiteList == null){
|
||||
continue;
|
||||
}
|
||||
userInfoDao.delWhiteList(cUserInfo.getOpenId());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.jmfy.dao;
|
|||
import com.jmfy.model.BlackList;
|
||||
import com.jmfy.model.CUser;
|
||||
import com.jmfy.model.CUserInfo;
|
||||
import com.jmfy.model.WhiteList;
|
||||
import org.springframework.data.mongodb.core.query.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -29,5 +30,9 @@ public interface UserInfoDao {
|
|||
void updateStatus(Update update, CUserInfo cUserInfo) throws Exception;
|
||||
|
||||
CUser findCuserByName(int serverId, String userName) throws Exception;
|
||||
void addWhiteList(WhiteList whiteList) throws Exception;
|
||||
WhiteList findWhiteListInfo(String openId) throws Exception;
|
||||
|
||||
void delWhiteList(String openId) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,4 +123,32 @@ public class UserInfoDaoImpl implements UserInfoDao {
|
|||
return mongoTemplate.findOne(query, CUser.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addWhiteList(WhiteList whiteList) throws Exception {
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
mongoTemplate.insert(whiteList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WhiteList findWhiteListInfo(String openId) throws Exception {
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query();
|
||||
Criteria cr = new Criteria();
|
||||
cr.andOperator(Criteria.where("white_openid").is(openId));
|
||||
query.addCriteria(cr);
|
||||
return mongoTemplate.findOne(query, WhiteList.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delWhiteList(String openId) throws Exception {
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query();
|
||||
Criteria cr = new Criteria();
|
||||
cr.andOperator(Criteria.where("white_openid").is(openId));
|
||||
query.addCriteria(cr);
|
||||
mongoTemplate.remove(query,WhiteList.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
package com.jmfy.model;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
|
||||
/**
|
||||
* Description: des
|
||||
* Author: zsx
|
||||
* CreateDate: 2020/7/28 13:56
|
||||
*/
|
||||
@Document(collection="white_list")
|
||||
public class WhiteList {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
@Field(value = "channel")
|
||||
private String channel;
|
||||
|
||||
@Field(value = "plat")
|
||||
private String plat;
|
||||
|
||||
@Field(value = "white_openid")
|
||||
private String white_openid;
|
||||
|
||||
@Field(value = "serverid")
|
||||
private int serverid;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(String channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public String getPlat() {
|
||||
return plat;
|
||||
}
|
||||
|
||||
public void setPlat(String plat) {
|
||||
this.plat = plat;
|
||||
}
|
||||
|
||||
public String getWhite_openid() {
|
||||
return white_openid;
|
||||
}
|
||||
|
||||
public void setWhite_openid(String white_openid) {
|
||||
this.white_openid = white_openid;
|
||||
}
|
||||
|
||||
public int getServerid() {
|
||||
return serverid;
|
||||
}
|
||||
|
||||
public void setServerid(int serverid) {
|
||||
this.serverid = serverid;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<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" />
|
||||
<!--[if lt IE 9]>
|
||||
<script type="text/javascript" src="../lib/html5shiv.js"></script>
|
||||
<script type="text/javascript" src="../lib/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<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="../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" />
|
||||
<!--[if IE 6]>
|
||||
<script type="text/javascript" src="../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
|
||||
<script>DD_belatedPNG.fix('*');</script>
|
||||
<![endif]-->
|
||||
<title>添加白名单</title>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="breadcrumb"><i class="Hui-iconfont"></i> 首页
|
||||
<span class="c-gray en">></span>
|
||||
GM管理
|
||||
<span class="c-gray en">></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"></i></a>
|
||||
</nav>
|
||||
<div class="page-container" style="text-align: center">
|
||||
<h1><span style="color: red">添加白名单账号</span></h1>
|
||||
<form class="form form-horizontal" id="form-article-add" action="/getAllUserId" method="post"
|
||||
onsubmit="return getUserInfo()">
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-2">
|
||||
<span class="c-red">*</span>
|
||||
用 户 ID:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<input type="text" name="userIds" placeholder="uid#uid#uid...." autocomplete="off" value="" class="input-text"/>
|
||||
<span class="USERID"></span>
|
||||
</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">
|
||||
<select name="type" class="input-text" id="type"><!--下拉列表-->
|
||||
<option value="0" selected = "selected">添加</option>
|
||||
<option value="1" >删除</option>
|
||||
</select>
|
||||
</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="add_white_list();" style="font-size: 15px"><i class="Hui-iconfont"></i>
|
||||
执行
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="../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="../lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
function add_white_list() {
|
||||
var userId = $("input[name='userIds']").val();
|
||||
var erroCode = $('.SERVERID');
|
||||
if (userId === '' || userId == null) {
|
||||
erroCode = $('.USERID');
|
||||
erroCode.html('<span style="color: red; ">用户id不能为空!</span>');
|
||||
return false;
|
||||
}
|
||||
var type = document.getElementById("type").value;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: {
|
||||
"userIds": userId,
|
||||
"type": type
|
||||
},
|
||||
url: "/addWhiteList",
|
||||
success: function (data) {
|
||||
if (data === 0) {
|
||||
layer.msg('操作成功!', {icon: 6, time: 1000});
|
||||
}
|
||||
if (data === 1) {
|
||||
layer.msg('操作失败!', {icon: 6, time: 1000});
|
||||
}
|
||||
$("#load").hide();
|
||||
$("#conf").attr("onclick", "sendNoticeCheck();");
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -107,6 +107,7 @@
|
|||
<li><a data-href="/html/sendSysNotice.html" data-title="发送公告" href="javascript:;">发送公告</a></li>
|
||||
<li><a data-href="/html/sendSysCmd.html" data-title="发送gm" href="javascript:;">发送gm</a></li>
|
||||
<li><a data-href="noticeInfos" data-title="公告信息" href="javascript:void(0)">公告信息</a></li>
|
||||
<li><a data-href="/html/add_white_list.html" data-title="添加白名单账号" href="javascript:;">添加白名单账号</a></li>
|
||||
<!--<li><a data-href="/html/recoverItem.html" data-title="回收道具" href="javascript:;">回收道具</a></li>-->
|
||||
</ul>
|
||||
</dd>
|
||||
|
|
|
|||
Loading…
Reference in New Issue