generated from root/miduo_server
封禁功能和礼包
parent
8e46135e25
commit
e33a6fc875
|
|
@ -1,6 +1,7 @@
|
|||
package com.jmfy.controller;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jmfy.dao.BanFuctionDao;
|
||||
import com.jmfy.dao.ServerInfoDao;
|
||||
import com.jmfy.dao.UserInfoDao;
|
||||
import com.jmfy.model.*;
|
||||
|
|
@ -34,6 +35,8 @@ public class GmController {
|
|||
private ServerInfoDao serverInfoDao;
|
||||
@Resource
|
||||
private UserInfoDao userInfoDao;
|
||||
@Resource
|
||||
private BanFuctionDao banFuctionDao;
|
||||
@RequestMapping(value = "/sendGm", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public @ResponseBody
|
||||
int publishNotice(HttpServletRequest request) throws Exception {
|
||||
|
|
@ -248,6 +251,54 @@ public class GmController {
|
|||
// in.close();
|
||||
// out.close();
|
||||
// }
|
||||
@RequestMapping(value = "/banFunction", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public @ResponseBody int banFunction(HttpServletRequest request) throws Exception{
|
||||
String function = request.getParameter("function");// protocal/good
|
||||
String action = request.getParameter("action");// ban/opend
|
||||
String id = request.getParameter("id");// id
|
||||
|
||||
|
||||
ServerBanPro banDao = banFuctionDao.findUserInfo();
|
||||
if(banDao == null ){
|
||||
ServerBanPro serverBanPro = new ServerBanPro();
|
||||
//serverBanPro.setId(1);
|
||||
serverBanPro.setBanProtoId(new ArrayList<Integer>(Arrays.asList(1,2)));
|
||||
serverBanPro.setBanGoodList(new ArrayList<>());
|
||||
banFuctionDao.addServerBanPro(serverBanPro);
|
||||
banDao = serverBanPro;
|
||||
}
|
||||
switch (function){
|
||||
case "protocal":
|
||||
if(action.equals("ban")){
|
||||
if(!banDao.getBanProtoId().contains(Integer.valueOf(id))){
|
||||
banDao.getBanProtoId().add(Integer.valueOf(id));
|
||||
banFuctionDao.updateServerBanPro(banDao);
|
||||
}
|
||||
}else if(action.equals("open")){
|
||||
if(banDao.getBanProtoId().contains(Integer.valueOf(id))){
|
||||
banDao.getBanProtoId().remove(Integer.valueOf(id));
|
||||
banFuctionDao.updateServerBanPro(banDao);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "good":
|
||||
if(action.equals("ban")){
|
||||
if(!banDao.getBanGoodList().contains(Integer.valueOf(id))){
|
||||
banDao.getBanGoodList().add(Integer.valueOf(id));
|
||||
banFuctionDao.updateServerBanPro(banDao);
|
||||
}
|
||||
}else if(action.equals("open")){
|
||||
if(banDao.getBanGoodList().contains(Integer.valueOf(id))){
|
||||
banDao.getBanGoodList().remove(Integer.valueOf(id));
|
||||
banFuctionDao.updateServerBanPro(banDao);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public static void main(String[] args) throws IOException {
|
||||
String osName = System.getProperty("os.name");
|
||||
String filePath = "";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package com.jmfy.dao;
|
||||
|
||||
import com.jmfy.model.ServerBanPro;
|
||||
|
||||
public interface BanFuctionDao {
|
||||
ServerBanPro findUserInfo() throws Exception;
|
||||
|
||||
void updateServerBanPro(ServerBanPro serverBanPro) throws Exception;
|
||||
|
||||
void addServerBanPro(ServerBanPro serverBanPro) throws Exception;
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.jmfy.dao.impl;
|
||||
|
||||
import com.jmfy.dao.BanFuctionDao;
|
||||
import com.jmfy.model.BlackList;
|
||||
import com.jmfy.model.CAdmin;
|
||||
import com.jmfy.model.Constant;
|
||||
import com.jmfy.model.ServerBanPro;
|
||||
import com.jmfy.utils.Connect;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
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 BanFunctionImpl implements BanFuctionDao {
|
||||
@Resource
|
||||
private Connect connect ;
|
||||
String dbName = Constant.dbName;
|
||||
@Override
|
||||
public ServerBanPro findUserInfo() throws Exception {
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
List<ServerBanPro> list = mongoTemplate.findAll(ServerBanPro.class);
|
||||
if(list.size()>0){
|
||||
return list.get(0) ;
|
||||
}
|
||||
return null ;
|
||||
}
|
||||
@Override
|
||||
public void addServerBanPro(ServerBanPro serverBanPro) throws Exception{
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
mongoTemplate.insert(serverBanPro);
|
||||
}
|
||||
@Override
|
||||
public void updateServerBanPro(ServerBanPro serverBanPro) throws Exception{
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query();
|
||||
Update update = new Update();
|
||||
update.set("banProtoId",serverBanPro.getBanProtoId());
|
||||
mongoTemplate.updateFirst(query,update,ServerBanPro.class);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Document(collection = "server_ban_function")
|
||||
public class ServerBanPro {
|
||||
|
||||
@Id
|
||||
private int id;
|
||||
|
||||
@Field(value = "banProtoId")
|
||||
private List<Integer> banProtoId ;
|
||||
|
||||
@Field(value = "banGoodList")
|
||||
private List<Integer> banGoodList ;
|
||||
|
||||
public List<Integer> getBanProtoId() {
|
||||
return banProtoId;
|
||||
}
|
||||
|
||||
public void setBanProtoId(List<Integer> banProtoId) {
|
||||
this.banProtoId = banProtoId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<Integer> getBanGoodList() {
|
||||
return banGoodList;
|
||||
}
|
||||
|
||||
public void setBanGoodList(List<Integer> banGoodList) {
|
||||
this.banGoodList = banGoodList;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue