From 4636169e00fcbfddaa864b29f5e8d67ced8ec946 Mon Sep 17 00:00:00 2001
From: LN <2826967552@qq.com>
Date: Mon, 13 Jul 2026 14:28:33 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A7=B0=E5=8F=B7=E8=B7=9F?=
=?UTF-8?q?=E5=BE=BD=E7=AB=A0=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../game/user/unit_user_badge.cs | 57 ++++++++++
.../game/user/unit_user_maxname.cs | 69 ++++++++++++
.../resource/game/game_badge.cs | 33 ++++++
.../resource/game/game_maxname.cs | 39 +++++++
.../Interface/Pub/IGameBadgeService.cs | 17 +++
.../Interface/Pub/IGameMaxNameService.cs | 6 +-
.../Services/Service/Pub/GameBadgeService.cs | 55 ++++++++++
.../Service/Pub/GameMaxNameService.cs | 36 ++++++-
.../Controllers/Pub/BadgeController.cs | 101 ++++++++++++++++++
.../Controllers/Pub/MaxnameController.cs | 84 +++++++++++++++
.../RequestParms/Maxname/UpdateBadgeParms.cs | 9 ++
.../Maxname/UpdateMaxnameParms.cs | 9 ++
12 files changed, 513 insertions(+), 2 deletions(-)
create mode 100644 Service/Application.Domain.Entity/game/user/unit_user_badge.cs
create mode 100644 Service/Application.Domain.Entity/game/user/unit_user_maxname.cs
create mode 100644 Service/Application.Domain.Entity/resource/game/game_badge.cs
create mode 100644 Service/Application.Domain.Entity/resource/game/game_maxname.cs
create mode 100644 Service/Application.Domain/Services/Interface/Pub/IGameBadgeService.cs
create mode 100644 Service/Application.Domain/Services/Service/Pub/GameBadgeService.cs
create mode 100644 Service/Application.Web/Controllers/Pub/BadgeController.cs
create mode 100644 Service/Application.Web/Controllers/Pub/MaxnameController.cs
create mode 100644 Service/Application.Web/Model/RequestParms/Maxname/UpdateBadgeParms.cs
create mode 100644 Service/Application.Web/Model/RequestParms/Maxname/UpdateMaxnameParms.cs
diff --git a/Service/Application.Domain.Entity/game/user/unit_user_badge.cs b/Service/Application.Domain.Entity/game/user/unit_user_badge.cs
new file mode 100644
index 0000000..c58f0fa
--- /dev/null
+++ b/Service/Application.Domain.Entity/game/user/unit_user_badge.cs
@@ -0,0 +1,57 @@
+using SqlSugar;
+using System;
+
+namespace Application.Domain.Entity
+{
+ [Tenant("Kg.SeaTime.Game")]
+ public class unit_user_badge
+ {
+ ///
+ /// ubId
+ ///
+ [SugarColumn(IsPrimaryKey = true, Length = 50)]
+ public string ubId { get; set; }
+
+ ///
+ /// userId
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string userId { get; set; }
+
+ ///
+ /// badgeId
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string badgeId { get; set; }
+
+ ///
+ /// name
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string name { get; set; }
+
+ ///
+ /// img
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string img { get; set; }
+
+ ///
+ /// show
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? show { get; set; }
+
+ ///
+ /// showChat
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? showChat { get; set; }
+
+ ///
+ /// addTime
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? addTime { get; set; }
+ }
+}
diff --git a/Service/Application.Domain.Entity/game/user/unit_user_maxname.cs b/Service/Application.Domain.Entity/game/user/unit_user_maxname.cs
new file mode 100644
index 0000000..9c53c06
--- /dev/null
+++ b/Service/Application.Domain.Entity/game/user/unit_user_maxname.cs
@@ -0,0 +1,69 @@
+using SqlSugar;
+using System;
+
+namespace Application.Domain.Entity
+{
+ [Tenant("Kg.SeaTime.Game")]
+ public class unit_user_maxname
+ {
+ ///
+ /// umnId
+ ///
+ [SugarColumn(IsPrimaryKey = true, Length = 50)]
+ public string umnId { get; set; }
+
+ ///
+ /// userId
+ ///
+ [SugarColumn(Length = 50, IsNullable = false)]
+ public string userId { get; set; }
+
+ ///
+ /// mnId
+ ///
+ [SugarColumn(Length = 50, IsNullable = false)]
+ public string mnId { get; set; }
+
+ ///
+ /// name
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string name { get; set; }
+
+ ///
+ /// img
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string img { get; set; }
+
+ ///
+ /// attr
+ ///
+ [SugarColumn(Length = 1000, IsNullable = true)]
+ public string attr { get; set; }
+
+ ///
+ /// count
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? count { get; set; }
+
+ ///
+ /// addTime
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? addTime { get; set; }
+
+ ///
+ /// endTime
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? endTime { get; set; }
+
+ ///
+ /// show
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? show { get; set; }
+ }
+}
diff --git a/Service/Application.Domain.Entity/resource/game/game_badge.cs b/Service/Application.Domain.Entity/resource/game/game_badge.cs
new file mode 100644
index 0000000..f085770
--- /dev/null
+++ b/Service/Application.Domain.Entity/resource/game/game_badge.cs
@@ -0,0 +1,33 @@
+using SqlSugar;
+using System;
+
+namespace Application.Domain.Entity
+{
+ [Tenant("Kg.SeaTime.Resource")]
+ public class game_badge
+ {
+ ///
+ /// badgeId
+ ///
+ [SugarColumn(IsPrimaryKey = true, Length = 50)]
+ public string badgeId { get; set; }
+
+ ///
+ /// name
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string name { get; set; }
+
+ ///
+ /// remark
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string remark { get; set; }
+
+ ///
+ /// img
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string img { get; set; }
+ }
+}
diff --git a/Service/Application.Domain.Entity/resource/game/game_maxname.cs b/Service/Application.Domain.Entity/resource/game/game_maxname.cs
new file mode 100644
index 0000000..c140d41
--- /dev/null
+++ b/Service/Application.Domain.Entity/resource/game/game_maxname.cs
@@ -0,0 +1,39 @@
+using SqlSugar;
+using System;
+
+namespace Application.Domain.Entity
+{
+ [Tenant("Kg.SeaTime.Resource")]
+ public class game_maxname
+ {
+ ///
+ /// mnId
+ ///
+ [SugarColumn(IsPrimaryKey = true, Length = 50)]
+ public string mnId { get; set; }
+
+ ///
+ /// name
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string name { get; set; }
+
+ ///
+ /// img
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string img { get; set; }
+
+ ///
+ /// attr
+ ///
+ [SugarColumn(Length = 1000, IsNullable = true)]
+ public string attr { get; set; }
+
+ ///
+ /// remark
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string remark { get; set; }
+ }
+}
diff --git a/Service/Application.Domain/Services/Interface/Pub/IGameBadgeService.cs b/Service/Application.Domain/Services/Interface/Pub/IGameBadgeService.cs
new file mode 100644
index 0000000..3ebb376
--- /dev/null
+++ b/Service/Application.Domain/Services/Interface/Pub/IGameBadgeService.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Application.Domain.Services
+{
+ public interface IGameBadgeService
+ {
+ #region unit_user_badge
+ Task GetUserShowBadgeCount(string userId);
+ Task GetUserShowBadgeOnCount(string userId);
+ Task UpdateUserBadgeShow(string ubId, int show);
+ Task GetUserBadegInfo(string ubId);
+ Task> GetUserBadgeList(string userId, int page, int limit, RefAsync total);
+ #endregion
+ }
+}
diff --git a/Service/Application.Domain/Services/Interface/Pub/IGameMaxNameService.cs b/Service/Application.Domain/Services/Interface/Pub/IGameMaxNameService.cs
index 54cf695..beec1a4 100644
--- a/Service/Application.Domain/Services/Interface/Pub/IGameMaxNameService.cs
+++ b/Service/Application.Domain/Services/Interface/Pub/IGameMaxNameService.cs
@@ -2,5 +2,9 @@
public interface IGameMaxNameService
{
-
+ #region unit_user_maxname
+ Task UpdateUserMaxname(unit_user_maxname name);
+ Task GetUserMaxnameInfo(string umnId);
+ Task> GetUserMaxnameList(string userId, int page, int limit, RefAsync total);
+ #endregion
}
\ No newline at end of file
diff --git a/Service/Application.Domain/Services/Service/Pub/GameBadgeService.cs b/Service/Application.Domain/Services/Service/Pub/GameBadgeService.cs
new file mode 100644
index 0000000..ced35b7
--- /dev/null
+++ b/Service/Application.Domain/Services/Service/Pub/GameBadgeService.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Application.Domain.Services
+{
+ public class GameBadgeService(ISqlSugarClient DbClient, IRedisCache redis) : IGameBadgeService, ITransient
+ {
+ #region unit_user_badge
+ public async Task GetUserShowBadgeCount(string userId)
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ return await db.Queryable().Where(i => i.userId == userId && i.show == 1).CountAsync();
+ }
+ public async Task GetUserShowBadgeOnCount(string userId)
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ return await db.Queryable().Where(i => i.userId == userId).SumAsync(i => (int)i.showChat);
+ }
+ public async Task UpdateUserBadgeShow(string ubId, int show)
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ bool isok = await db.Updateable().SetColumns(i => i.show == show).Where(i => i.ubId == ubId)
+ .ExecuteCommandAsync() > 0;
+ if (isok)
+ {
+ string key = string.Format(BaseCache.BaseCacheKeys, "UserBadge", "BadgeInfo");
+ await redis.DelHashAsync(key, ubId);
+ }
+ return isok;
+ }
+ public async Task GetUserBadegInfo(string ubId)
+ {
+ string key = string.Format(BaseCache.BaseCacheKeys, "UserBadge", "BadgeInfo");
+ var data = await redis.GetHashAsync(key, ubId);
+ if (data == null)
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ data = await db.Queryable().Where(i => i.ubId == ubId).SingleAsync();
+ if (data != null)
+ {
+ await redis.AddHashAsync(key, ubId, data);
+ }
+ }
+ return data;
+ }
+ public async Task> GetUserBadgeList(string userId, int page, int limit, RefAsync total)
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ return await db.Queryable().Where(i => i.userId == userId).OrderBy(i => i.addTime)
+ .ToPageListAsync(page, limit, total);
+ }
+ #endregion
+ }
+}
diff --git a/Service/Application.Domain/Services/Service/Pub/GameMaxNameService.cs b/Service/Application.Domain/Services/Service/Pub/GameMaxNameService.cs
index 94314da..770c29d 100644
--- a/Service/Application.Domain/Services/Service/Pub/GameMaxNameService.cs
+++ b/Service/Application.Domain/Services/Service/Pub/GameMaxNameService.cs
@@ -2,5 +2,39 @@
public class GameMaxNameService(ISqlSugarClient DbClient, IRedisCache redis) : IGameMaxNameService, ITransient
{
-
+
+ #region unit_user_maxname
+ public async Task UpdateUserMaxname(unit_user_maxname name)
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ bool isok = await db.Updateable(name).ExecuteCommandAsync() > 0;
+ if (isok)
+ {
+ string key = string.Format(BaseCache.BaseCacheKeys, "UserMaxname", "MaxnameInfo");
+ await redis.DelHashAsync(key, name.umnId);
+ }
+ return isok;
+ }
+ public async Task GetUserMaxnameInfo(string umnId)
+ {
+ string key = string.Format(BaseCache.BaseCacheKeys, "UserMaxname", "MaxnameInfo");
+ var data = await redis.GetHashAsync(key, umnId);
+ if (data == null)
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ data = await db.Queryable().Where(i => i.umnId == umnId).SingleAsync();
+ if (data != null)
+ {
+ await redis.AddHashAsync(key, umnId, data);
+ }
+ }
+ return data;
+ }
+ public async Task> GetUserMaxnameList(string userId, int page, int limit, RefAsync total)
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ return await db.Queryable().Where(i => i.userId == userId).OrderBy(i => i.addTime)
+ .ToPageListAsync(page, limit, total);
+ }
+ #endregion
}
\ No newline at end of file
diff --git a/Service/Application.Web/Controllers/Pub/BadgeController.cs b/Service/Application.Web/Controllers/Pub/BadgeController.cs
new file mode 100644
index 0000000..243c67d
--- /dev/null
+++ b/Service/Application.Web/Controllers/Pub/BadgeController.cs
@@ -0,0 +1,101 @@
+using Application.Domain.Services;
+using Application.Web.Model.RequestParms.Maxname;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Application.Web.Controllers.Pub
+{
+ ///
+ /// 徽章接口
+ ///
+ [Route("[controller]/[action]")]
+ [ApiController]
+ [Authorize]
+ public class BadgeController : ControllerBase
+ {
+ private readonly IGameBadgeService badgeService;
+ public BadgeController(IGameBadgeService _badgeService)
+ {
+ badgeService = _badgeService;
+ }
+
+ ///
+ /// 获取用户徽章列表
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task GetUserBadgeList(int page)
+ {
+ RefAsync total = 0;
+ string userId = StateHelper.userId;
+ var list = await badgeService.GetUserBadgeList(userId, page, 10, total);
+ return PoAction.Ok(new { list, total });
+ }
+
+ ///
+ /// 获取徽章详情
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task GetUserBadgeInfo(string ubId)
+ {
+ var data = await badgeService.GetUserBadegInfo(ubId);
+ if (data == null)
+ {
+ return PoAction.Message("徽章信息不存在!");
+ }
+ string userId = StateHelper.userId;
+ if (data.userId != userId)
+ {
+ return PoAction.Message("徽章信息不存在!");
+ }
+ return PoAction.Ok(new { data });
+ }
+
+ ///
+ /// 修改徽章展示不展示
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task UpdateBadgeShow([FromBody] UpdateBadgeParms par)
+ {
+ var data = await badgeService.GetUserBadegInfo(par.ubId);
+ if (data == null)
+ {
+ return PoAction.Message("徽章信息不存在!");
+ }
+ string userId = StateHelper.userId;
+ if (data.userId != userId)
+ {
+ return PoAction.Message("徽章信息不存在!");
+ }
+ //int onCount = await badgeService.GetUserShowBadgeOnCount(userId);
+ //int showCount = await badgeService.GetUserShowBadgeCount(userId);
+ //if (onCount == 0)
+ //{
+ // if (showCount >= 1)
+ // {
+ // return PoAction.Message("您最多可以同时展示1个徽章!");
+ // }
+ //}
+ //else
+ //{
+ // if (showCount >= onCount)
+ // {
+ // return PoAction.Message(string.Format("您最多可以同时展示{0}个徽章!", onCount));
+ // }
+ //}
+ int show = data.show == 1 ? 0 : 1;
+ if (await badgeService.UpdateUserBadgeShow(par.ubId, show))
+ {
+ return PoAction.Ok("操作成功!");
+ }
+ else
+ {
+ return PoAction.Message("操作失败!");
+ }
+ }
+ }
+}
diff --git a/Service/Application.Web/Controllers/Pub/MaxnameController.cs b/Service/Application.Web/Controllers/Pub/MaxnameController.cs
new file mode 100644
index 0000000..375152e
--- /dev/null
+++ b/Service/Application.Web/Controllers/Pub/MaxnameController.cs
@@ -0,0 +1,84 @@
+using Application.Web.Model.RequestParms.Maxname;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Application.Web.Controllers.Pub
+{
+ ///
+ /// 称号接口
+ ///
+ [Route("[controller]/[action]")]
+ [ApiController]
+ [Authorize]
+ public class MaxnameController : ControllerBase
+ {
+ private readonly IGameMaxNameService maxnameService;
+ public MaxnameController(IGameMaxNameService _maxnameService)
+ {
+ maxnameService = _maxnameService;
+ }
+
+ ///
+ /// 获取用户称号列表
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task GetUserMaxnameList(int page)
+ {
+ RefAsync total = 0;
+ string userId = StateHelper.userId;
+ var list = await maxnameService.GetUserMaxnameList(userId, page, 10, total);
+ return PoAction.Ok(new { list, total });
+ }
+
+ ///
+ /// 获取称号详情
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task GetUserMaxnameInfo(string umnId)
+ {
+ var data = await maxnameService.GetUserMaxnameInfo(umnId);
+ if (data == null)
+ {
+ return PoAction.Message("称号信息不存在!");
+ }
+ string userId = StateHelper.userId;
+ if (data.userId != userId)
+ {
+ return PoAction.Message("称号信息不存在!");
+ }
+ return PoAction.Ok(new { data });
+ }
+
+ ///
+ /// 修改称号展示不展示
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task UpdateMaxnameShow([FromBody] UpdateMaxnameParms par)
+ {
+ var data = await maxnameService.GetUserMaxnameInfo(par.umnId);
+ if (data == null)
+ {
+ return PoAction.Message("称号信息不存在!");
+ }
+ string userId = StateHelper.userId;
+ if (data.userId != userId)
+ {
+ return PoAction.Message("称号信息不存在!");
+ }
+ data.show = data.show == 1 ? 0 : 1;
+ if (await maxnameService.UpdateUserMaxname(data))
+ {
+ return PoAction.Ok("操作成功!");
+ }
+ else
+ {
+ return PoAction.Message("操作失败!");
+ }
+ }
+ }
+}
diff --git a/Service/Application.Web/Model/RequestParms/Maxname/UpdateBadgeParms.cs b/Service/Application.Web/Model/RequestParms/Maxname/UpdateBadgeParms.cs
new file mode 100644
index 0000000..f2c6a3b
--- /dev/null
+++ b/Service/Application.Web/Model/RequestParms/Maxname/UpdateBadgeParms.cs
@@ -0,0 +1,9 @@
+using Microsoft.AspNetCore.Mvc;
+
+namespace Application.Web.Model.RequestParms.Maxname
+{
+ public class UpdateBadgeParms
+ {
+ public string ubId { get; set; }
+ }
+}
diff --git a/Service/Application.Web/Model/RequestParms/Maxname/UpdateMaxnameParms.cs b/Service/Application.Web/Model/RequestParms/Maxname/UpdateMaxnameParms.cs
new file mode 100644
index 0000000..6d56975
--- /dev/null
+++ b/Service/Application.Web/Model/RequestParms/Maxname/UpdateMaxnameParms.cs
@@ -0,0 +1,9 @@
+using Microsoft.AspNetCore.Mvc;
+
+namespace Application.Web.Model.RequestParms.Maxname
+{
+ public class UpdateMaxnameParms
+ {
+ public string umnId { get; set; }
+ }
+}