refactor(rule-groups): 替换创建/编辑页面为 FastAPI v3 接口
变更内容: 1. 补充重命名 getRuleGroup → getRuleGroup_legacy (rule-groups.ts) 2. 更新导入语句,使用新的 FastAPI v3 函数 (rule-groups.new.tsx) 3. 替换所有函数调用: - getRuleGroups → getEvaluationPointGroups (2处) - getRuleGroup → getEvaluationPointGroup - createRuleGroup → createEvaluationPointGroup - updateRuleGroup → updateEvaluationPointGroup 影响范围: - app/api/evaluation_points/rule-groups.ts (补充遗漏的重命名) - app/routes/rule-groups.new.tsx (创建/编辑页面) 功能: - 分组创建、编辑、编码唯一性验证 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -363,11 +363,12 @@ export async function getAllRuleGroups_legacy(token?: string): Promise<{data: Ru
|
||||
|
||||
/**
|
||||
* 获取单个评查点分组详情(包含评查点数量统计)
|
||||
* @deprecated 使用 getEvaluationPointGroup 代替(FastAPI v3)
|
||||
* @param id 分组ID
|
||||
* @param token JWT token (可选)
|
||||
* @returns 分组详情
|
||||
*/
|
||||
export async function getRuleGroup(id: string, token?: string): Promise<{data: RuleGroup; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
export async function getRuleGroup_legacy(id: string, token?: string): Promise<{data: RuleGroup; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
try {
|
||||
if (!id) {
|
||||
return { error: '分组ID不能为空', status: 400 };
|
||||
|
||||
@@ -6,13 +6,13 @@ import { Button } from "~/components/ui/Button";
|
||||
import { Card } from "~/components/ui/Card";
|
||||
import { toastService } from "~/components/ui/Toast";
|
||||
import ruleGroupsNewStyles from "~/styles/pages/rule-groups_new.css?url";
|
||||
import {
|
||||
getRuleGroups,
|
||||
getRuleGroup,
|
||||
createRuleGroup,
|
||||
updateRuleGroup,
|
||||
import {
|
||||
getEvaluationPointGroups,
|
||||
getEvaluationPointGroup,
|
||||
createEvaluationPointGroup,
|
||||
updateEvaluationPointGroup,
|
||||
type RuleGroup as ApiRuleGroup,
|
||||
type RuleGroupCreateUpdateDto
|
||||
type RuleGroupCreateUpdateDto
|
||||
} from "~/api/evaluation_points/rule-groups";
|
||||
|
||||
// 类型定义
|
||||
@@ -100,13 +100,13 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
// console.log("获取到的ID参数:", id);
|
||||
|
||||
// 获取一级分组列表 (用于选择父级分组)
|
||||
// 🆕 使用增强的 getRuleGroups API,仅获取一级分组且已启用的分组
|
||||
const parentGroupsResponse = await getRuleGroups({
|
||||
// 🆕 使用 FastAPI v3 的 getEvaluationPointGroups API,仅获取一级分组且已启用的分组
|
||||
const parentGroupsResponse = await getEvaluationPointGroups({
|
||||
pid: null, // 仅获取一级分组(pid为null表示顶级分组)
|
||||
is_enabled: true, // 仅获取已启用的分组
|
||||
pageSize: 100, // 获取足够多的分组
|
||||
token: frontendJWT
|
||||
});
|
||||
}, frontendJWT);
|
||||
if (parentGroupsResponse.error) {
|
||||
console.error("获取父分组列表失败:", parentGroupsResponse.error);
|
||||
throw new Error(parentGroupsResponse.error);
|
||||
@@ -122,7 +122,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
|
||||
// 如果有ID,获取分组详情
|
||||
if (id) {
|
||||
const groupResponse = await getRuleGroup(id, frontendJWT);
|
||||
const groupResponse = await getEvaluationPointGroup(id, true, frontendJWT);
|
||||
if (groupResponse.error) {
|
||||
console.error("获取分组详情失败:", groupResponse.error);
|
||||
throw new Error(groupResponse.error);
|
||||
@@ -207,9 +207,9 @@ export async function action({ request }: ActionFunctionArgs) {
|
||||
// 根据是否有ID决定是创建还是更新
|
||||
let response;
|
||||
if (id) {
|
||||
response = await updateRuleGroup(id, saveData, frontendJWT);
|
||||
response = await updateEvaluationPointGroup(id, saveData, frontendJWT);
|
||||
} else {
|
||||
response = await createRuleGroup(saveData, frontendJWT);
|
||||
response = await createEvaluationPointGroup(saveData, frontendJWT);
|
||||
}
|
||||
|
||||
// 处理API响应
|
||||
@@ -328,11 +328,11 @@ export default function RuleGroupNew() {
|
||||
|
||||
try {
|
||||
setCodeValidating(true);
|
||||
const response = await getRuleGroups({
|
||||
const response = await getEvaluationPointGroups({
|
||||
code: code.trim(),
|
||||
pageSize: 10,
|
||||
token: data.frontendJWT
|
||||
});
|
||||
}, data.frontendJWT);
|
||||
|
||||
if (response.error) {
|
||||
console.error("验证编码唯一性失败:", response.error);
|
||||
|
||||
Reference in New Issue
Block a user