数据库修改
parent
f8dc7f535c
commit
8575bd5ba5
|
@ -352,10 +352,12 @@ public class BeanUtil {
|
|||
Object object = null;
|
||||
if (varName.equals("id")) {
|
||||
object = dbObject.get("_id");
|
||||
} else if(varName.equals("_root")){
|
||||
((MongoBase)bean).setRoot((MongoRoot) root);
|
||||
continue;
|
||||
} else if(varName.equals("bsave")){
|
||||
}
|
||||
// else if(varName.equals("_root")){
|
||||
// ((MongoBase)bean).setRoot((MongoRoot) root);
|
||||
// continue;
|
||||
// }
|
||||
else if(varName.equals("bsave")){
|
||||
((MongoRoot)bean).setBsave(true);
|
||||
continue;
|
||||
} else {
|
||||
|
|
|
@ -6,62 +6,55 @@ import java.lang.ref.WeakReference;
|
|||
|
||||
//使用下划线,是为了在json转换时,能转为正确的值
|
||||
public abstract class MongoBase {
|
||||
@Transient
|
||||
private WeakReference<MongoRoot> _root;
|
||||
|
||||
private String mongoKey; //该级对应的mongodb的key
|
||||
|
||||
@Transient
|
||||
private boolean _save;
|
||||
|
||||
public void init(MongoRoot root, String mongoKey, boolean _save) {
|
||||
this._root = new WeakReference<>(root);
|
||||
@Transient
|
||||
private String rootCollection;
|
||||
|
||||
@Transient
|
||||
private String id;
|
||||
|
||||
@Transient
|
||||
private LjsdMongoTemplate _myMongoTemplate;
|
||||
|
||||
public void init(String id, LjsdMongoTemplate _myMongoTemplate ,String rootCollection ,String mongoKey, boolean _save) {
|
||||
this.id = id;
|
||||
this.rootCollection = rootCollection;
|
||||
this._myMongoTemplate = _myMongoTemplate;
|
||||
this.mongoKey = mongoKey;
|
||||
this._save = _save;
|
||||
}
|
||||
|
||||
public void init(MongoRoot root, String mongoKey) {
|
||||
this._root = new WeakReference<>(root);
|
||||
public void init(String id, LjsdMongoTemplate _myMongoTemplate ,String rootCollection ,String mongoKey) {
|
||||
this.id = id;
|
||||
this.rootCollection = rootCollection;
|
||||
this._myMongoTemplate = _myMongoTemplate;
|
||||
this.mongoKey = mongoKey;
|
||||
this._save = true;
|
||||
}
|
||||
|
||||
public void updateString(String fieldName, Object value) throws Exception {
|
||||
MongoRoot mongoRoot = getMongoRoot();
|
||||
if (mongoRoot == null) return;
|
||||
public void updateString(MongoBase dataBase, String fieldName, Object value) throws Exception {
|
||||
|
||||
MongoUpdateCacheThreadLocal.addUpdateRequest(this, mongoRoot.getMyMongoDBPool(), mongoRoot.getCollection(), mongoRoot.getId(),
|
||||
MongoUpdateCacheThreadLocal.addUpdateRequest(this, dataBase.get_myMongoTemplate(), dataBase.getRootCollection(), dataBase.getId(),
|
||||
mongoKey + "." + fieldName, value);
|
||||
}
|
||||
|
||||
|
||||
public void updateString(String fieldName, MongoBase value) throws Exception {
|
||||
MongoRoot mongoRoot = getMongoRoot();
|
||||
if (mongoRoot == null) return;
|
||||
|
||||
MongoUpdateCacheThreadLocal.addUpdateRequest(value, mongoRoot.getMyMongoDBPool(), mongoRoot.getCollection(), mongoRoot.getId(),
|
||||
MongoUpdateCacheThreadLocal.addUpdateRequest(value, value.get_myMongoTemplate(), value.getRootCollection(), value.getId(),
|
||||
mongoKey + "." + fieldName, value);
|
||||
}
|
||||
|
||||
|
||||
public void removeString(String key) {
|
||||
MongoRoot mongoRoot = getMongoRoot();
|
||||
if (mongoRoot == null) return;
|
||||
MongoUpdateCacheThreadLocal.removeRequest(this, mongoRoot.getMyMongoDBPool(), mongoRoot.getCollection(), mongoRoot.getId(), key);
|
||||
public void removeString(String key, MongoBase value) {
|
||||
MongoUpdateCacheThreadLocal.removeRequest(this, value.get_myMongoTemplate(), value.getRootCollection(), value.getId(), key);
|
||||
}
|
||||
|
||||
|
||||
private MongoRoot getMongoRoot() {
|
||||
if (_root == null) {
|
||||
return null;
|
||||
}
|
||||
MongoRoot mongoRoot = _root.get();
|
||||
if (mongoRoot == null) {
|
||||
return null;
|
||||
}
|
||||
if (_save) {
|
||||
return null;
|
||||
}
|
||||
return mongoRoot;
|
||||
}
|
||||
|
||||
public String getMongoKey() {
|
||||
return mongoKey;
|
||||
}
|
||||
|
@ -70,15 +63,35 @@ public abstract class MongoBase {
|
|||
this.mongoKey = mongoKey;
|
||||
}
|
||||
|
||||
public MongoRoot getRoot() {
|
||||
return this._root.get();
|
||||
}
|
||||
|
||||
public void setRoot(MongoRoot root) {
|
||||
this._root = new WeakReference<>(root);
|
||||
public boolean is_save() {
|
||||
return _save;
|
||||
}
|
||||
|
||||
public void set_save(boolean _save) {
|
||||
this._save = _save;
|
||||
}
|
||||
|
||||
public String getRootCollection() {
|
||||
return rootCollection;
|
||||
}
|
||||
|
||||
public void setRootCollection(String rootCollection) {
|
||||
this.rootCollection = rootCollection;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public LjsdMongoTemplate get_myMongoTemplate() {
|
||||
return _myMongoTemplate;
|
||||
}
|
||||
|
||||
public void set_myMongoTemplate(LjsdMongoTemplate _myMongoTemplate) {
|
||||
this._myMongoTemplate = _myMongoTemplate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ import org.springframework.data.annotation.Transient;
|
|||
public abstract class MongoRoot {
|
||||
@Transient
|
||||
private boolean _bsave; //是否已经保存到了数据库
|
||||
@Transient
|
||||
private LjsdMongoTemplate _ljsdMongoTemplate; //对应的mongodb连接池
|
||||
|
||||
private String id; //如果是mongodb的根,则需要设置id
|
||||
|
||||
public MongoRoot() {
|
||||
|
@ -32,10 +31,6 @@ public abstract class MongoRoot {
|
|||
|
||||
public abstract String getCollection();
|
||||
|
||||
public LjsdMongoTemplate getMyMongoDBPool() {
|
||||
return _ljsdMongoTemplate;
|
||||
}
|
||||
|
||||
|
||||
public boolean isBsave() {
|
||||
return _bsave;
|
||||
|
@ -45,7 +40,4 @@ public abstract class MongoRoot {
|
|||
this._bsave = bsave;
|
||||
}
|
||||
|
||||
public void setMyMongoDBPool(LjsdMongoTemplate _ljsdMongoTemplate) {
|
||||
this._ljsdMongoTemplate = _ljsdMongoTemplate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,14 @@ public class AdventureManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void clearStation(int position){
|
||||
removeString("adventureStateInfoMap." + position);
|
||||
AdventureStateInfo adventureStateInfo = adventureStateInfoMap.get(position);
|
||||
if (adventureStateInfo!=null){
|
||||
removeString("adventureStateInfoMap." + position, adventureStateInfo);
|
||||
adventureStateInfoMap.remove(position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Map<Integer, AdventureStateInfo> getAdventureStateInfoMap() {
|
||||
return adventureStateInfoMap;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AdventureStateInfo {
|
||||
public class AdventureStateInfo extends MongoBase {
|
||||
private int position;
|
||||
private List<String> heroIds;
|
||||
private int startTime;
|
||||
|
|
|
@ -15,7 +15,7 @@ public class AutoIncrement extends MongoBase {
|
|||
}
|
||||
|
||||
public void setCnt(int cnt) throws Exception {
|
||||
updateString("cnt", cnt);
|
||||
updateString(this,"cnt", cnt);
|
||||
this.cnt = cnt;
|
||||
}
|
||||
public AutoIncrement(String name){
|
||||
|
|
|
@ -13,7 +13,8 @@ public class AutoIncrementManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void addAutoIncrement(AutoIncrement autoIncrement) throws Exception {
|
||||
autoIncrement.init(getRoot(), getMongoKey() + ".autoIncrementMap." + autoIncrement.getName());
|
||||
autoIncrement.init(autoIncrement.getId(), autoIncrement.get_myMongoTemplate(), autoIncrement.getRootCollection(),
|
||||
getMongoKey() + ".autoIncrementMap." + autoIncrement.getName());
|
||||
updateString("autoIncrementMap." + autoIncrement.getName(), autoIncrement);
|
||||
autoIncrementMap.put(autoIncrement.getName(),autoIncrement);
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ public class Equip extends MongoBase {
|
|||
}
|
||||
|
||||
public void setEquipId(int equipId) throws Exception {
|
||||
updateString("equipId",equipId);
|
||||
updateString(this,"equipId",equipId);
|
||||
this.equipId = equipId;
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ public class Equip extends MongoBase {
|
|||
}
|
||||
|
||||
public void setLevel(int level) throws Exception {
|
||||
updateString("level",level);
|
||||
updateString(this,"level",level);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ public class Equip extends MongoBase {
|
|||
}
|
||||
|
||||
public void setStar(int star) throws Exception {
|
||||
updateString("star",star);
|
||||
updateString(this,"star",star);
|
||||
this.star = star;
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ public class Equip extends MongoBase {
|
|||
}
|
||||
|
||||
public void setHeroId(String heroId) throws Exception {
|
||||
updateString("heroId",heroId);
|
||||
updateString(this,"heroId",heroId);
|
||||
this.heroId = heroId;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,12 @@ public class EquipManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void remove(String equipId){
|
||||
removeString("equipMap." + equipId);
|
||||
Equip equip = equipMap.get(equipId);
|
||||
if (equip!=null){
|
||||
removeString("equipMap." + equipId, equip);
|
||||
equipMap.remove(equipId);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Equip> getEquipMap() {
|
||||
return equipMap;
|
||||
|
|
|
@ -72,8 +72,8 @@ public class Hero extends MongoBase {
|
|||
}
|
||||
this.skillList.addAll(skillIds);
|
||||
}
|
||||
updateString("star",star);
|
||||
updateString("skillList",skillList);
|
||||
updateString(this,"star",star);
|
||||
updateString(this,"skillList",skillList);
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class Hero extends MongoBase {
|
|||
}
|
||||
|
||||
public void setTemplateId(int templateId) throws Exception {
|
||||
updateString("templateId",templateId);
|
||||
updateString(this,"templateId",templateId);
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
|
@ -91,17 +91,17 @@ public class Hero extends MongoBase {
|
|||
}
|
||||
|
||||
public void setCurHp(float curHp) throws Exception {
|
||||
updateString("curHp",curHp);
|
||||
updateString(this,"curHp",curHp);
|
||||
this.curHp = curHp;
|
||||
}
|
||||
|
||||
public void setLevel(int level) throws Exception {
|
||||
updateString("level",level);
|
||||
updateString(this,"level",level);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public void setStar(int star) throws Exception {
|
||||
updateString("star",star);
|
||||
updateString(this,"star",star);
|
||||
this.star = star;
|
||||
}
|
||||
|
||||
|
@ -136,26 +136,29 @@ public class Hero extends MongoBase {
|
|||
}
|
||||
|
||||
public void setEquipByPositionMap(Map<Integer, String> equipByPositionMap) throws Exception {
|
||||
updateString("equipByPositionMap",equipByPositionMap);
|
||||
updateString(this,"equipByPositionMap",equipByPositionMap);
|
||||
this.equipByPositionMap = equipByPositionMap;
|
||||
}
|
||||
|
||||
public void updateEquipPositionMap(int position,String equipId) throws Exception {
|
||||
updateString("equipByPositionMap." + position ,equipId);
|
||||
updateString(this,"equipByPositionMap." + position ,equipId);
|
||||
this.equipByPositionMap.put(position,equipId);
|
||||
}
|
||||
|
||||
public void removeEquip(int position){
|
||||
removeString("equipByPositionMap." + position);
|
||||
String value = this.equipByPositionMap.get(position);
|
||||
if (value!=null){
|
||||
removeString("equipByPositionMap." + position, this);
|
||||
this.equipByPositionMap.remove(position);
|
||||
}
|
||||
}
|
||||
|
||||
public int getBreakId() {
|
||||
return breakId;
|
||||
}
|
||||
|
||||
public void setBreakId(int breakId) throws Exception {
|
||||
updateString("breakId",breakId);
|
||||
updateString(this,"breakId",breakId);
|
||||
this.breakId = breakId;
|
||||
}
|
||||
|
||||
|
@ -164,19 +167,19 @@ public class Hero extends MongoBase {
|
|||
}
|
||||
|
||||
public void updateEnergy(int energy,int updateTime) throws Exception {
|
||||
updateString("energy",energy);
|
||||
updateString("lastUpdateEnergyTime",energy);
|
||||
updateString(this,"energy",energy);
|
||||
updateString(this,"lastUpdateEnergyTime",energy);
|
||||
this.energy = energy;
|
||||
this.lastUpdateEnergyTime = updateTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(int createTime) throws Exception {
|
||||
updateString("createTime",createTime);
|
||||
updateString(this,"createTime",createTime);
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public void setLastUpdateEnergyTime(int lastUpdateEnergyTime) throws Exception {
|
||||
updateString("lastUpdateEnergyTime",lastUpdateEnergyTime);
|
||||
updateString(this,"lastUpdateEnergyTime",lastUpdateEnergyTime);
|
||||
this.lastUpdateEnergyTime = lastUpdateEnergyTime;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public class HeroManager extends MongoBase {
|
|||
|
||||
public void addHero(Hero hero) throws Exception {
|
||||
//绑定关系
|
||||
hero.init(getRoot(), getMongoKey() + ".heroMap." + hero.getId());
|
||||
hero.init(hero.getId(),hero.get_myMongoTemplate(), hero.getRootCollection(),getMongoKey() + ".heroMap." + hero.getId());
|
||||
updateString("heroMap." + hero.getId(), hero);
|
||||
heroMap.put(hero.getId(), hero);
|
||||
}
|
||||
|
@ -32,9 +32,12 @@ public class HeroManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void removeHero(String heroId) {
|
||||
removeString("heroMap." + heroId);
|
||||
Hero hero = heroMap.get(heroId);
|
||||
if (hero!=null){
|
||||
removeString("heroMap." + heroId, hero);
|
||||
heroMap.remove(heroId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class Item extends MongoBase {
|
|||
}
|
||||
|
||||
public void setItemId(int itemId) throws Exception {
|
||||
updateString("itemId", itemId);
|
||||
updateString(this,"itemId", itemId);
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class Item extends MongoBase {
|
|||
}
|
||||
|
||||
public void setItemNum(int itemNum) throws Exception {
|
||||
updateString("itemNum", itemNum);
|
||||
updateString(this,"itemNum", itemNum);
|
||||
this.itemNum = itemNum;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class Item extends MongoBase {
|
|||
}
|
||||
|
||||
public void setEndingTime(int endingTime) throws Exception {
|
||||
updateString("endingTime", endingTime);
|
||||
updateString(this,"endingTime", endingTime);
|
||||
this.endingTime = endingTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class ItemManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void addItem(Item item) throws Exception {
|
||||
item.init(getRoot(), getMongoKey() + ".itemMap." + item.getItemId());
|
||||
item.init(item.getId(),item.get_myMongoTemplate(), item.getRootCollection(), getMongoKey() + ".itemMap." + item.getItemId());
|
||||
updateString("itemMap." + item.getItemId(), item);
|
||||
itemMap.put(item.getItemId(), item);
|
||||
}
|
||||
|
@ -33,8 +33,11 @@ public class ItemManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void removeItem(Integer key) {
|
||||
Item item = itemMap.get(key);
|
||||
if (item!=null){
|
||||
itemMap.remove(key);
|
||||
removeString(getMongoKey() + ".itemMap." + key);
|
||||
removeString(getMongoKey() + ".itemMap." + key, item);
|
||||
}
|
||||
}
|
||||
|
||||
public Item newItem(int itemId, int itemNum) throws Exception {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class Mail extends MongoBase {
|
|||
this.mailType = mailType;
|
||||
}
|
||||
public void setState(int state) throws Exception {
|
||||
updateString("state", state);
|
||||
updateString(this,"state", state);
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ public class MailManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void addMail(Mail mail) throws Exception {
|
||||
mail.init(getRoot(), getMongoKey() + ".mailMap." + mail.getId());
|
||||
mail.init(mail.getId(),mail.get_myMongoTemplate(),mail.getRootCollection(), getMongoKey() + ".mailMap." + mail.getId());
|
||||
updateString("mailMap." + mail.getId(), mail);
|
||||
mailMap.put(mail.getId(), mail);
|
||||
}
|
||||
|
@ -23,7 +23,10 @@ public class MailManager extends MongoBase {
|
|||
return mailMap.get(key);
|
||||
}
|
||||
public void removeMail(String key) {
|
||||
Mail mail = mailMap.get(key);
|
||||
if (mail!=null){
|
||||
mailMap.remove(key);
|
||||
removeString(getMongoKey() + ".mailMap." + key);
|
||||
removeString(getMongoKey() + ".mailMap." + key, mail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.common.mogodb.LjsdMongoTemplate;
|
||||
import com.ljsd.common.mogodb.MongoRoot;
|
||||
|
||||
|
@ -20,16 +21,16 @@ public class MailingSystem extends MongoRoot {
|
|||
|
||||
|
||||
public MailingSystem(){
|
||||
setMyMongoDBPool(_myMongoDBPool);
|
||||
setId("1");
|
||||
String id = Integer.toString(GameApplication.serverId);
|
||||
setId(id);
|
||||
systemMailManager = new SystemMailManager();
|
||||
sysMailManager = new SysMailManager();
|
||||
cAutoIncrementManager = new AutoIncrementManager();
|
||||
|
||||
//綁定关系
|
||||
systemMailManager.init(this, "systemMailManager", false);
|
||||
sysMailManager.init(this, "sysMailManager", false);
|
||||
cAutoIncrementManager.init(this, "autoIncrementManager", false);
|
||||
systemMailManager.init(id, _myMongoDBPool, _COLLECTION_NAME,"systemMailManager", false);
|
||||
sysMailManager.init(id, _myMongoDBPool, _COLLECTION_NAME,"sysMailManager", false);
|
||||
cAutoIncrementManager.init(id, _myMongoDBPool, _COLLECTION_NAME,"autoIncrementManager", false);
|
||||
}
|
||||
public static void init(LjsdMongoTemplate ljsdMongoTemplate) {
|
||||
_myMongoDBPool = ljsdMongoTemplate;
|
||||
|
|
|
@ -2,7 +2,6 @@ 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;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class PlayerManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setNickName(String nickName) throws Exception {
|
||||
updateString("nickName", nickName);
|
||||
updateString(this,"nickName", nickName);
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class PlayerManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setLevel(int level) throws Exception {
|
||||
updateString("level", level);
|
||||
updateString(this,"level", level);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class PlayerManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setExp(int exp) throws Exception {
|
||||
updateString("exp", exp);
|
||||
updateString(this,"exp", exp);
|
||||
this.exp = exp;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class PlayerManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setVipLevel(int vipLevel) throws Exception {
|
||||
updateString("vipLevel", vipLevel);
|
||||
updateString(this,"vipLevel", vipLevel);
|
||||
this.vipLevel = vipLevel;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class PlayerManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setFamilyId(String familyId) throws Exception {
|
||||
updateString("familyId", familyId);
|
||||
updateString(this,"familyId", familyId);
|
||||
this.familyId = familyId;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class PlayerManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setHead(String head) throws Exception {
|
||||
updateString("head", head);
|
||||
updateString(this,"head", head);
|
||||
this.head = head;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class PlayerManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setGold(long gold) throws Exception {
|
||||
updateString("gold", gold);
|
||||
updateString(this,"gold", gold);
|
||||
this.gold = gold;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ public class PlayerManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setGem(int gem) throws Exception {
|
||||
updateString("gem", gem);
|
||||
updateString(this,"gem", gem);
|
||||
this.gem = gem;
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class PlayerManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setChargeGem(int chargeGem) throws Exception {
|
||||
updateString("chargeGem", chargeGem);
|
||||
updateString(this,"chargeGem", chargeGem);
|
||||
this.chargeGem = chargeGem;
|
||||
}
|
||||
|
||||
|
@ -130,12 +130,12 @@ public class PlayerManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setMapId(int mapId) throws Exception {
|
||||
updateString("mapId", mapId);
|
||||
updateString(this,"mapId", mapId);
|
||||
this.mapId = mapId;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) throws Exception {
|
||||
updateString("createTime", createTime);
|
||||
updateString(this,"createTime", createTime);
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class PlayerManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setClientVersion(String clientVersion) throws Exception {
|
||||
updateString("clientVersion", clientVersion);
|
||||
updateString(this,"clientVersion", clientVersion);
|
||||
this.clientVersion = clientVersion;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public class Pokemon extends MongoBase {
|
|||
if( integer != null){
|
||||
level = integer+1 ;
|
||||
}
|
||||
updateString("comonpentsLevelMap."+comonpentId,level);
|
||||
updateString(this,"comonpentsLevelMap."+comonpentId,level);
|
||||
this.comonpentsLevelMap.put(comonpentId,level);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class Pokemon extends MongoBase {
|
|||
}
|
||||
|
||||
public void setAllStage(int allStage) throws Exception {
|
||||
updateString("allStage."+allStage,allStage);
|
||||
updateString(this,"allStage."+allStage,allStage);
|
||||
this.allStage = allStage;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class Skill extends MongoBase {
|
|||
}
|
||||
|
||||
public void setSkillId(int skillId) throws Exception {
|
||||
updateString("skillId",skillId);
|
||||
updateString(this,"skillId", skillId);
|
||||
this.skillId = skillId;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class Skill extends MongoBase {
|
|||
}
|
||||
|
||||
public void setSkillType(int skillType) throws Exception {
|
||||
updateString("skillType",skillType);
|
||||
updateString(this,"skillType",skillType);
|
||||
this.skillType = skillType;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class Skill extends MongoBase {
|
|||
}
|
||||
|
||||
public void setLevel(int level) throws Exception {
|
||||
updateString("level",level);
|
||||
updateString(this,"level",level);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class Skill extends MongoBase {
|
|||
}
|
||||
|
||||
public void setStar(int star) throws Exception {
|
||||
updateString("star",star);
|
||||
updateString(this,"star",star);
|
||||
this.star = star;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ public class SysMail extends MongoBase {
|
|||
|
||||
}
|
||||
public void setSysMailIds(List<Integer> sysMailIds) throws Exception {
|
||||
updateString("sysMailIds", sysMailIds);
|
||||
updateString(this,"sysMailIds", sysMailIds);
|
||||
this.sysMailIds = sysMailIds;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,14 +13,13 @@ public class SysMailManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void addSystemMail(SysMail sysMail) throws Exception {
|
||||
sysMail.init(getRoot(), getMongoKey() + ".sysMailMap." + sysMail.getRoleUid());
|
||||
sysMail.init(sysMail.getId(),sysMail.get_myMongoTemplate(),sysMail.getRootCollection(), getMongoKey() + ".sysMailMap." + sysMail.getRoleUid());
|
||||
updateString("sysMailMap." + sysMail.getRoleUid(), sysMail);
|
||||
sysMailMap.put(sysMail.getRoleUid(),sysMail);
|
||||
}
|
||||
|
||||
public void removeSystemMail(int key) {
|
||||
sysMailMap.remove(key);
|
||||
removeString(getMongoKey() + ".sysMailMap." + key);
|
||||
//TODO
|
||||
}
|
||||
|
||||
public SysMail getSysMail(int userId) {
|
||||
|
|
|
@ -13,14 +13,12 @@ public class SystemMailManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void addSystemMail(SystemMail systemMail) throws Exception {
|
||||
systemMail.init(getRoot(), getMongoKey() + ".systemMailMap." + systemMail.getId());
|
||||
updateString("systemMailMap." + systemMail.getId(), systemMail);
|
||||
systemMailMap.put(systemMail.getId(),systemMail);
|
||||
}
|
||||
|
||||
public void removeSystemMail(int key) {
|
||||
systemMailMap.remove(key);
|
||||
removeString(getMongoKey() + ".systemMailMap." + key);
|
||||
//TODO
|
||||
}
|
||||
public String getName (){
|
||||
return "systemMail";
|
||||
|
|
|
@ -22,7 +22,7 @@ public class TeamPosManager extends MongoBase {
|
|||
|
||||
public void changeName(int teamId,String teamName) throws Exception {
|
||||
teamNames.put(teamId,teamName);
|
||||
updateString("teamNames",teamNames);
|
||||
updateString(this,"teamNames",teamNames);
|
||||
}
|
||||
|
||||
public void changeTeamInfo(int teamId, List<CommonProto.TeamHeroInfo> heroIds, List<CommonProto.TeamPokemonInfo> pokemonoIds) throws Exception {
|
||||
|
@ -38,8 +38,8 @@ public class TeamPosManager extends MongoBase {
|
|||
}
|
||||
teamPosForHero.put(teamId,teamPosHeroInfoList);
|
||||
teamPosForPoken.put(teamId,teamPosForPokenInfos);
|
||||
updateString("teamPosForHero",teamPosForHero);
|
||||
updateString("teamPosForPoken",teamPosForPoken);
|
||||
updateString(this,"teamPosForHero",teamPosForHero);
|
||||
updateString(this,"teamPosForPoken",teamPosForPoken);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,9 @@ import com.ljsd.jieling.handler.map.MapManager;
|
|||
import com.ljsd.jieling.handler.mission.MissionManager;
|
||||
|
||||
public class User extends MongoRoot {
|
||||
|
||||
public static final String _COLLECTION_NAME = "user";
|
||||
|
||||
private static LjsdMongoTemplate _myMongoDBPool;
|
||||
|
||||
private PlayerManager playerManager;
|
||||
|
@ -33,14 +35,13 @@ public class User extends MongoRoot {
|
|||
|
||||
|
||||
|
||||
public User(int uid, PlayerManager playerManager, ItemManager itemManager,
|
||||
HeroManager heroManager, MapManager mapManager){
|
||||
setMyMongoDBPool(_myMongoDBPool);
|
||||
setId(Integer.toString(uid));
|
||||
this.playerManager = playerManager;
|
||||
this.itemManager = itemManager;
|
||||
this.heroManager = heroManager;
|
||||
this.mapManager = mapManager;
|
||||
public User(int uid){
|
||||
String suid = Integer.toString(uid);
|
||||
setId(suid);
|
||||
this.playerManager = new PlayerManager();
|
||||
this.itemManager = new ItemManager();
|
||||
this.heroManager = new HeroManager();
|
||||
this.mapManager = new MapManager();
|
||||
this.missionManager = new MissionManager();
|
||||
this.teamPosManager = new TeamPosManager();
|
||||
this.mailManager = new MailManager();
|
||||
|
@ -50,41 +51,19 @@ public class User extends MongoRoot {
|
|||
this.workShopController = new WorkShopController();
|
||||
|
||||
//綁定关系
|
||||
this.playerManager.init(this, "playerManager", false);
|
||||
this.itemManager.init(this, "itemManager", false);
|
||||
this.heroManager.init(this, "heroManager", false);
|
||||
this.mapManager.init(this, "mapManager", false);
|
||||
this.missionManager.init(this, "missionManager", false);
|
||||
this.teamPosManager.init(this,"teamPosManager",false);
|
||||
this.mailManager.init(this,"mailManager",false);
|
||||
this.equipManager.init(this,"equipManager",false);
|
||||
this.adventureManager.init(this,"adventureManager",false);
|
||||
this.pokemonManager.init(this,"pokemonManager",false);
|
||||
this.workShopController.init(this,"workShopController",false);
|
||||
this.playerManager.init(suid, _myMongoDBPool, _COLLECTION_NAME,"playerManager", false);
|
||||
this.itemManager.init(suid, _myMongoDBPool, _COLLECTION_NAME,"itemManager", false);
|
||||
this.heroManager.init(suid, _myMongoDBPool, _COLLECTION_NAME,"heroManager", false);
|
||||
this.mapManager.init(suid, _myMongoDBPool, _COLLECTION_NAME,"mapManager", false);
|
||||
this.missionManager.init(suid, _myMongoDBPool, _COLLECTION_NAME,"missionManager", false);
|
||||
this.teamPosManager.init(suid, _myMongoDBPool, _COLLECTION_NAME,"teamPosManager",false);
|
||||
this.mailManager.init(suid, _myMongoDBPool, _COLLECTION_NAME,"mailManager",false);
|
||||
this.equipManager.init(suid, _myMongoDBPool, _COLLECTION_NAME,"equipManager",false);
|
||||
this.adventureManager.init(suid, _myMongoDBPool, _COLLECTION_NAME,"adventureManager",false);
|
||||
this.pokemonManager.init(suid, _myMongoDBPool, _COLLECTION_NAME,"pokemonManager",false);
|
||||
this.workShopController.init(suid, _myMongoDBPool, _COLLECTION_NAME,"workShopController",false);
|
||||
}
|
||||
|
||||
public User(){
|
||||
setMyMongoDBPool(_myMongoDBPool);
|
||||
this.playerManager = new PlayerManager();
|
||||
this.itemManager = new ItemManager();
|
||||
this.heroManager = new HeroManager();
|
||||
this.mapManager = new MapManager();
|
||||
this.missionManager = new MissionManager();
|
||||
this.equipManager = new EquipManager();
|
||||
this.adventureManager = new AdventureManager();
|
||||
this.pokemonManager = new PokemonManager();
|
||||
this.workShopController = new WorkShopController();
|
||||
//綁定关系
|
||||
playerManager.init(this, "playerManager", false);
|
||||
itemManager.init(this, "itemManager", false);
|
||||
heroManager.init(this, "heroManager", false);
|
||||
mapManager.init(this, "mapManager", false);
|
||||
equipManager.init(this,"equipManager",false);
|
||||
missionManager.init(this, "missionManager", false);
|
||||
adventureManager.init(this,"adventureManager",false);
|
||||
pokemonManager.init(this,"pokemonManager",false);
|
||||
workShopController.init(this,"workShopController",false);
|
||||
}
|
||||
|
||||
public static void init(LjsdMongoTemplate ljsdMongoTemplate) {
|
||||
_myMongoDBPool = ljsdMongoTemplate;
|
||||
|
|
|
@ -61,7 +61,7 @@ public class UserManager {
|
|||
|
||||
|
||||
private static User registerUser(int uid) throws Exception {
|
||||
User user = new User(uid,new PlayerManager(),new ItemManager(),new HeroManager(),new MapManager());
|
||||
User user = new User(uid);
|
||||
initPlayer(user);
|
||||
UserManager.addUser(user);
|
||||
ljsdMongoTemplate.save(user);
|
||||
|
|
Loading…
Reference in New Issue