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