mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-11 02:36:54 +08:00
feat: eslint
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { request } from '@/utils/request'
|
||||
|
||||
export const userApi = {
|
||||
pager: (pageNumber: number, pageSize: number) => request.get(`/user/pager/${pageNumber}/${pageSize}`),
|
||||
pager: (pageNumber: number, pageSize: number) =>
|
||||
request.get(`/user/pager/${pageNumber}/${pageSize}`),
|
||||
add: (data: any) => request.post('/settings/terminology', data),
|
||||
edit: (data: any) => request.put('/settings/terminology', data),
|
||||
delete: (id: number) => request.delete(`/settings/terminology/${id}`),
|
||||
query: (id: number) => request.get(`/settings/terminology/${id}`),
|
||||
language: (data: any) => request.put('/user/language', data),
|
||||
}
|
||||
}
|
||||
|
||||
+220
-129
@@ -1,185 +1,276 @@
|
||||
import {request} from '@/utils/request'
|
||||
import {getDate} from "@/utils/utils.ts";
|
||||
import { request } from '@/utils/request'
|
||||
import { getDate } from '@/utils/utils.ts'
|
||||
|
||||
export const questionApi = {
|
||||
|
||||
pager: (pageNumber: number, pageSize: number) => request.get(`/chat/question/pager/${pageNumber}/${pageSize}`),
|
||||
/* add: (data: any) => new Promise((resolve, reject) => {
|
||||
pager: (pageNumber: number, pageSize: number) =>
|
||||
request.get(`/chat/question/pager/${pageNumber}/${pageSize}`),
|
||||
/* add: (data: any) => new Promise((resolve, reject) => {
|
||||
request.post('/chat/question', data, { responseType: 'stream', timeout: 0, onDownloadProgress: p => {
|
||||
resolve(p)
|
||||
}}).catch(e => reject(e))
|
||||
}), */
|
||||
// add: (data: any) => request.post('/chat/question', data),
|
||||
add: (data: any) => request.fetchStream('/chat/question', data),
|
||||
edit: (data: any) => request.put('/chat/question', data),
|
||||
delete: (id: number) => request.delete(`/chat/question/${id}`),
|
||||
query: (id: number) => request.get(`/chat/question/${id}`)
|
||||
// add: (data: any) => request.post('/chat/question', data),
|
||||
add: (data: any) => request.fetchStream('/chat/question', data),
|
||||
edit: (data: any) => request.put('/chat/question', data),
|
||||
delete: (id: number) => request.delete(`/chat/question/${id}`),
|
||||
query: (id: number) => request.get(`/chat/question/${id}`),
|
||||
}
|
||||
|
||||
export interface ChatMessage {
|
||||
role: 'user' | 'assistant'
|
||||
create_time?: Date | string
|
||||
content?: string | number
|
||||
record?: ChatRecord
|
||||
isTyping?: boolean
|
||||
isWelcome?: boolean
|
||||
role: 'user' | 'assistant'
|
||||
create_time?: Date | string
|
||||
content?: string | number
|
||||
record?: ChatRecord
|
||||
isTyping?: boolean
|
||||
isWelcome?: boolean
|
||||
}
|
||||
|
||||
export class ChatRecord {
|
||||
id?: number
|
||||
chat_id?: number
|
||||
create_time?: Date | string
|
||||
finish_time?: Date | string
|
||||
question?: string
|
||||
sql_answer?: string
|
||||
sql?: string
|
||||
data?: string
|
||||
chart_answer?: string
|
||||
chart?: string
|
||||
finish?: boolean = false
|
||||
error?: string
|
||||
run_time: number = 0
|
||||
id?: number
|
||||
chat_id?: number
|
||||
create_time?: Date | string
|
||||
finish_time?: Date | string
|
||||
question?: string
|
||||
sql_answer?: string
|
||||
sql?: string
|
||||
data?: string
|
||||
chart_answer?: string
|
||||
chart?: string
|
||||
finish?: boolean = false
|
||||
error?: string
|
||||
run_time: number = 0
|
||||
|
||||
constructor()
|
||||
constructor(id: number, chat_id: number, create_time: Date | string, finish_time: Date | string | undefined, question: string, sql_answer: string | undefined, sql: string | undefined, data: string | undefined, chart_answer: string | undefined, chart: string | undefined, finish: boolean, error: string | undefined, run_time: number)
|
||||
constructor(id?: number, chat_id?: number, create_time?: Date | string, finish_time?: Date | string, question?: string, sql_answer?: string, sql?: string, data?: string, chart_answer?: string, chart?: string, finish?: boolean, error?: string, run_time?: number) {
|
||||
this.id = id
|
||||
this.chat_id = chat_id
|
||||
this.create_time = getDate(create_time)
|
||||
this.finish_time = getDate(finish_time)
|
||||
this.question = question
|
||||
this.sql_answer = sql_answer
|
||||
this.sql = sql
|
||||
this.data = data
|
||||
this.chart_answer = chart_answer
|
||||
this.chart = chart
|
||||
this.finish = finish
|
||||
this.error = error
|
||||
this.run_time = run_time ?? 0
|
||||
}
|
||||
constructor()
|
||||
constructor(
|
||||
id: number,
|
||||
chat_id: number,
|
||||
create_time: Date | string,
|
||||
finish_time: Date | string | undefined,
|
||||
question: string,
|
||||
sql_answer: string | undefined,
|
||||
sql: string | undefined,
|
||||
data: string | undefined,
|
||||
chart_answer: string | undefined,
|
||||
chart: string | undefined,
|
||||
finish: boolean,
|
||||
error: string | undefined,
|
||||
run_time: number
|
||||
)
|
||||
constructor(
|
||||
id?: number,
|
||||
chat_id?: number,
|
||||
create_time?: Date | string,
|
||||
finish_time?: Date | string,
|
||||
question?: string,
|
||||
sql_answer?: string,
|
||||
sql?: string,
|
||||
data?: string,
|
||||
chart_answer?: string,
|
||||
chart?: string,
|
||||
finish?: boolean,
|
||||
error?: string,
|
||||
run_time?: number
|
||||
) {
|
||||
this.id = id
|
||||
this.chat_id = chat_id
|
||||
this.create_time = getDate(create_time)
|
||||
this.finish_time = getDate(finish_time)
|
||||
this.question = question
|
||||
this.sql_answer = sql_answer
|
||||
this.sql = sql
|
||||
this.data = data
|
||||
this.chart_answer = chart_answer
|
||||
this.chart = chart
|
||||
this.finish = finish
|
||||
this.error = error
|
||||
this.run_time = run_time ?? 0
|
||||
}
|
||||
}
|
||||
|
||||
export class Chat {
|
||||
id?: number
|
||||
create_time?: Date | string
|
||||
create_by?: number
|
||||
brief?: string
|
||||
chat_type?: string
|
||||
datasource?: number
|
||||
engine_type?: string
|
||||
id?: number
|
||||
create_time?: Date | string
|
||||
create_by?: number
|
||||
brief?: string
|
||||
chat_type?: string
|
||||
datasource?: number
|
||||
engine_type?: string
|
||||
|
||||
constructor()
|
||||
constructor(id: number, create_time: Date | string, create_by: number, brief: string, chat_type: string, datasource: number, engine_type: string)
|
||||
constructor(id?: number, create_time?: Date | string, create_by?: number, brief?: string, chat_type?: string, datasource?: number, engine_type?: string) {
|
||||
this.id = id
|
||||
constructor()
|
||||
constructor(
|
||||
id: number,
|
||||
create_time: Date | string,
|
||||
create_by: number,
|
||||
brief: string,
|
||||
chat_type: string,
|
||||
datasource: number,
|
||||
engine_type: string
|
||||
)
|
||||
constructor(
|
||||
id?: number,
|
||||
create_time?: Date | string,
|
||||
create_by?: number,
|
||||
brief?: string,
|
||||
chat_type?: string,
|
||||
datasource?: number,
|
||||
engine_type?: string
|
||||
) {
|
||||
this.id = id
|
||||
this.create_time = getDate(create_time)
|
||||
this.create_by = create_by
|
||||
this.brief = brief
|
||||
this.chat_type = chat_type
|
||||
this.datasource = datasource
|
||||
this.engine_type = engine_type
|
||||
}
|
||||
}
|
||||
|
||||
export class ChatInfo extends Chat {
|
||||
datasource_name?: string
|
||||
datasource_exists: boolean = true
|
||||
records: Array<ChatRecord> = []
|
||||
|
||||
constructor()
|
||||
constructor(chat: Chat)
|
||||
constructor(
|
||||
id: number,
|
||||
create_time: Date | string,
|
||||
create_by: number,
|
||||
brief: string,
|
||||
chat_type: string,
|
||||
datasource: number,
|
||||
engine_type: string,
|
||||
datasource_name: string,
|
||||
datasource_exists: boolean,
|
||||
records: Array<ChatRecord>
|
||||
)
|
||||
constructor(
|
||||
param1?: number | Chat,
|
||||
create_time?: Date | string,
|
||||
create_by?: number,
|
||||
brief?: string,
|
||||
chat_type?: string,
|
||||
datasource?: number,
|
||||
engine_type?: string,
|
||||
datasource_name?: string,
|
||||
datasource_exists: boolean = true,
|
||||
records: Array<ChatRecord> = []
|
||||
) {
|
||||
super()
|
||||
if (param1 !== undefined) {
|
||||
if (param1 instanceof Chat) {
|
||||
this.id = param1.id
|
||||
this.create_time = getDate(param1.create_time)
|
||||
this.create_by = param1.create_by
|
||||
this.brief = param1.brief
|
||||
this.chat_type = param1.chat_type
|
||||
this.datasource = param1.datasource
|
||||
this.engine_type = param1.engine_type
|
||||
} else {
|
||||
this.id = param1
|
||||
this.create_time = getDate(create_time)
|
||||
this.create_by = create_by
|
||||
this.brief = brief
|
||||
this.chat_type = chat_type
|
||||
this.datasource = datasource
|
||||
this.engine_type = engine_type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class ChatInfo extends Chat {
|
||||
datasource_name?: string
|
||||
datasource_exists: boolean = true
|
||||
records: Array<ChatRecord> = []
|
||||
|
||||
constructor()
|
||||
constructor(chat: Chat)
|
||||
constructor(id: number, create_time: Date | string, create_by: number, brief: string, chat_type: string, datasource: number, engine_type: string, datasource_name: string, datasource_exists: boolean, records: Array<ChatRecord>)
|
||||
constructor(param1?: number | Chat, create_time?: Date | string, create_by?: number, brief?: string, chat_type?: string, datasource?: number, engine_type?: string, datasource_name?: string, datasource_exists: boolean = true, records: Array<ChatRecord> = []) {
|
||||
super()
|
||||
if (param1 !== undefined) {
|
||||
if (param1 instanceof Chat) {
|
||||
this.id = param1.id
|
||||
this.create_time = getDate(param1.create_time)
|
||||
this.create_by = param1.create_by
|
||||
this.brief = param1.brief
|
||||
this.chat_type = param1.chat_type
|
||||
this.datasource = param1.datasource
|
||||
this.engine_type = param1.engine_type
|
||||
} else {
|
||||
this.id = param1
|
||||
this.create_time = getDate(create_time)
|
||||
this.create_by = create_by
|
||||
this.brief = brief
|
||||
this.chat_type = chat_type
|
||||
this.datasource = datasource
|
||||
this.engine_type = engine_type
|
||||
}
|
||||
}
|
||||
this.datasource_name = datasource_name
|
||||
this.datasource_exists = datasource_exists
|
||||
this.records = records
|
||||
}
|
||||
this.datasource_name = datasource_name
|
||||
this.datasource_exists = datasource_exists
|
||||
this.records = records
|
||||
}
|
||||
}
|
||||
|
||||
function toChatRecord(data?: any): ChatRecord | undefined {
|
||||
if (!data) {
|
||||
return undefined
|
||||
}
|
||||
return new ChatRecord(data.id, data.chat_id, data.create_time, data.finish_time, data.question, data.sql_answer, data.sql, data.data, data.chart_answer, data.chart, data.finish, data.error, data.run_time)
|
||||
if (!data) {
|
||||
return undefined
|
||||
}
|
||||
return new ChatRecord(
|
||||
data.id,
|
||||
data.chat_id,
|
||||
data.create_time,
|
||||
data.finish_time,
|
||||
data.question,
|
||||
data.sql_answer,
|
||||
data.sql,
|
||||
data.data,
|
||||
data.chart_answer,
|
||||
data.chart,
|
||||
data.finish,
|
||||
data.error,
|
||||
data.run_time
|
||||
)
|
||||
}
|
||||
|
||||
function toChatRecordList(list: any = []): ChatRecord[] {
|
||||
const records: Array<ChatRecord> = []
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const record = toChatRecord(list[i])
|
||||
if (record) {
|
||||
records.push(record)
|
||||
}
|
||||
const records: Array<ChatRecord> = []
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const record = toChatRecord(list[i])
|
||||
if (record) {
|
||||
records.push(record)
|
||||
}
|
||||
return records
|
||||
}
|
||||
return records
|
||||
}
|
||||
|
||||
function toChatInfo(data?: any): ChatInfo | undefined {
|
||||
if (!data) {
|
||||
return undefined
|
||||
}
|
||||
return new ChatInfo(data.id, data.create_time, data.create_by, data.brief, data.chat_type, data.datasource, data.engine_type, data.datasource_name, data.datasource_exists, toChatRecordList(data.records))
|
||||
if (!data) {
|
||||
return undefined
|
||||
}
|
||||
return new ChatInfo(
|
||||
data.id,
|
||||
data.create_time,
|
||||
data.create_by,
|
||||
data.brief,
|
||||
data.chat_type,
|
||||
data.datasource,
|
||||
data.engine_type,
|
||||
data.datasource_name,
|
||||
data.datasource_exists,
|
||||
toChatRecordList(data.records)
|
||||
)
|
||||
}
|
||||
|
||||
function toChatInfoList(list: any[] = []): ChatInfo[] {
|
||||
const infos: Array<ChatInfo> = []
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const chatInfo = toChatInfo(list[i])
|
||||
if (chatInfo) {
|
||||
infos.push(chatInfo)
|
||||
}
|
||||
const infos: Array<ChatInfo> = []
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const chatInfo = toChatInfo(list[i])
|
||||
if (chatInfo) {
|
||||
infos.push(chatInfo)
|
||||
}
|
||||
return infos
|
||||
}
|
||||
return infos
|
||||
}
|
||||
|
||||
function list(): Promise<Array<ChatInfo>> {
|
||||
return request.get('/chat/list')
|
||||
return request.get('/chat/list')
|
||||
}
|
||||
|
||||
function get(id: number): Promise<ChatInfo> {
|
||||
return request.get(`/chat/get/${id}`)
|
||||
return request.get(`/chat/get/${id}`)
|
||||
}
|
||||
|
||||
function startChat(data: any): Promise<ChatInfo> {
|
||||
return request.post('/chat/start', data)
|
||||
return request.post('/chat/start', data)
|
||||
}
|
||||
|
||||
function renameChat(chat_id: number | undefined, brief: string): Promise<string> {
|
||||
return request.post('/chat/rename', {id: chat_id, brief: brief})
|
||||
return request.post('/chat/rename', { id: chat_id, brief: brief })
|
||||
}
|
||||
|
||||
function deleteChat(id: number | undefined): Promise<string> {
|
||||
return request.get(`/chat/delete/${id}`)
|
||||
return request.get(`/chat/delete/${id}`)
|
||||
}
|
||||
|
||||
export const chatApi = {
|
||||
toChatRecord,
|
||||
toChatRecordList,
|
||||
toChatInfo,
|
||||
toChatInfoList,
|
||||
list,
|
||||
get,
|
||||
startChat,
|
||||
renameChat,
|
||||
deleteChat
|
||||
}
|
||||
toChatRecord,
|
||||
toChatRecordList,
|
||||
toChatInfo,
|
||||
toChatInfoList,
|
||||
list,
|
||||
get,
|
||||
startChat,
|
||||
renameChat,
|
||||
deleteChat,
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { request } from '@/utils/request'
|
||||
|
||||
export const dashboardApi = {
|
||||
list_resource: (params: any) => request.post('/dashboard/list_resource',params),
|
||||
load_resource: (params:any) => request.post('/dashboard/load_resource',params),
|
||||
create_resource: (params: any) => request.post('/dashboard/create_resource',params),
|
||||
update_resource: (params: any) => request.post('/dashboard/update_resource',params),
|
||||
create_canvas: (params: any) => request.post('/dashboard/create_canvas',params),
|
||||
update_canvas: (params: any) => request.post('/dashboard/update_canvas',params),
|
||||
check_name: (params: any) => request.post('/dashboard/check_name',params),
|
||||
delete_resource: (params: any) => request.delete(`/dashboard/delete_resource/${params.id}`,params),
|
||||
move_resource: (params: any) => request.delete(`/dashboard/move_resource/${params.id}`,params),
|
||||
}
|
||||
list_resource: (params: any) => request.post('/dashboard/list_resource', params),
|
||||
load_resource: (params: any) => request.post('/dashboard/load_resource', params),
|
||||
create_resource: (params: any) => request.post('/dashboard/create_resource', params),
|
||||
update_resource: (params: any) => request.post('/dashboard/update_resource', params),
|
||||
create_canvas: (params: any) => request.post('/dashboard/create_canvas', params),
|
||||
update_canvas: (params: any) => request.post('/dashboard/update_canvas', params),
|
||||
check_name: (params: any) => request.post('/dashboard/check_name', params),
|
||||
delete_resource: (params: any) =>
|
||||
request.delete(`/dashboard/delete_resource/${params.id}`, params),
|
||||
move_resource: (params: any) => request.delete(`/dashboard/move_resource/${params.id}`, params),
|
||||
}
|
||||
|
||||
@@ -5,17 +5,18 @@ export const datasourceApi = {
|
||||
add: (data: any) => request.post('/datasource/add', data),
|
||||
list: () => request.get('/datasource/list'),
|
||||
update: (data: any) => request.post('/datasource/update', data),
|
||||
delete: (id: Number) => request.post(`/datasource/delete/${id}`),
|
||||
getTables: (id: Number) => request.post(`/datasource/getTables/${id}`),
|
||||
delete: (id: number) => request.post(`/datasource/delete/${id}`),
|
||||
getTables: (id: number) => request.post(`/datasource/getTables/${id}`),
|
||||
getTablesByConf: (data: any) => request.post('/datasource/getTablesByConf', data),
|
||||
getFields: (id: Number, table_name: string) => request.post(`/datasource/getFields/${id}/${table_name}`),
|
||||
execSql: (id: Number, sql: string) => request.post(`/datasource/execSql/${id}/${sql}`),
|
||||
chooseTables: (id: Number, data: any) => request.post(`/datasource/chooseTables/${id}`, data),
|
||||
tableList: (id: Number) => request.post(`/datasource/tableList/${id}`),
|
||||
fieldList: (id: Number) => request.post(`/datasource/fieldList/${id}`),
|
||||
getFields: (id: number, table_name: string) =>
|
||||
request.post(`/datasource/getFields/${id}/${table_name}`),
|
||||
execSql: (id: number, sql: string) => request.post(`/datasource/execSql/${id}/${sql}`),
|
||||
chooseTables: (id: number, data: any) => request.post(`/datasource/chooseTables/${id}`, data),
|
||||
tableList: (id: number) => request.post(`/datasource/tableList/${id}`),
|
||||
fieldList: (id: number) => request.post(`/datasource/fieldList/${id}`),
|
||||
edit: (data: any) => request.post('/datasource/editLocalComment', data),
|
||||
previewData: (id: Number, data: any) => request.post(`/datasource/previewData/${id}`, data),
|
||||
previewData: (id: number, data: any) => request.post(`/datasource/previewData/${id}`, data),
|
||||
saveTable: (data: any) => request.post('/datasource/editTable', data),
|
||||
saveField: (data: any) => request.post('/datasource/editField', data),
|
||||
getDs: (id: Number) => request.post(`/datasource/get/${id}`),
|
||||
}
|
||||
getDs: (id: number) => request.post(`/datasource/get/${id}`),
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { request } from '@/utils/request'
|
||||
|
||||
export const AuthApi = {
|
||||
login: (credentials: { username: string; password: string }) => request.post<{
|
||||
data: any; token: string
|
||||
}>('/login/access-token', credentials, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
}),
|
||||
login: (credentials: { username: string; password: string }) =>
|
||||
request.post<{
|
||||
data: any
|
||||
token: string
|
||||
}>('/login/access-token', credentials, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
}),
|
||||
logout: () => request.post('/auth/logout'),
|
||||
info: () => request.get('/user/info')
|
||||
}
|
||||
info: () => request.get('/user/info'),
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { request } from '@/utils/request'
|
||||
|
||||
export const termApi = {
|
||||
pager: (pageNumber: number, pageSize: number) => request.get(`/settings/terminology/pager/${pageNumber}/${pageSize}`),
|
||||
pager: (pageNumber: number, pageSize: number) =>
|
||||
request.get(`/settings/terminology/pager/${pageNumber}/${pageSize}`),
|
||||
add: (data: any) => request.post('/settings/terminology', data),
|
||||
edit: (data: any) => request.put('/settings/terminology', data),
|
||||
delete: (id: number) => request.delete(`/settings/terminology/${id}`),
|
||||
query: (id: number) => request.get(`/settings/terminology/${id}`)
|
||||
}
|
||||
query: (id: number) => request.get(`/settings/terminology/${id}`),
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { request } from '@/utils/request'
|
||||
|
||||
export const modelApi = {
|
||||
pager: (pageNumber: number, pageSize: number) => request.get(`/system/aimodel/pager/${pageNumber}/${pageSize}`),
|
||||
pager: (pageNumber: number, pageSize: number) =>
|
||||
request.get(`/system/aimodel/pager/${pageNumber}/${pageSize}`),
|
||||
add: (data: any) => request.post('/system/aimodel', data),
|
||||
edit: (data: any) => request.put('/system/aimodel', data),
|
||||
delete: (id: number) => request.delete(`/system/aimodel/${id}`),
|
||||
query: (id: number) => request.get(`/system/aimodel/${id}`),
|
||||
status: (data: any) => request.patch('/system/aimodel/status', data),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user