diff --git a/Service/Application.Domain.Entity/Application.Domain.Entity.csproj b/Service/Application.Domain.Entity/Application.Domain.Entity.csproj
index f7d78e1..8f5e89a 100644
--- a/Service/Application.Domain.Entity/Application.Domain.Entity.csproj
+++ b/Service/Application.Domain.Entity/Application.Domain.Entity.csproj
@@ -10,8 +10,4 @@
-
-
-
-
diff --git a/Service/Application.Domain.Entity/resource/base/MapNear.cs b/Service/Application.Domain.Entity/base/MapNear.cs
similarity index 100%
rename from Service/Application.Domain.Entity/resource/base/MapNear.cs
rename to Service/Application.Domain.Entity/base/MapNear.cs
diff --git a/Service/Application.Domain.Entity/game/game/game_chat.cs b/Service/Application.Domain.Entity/game/game/game_chat.cs
new file mode 100644
index 0000000..18eacb4
--- /dev/null
+++ b/Service/Application.Domain.Entity/game/game/game_chat.cs
@@ -0,0 +1,69 @@
+using SqlSugar;
+using System;
+
+namespace Application.Domain.Entity
+{
+ [Tenant("Kg.SeaTime.Game")]
+ public class game_chat
+ {
+ ///
+ /// chatId
+ ///
+ [SugarColumn(IsPrimaryKey = true, Length = 50)]
+ public string chatId { get; set; }
+
+ ///
+ /// code
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string? code { get; set; }
+
+ ///
+ /// areaId
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? areaId { get; set; }
+
+ ///
+ /// userId
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string? userId { get; set; }
+
+ ///
+ /// par
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string? par { get; set; }
+
+ ///
+ /// sign
+ ///
+ [SugarColumn(Length = 255, IsNullable = true)]
+ public string? sign { get; set; }
+
+ ///
+ /// addTime
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? addTime { get; set; }
+
+ ///
+ /// sort
+ ///
+ [SugarColumn(IsNullable = true)]
+ public long? sort { get; set; }
+
+ ///
+ /// delTime
+ ///
+ [SugarColumn(IsNullable = true)]
+ public long? delTime { get; set; }
+
+ ///
+ /// state
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? state { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Service/Application.Domain.Entity/model/UserModel.cs b/Service/Application.Domain.Entity/model/UserModel.cs
new file mode 100644
index 0000000..d1c58dc
--- /dev/null
+++ b/Service/Application.Domain.Entity/model/UserModel.cs
@@ -0,0 +1,11 @@
+namespace Application.Domain.Entity;
+
+public class UserModel
+{
+ public string userNo { get; set; }
+ public string nick { get; set; }
+ public string sex { get; set; }
+ public string headImg { get; set; }
+ public int area { get; set; }
+ public string icon { get; set; }
+}
\ No newline at end of file
diff --git a/Service/Application.Domain.Entity/view/GameChatView.cs b/Service/Application.Domain.Entity/view/GameChatView.cs
new file mode 100644
index 0000000..20dd86b
--- /dev/null
+++ b/Service/Application.Domain.Entity/view/GameChatView.cs
@@ -0,0 +1,8 @@
+namespace Application.Domain.Entity;
+
+public class GameChatView
+{
+ public game_chat chat { get; set; }
+ public UserModel user { get; set; }
+
+}
\ No newline at end of file
diff --git a/Service/Application.Domain/Enum/GameChatEnum.cs b/Service/Application.Domain/Enum/GameChatEnum.cs
new file mode 100644
index 0000000..a30f4d3
--- /dev/null
+++ b/Service/Application.Domain/Enum/GameChatEnum.cs
@@ -0,0 +1,14 @@
+namespace Application.Domain;
+
+public class GameChatEnum
+{
+ public enum Code
+ {
+ Public,//公共
+ Group,//帮派
+ Team,//队伍
+ Region,//全区
+ Dress,//全服
+ System//系统
+ }
+}
\ No newline at end of file
diff --git a/Service/Application.Domain/GlobalUsings.cs b/Service/Application.Domain/GlobalUsings.cs
index 9a7ca0e..25af9a9 100644
--- a/Service/Application.Domain/GlobalUsings.cs
+++ b/Service/Application.Domain/GlobalUsings.cs
@@ -2,4 +2,5 @@
global using SqlSugar;
global using Application.Domain.Entity;
global using Photon.Core.Redis;
-global using Photon.Core.Assist;
\ No newline at end of file
+global using Photon.Core.Assist;
+global using Application.Service.Pub;
diff --git a/Service/Application.Domain/Services/Interface/Chat/IGameChatService.cs b/Service/Application.Domain/Services/Interface/Chat/IGameChatService.cs
new file mode 100644
index 0000000..6d1f618
--- /dev/null
+++ b/Service/Application.Domain/Services/Interface/Chat/IGameChatService.cs
@@ -0,0 +1,13 @@
+namespace Application.Domain;
+
+public interface IGameChatService
+{
+ Task> GetChatTop(int areaId, int top, string teamId, string groupId);
+
+ Task> GetChatData(int type, int areaId, string teamId, string groupId, int page, int limit,
+ RefAsync total);
+
+ Task SendChat(string userId, int areaId, string code, string sign, string par = "");
+ Task DeleteChat(string chatId);
+
+}
\ No newline at end of file
diff --git a/Service/Application.Domain/Services/Service/Chat/GameChatService.cs b/Service/Application.Domain/Services/Service/Chat/GameChatService.cs
new file mode 100644
index 0000000..a6c9a0c
--- /dev/null
+++ b/Service/Application.Domain/Services/Service/Chat/GameChatService.cs
@@ -0,0 +1,153 @@
+namespace Application.Domain;
+
+public class GameChatService : IGameChatService, ITransient
+{
+ private readonly ISqlSugarClient _dbClient;
+ private readonly IRedisCache _redisClient;
+
+ public GameChatService(ISqlSugarClient dbClient, IRedisCache redisClient)
+ {
+ _dbClient = dbClient;
+ _redisClient = redisClient;
+ }
+
+ public async Task> GetChatTop(int areaId, int top, string teamId, string groupId)
+ {
+ var db = _dbClient.AsTenant().GetConnectionWithAttr();
+ List allCode = new List() { "Public", "Region", "System" };
+ var data = await db.Queryable().Where(it => it.state == 1 &&
+ (
+ (allCode.Contains(it.code) && it.areaId == areaId) ||
+ (it.code == "Group" && it.par == groupId) ||
+ (it.code == "Team" && it.par == teamId) ||
+ (it.code == "Dress")
+ )
+ ).Take(top).OrderByDescending(it => it.sort).ToListAsync();
+
+ var result = new List();
+ foreach (var item in data)
+ {
+ var userModel = await UserModelTool.GetUserView(item.userId, true);
+ result.Add(new GameChatView() { chat = item, user = userModel });
+ }
+
+ return result;
+ }
+
+ public async Task> GetChatData(int type, int areaId, string teamId, string groupId, int page,
+ int limit,
+ RefAsync total)
+ {
+ List data = new List();
+ var db = _dbClient.AsTenant().GetConnectionWithAttr();
+ if (type == 0)
+ {
+ List allCode = new List() { "Public", "Region", "System" };
+ data = await db.Queryable().Where(it => it.state == 1 &&
+ (
+ (allCode.Contains(it.code) && it.areaId == areaId) ||
+ (it.code == "Group" && it.par == groupId) ||
+ (it.code == "Team" && it.par == teamId) ||
+ (it.code == "Dress")
+ )
+ ).OrderByDescending(it => it.sort).ToPageListAsync(page, limit, total);
+ }
+ else if (type == 1) //队伍
+ {
+ data = await db.Queryable().Where(it => it.state == 1 && it.code == "Team" && it.par == teamId
+ ).OrderByDescending(it => it.sort).ToPageListAsync(page, limit, total);
+ }
+ else if (type == 2) //帮派
+ {
+ data = await db.Queryable().Where(it => it.state == 1 && it.code == "Group" && it.par == groupId
+ ).OrderByDescending(it => it.sort).ToPageListAsync(page, limit, total);
+ }
+ else if (type == 3) //全区
+ {
+ data = await db.Queryable()
+ .Where(it => it.state == 1 && it.code == "Region" && it.areaId == areaId
+ ).OrderByDescending(it => it.sort).ToPageListAsync(page, limit, total);
+ }
+ else if (type == 4) //全服
+ {
+ data = await db.Queryable().Where(it => it.state == 1 && it.code == "Dress"
+ ).OrderByDescending(it => it.sort).ToPageListAsync(page, limit, total);
+ }
+ else if (type == 5) //系统
+ {
+ data = await db.Queryable()
+ .Where(it => it.state == 1 && it.code == "System" && it.areaId == areaId
+ ).OrderByDescending(it => it.sort).ToPageListAsync(page, limit, total);
+ }
+ else
+ {
+ data = new List();
+ }
+ var result = new List();
+ foreach (var item in data)
+ {
+ var userModel = await UserModelTool.GetUserView(item.userId, true);
+ result.Add(new GameChatView() { chat = item, user = userModel });
+ }
+
+ return result;
+ }
+
+ ///
+ /// 添加聊天
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task SendChat(string userId, int areaId, string code, string sign, string par = "")
+ {
+ game_chat chat = new game_chat();
+ chat.chatId = StringAssist.NewGuid;
+ chat.userId = userId;
+ chat.areaId = areaId;
+ chat.code = code;
+ chat.par = par;
+ chat.sign = sign;
+ chat.state = 1;
+ chat.addTime = DateTime.Now;
+ chat.sort = TimeExtend.GetTimeStampSeconds;
+ chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(3));
+ switch (code)
+ {
+ case "Region":
+ chat.sort += 300; //五分钟
+ break;
+
+ case "Dress":
+ chat.sort += 600; //10分钟
+ break;
+ case "System":
+ chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddHours(6));
+ break;
+ case "Group":
+ chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddHours(6));
+ break;
+ case "Team":
+ chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddHours(6));
+ break;
+ }
+
+ var db = _dbClient.AsTenant().GetConnectionWithAttr();
+ return await db.Insertable(chat).ExecuteCommandAsync() > 0;
+ }
+
+ ///
+ /// 删除聊天
+ ///
+ ///
+ ///
+ public async Task DeleteChat(string chatId)
+ {
+ var db = _dbClient.AsTenant().GetConnectionWithAttr();
+ return await db.Updateable().SetColumns(it => it.state == 0).Where(it => it.chatId == chatId)
+ .ExecuteCommandAsync() > 0;
+ }
+}
\ No newline at end of file
diff --git a/Service/Application.Domain/Tool/GameTool.cs b/Service/Application.Domain/Tool/Base/GameTool.cs
similarity index 97%
rename from Service/Application.Domain/Tool/GameTool.cs
rename to Service/Application.Domain/Tool/Base/GameTool.cs
index 0c0cb61..bd90aba 100644
--- a/Service/Application.Domain/Tool/GameTool.cs
+++ b/Service/Application.Domain/Tool/Base/GameTool.cs
@@ -1,5 +1,4 @@
-using Photon.Core.Assist;
-
+
namespace Application.Domain;
public class GameTool
@@ -38,4 +37,5 @@ public class GameTool
List onArea = new List() {"0",area.ToString() };
return onArea.Any(it => areas.Contains(it));
}
+
}
\ No newline at end of file
diff --git a/Service/Application.Domain/Tool/ModelTool/UserModelTool.cs b/Service/Application.Domain/Tool/ModelTool/UserModelTool.cs
new file mode 100644
index 0000000..b96c197
--- /dev/null
+++ b/Service/Application.Domain/Tool/ModelTool/UserModelTool.cs
@@ -0,0 +1,32 @@
+namespace Application.Domain;
+
+public class UserModelTool
+{
+ ///
+ /// 获取用户模型
+ ///
+ ///
+ ///
+ ///
+ public static async Task GetUserView(string userId,bool addIcon=false)
+ {
+ UserModel result = new UserModel();
+ var userService = App.GetService();
+ var userInfo = await userService.GetUserInfoByUserId(userId);
+ if (userInfo != null)
+ {
+ result.userNo = userInfo.userNo;
+ result.nick = userInfo.nick;
+ result.sex = userInfo.sex;
+ result.headImg = userInfo.headImg;
+ result.area = (int)userInfo.areaId;
+ result.icon = "";
+ if (addIcon)//获取图标信息
+ {
+ result.icon = "";
+ }
+ }
+
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/Service/Application.Service.Pub/Extends/TimeExtend.cs b/Service/Application.Service.Pub/Extends/TimeExtend.cs
new file mode 100644
index 0000000..be6027d
--- /dev/null
+++ b/Service/Application.Service.Pub/Extends/TimeExtend.cs
@@ -0,0 +1,24 @@
+namespace Application.Service.Pub;
+
+public class TimeExtend
+{
+ public static long GetTimeStampSeconds
+ {
+ get => Convert.ToInt64((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
+ }
+
+ public static long GetTimeStampMilliseconds
+ {
+ get => Convert.ToInt64((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalMilliseconds);
+ }
+
+ public static long GetTimeStampBySeconds(DateTime time)
+ {
+ return Convert.ToInt64((time - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
+ }
+
+ public static long GetTimeStampByMilliseconds(DateTime time)
+ {
+ return Convert.ToInt64((time - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalMilliseconds);
+ }
+}
\ No newline at end of file
diff --git a/Service/Application.Web/Controllers/Chat/ChatController.cs b/Service/Application.Web/Controllers/Chat/ChatController.cs
new file mode 100644
index 0000000..7c31719
--- /dev/null
+++ b/Service/Application.Web/Controllers/Chat/ChatController.cs
@@ -0,0 +1,117 @@
+using Microsoft.AspNetCore.Mvc;
+
+namespace Application.Web.Controllers.Chat;
+
+///
+/// 公聊接口
+///
+[Route("Chat/[controller]/[action]")]
+[ApiController]
+[Authorize]
+public class ChatController : ControllerBase
+{
+ private readonly IGameChatService _chatService;
+
+ public ChatController(IGameChatService chatService)
+ {
+ _chatService = chatService;
+ }
+
+ ///
+ /// 获取公聊信息
+ ///
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task GetChatData(int type, int page)
+ {
+ int areaId = StateHelper.areaId;
+ string teamId = "";
+ string groupId = "";
+ RefAsync Total = 0;
+ var data = await _chatService.GetChatData(type, areaId, teamId, groupId, page, 10, Total);
+ //物品数量
+ int sendGoodsCount = 0;
+ string sendGoodsName = "";
+ switch (type)
+ {
+ case 0:
+ sendGoodsCount = 199;
+ sendGoodsName = "小海螺";
+ break;
+ case 3:
+ sendGoodsCount = 15;
+ sendGoodsName = "大海螺";
+ break;
+ case 4:
+ sendGoodsCount = 9;
+ sendGoodsName = "金海螺";
+ break;
+ }
+
+
+ return PoAction.Ok(new { data, total = Total.Value ,sendGoodsCount,sendGoodsName});
+ }
+
+ ///
+ /// 发言
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task SendChat([FromBody] SendChatParms pars)
+ {
+ if (string.IsNullOrEmpty(pars.sign))
+ {
+ return PoAction.Message("发言内容不能为空!");
+ }
+
+ string userId = StateHelper.userId;
+ int areaId = StateHelper.areaId;
+ string par = string.Empty;
+ string code = GameChatEnum.Code.Public.ToString();
+ bool isSend = false;
+ switch (pars.type)
+ {
+ case 0:
+ isSend = true;
+ code =nameof(GameChatEnum.Code.Public);
+ break;
+ case 1:
+ isSend = true;
+ code = nameof(GameChatEnum.Code.Team);
+ par = "";
+ break;
+ case 2:
+ isSend = true;
+ code = nameof(GameChatEnum.Code.Group);
+ par="";
+ break;
+ case 3:
+ isSend = true;
+ code = nameof(GameChatEnum.Code.Region);
+ break;
+ case 4:
+ isSend = true;
+ code = nameof(GameChatEnum.Code.Dress);
+ break;
+
+ }
+
+ if (isSend == false)
+ {
+ return PoAction.Message("无法发言!");
+ }
+ string sign = StringAssist.NoHTML(pars.sign);
+ bool result = await _chatService.SendChat(userId, areaId, code, sign, par);
+ if (result)
+ {
+ return PoAction.Ok(true);
+ }
+ else
+ {
+ return PoAction.Message("发送失败,请稍后尝试!");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Service/Application.Web/Controllers/Map/MapController.cs b/Service/Application.Web/Controllers/Map/MapController.cs
index eb75aac..99161a2 100644
--- a/Service/Application.Web/Controllers/Map/MapController.cs
+++ b/Service/Application.Web/Controllers/Map/MapController.cs
@@ -13,11 +13,13 @@ public class MapController : ControllerBase
{
private readonly IUnitUserService _userService;
private readonly IGameMapService _mapService;
+ private readonly IGameChatService _chatService;
- public MapController(IUnitUserService userService, IGameMapService mapService)
+ public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService)
{
_userService = userService;
_mapService = mapService;
+ _chatService = chatService;
}
///
@@ -29,6 +31,7 @@ public class MapController : ControllerBase
public async Task GetMapData(string? map)
{
string userId = StateHelper.userId;
+ int area = StateHelper.areaId;
var onMap = await _mapService.GetUserOnMap(userId);
game_city_map mapInfo = new game_city_map();
if (string.IsNullOrEmpty(map))
@@ -40,10 +43,14 @@ public class MapController : ControllerBase
mapInfo = await _mapService.GetMapInfo(map);
}
+ //公聊信息
+ string teamId = "";
+ string groupId = "";
+ var chatData = await _chatService.GetChatTop(area, 2, teamId, groupId);
//NPC信息
-
+
var npcData = await _mapService.GetMapNpc(mapInfo.mapId);
- npcData = npcData.FindAll(it => GameTool.AreaVerify(StateHelper.areaId,it.areaId));
+ npcData = npcData.FindAll(it => GameTool.AreaVerify(StateHelper.areaId, it.areaId));
//城市信息
var cityInfo = await _mapService.GetCityInfo((int)mapInfo.cityId);
@@ -54,7 +61,7 @@ public class MapController : ControllerBase
#endregion
- object ret = new { mapInfo, cityInfo, npcData };
+ object ret = new { mapInfo, cityInfo, npcData, chatData };
return PoAction.Ok(ret);
}
diff --git a/Service/Application.Web/Model/RequestParms/Chat/SendChatParms.cs b/Service/Application.Web/Model/RequestParms/Chat/SendChatParms.cs
new file mode 100644
index 0000000..685438d
--- /dev/null
+++ b/Service/Application.Web/Model/RequestParms/Chat/SendChatParms.cs
@@ -0,0 +1,7 @@
+namespace Application.Web;
+
+public class SendChatParms
+{
+ public int type { get; set; }
+ public string sign { get; set; }
+}
\ No newline at end of file
diff --git a/Web/src/components/Base/Pagination.vue b/Web/src/components/Base/Pagination.vue
index 3df5894..784b5c4 100644
--- a/Web/src/components/Base/Pagination.vue
+++ b/Web/src/components/Base/Pagination.vue
@@ -1,31 +1,26 @@
-