From 235989fb45ed183288a7100dc4c9f169d043889a Mon Sep 17 00:00:00 2001 From: yanghongwei Date: Sun, 13 Apr 2025 18:44:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BD=E5=90=8D=E5=8D=95=E5=8F=8D=E6=98=BE?= =?UTF-8?q?=EF=BC=8C=E9=98=B2=E5=8C=BA=E8=BD=ACstring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/WhitListController.cs | 2 +- Model/Whitelist.cs | 4 +++- Service/WhitListService.cs | 8 ++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Controllers/WhitListController.cs b/Controllers/WhitListController.cs index 701c27b..0728a63 100644 --- a/Controllers/WhitListController.cs +++ b/Controllers/WhitListController.cs @@ -30,7 +30,7 @@ namespace LY.App.Controllers /// /// [HttpGet("list")] - public async Task List(int pageNum, int pageSize, string key) + public async Task List(int pageNum = 1, int pageSize = 10, string key = null) { var result = await _whitListService.GetList(pageNum, pageSize, key); return Ok(result); diff --git a/Model/Whitelist.cs b/Model/Whitelist.cs index 859223f..151bd85 100644 --- a/Model/Whitelist.cs +++ b/Model/Whitelist.cs @@ -20,9 +20,11 @@ namespace LY.App.Model public DateTime? startTime { get; set; } [SugarColumn(IsNullable = true)] public DateTime? endTime { get; set; } - [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(ColumnName = "position_id", ColumnDescription = "阵地id", IsJson = true)] public List positionId { get; set; } + [SugarColumn(IsIgnore = true)] + public List positionIds { get; set; } /// /// 所属单位 /// diff --git a/Service/WhitListService.cs b/Service/WhitListService.cs index efad679..0515406 100644 --- a/Service/WhitListService.cs +++ b/Service/WhitListService.cs @@ -22,7 +22,7 @@ namespace LY.App.Service public WhitListService(SqlSugarClient sqlSugarClient, RedisService redisService) { _db = sqlSugarClient; - _redisService=redisService; + _redisService = redisService; } /// /// 新增白名单 @@ -69,7 +69,7 @@ namespace LY.App.Service /// /// /// - public async Task GetList(int pageNum, int pageSize, string key) + public async Task GetList(int pageNum = 1, int pageSize = 10, string key = null) { var result = new ApiResult(); RefAsync total = 0; @@ -78,6 +78,10 @@ namespace LY.App.Service .WhereIF(!string.IsNullOrEmpty(key), s => s.sn.Contains(key)) .OrderByDescending(s => s.Id) .ToPageListAsync(pageNum, pageSize, total); + items.ForEach(x => + { + x.positionIds = x.positionId.Select(s => s.ToString()).ToList(); + }); return new ApiResult() { data = new