mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-10 18:53:36 +08:00
Merge pull request #297 from awesomeYG/feat-employee
feat: 研发成员账号展示 AI 员工模块
This commit is contained in:
166
ui/src/api/UserAiEmployee.ts
Normal file
166
ui/src/api/UserAiEmployee.ts
Normal file
@@ -0,0 +1,166 @@
|
||||
/* eslint-disable */
|
||||
/* tslint:disable */
|
||||
// @ts-nocheck
|
||||
/*
|
||||
* ---------------------------------------------------------------
|
||||
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
|
||||
* ## ##
|
||||
* ## AUTHOR: acacode ##
|
||||
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
|
||||
* ---------------------------------------------------------------
|
||||
*/
|
||||
|
||||
import request, { ContentType, RequestParams } from "./httpClient";
|
||||
import {
|
||||
DomainAIEmployee,
|
||||
DomainCreateAIEmployeeReq,
|
||||
DomainListAIEmployeeResp,
|
||||
DomainUUIDReq,
|
||||
DomainUpdateAIEmployeeReq,
|
||||
GetUserAiemployeeInfoParams,
|
||||
GetUserAiemployeeListParams,
|
||||
WebResp,
|
||||
} from "./types";
|
||||
|
||||
/**
|
||||
* @description 获取AI员工列表
|
||||
*
|
||||
* @tags User AIEmployee
|
||||
* @name GetUserAiemployeeList
|
||||
* @summary 获取AI员工列表
|
||||
* @request GET:/api/v1/user/aiemployee
|
||||
* @response `200` `(WebResp & {
|
||||
data?: DomainListAIEmployeeResp,
|
||||
|
||||
})` OK
|
||||
*/
|
||||
|
||||
export const getUserAiemployeeList = (
|
||||
query: GetUserAiemployeeListParams,
|
||||
params: RequestParams = {},
|
||||
) =>
|
||||
request<
|
||||
WebResp & {
|
||||
data?: DomainListAIEmployeeResp;
|
||||
}
|
||||
>({
|
||||
path: `/api/v1/user/aiemployee`,
|
||||
method: "GET",
|
||||
query: query,
|
||||
type: ContentType.Json,
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
/**
|
||||
* @description 更新AI员工
|
||||
*
|
||||
* @tags User AIEmployee
|
||||
* @name PutUserAiemployeeUpdate
|
||||
* @summary 更新AI员工
|
||||
* @request PUT:/api/v1/user/aiemployee
|
||||
* @response `200` `(WebResp & {
|
||||
data?: DomainAIEmployee,
|
||||
|
||||
})` OK
|
||||
*/
|
||||
|
||||
export const putUserAiemployeeUpdate = (
|
||||
param: DomainUpdateAIEmployeeReq,
|
||||
params: RequestParams = {},
|
||||
) =>
|
||||
request<
|
||||
WebResp & {
|
||||
data?: DomainAIEmployee;
|
||||
}
|
||||
>({
|
||||
path: `/api/v1/user/aiemployee`,
|
||||
method: "PUT",
|
||||
body: param,
|
||||
type: ContentType.Json,
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
/**
|
||||
* @description 创建AI员工
|
||||
*
|
||||
* @tags User AIEmployee
|
||||
* @name PostUserAiemployeeCreate
|
||||
* @summary 创建AI员工
|
||||
* @request POST:/api/v1/user/aiemployee
|
||||
* @response `200` `(WebResp & {
|
||||
data?: DomainAIEmployee,
|
||||
|
||||
})` OK
|
||||
*/
|
||||
|
||||
export const postUserAiemployeeCreate = (
|
||||
param: DomainCreateAIEmployeeReq,
|
||||
params: RequestParams = {},
|
||||
) =>
|
||||
request<
|
||||
WebResp & {
|
||||
data?: DomainAIEmployee;
|
||||
}
|
||||
>({
|
||||
path: `/api/v1/user/aiemployee`,
|
||||
method: "POST",
|
||||
body: param,
|
||||
type: ContentType.Json,
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
/**
|
||||
* @description 删除AI员工
|
||||
*
|
||||
* @tags User AIEmployee
|
||||
* @name DeleteUserAiemployeeDelete
|
||||
* @summary 删除AI员工
|
||||
* @request DELETE:/api/v1/user/aiemployee
|
||||
* @response `200` `WebResp` OK
|
||||
*/
|
||||
|
||||
export const deleteUserAiemployeeDelete = (
|
||||
param: DomainUUIDReq,
|
||||
params: RequestParams = {},
|
||||
) =>
|
||||
request<WebResp>({
|
||||
path: `/api/v1/user/aiemployee`,
|
||||
method: "DELETE",
|
||||
body: param,
|
||||
type: ContentType.Json,
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
/**
|
||||
* @description 获取AI员工详情
|
||||
*
|
||||
* @tags User AIEmployee
|
||||
* @name GetUserAiemployeeInfo
|
||||
* @summary 获取AI员工详情
|
||||
* @request GET:/api/v1/user/aiemployee/info
|
||||
* @response `200` `(WebResp & {
|
||||
data?: DomainAIEmployee,
|
||||
|
||||
})` OK
|
||||
*/
|
||||
|
||||
export const getUserAiemployeeInfo = (
|
||||
query: GetUserAiemployeeInfoParams,
|
||||
params: RequestParams = {},
|
||||
) =>
|
||||
request<
|
||||
WebResp & {
|
||||
data?: DomainAIEmployee;
|
||||
}
|
||||
>({
|
||||
path: `/api/v1/user/aiemployee/info`,
|
||||
method: "GET",
|
||||
query: query,
|
||||
type: ContentType.Json,
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
@@ -9,6 +9,7 @@ export * from './Model'
|
||||
export * from './OpenAiv1'
|
||||
export * from './SecurityScanning'
|
||||
export * from './User'
|
||||
export * from './UserAiEmployee'
|
||||
export * from './UserDashboard'
|
||||
export * from './UserGroup'
|
||||
export * from './UserManage'
|
||||
|
||||
@@ -1749,6 +1749,27 @@ export interface GetSecurityScanningDetailParams {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface GetUserAiemployeeListParams {
|
||||
/** 下一页标识 */
|
||||
next_token?: string;
|
||||
/**
|
||||
* 分页
|
||||
* @min 1
|
||||
* @default 1
|
||||
*/
|
||||
page?: number;
|
||||
/**
|
||||
* 每页多少条记录
|
||||
* @min 1
|
||||
* @default 10
|
||||
*/
|
||||
size?: number;
|
||||
}
|
||||
|
||||
export interface GetUserAiemployeeInfoParams {
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface GetUserChatInfoParams {
|
||||
/** 对话记录ID */
|
||||
id: string;
|
||||
|
||||
@@ -41,7 +41,7 @@ const ADMIN_MENUS = [
|
||||
show: true,
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
{
|
||||
label: 'AI 员工',
|
||||
value: '/employee',
|
||||
pathname: 'employee',
|
||||
@@ -100,6 +100,14 @@ const USER_MENUS = [
|
||||
show: true,
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'AI 员工',
|
||||
value: '/user/employee',
|
||||
pathname: '/user/employee',
|
||||
icon: 'icon-zhanghao',
|
||||
show: true,
|
||||
disabled: false,
|
||||
},
|
||||
// {
|
||||
// label: '设置',
|
||||
// value: '/user/setting',
|
||||
|
||||
@@ -5,6 +5,8 @@ import {
|
||||
DomainUpdateAIEmployeeReq,
|
||||
postAiemployeeCreate,
|
||||
putAiemployeeUpdate,
|
||||
postUserAiemployeeCreate,
|
||||
putUserAiemployeeUpdate,
|
||||
} from "@/api";
|
||||
import { Ellipsis, message, Modal } from "@c-x/ui";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
@@ -25,6 +27,7 @@ import {
|
||||
import { useEffect, useState } from "react";
|
||||
import CopyToClipboard from "react-copy-to-clipboard";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { z } from "zod";
|
||||
|
||||
const formSchema = z.object({
|
||||
@@ -61,6 +64,8 @@ const EmloyeeModal = ({
|
||||
const [webhookUrl, setWebhookUrl] = useState<
|
||||
Pick<DomainAIEmployee, "webhook_url" | "webhook_secret"> | undefined
|
||||
>();
|
||||
const { pathname } = useLocation();
|
||||
const isUser = pathname.startsWith("/user/");
|
||||
const {
|
||||
reset,
|
||||
register,
|
||||
@@ -74,8 +79,8 @@ const EmloyeeModal = ({
|
||||
const handleChange = handleSubmit(
|
||||
async (data) => {
|
||||
const res = await (record
|
||||
? putAiemployeeUpdate({ ...data, id: record.id })
|
||||
: postAiemployeeCreate(data));
|
||||
? (isUser ? putUserAiemployeeUpdate : putAiemployeeUpdate)({ ...data, id: record.id })
|
||||
: (isUser ? postUserAiemployeeCreate : postAiemployeeCreate)(data));
|
||||
onChanged?.(); // 调用回调函数,刷新列表
|
||||
setWebhookUrl(res);
|
||||
setWebhookOpen(true);
|
||||
|
||||
@@ -5,6 +5,10 @@ import Card from "@/components/card";
|
||||
import { Box, Button, Stack } from "@mui/material";
|
||||
|
||||
import { deleteAiemployeeDelete, getAiemployeeList } from "@/api/AiEmployee";
|
||||
import {
|
||||
deleteUserAiemployeeDelete,
|
||||
getUserAiemployeeList,
|
||||
} from "@/api/UserAiEmployee";
|
||||
import {
|
||||
ConstsRepoPlatform,
|
||||
DomainAIEmployee,
|
||||
@@ -13,6 +17,7 @@ import {
|
||||
import { ColumnsType } from "@c-x/ui/dist/Table";
|
||||
import dayjs from "dayjs";
|
||||
import EmloyeeModal from "./emloyeeModal";
|
||||
import { useLocation } from "react-router-dom";
|
||||
|
||||
const gitPlatformIcons = {
|
||||
[ConstsRepoPlatform.RepoPlatformGitHub]: "icon-github",
|
||||
@@ -27,6 +32,8 @@ const EmployeeTaskList = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [dataSource, setDataSource] = useState<DomainAIEmployee[]>([]);
|
||||
const [detail, setDetail] = useState<DomainUpdateAIEmployeeReq | undefined>();
|
||||
const { pathname } = useLocation();
|
||||
const isUser = pathname.startsWith("/user/");
|
||||
const [open, setOpen] = useState(false);
|
||||
const onClose = () => {
|
||||
setOpen(false);
|
||||
@@ -39,7 +46,7 @@ const EmployeeTaskList = () => {
|
||||
|
||||
const fetchData = async (params: { page?: number; size?: number }) => {
|
||||
setLoading(true);
|
||||
const res = await getAiemployeeList({
|
||||
const res = await (isUser ? getUserAiemployeeList : getAiemployeeList)({
|
||||
page: params.page || page,
|
||||
size: params.size || size,
|
||||
});
|
||||
@@ -79,7 +86,9 @@ const EmployeeTaskList = () => {
|
||||
</>
|
||||
),
|
||||
onOk: () => {
|
||||
deleteAiemployeeDelete({ id: record.id! }).then(() => {
|
||||
(isUser ? deleteUserAiemployeeDelete : deleteAiemployeeDelete)({
|
||||
id: record.id!,
|
||||
}).then(() => {
|
||||
message.success("删除成功");
|
||||
fetchData({});
|
||||
});
|
||||
@@ -259,6 +268,7 @@ const EmployeeTaskList = () => {
|
||||
size="small"
|
||||
sx={{ mb: 2, alignSelf: "flex-end" }}
|
||||
onClick={() => setOpen(true)}
|
||||
disabled={isUser && total > 0}
|
||||
>
|
||||
创建 AI 员工
|
||||
</Button>
|
||||
|
||||
@@ -116,6 +116,10 @@ const routerConfig = [
|
||||
path: 'codescan',
|
||||
element: <UserCodeScan />,
|
||||
},
|
||||
{
|
||||
path: 'employee',
|
||||
element: <AdminEmployee />,
|
||||
},
|
||||
{
|
||||
path: 'setting',
|
||||
element: <UserSetting />,
|
||||
|
||||
Reference in New Issue
Block a user