diff --git a/WebFirst/database/sqlite.db b/WebFirst/database/sqlite.db index 7b57d339..d34d58c6 100644 Binary files a/WebFirst/database/sqlite.db and b/WebFirst/database/sqlite.db differ 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 f7907dac..131a3a49 100644 Binary files a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db differ diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IConfigService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IConfigService.cs new file mode 100644 index 00000000..3edb9a3c --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IConfigService.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; + +namespace Yi.Framework.Interface +{ + public partial interface IConfigService:IBaseService + { + 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(() => {