修改提示词类型和提示词预设
This commit is contained in:
@@ -51,7 +51,7 @@ export function getOptionsValue<T>(options: OptionModel.Option[], keyName: strin
|
||||
* @throws 如果未找到指定键名的选项且未提供默认值时抛出错误。
|
||||
* @throws 如果处理选项值时发生错误抛出错误。
|
||||
*/
|
||||
export function getOptionsStringValue(options: OptionModel.Option[], keyName: string, defaultValue?: string): string {
|
||||
export function getOptionsStringValue(options: OptionModel.Option[], keyName: string, defaultValue?: string): string | undefined {
|
||||
// if (options.length === 0) {
|
||||
// throw new Error("Options array is empty");
|
||||
// }
|
||||
@@ -64,7 +64,7 @@ export function getOptionsStringValue(options: OptionModel.Option[], keyName: st
|
||||
}
|
||||
|
||||
if (isEmpty(option.value)) {
|
||||
return defaultValue ?? "";
|
||||
return defaultValue ?? undefined;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -117,7 +117,7 @@ export async function SaveOptions(options: object): Promise<void> {
|
||||
|
||||
let data: { key: string; value: any; }[] = [];
|
||||
Object.entries(options).reduce((acc, [key, value]) => {
|
||||
data.push({ key: key, value: value });
|
||||
data.push({ key: key, value: value.toString() });
|
||||
return "";
|
||||
}, {});
|
||||
console.log("SaveOptionsDataParams", data)
|
||||
|
||||
+162
-102
@@ -1,79 +1,96 @@
|
||||
import { request } from '@umijs/max';
|
||||
import { errorMessage } from './response';
|
||||
import { objectToQueryString } from './common';
|
||||
|
||||
//#region 提示词数据相关
|
||||
|
||||
/**
|
||||
* 获取提示词数据
|
||||
* @param typeId 提示类型的Id,要是获取全部,就是all
|
||||
* @param pageSize 每页的大小
|
||||
* @param current 当前也
|
||||
* @param options 其余请求操作项
|
||||
* 获取提示词预设的集合
|
||||
* @param param 查询的参数
|
||||
* @returns
|
||||
*/
|
||||
export async function getPromptSample(typeId: string, pageSize: number | undefined, current: number | undefined, options?: { [key: string]: any }): Promise<API.SuccessItem | API.ErrorItem> {
|
||||
try {
|
||||
|
||||
return await request(`/api/Prompt/GetPromptString/${typeId}/${pageSize}/${current}`, {
|
||||
method: 'GET',
|
||||
...(options || {}),
|
||||
});
|
||||
} catch (error: any) {
|
||||
return errorMessage(error.toString())
|
||||
export async function QueryPromptCollection(param: Prompt.PromptQueryCondition): Promise<Prompt.PromptResponse> {
|
||||
let query = objectToQueryString(param)
|
||||
let res = await request<ApiResponse.SuccessItem<Prompt.PromptResponse>>(`/lms/Prompt/QueryPromptStringCollection/?${query}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
if (res.code != 1) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
return res.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提示词的详细信息
|
||||
* @param id 指定的提示词ID
|
||||
*/
|
||||
export async function GetPromptInfo(id: string): Promise<Prompt.PromptItem> {
|
||||
let res = await request<ApiResponse.SuccessItem<Prompt.PromptItem>>(`/lms/Prompt/GetPromptInfo/${id}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
if (res.code != 1) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
console.log("GetPromptInfo", res.data);
|
||||
return res.data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加提示词数据
|
||||
* @param data 提示词数据
|
||||
* @returns
|
||||
*/
|
||||
export async function AddPrompt(data: Prompt.PromptItem): Promise<string> {
|
||||
console.log("AddPrompt", data)
|
||||
let res = await request('/lms/Prompt/AddPrompt', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
name: data.name,
|
||||
promptTypeId: data.promptTypeId,
|
||||
promptString: data.promptString,
|
||||
description: data.description,
|
||||
remark: data.remark,
|
||||
status: data.status,
|
||||
version: data.version,
|
||||
}
|
||||
})
|
||||
if (res.code != 1) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
return res.data as string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改提示词数据
|
||||
* @param id 提示词数据ID
|
||||
* @param params 参数
|
||||
*/
|
||||
export async function ModifyPrompt(id: string, params: Prompt.PromptItem): Promise<void> {
|
||||
let res = await request(`/lms/Prompt/ModifyPrompt/${id}`, {
|
||||
method: "POST",
|
||||
data: {
|
||||
...params
|
||||
}
|
||||
})
|
||||
if (res.code != 1) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getPromptDetail(id: string): Promise<API.SuccessItem | API.ErrorItem> {
|
||||
try {
|
||||
|
||||
return await request(`/api/Prompt/GetPromptDetailById/${id}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
} catch (error: any) {
|
||||
return errorMessage(error.toString())
|
||||
/**
|
||||
* 删除提示词数据
|
||||
* @param id 要删除的提示词ID
|
||||
*/
|
||||
export async function DeletePrompt(id: string): Promise<void> {
|
||||
let res = await request(`/lms/Prompt/DeletePrompt/${id}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
if (res.code != 1) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
export async function addPrompt(data: Prompt.AddPrompt): Promise<API.SuccessItem | API.ErrorItem> {
|
||||
try {
|
||||
return await request('/api/Prompt/AddPromptString', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
name: data.name,
|
||||
promptTypeId: data.promptTypeId,
|
||||
promptTypeCode: data.promptTypeCode,
|
||||
promptString: data.promptString,
|
||||
description: data.description,
|
||||
remark: data.remark,
|
||||
}
|
||||
});
|
||||
|
||||
} catch (error: any) {
|
||||
return errorMessage(error.toString())
|
||||
}
|
||||
}
|
||||
|
||||
export async function modifyPrompt(data: Prompt.AddPrompt): Promise<API.SuccessItem | API.ErrorItem> {
|
||||
try {
|
||||
return await request('/api/Prompt/ModifyPromptString', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
promptTypeId: data.promptTypeId,
|
||||
promptTypeCode: data.promptTypeCode,
|
||||
promptString: data.promptString,
|
||||
description: data.description,
|
||||
remark: data.remark,
|
||||
status: data.status,
|
||||
version: data.version,
|
||||
}
|
||||
});
|
||||
} catch (error: any) {
|
||||
return errorMessage(error.toString())
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -85,60 +102,103 @@ export async function modifyPrompt(data: Prompt.AddPrompt): Promise<API.SuccessI
|
||||
* @param current 页码
|
||||
* @returns
|
||||
*/
|
||||
export async function getPrompyType(pageSize: number | undefined, current: number | undefined): Promise<API.SuccessItem | API.ErrorItem> {
|
||||
try {
|
||||
return await request(`/api/Prompt/GetPromptType/${pageSize}/${current}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
} catch (error: any) {
|
||||
return errorMessage(error.toString())
|
||||
export async function QueryPromptypeCollection(param: Prompt.PromptTypeQueryCondition): Promise<Prompt.PromptTypeResponse> {
|
||||
let query = objectToQueryString(param)
|
||||
console.log("query", query)
|
||||
let res = await request<ApiResponse.SuccessItem<Prompt.PromptTypeResponse>>(`/lms/Prompt/QueryPromptypeCollection/?${query}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
if (res.code != 1) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
console.log("QueryPromptypeCollection", res.data);
|
||||
return res.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的提示词类型的ID和Name,可以用作选项
|
||||
* @returns
|
||||
*/
|
||||
export async function GetPromptTypeOptions(): Promise<Prompt.PromptTypeOptions[]> {
|
||||
let res = await request<ApiResponse.SuccessItem<Prompt.PromptTypeOptions[]>>(`/lms/Prompt/GetPromptTypeOptions`, {
|
||||
method: 'GET',
|
||||
});
|
||||
if (res.code != 1) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
return res.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提示词类型的详细数据,通过ID
|
||||
* @param id 提示词类型ID
|
||||
* @returns
|
||||
*/
|
||||
export async function GetPromptTypeInfo(id: string): Promise<Prompt.PromptTypeItem> {
|
||||
let res = await request<ApiResponse.SuccessItem<Prompt.PromptTypeItem>>(`/lms/Prompt/GetPromptTypeInfo/${id}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
if (res.code != 1) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
return res.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加提示词类型
|
||||
* @param data 添加的类型
|
||||
*/
|
||||
export async function addPromptType(data: Prompt.AddPromptType): Promise<API.SuccessItem | API.ErrorItem> {
|
||||
try {
|
||||
let res = await request('/api/Prompt/AddPromptType', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
name: data.name,
|
||||
code: data.code,
|
||||
remark: data.remark,
|
||||
}
|
||||
})
|
||||
return res
|
||||
|
||||
} catch (error: any) {
|
||||
return errorMessage(error.toString())
|
||||
export async function AddPromptType(data: Prompt.AddPromptType): Promise<string> {
|
||||
let res = await request('/lms/Prompt/AddPromptType', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
name: data.name,
|
||||
code: data.code,
|
||||
status: data.status,
|
||||
remark: data.remark,
|
||||
}
|
||||
})
|
||||
if (res.code != 1) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
return res.data as string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改提示词类型
|
||||
* @param data 修改的数据
|
||||
*/
|
||||
export async function editPromptType(data: Prompt.AddPromptType): Promise<API.SuccessItem | API.ErrorItem> {
|
||||
try {
|
||||
|
||||
let res = await request('/api/Prompt/ModifyPromptType', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
code: data.code,
|
||||
remark: data.remark,
|
||||
status: data.status,
|
||||
}
|
||||
})
|
||||
return res;
|
||||
|
||||
} catch (error: any) {
|
||||
console.log(error)
|
||||
return errorMessage("修改提示词数据失败")
|
||||
export async function EditPromptType(data: Prompt.AddPromptType): Promise<string> {
|
||||
let id = data.id;
|
||||
if (id == null || id == undefined) {
|
||||
throw new Error("修改提示词类型的ID不能为空")
|
||||
}
|
||||
let res = await request(`/lms/Prompt/ModityPromptType/${id}`, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
name: data.name,
|
||||
code: data.code,
|
||||
remark: data.remark,
|
||||
status: data.status,
|
||||
}
|
||||
})
|
||||
if (res.code != 1) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
return res.data as string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除提示词类型数据,并且关联删除提示词数据
|
||||
* @param id 提示词类型ID
|
||||
* @param deletePrompt 是不是删除对应的提示词数据
|
||||
* @returns
|
||||
*/
|
||||
export async function DeletePromptType(id: string, deletePrompt: boolean): Promise<API.SuccessItem> {
|
||||
let res = await request(`/lms/Prompt/DeletePromptType/${id}/${deletePrompt}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
return res;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Vendored
+76
-28
@@ -1,25 +1,6 @@
|
||||
|
||||
declare namespace Prompt {
|
||||
|
||||
type PromptListItem = {
|
||||
key: string;
|
||||
id: string;
|
||||
name: string;
|
||||
promptTypeId: string;
|
||||
promptTypeCode: string;
|
||||
promptString: string;
|
||||
description?: string;
|
||||
remark?: string;
|
||||
createUser: API.SubUserResponse;
|
||||
createTime: Date;
|
||||
updateUser: API.SubUserResponse;
|
||||
updateTime: Date;
|
||||
status: string;
|
||||
version: number;
|
||||
count: number;
|
||||
}
|
||||
|
||||
|
||||
type AddPrompt = {
|
||||
id?: string;
|
||||
name: string;
|
||||
@@ -36,23 +17,89 @@ declare namespace Prompt {
|
||||
version: number;
|
||||
}
|
||||
|
||||
//#region 提示词相关
|
||||
|
||||
type PromptTypeListItem = {
|
||||
key: string;
|
||||
/** 查询提示词预设的参数模型结构 */
|
||||
type PromptQueryCondition = {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
name?: string;
|
||||
promptTypeId?: string;
|
||||
status?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
type PromptItem = {
|
||||
id: string;
|
||||
name: string;
|
||||
promptTypeId: string;
|
||||
promptTypeCode: string;
|
||||
promptString: string;
|
||||
description?: string;
|
||||
remark?: string;
|
||||
createdUser: UserModel.UserBasic;
|
||||
createTime: Date;
|
||||
updatedUser: UserModel.UserBasic;
|
||||
updateTime: Date;
|
||||
status: string;
|
||||
version: number;
|
||||
promptType: PromptTypeBasic;
|
||||
|
||||
}
|
||||
|
||||
/** 返回的提示词类型的完整数据数据结构 */
|
||||
type PromptResponse = {
|
||||
collection: PromptItem[];
|
||||
total: number;
|
||||
current: number;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 提示词类型相关
|
||||
|
||||
interface PromptTypeBasic {
|
||||
id: string;
|
||||
name: string;
|
||||
code: string;
|
||||
remark?: string;
|
||||
status: string;
|
||||
createUser: API.SubUserResponse;
|
||||
createTime: Date;
|
||||
updateUser: API.SubUserResponse;
|
||||
updateTime: Date;
|
||||
coubt: number;
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
type PromptTypeOptions = {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
/** 提示词类型的collection的数据结构 */
|
||||
interface PromptTypeItem extends PromptTypeBasic {
|
||||
id: string;
|
||||
name: string;
|
||||
code: string;
|
||||
remark?: string;
|
||||
status: string;
|
||||
createdUser: UserModel.UserBasic;
|
||||
createTime: Date;
|
||||
updatedUser: UserModel.UserBasic;
|
||||
updateTime: Date;
|
||||
}
|
||||
|
||||
/** 查询提示词的参数模型结构 */
|
||||
type PromptTypeQueryCondition = {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
name?: string;
|
||||
code?: string;
|
||||
status?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 返回的提示词类型的完整数据数据结构 */
|
||||
type PromptTypeResponse = {
|
||||
collection: PromptTypeItem[];
|
||||
total: number;
|
||||
current: number;
|
||||
}
|
||||
|
||||
type AddPromptType = {
|
||||
id?: string;
|
||||
@@ -64,4 +111,5 @@ declare namespace Prompt {
|
||||
updateUser: API.SubUserResponse;
|
||||
updateTime: Date;
|
||||
}
|
||||
//#endregion
|
||||
}
|
||||
Vendored
+6
-2
@@ -29,14 +29,18 @@ declare namespace UserModel {
|
||||
affiliateMoney: number,
|
||||
}
|
||||
|
||||
//#region 用户基本的数据信息
|
||||
interface UserInfo {
|
||||
interface UserBasic {
|
||||
id: number;
|
||||
nickName: string;
|
||||
userName: string;
|
||||
avatar?: string;
|
||||
email: string;
|
||||
phoneNumber?: string;
|
||||
|
||||
}
|
||||
|
||||
//#region 用户基本的数据信息
|
||||
interface UserInfo extends UserBasic {
|
||||
roleNames: string[];
|
||||
allDeviceCount: number;
|
||||
agentPercent: number;
|
||||
|
||||
Reference in New Issue
Block a user