改数据库
parent
04ebb8ba6f
commit
bf43560c87
|
@ -16,13 +16,13 @@ public abstract class MongoBase {
|
|||
private String rootCollection;
|
||||
|
||||
@Transient
|
||||
private String id;
|
||||
private String rootId;
|
||||
|
||||
@Transient
|
||||
private LjsdMongoTemplate _myMongoTemplate;
|
||||
|
||||
public void init(String id, LjsdMongoTemplate _myMongoTemplate ,String rootCollection ,String mongoKey, boolean _save) {
|
||||
this.id = id;
|
||||
this.rootId = id;
|
||||
this.rootCollection = rootCollection;
|
||||
this._myMongoTemplate = _myMongoTemplate;
|
||||
this.mongoKey = mongoKey;
|
||||
|
@ -30,28 +30,28 @@ public abstract class MongoBase {
|
|||
}
|
||||
|
||||
public void init(String id, LjsdMongoTemplate _myMongoTemplate ,String rootCollection ,String mongoKey) {
|
||||
this.id = id;
|
||||
this.rootId = id;
|
||||
this.rootCollection = rootCollection;
|
||||
this._myMongoTemplate = _myMongoTemplate;
|
||||
this.mongoKey = mongoKey;
|
||||
this._save = true;
|
||||
}
|
||||
|
||||
public void updateString(MongoBase dataBase, String fieldName, Object value) throws Exception {
|
||||
public void updateString(MongoBase dataBase, String fieldName, Object value) {
|
||||
|
||||
MongoUpdateCacheThreadLocal.addUpdateRequest(this, dataBase.get_myMongoTemplate(), dataBase.getRootCollection(), dataBase.getId(),
|
||||
MongoUpdateCacheThreadLocal.addUpdateRequest(this, dataBase.get_myMongoTemplate(), dataBase.getRootCollection(), dataBase.getRootId(),
|
||||
mongoKey + "." + fieldName, value);
|
||||
}
|
||||
|
||||
|
||||
public void updateString(String fieldName, MongoBase value) throws Exception {
|
||||
MongoUpdateCacheThreadLocal.addUpdateRequest(value, value.get_myMongoTemplate(), value.getRootCollection(), value.getId(),
|
||||
public void updateString(String fieldName, MongoBase value) {
|
||||
MongoUpdateCacheThreadLocal.addUpdateRequest(value, value.get_myMongoTemplate(), value.getRootCollection(), value.getRootId(),
|
||||
mongoKey + "." + fieldName, value);
|
||||
}
|
||||
|
||||
|
||||
public void removeString(String key, MongoBase value) {
|
||||
MongoUpdateCacheThreadLocal.removeRequest(this, value.get_myMongoTemplate(), value.getRootCollection(), value.getId(), key);
|
||||
MongoUpdateCacheThreadLocal.removeRequest(this, value.get_myMongoTemplate(), value.getRootCollection(), value.getRootId(), key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,12 +79,12 @@ public abstract class MongoBase {
|
|||
this.rootCollection = rootCollection;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
public String getRootId() {
|
||||
return rootId;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
public void setRootId(String rootId) {
|
||||
this.rootId = rootId;
|
||||
}
|
||||
|
||||
public LjsdMongoTemplate get_myMongoTemplate() {
|
||||
|
|
|
@ -17,7 +17,8 @@ public class BaseInfoForTest extends MongoBase {
|
|||
}
|
||||
|
||||
public void addCard(int cardId,CardTestInfo cardTestInfo) throws Exception {
|
||||
cardTestInfo.init(getRoot(),getMongoKey() + ".cardTestInfoMap." + cardId);
|
||||
cardTestInfo.init(cardTestInfo.getRootId(),cardTestInfo.get_myMongoTemplate(),cardTestInfo.getRootCollection(),
|
||||
getMongoKey() + ".cardTestInfoMap." + cardId);
|
||||
updateString("cardMap." +cardId, cardTestInfo);
|
||||
cardTestInfoMap.put(cardId,cardTestInfo);
|
||||
}
|
||||
|
@ -27,7 +28,7 @@ public class BaseInfoForTest extends MongoBase {
|
|||
}
|
||||
|
||||
public void setName(String name) throws Exception {
|
||||
updateString("name", name);
|
||||
updateString(this,"name", name);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
@ -36,7 +37,7 @@ public class BaseInfoForTest extends MongoBase {
|
|||
}
|
||||
|
||||
public void setAge(int age) throws Exception {
|
||||
updateString("age", name);
|
||||
updateString(this,"age", name);
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
|
@ -45,13 +46,16 @@ public class BaseInfoForTest extends MongoBase {
|
|||
}
|
||||
|
||||
public void setOtherInfoMsg(Map<String, String> otherInfoMsg) throws Exception {
|
||||
updateString("otherInfoMsg", name);
|
||||
updateString(this,"otherInfoMsg", name);
|
||||
this.otherInfoMsg = otherInfoMsg;
|
||||
}
|
||||
|
||||
public void remove(String id){
|
||||
otherInfoMsg.remove(id);
|
||||
removeString("otherInfoMsg." + id);
|
||||
String value = otherInfoMsg.get(id);
|
||||
if (value!=null){
|
||||
otherInfoMsg.remove(id);
|
||||
removeString("otherInfoMsg." + id,this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@ public class CardTestInfo extends MongoBase {
|
|||
|
||||
private String level;
|
||||
|
||||
public void setId(String id) throws Exception {
|
||||
updateString("id",id);
|
||||
public void setId(String id) {
|
||||
updateString(this,"id",id);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setLevel(String level) throws Exception {
|
||||
updateString("level",level);
|
||||
updateString(this,"level",level);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,14 +18,13 @@ public class PlayerForTest extends MongoRoot {
|
|||
public PlayerForTest(int playerId,BaseInfoForTest baseInfoForTest){
|
||||
setId(String.valueOf(playerId));
|
||||
this.baseInfoForTest = baseInfoForTest;
|
||||
baseInfoForTest.init(this,"baseInfoForTest",false);
|
||||
baseInfoForTest.init(String.valueOf(playerId),_ljsdMongoTemplate,_COLLECTION_NAME,"baseInfoForTest",false);
|
||||
}
|
||||
|
||||
public PlayerForTest(){
|
||||
setMyMongoDBPool(_ljsdMongoTemplate);
|
||||
this.baseInfoForTest = new BaseInfoForTest();
|
||||
baseInfoForTest.init(this,"baseInfoForTest",false);
|
||||
}
|
||||
// public PlayerForTest(){
|
||||
// this.baseInfoForTest = new BaseInfoForTest();
|
||||
// baseInfoForTest.init(this,"baseInfoForTest",false);
|
||||
// }
|
||||
|
||||
|
||||
public BaseInfoForTest getBaseInfoForTest() {
|
||||
|
|
|
@ -33,12 +33,12 @@ public class Cell extends MongoBase {
|
|||
}
|
||||
|
||||
public void setPointId(int pointId) throws Exception {
|
||||
updateString("pointId", pointId);
|
||||
updateString(this,"pointId", pointId);
|
||||
this.pointId = pointId;
|
||||
}
|
||||
|
||||
public void setEventId(int eventId) throws Exception {
|
||||
updateString("eventId", eventId);
|
||||
updateString(this,"eventId", eventId);
|
||||
this.eventId = eventId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void updateCrossMapInfos(int key, CrossMapCell crossMapCell) throws Exception {
|
||||
updateString( "mapInfo." + key, crossMapCell);
|
||||
updateString(this, "mapInfo." + key, crossMapCell);
|
||||
crossMapInfos.put(key, crossMapCell);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setCurMapId(int curMapId) throws Exception {
|
||||
updateString("curMapId", curMapId);
|
||||
updateString(this,"curMapId", curMapId);
|
||||
this.curMapId = curMapId;
|
||||
}
|
||||
|
||||
|
@ -57,23 +57,23 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setCurXY(int curXY) throws Exception {
|
||||
updateString("curXY", curXY);
|
||||
updateString(this,"curXY", curXY);
|
||||
this.curXY = curXY;
|
||||
}
|
||||
|
||||
public void addOrUpdateCell(int key, Cell cell) throws Exception {
|
||||
updateString( "mapInfo." + key, cell);
|
||||
updateString(this,"mapInfo." + key, cell);
|
||||
this.mapInfo.put(key, cell);
|
||||
}
|
||||
|
||||
public void setMapInfo(Map<Integer, Cell> mapInfo) throws Exception {
|
||||
updateString( "mapInfo", mapInfo);
|
||||
updateString(this, "mapInfo", mapInfo);
|
||||
this.mapInfo = mapInfo;
|
||||
}
|
||||
|
||||
public void removeAllCell() {
|
||||
removeString("mapInfo");
|
||||
this.mapInfo.clear();
|
||||
// removeString("mapInfo");
|
||||
// this.mapInfo.clear();
|
||||
}
|
||||
|
||||
public Map<Integer, Cell> getTypeEight() {
|
||||
|
@ -81,7 +81,7 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setTypeEight(Map<Integer, Cell> typeEight) throws Exception {
|
||||
updateString( "typeEight", typeEight);
|
||||
updateString(this, "typeEight", typeEight);
|
||||
this.typeEight = typeEight;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setHeroes(Set<String> heroes) throws Exception {
|
||||
updateString( "heroes", heroes);
|
||||
updateString(this, "heroes", heroes);
|
||||
this.heroes = heroes;
|
||||
}
|
||||
|
||||
|
@ -99,12 +99,12 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setWalkCells(Set<Integer> walkCells) throws Exception {
|
||||
updateString( "walkCells", walkCells);
|
||||
updateString(this, "walkCells", walkCells);
|
||||
this.walkCells = walkCells;
|
||||
}
|
||||
|
||||
public void addWalkCells(Set<Integer> walkCells) throws Exception {
|
||||
updateString( "walkCells", walkCells);
|
||||
updateString(this, "walkCells", walkCells);
|
||||
if (this.walkCells == null) {
|
||||
this.walkCells = walkCells;
|
||||
} else {
|
||||
|
@ -117,7 +117,7 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setMaxMapId(int maxMapId) throws Exception {
|
||||
updateString( "maxMapId", maxMapId);
|
||||
updateString(this, "maxMapId", maxMapId);
|
||||
this.maxMapId = maxMapId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class Mission extends MongoBase {
|
|||
}
|
||||
|
||||
public void setMissionInfo(String missionInfo) throws Exception {
|
||||
updateString("missionInfo", missionInfo);
|
||||
updateString(this,"missionInfo", missionInfo);
|
||||
this.missionInfo = missionInfo;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class Mission extends MongoBase {
|
|||
}
|
||||
|
||||
public void updateMapPoints(int pointId, int eventId) throws Exception {
|
||||
updateString("mapPoints." + pointId, eventId);
|
||||
updateString(this,"mapPoints." + pointId, eventId);
|
||||
this.mapPoints.put(pointId, eventId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,21 +29,21 @@ public class MissionManager extends MongoBase {
|
|||
|
||||
public void updateDoingMissions(Map<Integer, Mission> doingMissions) throws Exception {
|
||||
this.doingMissions = doingMissions;
|
||||
updateString( "doingMissions", doingMissions);
|
||||
updateString(this, "doingMissions", doingMissions);
|
||||
}
|
||||
|
||||
public void updateOneDoingMissions(int missionId, Mission mission) throws Exception {
|
||||
this.doingMissions.put(missionId, mission);
|
||||
updateString( "doingMissions." + missionId, mission);
|
||||
updateString(this, "doingMissions." + missionId, mission);
|
||||
}
|
||||
|
||||
public void updateFinishMissions(Set<Integer> finishMissions) throws Exception {
|
||||
this.finishMissions = finishMissions;
|
||||
updateString( "finishMissions", finishMissions);
|
||||
updateString(this, "finishMissions", finishMissions);
|
||||
}
|
||||
|
||||
public void addTakeRewardMissions(int missionId) throws Exception {
|
||||
takeRewardMissions.add(missionId);
|
||||
updateString( "takeRewardMissions", takeRewardMissions);
|
||||
updateString(this, "takeRewardMissions", takeRewardMissions);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public class AutoIncrementManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void addAutoIncrement(AutoIncrement autoIncrement) throws Exception {
|
||||
autoIncrement.init(autoIncrement.getId(), autoIncrement.get_myMongoTemplate(), autoIncrement.getRootCollection(),
|
||||
autoIncrement.init(autoIncrement.getRootId(), autoIncrement.get_myMongoTemplate(), autoIncrement.getRootCollection(),
|
||||
getMongoKey() + ".autoIncrementMap." + autoIncrement.getName());
|
||||
updateString("autoIncrementMap." + autoIncrement.getName(), autoIncrement);
|
||||
autoIncrementMap.put(autoIncrement.getName(),autoIncrement);
|
||||
|
|
|
@ -23,7 +23,7 @@ public class ItemManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void addItem(Item item) throws Exception {
|
||||
item.init(item.getId(),item.get_myMongoTemplate(), item.getRootCollection(), getMongoKey() + ".itemMap." + item.getItemId());
|
||||
item.init(item.getRootId(),item.get_myMongoTemplate(), item.getRootCollection(), getMongoKey() + ".itemMap." + item.getItemId());
|
||||
updateString("itemMap." + item.getItemId(), item);
|
||||
itemMap.put(item.getItemId(), item);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.ljsd.jieling.logic.dao;
|
|||
|
||||
|
||||
import com.ljsd.common.mogodb.LjsdMongoTemplate;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ public class SysMailManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void addSystemMail(SysMail sysMail) throws Exception {
|
||||
sysMail.init(sysMail.getId(),sysMail.get_myMongoTemplate(),sysMail.getRootCollection(), getMongoKey() + ".sysMailMap." + sysMail.getRoleUid());
|
||||
sysMail.init(sysMail.getRootId(),sysMail.get_myMongoTemplate(),sysMail.getRootCollection(), getMongoKey() + ".sysMailMap." + sysMail.getRoleUid());
|
||||
updateString("sysMailMap." + sysMail.getRoleUid(), sysMail);
|
||||
sysMailMap.put(sysMail.getRoleUid(),sysMail);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TeamPosManager extends MongoBase {
|
|||
teamPosHeroInfoList.add(teamPosHeroInfo);
|
||||
}
|
||||
teamPosForHero.put(1,teamPosHeroInfoList);
|
||||
updateString("teamPosForHero",teamPosForHero);
|
||||
updateString(this,"teamPosForHero",teamPosForHero);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class WorkShopController extends MongoBase {
|
|||
openBlueStateMap.put(type,new ArrayList<>());
|
||||
}
|
||||
openBlueStateMap.get(type).add(openId);
|
||||
updateString("openBlueStateMap." + type, openBlueStateMap.get(type));
|
||||
updateString(this,"openBlueStateMap." + type, openBlueStateMap.get(type));
|
||||
}
|
||||
|
||||
public void addWorkShopExp(int addExp) throws Exception {
|
||||
|
@ -88,7 +88,7 @@ public class WorkShopController extends MongoBase {
|
|||
}
|
||||
|
||||
public void setWorkShopLevel(int workShopLevel) throws Exception {
|
||||
updateString("workShopLevel", workShopLevel);
|
||||
updateString(this,"workShopLevel", workShopLevel);
|
||||
this.workShopLevel = workShopLevel;
|
||||
}
|
||||
|
||||
|
@ -97,17 +97,17 @@ public class WorkShopController extends MongoBase {
|
|||
}
|
||||
|
||||
public void setWorkShopExp(int workShopExp) throws Exception {
|
||||
updateString("workShopExp", workShopExp);
|
||||
updateString(this,"workShopExp", workShopExp);
|
||||
this.workShopExp = workShopExp;
|
||||
}
|
||||
|
||||
public void setCookLevel(int cookLevel) throws Exception {
|
||||
updateString("cookLevel", cookLevel);
|
||||
updateString(this,"cookLevel", cookLevel);
|
||||
this.cookLevel = cookLevel;
|
||||
}
|
||||
|
||||
public void setCookExp(int cookExp) throws Exception {
|
||||
updateString("cookExp", cookExp);
|
||||
updateString(this,"cookExp", cookExp);
|
||||
this.cookExp = cookExp;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue