字典信息表查询删除接口
This commit is contained in:
Binary file not shown.
@@ -102,6 +102,63 @@
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryController.PageList(Yi.Framework.Model.Models.DictionaryEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="dic"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryController.Add(Yi.Framework.Model.Models.DictionaryEntity)">
|
||||
<summary>
|
||||
添加字典表
|
||||
</summary>
|
||||
<param name="dic"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryController.GetById(System.Int64)">
|
||||
<summary>
|
||||
根据字典id获取字典表
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryController.GetList">
|
||||
<summary>
|
||||
获取全部字典表
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryInfoController.PageList(Yi.Framework.Model.Models.DictionaryInfoEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="dicInfo"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryInfoController.Add(Yi.Framework.Model.Models.DictionaryInfoEntity)">
|
||||
<summary>
|
||||
添加字典信息表
|
||||
</summary>
|
||||
<param name="dicInfo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryInfoController.GetListByType(System.String)">
|
||||
<summary>
|
||||
根据字典类别获取字典信息
|
||||
</summary>
|
||||
<param name="type"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryInfoController.DelList(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
id范围删除
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.FileController">
|
||||
<summary>
|
||||
文件
|
||||
|
||||
@@ -21,29 +21,57 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public class DictionaryController
|
||||
{
|
||||
private IDictionaryService _iDictionaryService;
|
||||
public DictionaryController(ILogger<DictionaryEntity> logger, IDictionaryService iDictionaryService)
|
||||
private IDictionaryInfoService _iDictionaryInfoService;
|
||||
public DictionaryController(ILogger<DictionaryEntity> logger, IDictionaryService iDictionaryService, IDictionaryInfoService iDictionaryInfoService)
|
||||
{
|
||||
_iDictionaryService = iDictionaryService;
|
||||
_iDictionaryInfoService = iDictionaryInfoService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] DictionaryEntity dic, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryService.SelctPageList(dic, page));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加字典表
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Add(DictionaryEntity dic)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryService._repository.InsertReturnSnowflakeIdAsync(dic));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据字典id获取字典表
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{type}")]
|
||||
public async Task<Result> GetListByType([FromRoute] string type)
|
||||
[Route("{id}")]
|
||||
public async Task<Result> 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));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取全部字典表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> GetList()
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryService._repository.GetListAsync());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<DictionaryEntity> logger, IDictionaryService iDictionaryService, IDictionaryInfoService iDictionaryInfoService)
|
||||
{
|
||||
_iDictionaryService = iDictionaryService;
|
||||
_iDictionaryInfoService = iDictionaryInfoService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="dicInfo"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] DictionaryInfoEntity dicInfo, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryInfoService.SelctPageList(dicInfo, page));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加字典信息表
|
||||
/// </summary>
|
||||
/// <param name="dicInfo"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Add(DictionaryInfoEntity dicInfo)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryInfoService._repository.InsertReturnSnowflakeIdAsync(dicInfo));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据字典类别获取字典信息
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{type}")]
|
||||
public async Task<Result> GetListByType([FromRoute] string type)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryInfoService._repository.GetListAsync(u=>u.DictType==type&&u.IsDeleted==false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// id范围删除
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
|
||||
public async Task<Result> DelList(List<long> ids)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iDictionaryInfoService._repository.DeleteByIdsAsync(ids.ToDynamicArray()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
16
Yi.Framework.Net6/Yi.Framework.Common/Helper/IdHelper.cs
Normal file
16
Yi.Framework.Net6/Yi.Framework.Common/Helper/IdHelper.cs
Normal file
@@ -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<long> ids)
|
||||
{
|
||||
return ids.Select(id => (dynamic)id).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<DictionaryInfoEntity>
|
||||
{
|
||||
Task<PageModel<List<DictionaryInfoEntity>>> SelctPageList(DictionaryInfoEntity dicInfo, PageParModel page);
|
||||
}
|
||||
}
|
||||
@@ -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<DictionaryInfoEntity>
|
||||
{
|
||||
public partial interface IDictionaryInfoService : IBaseService<DictionaryInfoEntity>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace Yi.Framework.Model.Models
|
||||
/// <summary>
|
||||
/// 字典名称
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="DicName" )]
|
||||
public string DicName { get; set; }
|
||||
[SugarColumn(ColumnName= "DictName")]
|
||||
public string DictName { get; set; }
|
||||
/// <summary>
|
||||
/// 字典类型
|
||||
///</summary>
|
||||
|
||||
@@ -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<DictionaryInfoEntity>, IDictionaryInfoService
|
||||
{
|
||||
public async Task<PageModel<List<DictionaryInfoEntity>>> SelctPageList(DictionaryInfoEntity dicInfo, PageParModel page)
|
||||
{
|
||||
RefAsync<int> 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<List<DictionaryInfoEntity>>(data, total);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace Yi.Framework.Service
|
||||
{
|
||||
RefAsync<int> 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)
|
||||
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<el-select v-model="queryParams.dictType">
|
||||
<el-option
|
||||
v-for="item in typeOptions"
|
||||
:key="item.dictId"
|
||||
:key="item.id"
|
||||
:label="item.dictName"
|
||||
:value="item.dictType"
|
||||
/>
|
||||
@@ -87,7 +87,7 @@
|
||||
|
||||
<el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="字典编码" align="center" prop="dictCode" />
|
||||
<el-table-column label="字典编码" align="center" prop="id" />
|
||||
<el-table-column label="字典标签" align="center" prop="dictLabel">
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.listClass == '' || scope.row.listClass == 'default'">{{ scope.row.dictLabel }}</span>
|
||||
@@ -95,10 +95,10 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="字典键值" align="center" prop="dictValue" />
|
||||
<el-table-column label="字典排序" align="center" prop="dictSort" />
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<el-table-column label="字典排序" align="center" prop="orderNum" />
|
||||
<el-table-column label="状态" align="center" prop="isDeleted">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="sys_normal_disable" :value="scope.row.status" />
|
||||
<dict-tag :options="sys_normal_disable" :value="scope.row.isDeleted" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
|
||||
@@ -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("删除成功");
|
||||
|
||||
Reference in New Issue
Block a user