diff --git a/WebFirst/database/sqlite.db b/WebFirst/database/sqlite.db index 6f14ee40..707b9b1d 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 78efbe24..73c9f8fe 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -102,6 +102,63 @@ + + + 动态条件分页查询 + + + + + + + + 添加字典表 + + + + + + + 根据字典id获取字典表 + + + + + + + 获取全部字典表 + + + + + + 动态条件分页查询 + + + + + + + + 添加字典信息表 + + + + + + + 根据字典类别获取字典信息 + + + + + + + id范围删除 + + + + 文件 diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DictionaryController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DictionaryController.cs index 59b268c9..0fcc3abb 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DictionaryController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DictionaryController.cs @@ -21,29 +21,57 @@ namespace Yi.Framework.ApiMicroservice.Controllers public class DictionaryController { private IDictionaryService _iDictionaryService; - public DictionaryController(ILogger logger, IDictionaryService iDictionaryService) + private IDictionaryInfoService _iDictionaryInfoService; + public DictionaryController(ILogger logger, IDictionaryService iDictionaryService, IDictionaryInfoService iDictionaryInfoService) { _iDictionaryService = iDictionaryService; + _iDictionaryInfoService = iDictionaryInfoService; } - + /// + /// 动态条件分页查询 + /// + /// + /// + /// [HttpGet] public async Task PageList([FromQuery] DictionaryEntity dic, [FromQuery] PageParModel page) { return Result.Success().SetData(await _iDictionaryService.SelctPageList(dic, page)); } + /// + /// 添加字典表 + /// + /// + /// [HttpPost] public async Task Add(DictionaryEntity dic) { return Result.Success().SetData(await _iDictionaryService._repository.InsertReturnSnowflakeIdAsync(dic)); } + /// + /// 根据字典id获取字典表 + /// + /// + /// [HttpGet] - [Route("{type}")] - public async Task GetListByType([FromRoute] string type) + [Route("{id}")] + public async Task GetById(long id) { - return Result.Success().SetData(await _iDictionaryService._repository.GetListAsync(u=>u.DictType==type&&u.IsDeleted==false)); + return Result.Success().SetData(await _iDictionaryService._repository.GetByIdAsync(id)); + } + + + /// + /// 获取全部字典表 + /// + /// + [HttpGet] + public async Task GetList() + { + return Result.Success().SetData(await _iDictionaryService._repository.GetListAsync()); } } } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DictionaryInfoController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DictionaryInfoController.cs new file mode 100644 index 00000000..06a321df --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DictionaryInfoController.cs @@ -0,0 +1,80 @@ +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.Helper; +using Yi.Framework.Common.Models; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; +using Yi.Framework.Service; +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 DictionaryInfoController + { + private IDictionaryService _iDictionaryService; + private IDictionaryInfoService _iDictionaryInfoService; + public DictionaryInfoController(ILogger logger, IDictionaryService iDictionaryService, IDictionaryInfoService iDictionaryInfoService) + { + _iDictionaryService = iDictionaryService; + _iDictionaryInfoService = iDictionaryInfoService; + } + + /// + /// 动态条件分页查询 + /// + /// + /// + /// + [HttpGet] + public async Task PageList([FromQuery] DictionaryInfoEntity dicInfo, [FromQuery] PageParModel page) + { + return Result.Success().SetData(await _iDictionaryInfoService.SelctPageList(dicInfo, page)); + } + + /// + /// 添加字典信息表 + /// + /// + /// + [HttpPost] + public async Task Add(DictionaryInfoEntity dicInfo) + { + return Result.Success().SetData(await _iDictionaryInfoService._repository.InsertReturnSnowflakeIdAsync(dicInfo)); + } + + /// + /// 根据字典类别获取字典信息 + /// + /// + /// + [HttpGet] + [Route("{type}")] + public async Task GetListByType([FromRoute] string type) + { + return Result.Success().SetData(await _iDictionaryInfoService._repository.GetListAsync(u=>u.DictType==type&&u.IsDeleted==false)); + } + + /// + /// id范围删除 + /// + /// + /// + [HttpDelete] + + public async Task DelList(List ids) + { + return Result.Success().SetStatus(await _iDictionaryInfoService._repository.DeleteByIdsAsync(ids.ToDynamicArray())); + } + + } +} 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 610f1659..323989b1 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.Common/Helper/IdHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/IdHelper.cs new file mode 100644 index 00000000..8e09d66c --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/IdHelper.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Helper +{ + public static class IdHelper + { + public static dynamic[] ToDynamicArray(this IEnumerable ids) + { + return ids.Select(id => (dynamic)id).ToArray(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IDictionaryInfoService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IDictionaryInfoService.cs new file mode 100644 index 00000000..1244d240 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IDictionaryInfoService.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 IDictionaryInfoService:IBaseService + { + Task>> SelctPageList(DictionaryInfoEntity dicInfo, PageParModel page); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IDictionaryInfoService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IDictionaryInfoService.cs index 7bf4b670..5cdaf1d3 100644 --- a/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IDictionaryInfoService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IDictionaryInfoService.cs @@ -1,9 +1,12 @@ -using Yi.Framework.Model.Models; +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 IDictionaryInfoService:IBaseService - { + public partial interface IDictionaryInfoService : IBaseService + { } } diff --git a/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/DictionaryEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/DictionaryEntity.cs index 23ac74bc..e0693c09 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/DictionaryEntity.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/DictionaryEntity.cs @@ -22,8 +22,8 @@ namespace Yi.Framework.Model.Models /// /// 字典名称 /// - [SugarColumn(ColumnName="DicName" )] - public string DicName { get; set; } + [SugarColumn(ColumnName= "DictName")] + public string DictName { get; set; } /// /// 字典类型 /// diff --git a/Yi.Framework.Net6/Yi.Framework.Service/DictionaryInfoService.cs b/Yi.Framework.Net6/Yi.Framework.Service/DictionaryInfoService.cs new file mode 100644 index 00000000..391e7196 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/DictionaryInfoService.cs @@ -0,0 +1,26 @@ +using SqlSugar; +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 DictionaryInfoService : BaseService, IDictionaryInfoService + { + public async Task>> SelctPageList(DictionaryInfoEntity dicInfo, PageParModel page) + { + RefAsync total = 0; + var data = await _repository._DbQueryable + .WhereIF(!string.IsNullOrEmpty(dicInfo.DictLabel), u => u.DictLabel.Contains(dicInfo.DictLabel)) + .WhereIF(!string.IsNullOrEmpty(dicInfo.DictType), u => u.DictType.Contains(dicInfo.DictType)) + .Where(u => u.IsDeleted == false) + .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/DictionaryService.cs b/Yi.Framework.Net6/Yi.Framework.Service/DictionaryService.cs index 44286993..b70d1e21 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/DictionaryService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/DictionaryService.cs @@ -15,7 +15,7 @@ namespace Yi.Framework.Service { RefAsync total = 0; var data = await _repository._DbQueryable - .WhereIF(!string.IsNullOrEmpty(dic.DicName), u => u.DicName.Contains(dic.DicName)) + .WhereIF(!string.IsNullOrEmpty(dic.DictName), u => u.DictName.Contains(dic.DictName)) .WhereIF(!string.IsNullOrEmpty(dic.DictType), u => u.DictType.Contains(dic.DictType)) .WhereIF(page.StartTime.IsNotNull() && page.EndTime.IsNotNull(), u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime) .Where(u => u.IsDeleted == false) diff --git a/Yi.Vue3.X.RuoYi/src/api/system/dict/data.js b/Yi.Vue3.X.RuoYi/src/api/system/dict/data.js index eb6f8467..5ff5ac04 100644 --- a/Yi.Vue3.X.RuoYi/src/api/system/dict/data.js +++ b/Yi.Vue3.X.RuoYi/src/api/system/dict/data.js @@ -3,7 +3,7 @@ import request from '@/utils/request' // 查询字典数据列表 export function listData(query) { return request({ - url: '/system/dict/data/list', + url: '/dictionaryInfo/pageList', method: 'get', params: query }) @@ -20,7 +20,7 @@ export function getData(dictCode) { // 根据字典类型查询字典数据信息 export function getDicts(dictType) { return request({ - url: '/dictionary/GetListByType/' + dictType, + url: '/dictionaryInfo/GetListByType/' + dictType, method: 'get' }) } @@ -28,7 +28,7 @@ export function getDicts(dictType) { // 新增字典数据 export function addData(data) { return request({ - url: '/system/dict/data', + url: '/dictionaryInfo/add', method: 'post', data: data }) @@ -45,8 +45,14 @@ export function updateData(data) { // 删除字典数据 export function delData(dictCode) { + +if("string"==typeof(dictCode)) +{ + dictCode=[dictCode]; +} return request({ - url: '/system/dict/data/' + dictCode, - method: 'delete' + url: '/dictionaryInfo/delList', + method: 'delete', + data:dictCode }) } diff --git a/Yi.Vue3.X.RuoYi/src/api/system/dict/type.js b/Yi.Vue3.X.RuoYi/src/api/system/dict/type.js index cf0e0d69..f886c6a8 100644 --- a/Yi.Vue3.X.RuoYi/src/api/system/dict/type.js +++ b/Yi.Vue3.X.RuoYi/src/api/system/dict/type.js @@ -12,7 +12,7 @@ export function listType(query) { // 查询字典类型详细 export function getType(dictId) { return request({ - url: '/system/dict/type/' + dictId, + url: '/dictionary/getById/' + dictId, method: 'get' }) } @@ -54,7 +54,7 @@ export function refreshCache() { // 获取字典选择框列表 export function optionselect() { return request({ - url: '/system/dict/type/optionselect', + url: '/dictionary/getList', method: 'get' }) } diff --git a/Yi.Vue3.X.RuoYi/src/views/system/dict/data.vue b/Yi.Vue3.X.RuoYi/src/views/system/dict/data.vue index a5d5b3c3..3356f84e 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/dict/data.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/dict/data.vue @@ -5,7 +5,7 @@ @@ -87,7 +87,7 @@ - + - - + + @@ -221,12 +221,12 @@ const data = reactive({ pageSize: 10, dictName: undefined, dictType: undefined, - status: undefined + isDeleted: undefined }, rules: { dictLabel: [{ required: true, message: "数据标签不能为空", trigger: "blur" }], dictValue: [{ required: true, message: "数据键值不能为空", trigger: "blur" }], - dictSort: [{ required: true, message: "数据顺序不能为空", trigger: "blur" }] + orderNum: [{ required: true, message: "数据顺序不能为空", trigger: "blur" }] } }); @@ -251,8 +251,8 @@ function getTypeList() { function getList() { loading.value = true; listData(queryParams.value).then(response => { - dataList.value = response.rows; - total.value = response.total; + dataList.value = response.data.data; + total.value = response.data.total; loading.value = false; }); } @@ -264,13 +264,13 @@ function cancel() { /** 表单重置 */ function reset() { form.value = { - dictCode: undefined, + id: undefined, dictLabel: undefined, dictValue: undefined, cssClass: undefined, listClass: "default", - dictSort: 0, - status: "0", + orderNum: 0, + isDeleted: false, remark: undefined }; proxy.resetForm("dataRef"); @@ -300,15 +300,15 @@ function handleAdd() { } /** 多选框选中数据 */ function handleSelectionChange(selection) { - ids.value = selection.map(item => item.dictCode); + ids.value = selection.map(item => item.id); single.value = selection.length != 1; multiple.value = !selection.length; } /** 修改按钮操作 */ function handleUpdate(row) { reset(); - const dictCode = row.dictCode || ids.value; - getData(dictCode).then(response => { + const id = row.id || ids.value; + getData(id).then(response => { form.value = response.data; open.value = true; title.value = "修改字典数据"; @@ -318,7 +318,7 @@ function handleUpdate(row) { function submitForm() { proxy.$refs["dataRef"].validate(valid => { if (valid) { - if (form.value.dictCode != undefined) { + if (form.value.id != undefined) { updateData(form.value).then(response => { useDictStore().removeDict(queryParams.value.dictType); proxy.$modal.msgSuccess("修改成功"); @@ -338,9 +338,9 @@ function submitForm() { } /** 删除按钮操作 */ function handleDelete(row) { - const dictCodes = row.dictCode || ids.value; - proxy.$modal.confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?').then(function() { - return delData(dictCodes); + const dictIds = row.id || ids.value; + proxy.$modal.confirm('是否确认删除字典编码为"' + dictIds + '"的数据项?').then(function() { + return delData(dictIds); }).then(() => { getList(); proxy.$modal.msgSuccess("删除成功");