222
This commit is contained in:
@@ -23,6 +23,8 @@ public interface IGameMapService
|
||||
Task<UserOnMap> GetUserOnMapInfo(string userId);
|
||||
Task SetUserMapDefult(string userId);
|
||||
Task<game_city_map> GetToMapInfo(string userId, string toMap, bool isUpUserMap = true, bool isChangeCity = false);
|
||||
Task<List<unit_user_map>> GetUserCityMapData(string userId);
|
||||
Task<bool> AddUserCityMap(string userId, int cityId);
|
||||
#endregion
|
||||
|
||||
#region 其他相关
|
||||
|
||||
@@ -290,6 +290,42 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<unit_user_map>> GetUserCityMapData(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKey, "UserCityMap");
|
||||
if (await redis.HExistsHashAsync(key, userId))
|
||||
{
|
||||
return await redis.GetHashAsync<List<unit_user_map>>(key, userId);
|
||||
}
|
||||
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_map>();
|
||||
var data = await db.Queryable<unit_user_map>().Where(it => it.userId == userId).ToListAsync();
|
||||
await redis.AddHashAsync(key, userId, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
private async Task ClearUserCityMapCache(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKey, "UserCityMap");
|
||||
await redis.DelHashAsync(key, userId);
|
||||
}
|
||||
|
||||
public async Task<bool> AddUserCityMap(string userId, int cityId)
|
||||
{
|
||||
unit_user_map map = new unit_user_map();
|
||||
map.umId = $"{userId}_{cityId}";
|
||||
map.userId = userId;
|
||||
map.cityId = cityId;
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_map>();
|
||||
bool result = await db.Storageable(map).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearUserCityMapCache(userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 其他相关
|
||||
|
||||
Reference in New Issue
Block a user