public HttpResponseMessage WinDataByUser([FromUri] GameWinDataRequest request) { ResultData resultData = new ResultData(); int intUid = UserTokenUtils.getIdByTokenString(request.token); if (intUid == -1) { resultData.status = "1"; resultData.message = "token解析失败"; return(ToJsonUtil.toJson(resultData)); } int intGameId = 0; if (string.IsNullOrWhiteSpace(request.gameId) || !int.TryParse(request.gameId, out intGameId)) { resultData.status = "1"; resultData.message = "游戏ID不正确"; return(ToJsonUtil.toJson(resultData)); } resultData.status = "0"; var dataList = game_RecordDAL.GetWinDataByUser(intUid, request.gameId, request.topNumber); if (dataList != null && dataList.Count > 0) { resultData.data = dataList.Select(p => new { time = p.time_stamp.ToString("yyyy-MM-dd HH:mm:ss"), remark = p.result_message.TrimEnd(',') }); } return(ToJsonUtil.toJson(resultData)); }
public UserAccount getUserInfoByToken(string token) { if (string.IsNullOrEmpty(token) || "null" == token || "undefined" == token) { return(null); } int userId = UserTokenUtils.getIdByTokenString(token); string sql = @"SELECT *, case when DATEDIFF(day, addtime, getdate())> isnull((select top 1 value from rrl_config where item = 'NewUser_Confirm_Days'),7) then '0' ELSE '1' end as is_news_user FROM rrl_user WHERE id = @id"; try { SqlDataBase db = new SqlDataBase(); UserAccount user = db.Single <UserAccount>(sql, new { id = userId }); return(user); } catch (Exception) { return(null); } /* * string sql = "SELECT * FROM rrl_user WHERE short_time_token = @token"; * try * { * SqlDataBase db = new SqlDataBase(); * UserAccount user = db.Single<UserAccount>(sql, new { token = token }); * return user; * } * catch (Exception) * { * * return null; * } */ }