封禁功能和礼包

master
xuexinpeng 2021-08-06 15:01:48 +08:00
parent 8e46135e25
commit e33a6fc875
4 changed files with 152 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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