From 02168e0c247c440bd907b7c02222f70dc7d0cb3f Mon Sep 17 00:00:00 2001 From: zpc Date: Sun, 16 Nov 2025 11:02:08 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CodeGenTemplate/csharp/TplControllers.txt | 14 ++- ZR.LiveForum.Model/GlobalUsing.cs | 3 +- .../Liveforum/Dto/T_UserLevelsDto.cs | 10 +- ZR.Service/Liveforum/T_UserLevelsService.cs | 4 +- ZR.Vue/src/api/system/dict/data.js | 19 ++- ZR.Vue/src/components/DictTag/index.vue | 16 ++- ZR.Vue/src/views/liveforum/tuserlevels.vue | 115 +++++++++--------- 7 files changed, 101 insertions(+), 80 deletions(-) diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt index 45f4fe1..bd7ed7a 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/csharp/TplControllers.txt @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using ${options.DtosNamespace}.${options.SubNamespace}.Dto; using ${options.ModelsNamespace}.${options.SubNamespace}; using ${options.IServicsNamespace}.${options.SubNamespace}.I${options.SubNamespace}Service; @@ -96,7 +96,17 @@ $if(replaceDto.ShowBtnEdit) [Log(Title = "${genTable.FunctionName}", BusinessType = BusinessType.UPDATE)] public IActionResult Update${replaceDto.ModelTypeName}([FromBody] ${replaceDto.ModelTypeName}Dto parm) { - var modal = parm.Adapt<${replaceDto.ModelTypeName}>().ToUpdate(HttpContext); + + if (parm.Id == 0) + { + throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空"); + } + var oldal = _${replaceDto.ModelTypeName}Service.GetById(parm.Id); + if (oldal == null) + { + throw new CustomException(ResultCode.CUSTOM_ERROR, "数据不存在"); + } + var modal = parm.Adapt(oldal); var response = _${replaceDto.ModelTypeName}Service.Update${replaceDto.ModelTypeName}(modal); return ToResponse(response); diff --git a/ZR.LiveForum.Model/GlobalUsing.cs b/ZR.LiveForum.Model/GlobalUsing.cs index 6980dcc..ca9baac 100644 --- a/ZR.LiveForum.Model/GlobalUsing.cs +++ b/ZR.LiveForum.Model/GlobalUsing.cs @@ -3,4 +3,5 @@ global using System; global using SqlSugar; global using Newtonsoft.Json; global using MiniExcelLibs.Attributes; -global using System.ComponentModel.DataAnnotations; \ No newline at end of file +global using System.ComponentModel.DataAnnotations; +global using ZR.Model; \ No newline at end of file diff --git a/ZR.LiveForum.Model/Liveforum/Dto/T_UserLevelsDto.cs b/ZR.LiveForum.Model/Liveforum/Dto/T_UserLevelsDto.cs index 4a08d5d..84c5062 100644 --- a/ZR.LiveForum.Model/Liveforum/Dto/T_UserLevelsDto.cs +++ b/ZR.LiveForum.Model/Liveforum/Dto/T_UserLevelsDto.cs @@ -28,11 +28,11 @@ namespace ZR.LiveForum.Model.Liveforum.Dto [ExcelColumn(Name = "等级图标")] [ExcelColumnName("等级图标")] - public string LevelIcon { get; set; } + public string? LevelIcon { get; set; } [ExcelColumn(Name = "显示颜色")] [ExcelColumnName("显示颜色")] - public string LevelColor { get; set; } + public string? LevelColor { get; set; } [ExcelColumn(Name = "最小经验值")] [ExcelColumnName("最小经验值")] @@ -44,7 +44,7 @@ namespace ZR.LiveForum.Model.Liveforum.Dto [ExcelColumn(Name = "特权配置")] [ExcelColumnName("特权配置")] - public string Privileges { get; set; } + public string? Privileges { get; set; } [Required(ErrorMessage = "状态不能为空")] [ExcelColumn(Name = "状态")] @@ -59,9 +59,7 @@ namespace ZR.LiveForum.Model.Liveforum.Dto [ExcelColumnName("更新时间")] public DateTime? UpdatedAt { get; set; } - - [ExcelColumn(Name = "状态")] - public string IsActiveLabel { get; set; } + public string? IsActiveLabel { get; set; } } } \ No newline at end of file diff --git a/ZR.Service/Liveforum/T_UserLevelsService.cs b/ZR.Service/Liveforum/T_UserLevelsService.cs index 49b2071..048ae1c 100644 --- a/ZR.Service/Liveforum/T_UserLevelsService.cs +++ b/ZR.Service/Liveforum/T_UserLevelsService.cs @@ -1,4 +1,4 @@ -using Infrastructure.Attribute; +using Infrastructure.Attribute; using Infrastructure.Extensions; using ZR.LiveForum.Model.Liveforum.Dto; using ZR.LiveForum.Model.Liveforum; @@ -80,7 +80,7 @@ namespace ZR.Service.Liveforum .Where(predicate.ToExpression()) .Select((it) => new T_UserLevelsDto() { - IsActiveLabel = it.IsActive.GetConfigValue("sys_common_status"), + IsActiveLabel = it.IsActive.GetConfigValue("sys_common_status_bool"), }, true) .ToPage(parm); diff --git a/ZR.Vue/src/api/system/dict/data.js b/ZR.Vue/src/api/system/dict/data.js index 77202b6..12b771b 100644 --- a/ZR.Vue/src/api/system/dict/data.js +++ b/ZR.Vue/src/api/system/dict/data.js @@ -18,7 +18,7 @@ export function getData(dictCode) { } // 根据字典类型查询字典数据信息 -export function getDicts(dictType) { +export async function getDicts(dictType) { if (typeof dictType === 'object') { var data = dictType.map((x) => { if (typeof x === 'object') { @@ -27,11 +27,24 @@ export function getDicts(dictType) { return x } }) - return request({ + var res = await request({ url: '/system/dict/data/dicts', data: data, method: 'post' - }) + }); + if (res.code == 200) { + res.data.forEach(element => { + if (element.dictType == "sys_common_status_bool") { + element.list.forEach(item => { + + item.value = item.value == "true" ? true : false; + item.dictValue = item.dictValue == "true" ? true : false; + }); + } + }); + } + + return res; } else { return request({ url: '/system/dict/data/type/' + dictType, diff --git a/ZR.Vue/src/components/DictTag/index.vue b/ZR.Vue/src/components/DictTag/index.vue index c8a650c..8d5da4a 100644 --- a/ZR.Vue/src/components/DictTag/index.vue +++ b/ZR.Vue/src/components/DictTag/index.vue @@ -1,13 +1,8 @@