From 9149d6de9a3a14ab7057b4fde6959434acda5eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 23 Sep 2022 18:46:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86=E5=A2=9E?= =?UTF-8?q?=E5=88=A0=E6=94=B9=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebFirst/database/sqlite.db | Bin 634880 -> 634880 bytes .../Config/SwaggerDoc.xml | 8 ++ .../Controllers/ConfigController.cs | 40 +++++++++ .../yi-sqlsugar-dev.db | Bin 151552 -> 163840 bytes .../Yi.Framework.Interface/IConfigService.cs | 13 +++ .../IServiceTemplate/IConfigService.cs | 9 ++ .../ModelsTemplate/ConfigEntity.cs | 82 ++++++++++++++++++ .../Yi.Framework.Service/ConfigService.cs | 29 +++++++ .../ServiceTemplate/ConfigService.cs | 14 +++ Yi.Vue3.X.RuoYi/src/api/system/config.js | 18 ++-- .../src/views/system/config/index.vue | 19 ++-- 11 files changed, 217 insertions(+), 15 deletions(-) create mode 100644 Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ConfigController.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Interface/IConfigService.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IConfigService.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/ConfigEntity.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Service/ConfigService.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/ConfigService.cs diff --git a/WebFirst/database/sqlite.db b/WebFirst/database/sqlite.db index 7b57d339f00c70a869e3f7b1372727180ce11caf..d34d58c626bcaccfbb208dbe5e6b026caf7fe4b1 100644 GIT binary patch delta 586 zcmZp8pw{p}ZGyBQI|Bp5Y#@e#{)sxqjO-f|#Pk`xCztEXGA1`q)o-7w&$xZ6K2yGc z5Ie5|1OF6$6TT~a3A~?pTX+>VD=KjD+9i2&GcZa@$~zkyb8xUY=jWwmrbEb=t-a6p zu6wa?g^_`gk*qb+fIgCdhUi??1|!t{gJ7Lj$0; zC~gL2WuP{Bd6>4a#GF#7J}?ua@oB>zm@WfvgSJR+26=h7wkS}*d8bxFYy&bNdR|Uh zhtOlv7J=bHzr$ASw#9PF7T;Eu5P{P>_>@ zlV6yT!864(#V|9k#9O7!mYYFRl4E+pHAboS6Ol|n%nZaVK+FonY(UHo#2njCL~>e$ F0RSSO0}PeWCCJlAZ7t# TRv=~rVs;?r*nT3C(;^H2wazyc diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml index 31e156df..9a2993e4 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -180,6 +180,14 @@ + + + 动态条件分页查询 + + + + + 动态条件查询 diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ConfigController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ConfigController.cs new file mode 100644 index 00000000..9ef0398f --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ConfigController.cs @@ -0,0 +1,40 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; +using Yi.Framework.WebCore; +using Yi.Framework.WebCore.AttributeExtend; +using Yi.Framework.WebCore.AuthorizationPolicy; + +namespace Yi.Framework.ApiMicroservice.Controllers +{ + [ApiController] + [Route("api/[controller]/[action]")] + public class ConfigController : BaseSimpleCrudController + { + private IConfigService _iConfigService; + public ConfigController(ILogger logger, IConfigService iConfigService) : base(logger, iConfigService) + { + _iConfigService = iConfigService; + } + + /// + /// 动态条件分页查询 + /// + /// + /// + /// + [HttpGet] + public async Task PageList([FromQuery] ConfigEntity dic, [FromQuery] PageParModel page) + { + return Result.Success().SetData(await _iConfigService.SelctPageList(dic, page)); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index f7907dacfe3bb8825e1dfcb6ee3e7755d570a12a..131a3a4938fa9ad3043b398b8831973e95165cc6 100644 GIT binary patch delta 1400 zcma)6U2NM_6!x(lCvhF$j4VyV7R`-lo02v2Pkx;6Ktm`{t(&T}upzoNZku(Js-{gg zx@Zs0vI+5mwki@HPh+Tpy+DN`&6PGl;tiw?q^eAeM^w_62_#rwc;UuwP`ipB%f9wG zKIgmN_vzkS`OsOZu-6alLj*yD@YA~bmkujlL_}V_ZNn)NZ8d*{(4T1Q^Yc~2;=tF5 zhjw?>ea8)SKgE+BmcHzdkq&DVo;EQhkgJ150c0vd`~_tEcL} zQqO?#APea>CcK~Vz38vqYU`-|K%v?alQ9-gLlye?Wx_=V2>zaJhz{^2PUBSeG~4T# zaCF%@X2Vv76>5YSq=IM-tu3WJ9ByzlnNlOf2yKKKr%E1U}x0kqn*bQN3ZM~m-!{210mg@AYc1Sx;* zCgvCNJMQ9B4q}X)x7lU7zN<_Amo`P&W4xlCP05K!LP^AvF?GspF3vB!Lh_8)>ub^S zV_Ki=$Fw9_k>u$1_!KE6o>G*E6ptm6iaKQ#vgi-2wn3ldw{WWwTkWFnDu!yUk(ayYsJa4S}`Pv zVy|%g^`Rj_IE=fjiZ`^G3;F-387Q{ zhCmT9;U0a-rn3hy%5$-Lv&u2=V|mN+cA}%?bk6`rtIY-i`i$H6Pn;3P0h6yuxGVovKTf$e&lgMMi700E?k;I|O z&cpVUwURY}c`b7b<9g;`22WvexZuVkV#){awDJ2^wt_C z;qBaYOkWwdSEe#*b8eSSVT@tiR=~)jz`?|yz`(zjKVh??LJ&Vwko5F~`HV||qPH0M zZ}ETLELd=ke|r6SM%L-~*E1@K1D(XdTfxA;gFl8}f^QFBBA*!VDc%a8<^ + { + Task>> SelctPageList(ConfigEntity config, PageParModel page); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IConfigService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IConfigService.cs new file mode 100644 index 00000000..d1f8d435 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IConfigService.cs @@ -0,0 +1,9 @@ +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; + +namespace Yi.Framework.Interface +{ + public partial interface IConfigService:IBaseService + { + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/ConfigEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/ConfigEntity.cs new file mode 100644 index 00000000..f41dd6b0 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/ConfigEntity.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json.Serialization; +using SqlSugar; +namespace Yi.Framework.Model.Models +{ + /// + /// 配置表 + /// + [SugarTable("Config")] + public partial class ConfigEntity:IBaseModelEntity + { + public ConfigEntity() + { + this.CreateTime = DateTime.Now; + } + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )] + public long Id { get; set; } + /// + /// 配置名称 + /// + [SugarColumn(ColumnName="ConfigName" )] + public string ConfigName { get; set; } + /// + /// 配置键 + /// + [SugarColumn(ColumnName="ConfigKey" )] + public string ConfigKey { get; set; } + /// + /// 配置值 + /// + [SugarColumn(ColumnName="ConfigValue" )] + public string ConfigValue { get; set; } + /// + /// 配置类别 + /// + [SugarColumn(ColumnName="ConfigType" )] + public string ConfigType { get; set; } + /// + /// 创建者 + /// + [SugarColumn(ColumnName="CreateUser" )] + public long? CreateUser { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(ColumnName="CreateTime" )] + public DateTime? CreateTime { get; set; } + /// + /// 修改者 + /// + [SugarColumn(ColumnName="ModifyUser" )] + public long? ModifyUser { get; set; } + /// + /// 修改时间 + /// + [SugarColumn(ColumnName="ModifyTime" )] + public DateTime? ModifyTime { get; set; } + /// + /// 是否删除 + /// + [SugarColumn(ColumnName="IsDeleted" )] + public bool? IsDeleted { get; set; } + /// + /// 租户Id + /// + [SugarColumn(ColumnName="TenantId" )] + public long? TenantId { get; set; } + /// + /// 排序字段 + /// + [SugarColumn(ColumnName="OrderNum" )] + public int? OrderNum { get; set; } + /// + /// 描述 + /// + [SugarColumn(ColumnName="Remark" )] + public string Remark { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Service/ConfigService.cs b/Yi.Framework.Net6/Yi.Framework.Service/ConfigService.cs new file mode 100644 index 00000000..47221328 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/ConfigService.cs @@ -0,0 +1,29 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; + +namespace Yi.Framework.Service +{ + public partial class ConfigService : BaseService, IConfigService + { + public async Task>> SelctPageList(ConfigEntity config, PageParModel page) + { + RefAsync total = 0; + var data = await _repository._DbQueryable + .WhereIF(!string.IsNullOrEmpty(config.ConfigName), u => u.ConfigName.Contains(config.ConfigName)) + .WhereIF(!string.IsNullOrEmpty(config.ConfigKey), u => u.ConfigKey.Contains(config.ConfigKey)) + .WhereIF(page.StartTime.IsNotNull() && page.EndTime.IsNotNull(), u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime) + .WhereIF(config.IsDeleted.IsNotNull(), u => u.IsDeleted == config.IsDeleted) + .OrderBy(u => u.OrderNum, OrderByType.Desc) + .ToPageListAsync(page.PageNum, page.PageSize, total); + + return new PageModel>(data, total); + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/ConfigService.cs b/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/ConfigService.cs new file mode 100644 index 00000000..a9f404b4 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/ConfigService.cs @@ -0,0 +1,14 @@ +using SqlSugar; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; + +namespace Yi.Framework.Service +{ + public partial class ConfigService : BaseService, IConfigService + { + public ConfigService(IRepository repository) : base(repository) + { + } + } +} diff --git a/Yi.Vue3.X.RuoYi/src/api/system/config.js b/Yi.Vue3.X.RuoYi/src/api/system/config.js index a404d825..e1d549e6 100644 --- a/Yi.Vue3.X.RuoYi/src/api/system/config.js +++ b/Yi.Vue3.X.RuoYi/src/api/system/config.js @@ -3,7 +3,7 @@ import request from '@/utils/request' // 查询参数列表 export function listConfig(query) { return request({ - url: '/system/config/list', + url: '/config/pageList', method: 'get', params: query }) @@ -12,7 +12,7 @@ export function listConfig(query) { // 查询参数详细 export function getConfig(configId) { return request({ - url: '/system/config/' + configId, + url: '/config/getById/' + configId, method: 'get' }) } @@ -28,7 +28,7 @@ export function getConfigKey(configKey) { // 新增参数配置 export function addConfig(data) { return request({ - url: '/system/config', + url: '/config/add', method: 'post', data: data }) @@ -37,7 +37,7 @@ export function addConfig(data) { // 修改参数配置 export function updateConfig(data) { return request({ - url: '/system/config', + url: '/config/update', method: 'put', data: data }) @@ -45,9 +45,15 @@ export function updateConfig(data) { // 删除参数配置 export function delConfig(configId) { + +if("string"==typeof(configId)) +{ + configId=[configId]; +} return request({ - url: '/system/config/' + configId, - method: 'delete' + url: '/config/delList', + method: 'delete', + data:configId }) } diff --git a/Yi.Vue3.X.RuoYi/src/views/system/config/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/config/index.vue index a81ec071..522a165c 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/config/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/config/index.vue @@ -98,7 +98,7 @@ - + @@ -213,8 +213,8 @@ const { queryParams, form, rules } = toRefs(data); function getList() { loading.value = true; listConfig(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => { - configList.value = response.rows; - total.value = response.total; + configList.value = response.data.data; + total.value = response.data.total; loading.value = false; }); } @@ -226,12 +226,13 @@ function cancel() { /** 表单重置 */ function reset() { form.value = { - configId: undefined, + id: undefined, configName: undefined, configKey: undefined, configValue: undefined, configType: "Y", - remark: undefined + remark: undefined, + isDeleted: false }; proxy.resetForm("configRef"); } @@ -248,7 +249,7 @@ function resetQuery() { } /** 多选框选中数据 */ function handleSelectionChange(selection) { - ids.value = selection.map(item => item.configId); + ids.value = selection.map(item => item.id); single.value = selection.length != 1; multiple.value = !selection.length; } @@ -261,7 +262,7 @@ function handleAdd() { /** 修改按钮操作 */ function handleUpdate(row) { reset(); - const configId = row.configId || ids.value; + const configId = row.id || ids.value; getConfig(configId).then(response => { form.value = response.data; open.value = true; @@ -272,7 +273,7 @@ function handleUpdate(row) { function submitForm() { proxy.$refs["configRef"].validate(valid => { if (valid) { - if (form.value.configId != undefined) { + if (form.value.id != undefined) { updateConfig(form.value).then(response => { proxy.$modal.msgSuccess("修改成功"); open.value = false; @@ -290,7 +291,7 @@ function submitForm() { } /** 删除按钮操作 */ function handleDelete(row) { - const configIds = row.configId || ids.value; + const configIds = row.id || ids.value; proxy.$modal.confirm('是否确认删除参数编号为"' + configIds + '"的数据项?').then(function () { return delConfig(configIds); }).then(() => {