Browse Source

用户id类型和后台保持一致,与游戏角色id区分

johnclot69 3 months ago
parent
commit
b52639d775

+ 2 - 2
incubator-common/src/main/java/com/incubator/common/net/Connection.java

@@ -12,13 +12,13 @@ public interface Connection {
 	 * 获取玩家ID
 	 * @return
 	 */
-	Long getUid();
+	String getUid();
 
 	/**
 	 * 设置玩家ID
 	 * @param uid
 	 */
-	void setUid(Long uid);
+	void setUid(String uid);
 
 	/**
 	 * 获取角色id

+ 3 - 3
incubator-common/src/main/java/com/incubator/common/net/netty/NettyConnection.java

@@ -19,7 +19,7 @@ public class NettyConnection implements Connection {
 
 	protected final Channel channel;
 	
-	private long uid;
+	private String uid;
 
 	private String playerId;
 
@@ -39,12 +39,12 @@ public class NettyConnection implements Connection {
 	}
 
 	@Override
-	public Long getUid() {
+	public String getUid() {
 		return uid;
 	}
 
 	@Override
-	public void setUid(Long uid) {
+	public void setUid(String uid) {
 		this.uid = uid;
 	}
 

+ 1 - 1
incubator-core/src/main/java/com/incubator/core/player/GPlayerInterface.java

@@ -13,7 +13,7 @@ public interface GPlayerInterface {
 	public abstract int getLogicServerId();
 	
 	/** 功能描述:用户ID,用户中心的唯一标识ID */
-	public abstract long getUid();
+	public abstract String getUid();
 	
 	/** 玩家定时刷新操作 */
 	public abstract void doUpdate();

+ 13 - 12
incubator-game/src/main/java/com/incubator/game/data/po/PlayerInfoPO.java

@@ -35,11 +35,6 @@ public class PlayerInfoPO {
 	/** VIP结束时间 **/
 	public String endTimeVip;
 
-	/** GPS **/
-	public String gps;
-	/** GPS位置详情 **/
-	public String gpsAddr;
-
 	/** 福卡 **/
 	public long foca;
 	/** 系统排名 **/
@@ -47,13 +42,6 @@ public class PlayerInfoPO {
 	/** 人物形象序号 **/
 	public int figureId;
 
-	/** 实名 **/
-	public String realName;
-	/** 手机号 **/
-	public String phoneNum;
-	/** 身份证号 **/
-	public String idCard;
-
 	/** 好友局局数 **/
 	public int friendMasterNum;
 	/** 好友局胜率 **/
@@ -94,6 +82,19 @@ public class PlayerInfoPO {
 	/** 登录token **/
 	public String token;
 
+	/** 账号 **/
+	public String userId;
+	/** GPS **/
+	public String gps;
+	/** GPS位置详情 **/
+	public String gpsAddr;
+	/** 实名 **/
+	public String realName;
+	/** 手机号 **/
+	public String phoneNum;
+	/** 身份证号 **/
+	public String idCard;
+
 	public PlayerInfoPO () {
 
 	}

+ 2 - 2
incubator-game/src/main/java/com/incubator/game/player/GPlayer.java

@@ -23,7 +23,7 @@ public abstract class GPlayer extends GPlayerBase {
 	/** 0首次进入场景 1非首次进入场景 **/
 	protected byte state = 0;
 	/** 用户id **/
-	private long userId = 0;
+	private String userId = "";
 	
 	public GPlayer() {}
 
@@ -35,7 +35,7 @@ public abstract class GPlayer extends GPlayerBase {
 	 * @param playerId 玩家id
 	 * @param token token
 	 */
-	public void bind(Connection session, long userid, String playerId, String token) {
+	public void bind(Connection session, String userid, String playerId, String token) {
 		synchronized (this) {
 			this.userId = userid;
 			this.lastUpdateTime = GGame.APP_TIME;

+ 1 - 1
incubator-game/src/main/java/com/incubator/game/player/Player.java

@@ -179,7 +179,7 @@ public class Player extends GPlayer {
     }
 
     @Override
-    public long getUid() {
+    public String getUid() {
         return this.session.getUid();
     }
 

+ 6 - 3
incubator-game/src/main/java/com/incubator/game/util/PlayerUtil.java

@@ -5,6 +5,9 @@ import com.incubator.game.GGame;
 import com.incubator.game.data.po.PlayerInfoPO;
 import com.incubator.game.player.GPlayer;
 import com.incubator.game.player.Player;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Objects;
 
 /**
  * 玩家工具类
@@ -23,12 +26,12 @@ public final class PlayerUtil {
     }
 
     /** 根据账号查找玩家 */
-    public static GPlayer getPlayerByUid(long uid) {
-        if (uid <= 0) {
+    public static GPlayer getPlayerByUid(String uid) {
+        if (StringUtils.isEmpty(uid)) {
             return null;
         }
         for (GPlayer p : GGame.onlinePlayers.values()) {
-            if (p.getUid() == uid) {
+            if (Objects.equals(p.getUid(), uid)) {
                 return p;
             }
         }