Skip to content

Commit

Permalink
支持双击修改知识库导入的文件详情名称
Browse files Browse the repository at this point in the history
  • Loading branch information
239573049 committed Mar 23, 2024
1 parent 1d117d2 commit 5f5b736
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,12 @@ Task<SearchVectorQuantityResult> GetSearchVectorQuantityAsync(long wikiId, strin
/// <param name="id"></param>
/// <returns></returns>
Task RetryVectorDetailAsync(long id);

/// <summary>
/// 修改知识库详情名称
/// </summary>
/// <param name="id"></param>
/// <param name="name"></param>
/// <returns></returns>
Task DetailsRenameNameAsync(long id, string name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace FastWiki.Service.Application.Wikis.Commands;

/// <summary>
/// ÐÞ¸Ä֪ʶ¿âÏêÇéÃû³Æ
/// </summary>
/// <param name="Id"></param>
/// <param name="Name"></param>
public record DetailsRenameNameCommand(long Id, string Name) : Command;
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,10 @@ await QuantizeBackgroundService.AddWikiDetailAsync(new QuantizeWikiDetail()
FileId = wikiDetail.FileId,
});
}

[EventHandler]
public async Task DetailsRenameNameAsync(DetailsRenameNameCommand command)
{
await wikiRepository.DetailsRenameNameAsync(command.Id, command.Name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public sealed class WikiRepository(WikiDbContext context, IUnitOfWork unitOfWork
/// <inheritdoc />
public Task<List<Wiki>> GetListAsync(Guid userId, string? keyword, int page, int pageSize)
{
var query = CreateQuery(keyword,userId);
var query = CreateQuery(keyword, userId);
return query.Skip((page - 1) * pageSize).Take(pageSize).ToListAsync();
}

Expand All @@ -23,7 +23,7 @@ await Context.Wikis.Where(x => x.Id == wiki.Id)
/// <inheritdoc />
public Task<long> GetCountAsync(Guid userId, string? keyword)
{
var query = CreateQuery(keyword,userId);
var query = CreateQuery(keyword, userId);
return query.LongCountAsync();
}

Expand Down Expand Up @@ -83,6 +83,12 @@ await Context.Database.ExecuteSqlRawAsync(
$"delete from \"{ConnectionStringsOptions.TableNamePrefix + index}\" where id='{id}';");
}

public Task DetailsRenameNameAsync(long id, string name)
{
return Context.WikiDetails.Where(x => x.Id == id)
.ExecuteUpdateAsync(s => s.SetProperty(b => b.FileName, b => name));
}


private IQueryable<Wiki> CreateQuery(string? keyword, Guid userId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,6 @@ Task<List<WikiDetail>> GetDetailsListAsync(long wikiId, WikiQuantizationState? q
/// <param name="id"></param>
/// <returns></returns>
Task RemoveDetailsVectorAsync(string index, string id);

Task DetailsRenameNameAsync(long id, string name);
}
11 changes: 11 additions & 0 deletions src/Service/FastWiki.Service/Service/WikiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ public async Task CreateWikiDetailsAsync(CreateWikiDetailsInput input)
await EventBus.PublishAsync(command);
}

[Authorize]
public async Task CreateWikiDetailWebPageInputAsync(CreateWikiDetailWebPageInput input)
{
var command = new CreateWikiDetailWebPageCommand(input);

await EventBus.PublishAsync(command);
}

[Authorize]
public async Task CreateWikiDetailDataAsync(CreateWikiDetailDataInput input)
{
var command = new CreateWikiDetailDataCommand(input);
Expand Down Expand Up @@ -125,16 +127,25 @@ public async Task<SearchVectorQuantityResult> GetSearchVectorQuantityAsync(long
return query.Result;
}

[Authorize]
public async Task RemoveDetailsVectorAsync(string id)
{
var command = new RemoveDetailsVectorCommand(System.Web.HttpUtility.UrlDecode(id));

await EventBus.PublishAsync(command);
}

[Authorize]
public async Task RetryVectorDetailAsync(long id)
{
var command = new RetryVectorDetailCommand(id);
await EventBus.PublishAsync(command);
}

[Authorize]
public Task DetailsRenameNameAsync(long id, string name)
{
var command = new DetailsRenameNameCommand(id, name);
return EventBus.PublishAsync(command);
}
}
35 changes: 34 additions & 1 deletion web/src/pages/wiki-detail/features/WikiData.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Table, Button, Dropdown, MenuProps, message, Select } from 'antd';
import { useEffect, useState } from 'react';
import { DeleteWikiDetails, GetWikiDetailsList, RetryVectorDetail } from '../../../services/WikiService';
import { DeleteWikiDetails, DetailsRenameName, GetWikiDetailsList, RetryVectorDetail } from '../../../services/WikiService';
import WikiDetailFile from './WikiDetailFile';
import { WikiQuantizationState } from '../../../models/index.d';

Expand All @@ -11,11 +11,39 @@ interface IWikiDataProps {

export default function WikiData({ id, onChagePath }: IWikiDataProps) {


const columns = [
{
title: '文件名',
dataIndex: 'fileName',
key: 'fileName',
render: (text: string, item: any) => {
return item.isedit ? <input
autoFocus
style={{
width: '100%',
border: 'none',
outline: 'none',
background: 'transparent',
fontSize: 14
}}
onBlur={async (el) => {
item.isedit = false;
if (el.target.value !== text) {
item.fileName = el.target.value;
}
setData([...data]);

try {
await DetailsRenameName(item.id, el.target.value);
message.success('修改成功');
} catch (error) {
message.error('修改失败');
}
}}
defaultValue={text}
></input> : <span onDoubleClick={() => handleDoubleClick(item)}>{text}</span>;
},
},
{
title: '索引数量',
Expand Down Expand Up @@ -139,6 +167,11 @@ export default function WikiData({ id, onChagePath }: IWikiDataProps) {
},
];

function handleDoubleClick(item: any) {
item.isedit = true;
// 修改更新
setData([...data]);
}

async function RemoveDeleteWikiDetails(id: string) {
try {
Expand Down
10 changes: 10 additions & 0 deletions web/src/services/WikiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,14 @@ export function DelDetailsVector(id: string) {
*/
export function RetryVectorDetail(id:number){
return post(`${prefix}/RetryVectorDetail/${id}`)
}

/**
* 修改Wiki知识库详情名称
* @param id
* @param name
* @returns
*/
export function DetailsRenameName(id: string, name: string) {
return post(`${prefix}/DetailsRenameName/${id}?name=${name}`)
}

0 comments on commit 5f5b736

Please sign in to comment.