1.优化查询用户信息接口/api/v1/getPlayerInfo,如果没有用户则创建
This commit is contained in:
@@ -148,7 +148,18 @@ class GameController extends BaseController
|
||||
return $this->success($cached);
|
||||
}
|
||||
|
||||
$player = DicePlayer::field(self::PLAYER_INFO_DB_FIELDS)->where('username', $username)->where('dept_id', $deptId)->find();
|
||||
try {
|
||||
$logic = new UserLogic();
|
||||
$player = $logic->findOrCreatePlayerByUsername(
|
||||
$username,
|
||||
$this->agentAdminId($request),
|
||||
$deptId > 0 ? $deptId : null
|
||||
);
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage(), ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
$player = DicePlayer::field(self::PLAYER_INFO_DB_FIELDS)->where('id', (int) $player->id)->find();
|
||||
if (!$player) {
|
||||
return $this->fail('User not found', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user