更新login跟group服务
parent
4c84b402ad
commit
ba33fb29b2
|
|
@ -37,6 +37,10 @@ public class ErrorCode {
|
|||
// 设备号已经被锁定
|
||||
public final static int IS_LOCK = 20;
|
||||
|
||||
// 白名单已经被锁定
|
||||
public final static int IS_DEVICE_LOCK = 21;
|
||||
|
||||
|
||||
// 没有回放
|
||||
public final static int NO_REC = 25;
|
||||
//多次登录失败,禁止登录, 半个小时后再试
|
||||
|
|
|
|||
|
|
@ -29,8 +29,11 @@ public class EXGameController extends GameController {
|
|||
|
||||
@ActionKey(Config.GAME_ACTION)
|
||||
public void RouterAction(Session sender,ITObject params,int gid,Player owner) {
|
||||
if(owner.stateMachine!=null) {
|
||||
|
||||
owner.stateMachine.execute(EXActionEvent.EVENT_ACTION, 0, params);
|
||||
}
|
||||
}
|
||||
|
||||
@ActionKey(Config.GAME_DIS_CARD)
|
||||
public void RouterDisCard(Session sender,ITObject params,int gid,Player owner) {
|
||||
|
|
@ -132,9 +135,10 @@ public class EXGameController extends GameController {
|
|||
room.currenDiscardSeat = 0;
|
||||
|
||||
CardUtil.removeCard(player.cardInhand, discard, 1);
|
||||
|
||||
if(room.playerMapByPlaying.size()>=2) {
|
||||
room.broadCastToServer(player.playerid, EXActionEvent.EVENT_OTHER_DISCARD, discard);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,18 +17,20 @@ import com.taurus.permanent.TPServer;
|
|||
import extend.zp.*;
|
||||
import extend.zp.room.state.EXRoomSetpState;
|
||||
|
||||
|
||||
public class EXPlayerDiscardState extends StateBase<EXPlayer> {
|
||||
Logger logger = Logger.getLogger(getClass());
|
||||
|
||||
@Override
|
||||
public void enter(EXPlayer owner) {
|
||||
|
||||
owner.getRoom().tipMap.clear();
|
||||
if (owner.cardInhand.isEmpty()) {
|
||||
|
||||
owner.isLaoYe = true;
|
||||
owner.stateMachine.changeState(Global.getState(PlayerWaitState.class));
|
||||
owner.room.stateMachine.changeState(Global.getState(EXRoomSetpState.class));
|
||||
} else {
|
||||
|
||||
EXMainServer.gameCtr.discardTipEvent(owner);
|
||||
owner.startActionTimer();
|
||||
}
|
||||
|
|
@ -39,6 +41,7 @@ public class EXPlayerDiscardState extends StateBase<EXPlayer> {
|
|||
//// System.out.println("tonextstate:"+owner.getRoom().isFanPao);
|
||||
timer(owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit(EXPlayer owner) {
|
||||
owner.stopActionTimer();
|
||||
|
|
@ -90,7 +93,6 @@ public class EXPlayerDiscardState extends StateBase<EXPlayer> {
|
|||
|
||||
owner.getRoom().isDiHu = false;
|
||||
|
||||
|
||||
if (owner.getRoom().tipMap.size() != 0) {
|
||||
//// System.out.println("dddssssssss11111");
|
||||
if (!(owner.stateMachine.curState instanceof EXPlayerDrawTipState)) {
|
||||
|
|
@ -107,6 +109,7 @@ public class EXPlayerDiscardState extends StateBase<EXPlayer> {
|
|||
public static void timer(EXPlayer owner) {
|
||||
//// System.out.println("dddssssssss1111122222");
|
||||
if (owner.getRoom().isAllPass) {
|
||||
|
||||
ITObject resData = new TObject();
|
||||
resData.putInt("card", owner.getRoom().activeCard);
|
||||
resData.putInt("seat", owner.seat);
|
||||
|
|
@ -120,6 +123,7 @@ public class EXPlayerDiscardState extends StateBase<EXPlayer> {
|
|||
owner.room.stateMachine.changeState(Global.getState(EXRoomSetpState.class));
|
||||
} else {
|
||||
//// System.out.println("dddssssssss11111444444");
|
||||
|
||||
TPServer.me().getTimerPool().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
package extend.zp.tip;
|
||||
|
||||
import com.taurus.core.util.Logger;
|
||||
|
||||
import extend.zp.EXPlayer;
|
||||
|
||||
public class Action {
|
||||
public static final Logger logger = Logger.getLogger(Action.class);
|
||||
|
||||
public Tip tip;
|
||||
public EXPlayer player;
|
||||
|
||||
|
|
@ -15,6 +19,7 @@ public class Action {
|
|||
public void run() {
|
||||
this.player.actionTip = tip;
|
||||
this.player.initOpCard(tip.opcard);
|
||||
|
||||
this.tip.rule.action(this.player);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,4 +228,8 @@ public class Protocol {
|
|||
/** 成员禁止玩法详情*/
|
||||
public static final String GROUP_BAN_MEMBER_PLAY_SET = "ban_member_play_set";
|
||||
|
||||
// /** 重置多设备锁定*/
|
||||
// public static final String GROUP_RESET_MORE_LOCK = "group_reset_more_lock";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1606,6 +1606,24 @@ public class GroupController extends Controller {
|
|||
this.sendResponse(0, null);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 重置设备锁定状态
|
||||
// */
|
||||
// @ActionKey(value = Protocol.GROUP_RESET_MORE_LOCK, validate = WebInterceptor.V_SESSION | WebInterceptor.V_GROUP
|
||||
// | WebInterceptor.V_GROUP_MGR_OR_PARTNER)
|
||||
// public final void resetMoreLock() throws Exception {
|
||||
// ITObject reqData = this.getParams();
|
||||
// int tagId = reqData.getInt("tagId");// 解锁目标
|
||||
// int lockType = reqData.getInt("lockType");
|
||||
// String sql = "UPDATE account_device SET is_lock=? where user_id=?";
|
||||
// String[] params1 = new String[2];
|
||||
// params1[0] = lockType + "";
|
||||
// params1[1] = tagId + "";
|
||||
//
|
||||
// DataBase.use().executeUpdateLogin(sql, params1);
|
||||
// this.sendResponse(0, null);
|
||||
// }
|
||||
|
||||
@ActionKey(value = Protocol.GROUP_GET_PARTNER, validate = WebInterceptor.V_SESSION | WebInterceptor.V_GROUP
|
||||
| WebInterceptor.V_GROUP_MGR_OR_PARTNER)
|
||||
public final void getPartner() throws Exception {
|
||||
|
|
|
|||
|
|
@ -47,15 +47,30 @@ public class GroupRoomService {
|
|||
|
||||
private static final String _getSvr(Jedis jedis0, GameBean gb) {
|
||||
String svr = null;
|
||||
Set<String> gamesvrs = gb.svr_list;
|
||||
// Set<String> gamesvrs = gb.svr_list;
|
||||
Set<String> gamesvrs = Redis.use("group1_db1").smembers("game_svr:" + gb.id);
|
||||
List<String> games = Redis.use("group1_db1").lrange("isbk", 0, 4);
|
||||
String isbk = "";
|
||||
for (String game : games) {
|
||||
if (game.equalsIgnoreCase(gb.id + "")) {
|
||||
isbk = "1000" + gb.id;
|
||||
}
|
||||
}
|
||||
|
||||
Integer conns = null;
|
||||
for (String str : gamesvrs) {
|
||||
String currConns = jedis0.hget(str, "conns");
|
||||
|
||||
if (conns == null && currConns != null
|
||||
|| (conns != null && currConns != null && Integer.parseInt(currConns) < conns)) {
|
||||
conns = Integer.parseInt(currConns);
|
||||
svr = str;
|
||||
}
|
||||
if (isbk.equalsIgnoreCase("1000" + gb.id)) {
|
||||
svr = "svr" + (Integer.parseInt(svr.replace("svr", "")) + 1000) + "";
|
||||
}
|
||||
log.info("当前游戏链接:" + svr);
|
||||
|
||||
}
|
||||
return svr;
|
||||
}
|
||||
|
|
@ -596,9 +611,9 @@ public class GroupRoomService {
|
|||
int gameId1 = resData.getInt("gameId");
|
||||
String robot_host = null;
|
||||
if (gameId1 != 0) {
|
||||
/*if (gameId1 == 17) {
|
||||
robot_host = "8.138.120.132:8917";
|
||||
}*/
|
||||
/*
|
||||
* if (gameId1 == 17) { robot_host = "8.138.120.132:8917"; }
|
||||
*/
|
||||
if (gameId1 == 22) {
|
||||
robot_host = "8.138.120.132:8722";
|
||||
}
|
||||
|
|
@ -618,7 +633,6 @@ public class GroupRoomService {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
Jedis jedis11 = Redis.use("group1_db11").getJedis();
|
||||
jedis11.zremrangeByScore(grooms_key, 0, 0);
|
||||
jedis11.close();
|
||||
|
|
@ -1094,7 +1108,6 @@ public class GroupRoomService {
|
|||
resData = publicJoinRoom(groupId, session, key, platform);
|
||||
}
|
||||
|
||||
|
||||
// 检查玩家今天是否已经与机器人对打过
|
||||
if (!isPlayerRobotToday(acc.id)) {
|
||||
// 匹配
|
||||
|
|
@ -1107,9 +1120,9 @@ public class GroupRoomService {
|
|||
String gameId1 = jedis11.hget("g{383709}:play:" + pid, "gameId");
|
||||
String robot_host = null;
|
||||
if (StringUtil.isNotEmpty(gameId1)) {
|
||||
/*if (Integer.parseInt(gameId1) == 17) {
|
||||
robot_host = "8.138.120.132:8917";
|
||||
}*/
|
||||
/*
|
||||
* if (Integer.parseInt(gameId1) == 17) { robot_host = "8.138.120.132:8917"; }
|
||||
*/
|
||||
if (Integer.parseInt(gameId1) == 22) {
|
||||
robot_host = "8.138.120.132:8722";
|
||||
}
|
||||
|
|
@ -1140,6 +1153,7 @@ public class GroupRoomService {
|
|||
|
||||
/**
|
||||
* 检查玩家今天是否已经与机器人对打过
|
||||
*
|
||||
* @param playerId 玩家ID
|
||||
*/
|
||||
private static boolean isPlayerRobotToday(int playerId) {
|
||||
|
|
@ -1164,8 +1178,8 @@ public class GroupRoomService {
|
|||
/**
|
||||
* //发起机器人请求(HTTP 同步方式,替代原 TCP 异步多线程方式)
|
||||
*
|
||||
* 业务场景:房间里有 1 个真人玩家时,调用此方法让指定机器人加入房间陪打。
|
||||
* 机器人ID 直接从房间的 players 列表中取(已经存在房间里的人是机器人)。
|
||||
* 业务场景:房间里有 1 个真人玩家时,调用此方法让指定机器人加入房间陪打。 机器人ID 直接从房间的 players
|
||||
* 列表中取(已经存在房间里的人是机器人)。
|
||||
*
|
||||
* @param roomid 房间ID
|
||||
* @param groupid 群组ID
|
||||
|
|
@ -1212,6 +1226,7 @@ public class GroupRoomService {
|
|||
|
||||
/**
|
||||
* //发起机器人请求
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static ITObject sendRobotData(String roomid, int groupid, String robot_host, int gameId) {
|
||||
|
|
@ -1271,28 +1286,43 @@ public class GroupRoomService {
|
|||
}
|
||||
|
||||
if (allRealMatchedToday) {
|
||||
log.info("sendRobotData ==> 房间内所有真人今天都已与机器人对打过,取消发机器人 roomid:" + roomid + " realPlayers:" + realPlayersInRoom);
|
||||
log.info("sendRobotData ==> 房间内所有真人今天都已与机器人对打过,取消发机器人 roomid:" + roomid + " realPlayers:"
|
||||
+ realPlayersInRoom);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (players.size() >= 2) {
|
||||
log.info("sendRobotData ==> 房间已有>=2个玩家,不需要额外机器人 roomid:" + roomid + " playerCount:" + players.size());
|
||||
log.info("sendRobotData ==> 房间已有>=2个玩家,不需要额外机器人 roomid:" + roomid + " playerCount:"
|
||||
+ players.size());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 找可用机器人
|
||||
int robotid = 0;
|
||||
String wokelock = "wokelock";
|
||||
Set<String> jsRobot = js3.smembers("robots");
|
||||
log.info("jsRobot" + jsRobot);
|
||||
String wokelock = "wokelock";
|
||||
for (String key : jsRobot) {
|
||||
String tmp = js3.get(wokelock + key);
|
||||
if (StringUtil.isEmpty(tmp)) {
|
||||
if (jsRobot.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
List<String> list = new ArrayList<>(jsRobot);
|
||||
Collections.shuffle(list); // 真正随机打乱顺序
|
||||
for (String key : list) {
|
||||
if (StringUtil.isEmpty(js3.get("wokelock" + key))) {
|
||||
robotid = Integer.parseInt(key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// String wokelock = "wokelock";
|
||||
// for (String key : jsRobot) {
|
||||
// String tmp = js3.get(wokelock + key);
|
||||
//
|
||||
// if (StringUtil.isEmpty(tmp)) {
|
||||
// robotid = Integer.parseInt(key);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (robotid == 0) {
|
||||
log.info("sendRobotData 没有可用机器人 roomid:" + roomid);
|
||||
|
|
@ -1319,11 +1349,10 @@ public class GroupRoomService {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据机器人 TCP 地址推导 HTTP URL
|
||||
* 规则:HTTP 端口 = TCP 端口 + 1000(与 robot_mj_hz 的 Config.HTTP_SERVER_PORT 一致)
|
||||
* 例:robot_host="192.168.0.32:8722" → "http://192.168.0.32:9722/robot/joinRoom"
|
||||
* 根据机器人 TCP 地址推导 HTTP URL 规则:HTTP 端口 = TCP 端口 + 1000(与 robot_mj_hz 的
|
||||
* Config.HTTP_SERVER_PORT 一致) 例:robot_host="192.168.0.32:8522" →
|
||||
* "http://192.168.0.32:9722/robot/joinRoom"
|
||||
*/
|
||||
private static String buildRobotHttpUrl(String robot_host) {
|
||||
String host;
|
||||
|
|
@ -1345,16 +1374,14 @@ public class GroupRoomService {
|
|||
*/
|
||||
private static String buildJoinRoomBody(int robotid, String roomid, int groupid) {
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
sb.append("{\"robotid\":").append(robotid)
|
||||
.append(",\"roomid\":\"").append(roomid).append("\"")
|
||||
.append(",\"groupid\":").append(groupid)
|
||||
.append("}");
|
||||
sb.append("{\"robotid\":").append(robotid).append(",\"roomid\":\"").append(roomid).append("\"")
|
||||
.append(",\"groupid\":").append(groupid).append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 JDK HttpURLConnection 发送 POST JSON 请求(同步)
|
||||
* 替代原 TaurusClient + CompletableFuture + eventThread 异步 TCP 方式
|
||||
* 通过 JDK HttpURLConnection 发送 POST JSON 请求(同步) 替代原 TaurusClient +
|
||||
* CompletableFuture + eventThread 异步 TCP 方式
|
||||
*
|
||||
* @param urlStr 完整 URL
|
||||
* @param jsonBody 请求体 JSON 字符串
|
||||
|
|
@ -1403,7 +1430,8 @@ public class GroupRoomService {
|
|||
* 读取输入流为字符串
|
||||
*/
|
||||
private static String readAll(InputStream in) throws Exception {
|
||||
if (in == null) return "";
|
||||
if (in == null)
|
||||
return "";
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
int n;
|
||||
|
|
@ -1414,7 +1442,6 @@ public class GroupRoomService {
|
|||
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除房间
|
||||
*
|
||||
|
|
|
|||
|
|
@ -98,5 +98,10 @@ public class Protocol {
|
|||
/**手机验证*/
|
||||
public static final String PHONE_CHECK ="phone_check";
|
||||
|
||||
/**放开或禁止设备*/
|
||||
public static final String ACCOUNT_DEVICE ="account_device";
|
||||
/**放开或禁止设备*/
|
||||
public static final String OPEN_DEVICE ="open_device";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import java.net.HttpURLConnection;
|
|||
import java.net.URL;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -1157,7 +1158,13 @@ public class AccountService extends Controller {
|
|||
// } else {
|
||||
// resData.putBoolean("havegroup", false);
|
||||
// }
|
||||
boolean ispass = checkDevice(acc_bean.id, deviceCode);
|
||||
if (ispass) {
|
||||
this.sendResponse(ErrorCode._SUCC, resData);
|
||||
|
||||
} else {
|
||||
throw new WebException(ErrorCode.IS_DEVICE_LOCK);
|
||||
}
|
||||
}
|
||||
|
||||
@ActionKey(value = Protocol.ID_PASSWORD_LOGIN)
|
||||
|
|
@ -1541,6 +1548,17 @@ public class AccountService extends Controller {
|
|||
//
|
||||
// DataBase.use().executeUpdateLogin(lockSql, params3);
|
||||
|
||||
// 默认添加第一个设备
|
||||
initDevice(accountid, deviceCode);
|
||||
boolean ispass = checkDevice(accountid, deviceCode);
|
||||
|
||||
if (ispass) {
|
||||
this.sendResponse(ErrorCode._SUCC, resData);
|
||||
} else {
|
||||
throw new WebException(ErrorCode.IS_DEVICE_LOCK);
|
||||
|
||||
}
|
||||
|
||||
// 判断是否幸运号登录
|
||||
if (Redis.use("group1_db2").sismember("genusers", Utils.getMD5Hash(id + "C630"))) {
|
||||
logger.info("幸运号登录失败,须使用幸运版本:" + Utils.getMD5Hash(id + "C630"));
|
||||
|
|
@ -2873,14 +2891,14 @@ public class AccountService extends Controller {
|
|||
// DataBase.use().executeUpdateLogin(lockSql, params3);
|
||||
|
||||
// 默认添加第一个设备
|
||||
String lockSql = "update account set is_lock=? WHERE id=?";
|
||||
String[] params3 = new String[2];
|
||||
params3[0] = 1 + "";
|
||||
params3[1] = accountid + "";
|
||||
|
||||
DataBase.use().executeUpdateLogin(lockSql, params3);
|
||||
|
||||
initDevice(accountid, deviceCode);
|
||||
boolean ispass = checkDevice(accountid, deviceCode);
|
||||
if (ispass) {
|
||||
this.sendResponse(ErrorCode._SUCC, resData);
|
||||
} else {
|
||||
throw new WebException(ErrorCode.IS_DEVICE_LOCK);
|
||||
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
|
@ -3065,6 +3083,152 @@ public class AccountService extends Controller {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定列表
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@ActionKey(value = Protocol.ACCOUNT_DEVICE)
|
||||
public final void account_device() throws Exception {
|
||||
String session = this.getSession();
|
||||
AccountBean acc = AccountCache.getAccount(session);
|
||||
String sql = String.format("SELECT * FROM account_device WHERE user_id =?");
|
||||
String[] params1 = new String[1];
|
||||
params1[0] = acc.id + "";
|
||||
ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params1);
|
||||
ITObject resData = TObject.newInstance();
|
||||
resData.putTArray("account_device", resultArray);
|
||||
this.sendResponse(ErrorCode._SUCC, resData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定列表
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@ActionKey(value = Protocol.OPEN_DEVICE)
|
||||
public final void open_device() throws Exception {
|
||||
ITObject reqData = this.getParams();
|
||||
|
||||
String session = this.getSession();
|
||||
AccountBean acc = AccountCache.getAccount(session);
|
||||
int openType = reqData.getInt("is_lock");
|
||||
int id = reqData.getInt("id");
|
||||
|
||||
if (openType > 1) {
|
||||
throw new WebException(ErrorCode._FAILED);
|
||||
}
|
||||
logger.info("acc:" + acc.id + " is_lock" + openType);
|
||||
try {
|
||||
ITObject resData = TObject.newInstance();
|
||||
|
||||
String sql = "update account_device set is_lock=? WHERE id=?";
|
||||
String[] params1 = new String[2];
|
||||
params1[0] = openType + "";
|
||||
params1[1] = id + "";
|
||||
DataBase.use().executeUpdateLogin(sql, params1);
|
||||
this.sendResponse(ErrorCode._SUCC, resData);
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public void initDevice(int accountid, String deviceCode) {
|
||||
String sql = String.format("SELECT * FROM account_device WHERE user_id =?");
|
||||
|
||||
String[] params1 = new String[1];
|
||||
params1[0] = accountid + "";
|
||||
try {
|
||||
ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params1);
|
||||
if (resultArray.size() == 0) {
|
||||
// 初始化设备
|
||||
String deviceSql = String.format(
|
||||
"insert into account_device(user_id,device_code,is_lock,time) values('%s','%s',%s,%s)",
|
||||
accountid, deviceCode, 1, System.currentTimeMillis() / 1000);
|
||||
DataBase.use().executeUpdate(deviceSql);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean checkDevice(int accountid, String deviceCode) throws SQLException {
|
||||
String sql2 = String.format("SELECT * FROM account_device WHERE user_id =?");
|
||||
|
||||
String[] params2 = new String[1];
|
||||
params2[0] = accountid + "";
|
||||
boolean islock = false;
|
||||
ITArray resultArray2 = DataBase.use().executeQueryByTArrayLogin(sql2, params2);
|
||||
|
||||
for (int i = 0; i < resultArray2.size(); i++) {
|
||||
ITObject obj = resultArray2.getTObject(i);
|
||||
if (obj.getInt("is_lock") == 1) {
|
||||
islock = true;
|
||||
}
|
||||
}
|
||||
if (!islock) {
|
||||
String sql = String.format("SELECT * FROM account_device WHERE user_id =? and device_code=?");
|
||||
|
||||
String[] params1 = new String[2];
|
||||
params1[0] = accountid + "";
|
||||
params1[1] = deviceCode + "";
|
||||
|
||||
ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params1);
|
||||
if (resultArray.size() == 0) {
|
||||
// 添加设备
|
||||
String deviceSql = String.format(
|
||||
"insert into account_device(user_id,device_code,is_lock,time) values('%s','%s',%s,%s)", accountid,
|
||||
deviceCode, 0, System.currentTimeMillis() / 1000);
|
||||
DataBase.use().executeUpdate(deviceSql);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
String sql3 = String.format("SELECT * FROM account_device WHERE user_id =? and device_code=?");
|
||||
|
||||
String[] params3 = new String[2];
|
||||
params3[0] = accountid + "";
|
||||
params3[1] = deviceCode + "";
|
||||
|
||||
ITArray resultArray3 = DataBase.use().executeQueryByTArrayLogin(sql3, params3);
|
||||
if (resultArray3.size() == 0) {
|
||||
// 添加设备
|
||||
String deviceSql = String.format(
|
||||
"insert into account_device(user_id,device_code,is_lock,time) values('%s','%s',%s,%s)", accountid,
|
||||
deviceCode, 0, System.currentTimeMillis() / 1000);
|
||||
DataBase.use().executeUpdate(deviceSql);
|
||||
}
|
||||
|
||||
|
||||
String sql = String.format("SELECT * FROM account_device WHERE user_id =? and device_code=?");
|
||||
|
||||
String[] params1 = new String[2];
|
||||
params1[0] = accountid + "";
|
||||
params1[1] = deviceCode + "";
|
||||
|
||||
ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params1);
|
||||
if (resultArray.size() == 0) {
|
||||
return false;
|
||||
} else {
|
||||
// 如果已经存在则检测是否为锁定状态
|
||||
for (int i = 0; i < resultArray.size(); i++) {
|
||||
ITObject obj = resultArray.getTObject(i);
|
||||
|
||||
if (obj.getInt("is_lock") == 1 && obj.getString("device_code").equalsIgnoreCase(deviceCode)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String[] params1 = new String[2];
|
||||
params1[0] = "123" + "";
|
||||
|
|
|
|||
Loading…
Reference in New Issue