refactor: prefix every table with its module
Two tables were named after the concept they came from rather than the module
they belong to, so the schema read as if the template tables were part of the
paper module. Renamed (data preserved, `RENAME TABLE` moves rows in place):
paper_template -> template the 模板 module
section_field -> template_field_library the 字段库 the 模板 module owns
The paper tables and `template_field` already followed the rule. The rename
carries through everything that named a module:
models Template, TemplateField, TemplateFieldLibrary
schemas Template*, TemplateFieldLibrary*
crud app/crud/template.py, app/crud/template_field_library.py
API /template-field-library (was /section-fields); handlers are now
named after library entries, which removes the ambiguity with
TemplateField — a placement, a different thing entirely
client src/api/templateFieldLibrary.ts
`paper_template_filed_sort` is deliberately untouched: it is a column of the
paper module, spelled as the feature was specified.
TiDB v8.5 with tidb_enable_foreign_key on — as this cluster runs — enforces
foreign keys rather than ignoring them, so the docs' "TiDB does not enforce
foreign keys" was wrong. Corrected, with what actually follows from it: the
rename was rehearsed (RENAME TABLE carries a referencing constraint along), the
API keeps checking first so a violation names the row instead of surfacing a
driver error, and the ORM cascades stay so behaviour does not depend on a
cluster setting.
Revision f27a1c6d9e04 verified both ways; 40 smoke checks, type-check and build
all pass.
This commit is contained in:
@@ -14,18 +14,18 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
import { errorMessage } from '@/api/client'
|
||||
import {
|
||||
batchDeleteSectionFields,
|
||||
deleteSectionField,
|
||||
listSectionFields,
|
||||
type SectionField,
|
||||
} from '@/api/sectionFields'
|
||||
batchDeleteTemplateFieldLibrary,
|
||||
deleteTemplateFieldLibrary,
|
||||
listTemplateFieldLibrary,
|
||||
type TemplateFieldLibrary,
|
||||
} from '@/api/templateFieldLibrary'
|
||||
import FieldFormDialog from '@/components/fields/FieldFormDialog.vue'
|
||||
import { formatDateTime, levelIndent, typographyStyle } from '@/utils/format'
|
||||
|
||||
const loading = ref(false)
|
||||
const rows = ref<SectionField[]>([])
|
||||
const rows = ref<TemplateFieldLibrary[]>([])
|
||||
const total = ref(0)
|
||||
const selection = ref<SectionField[]>([])
|
||||
const selection = ref<TemplateFieldLibrary[]>([])
|
||||
|
||||
const query = reactive({
|
||||
keyword: '',
|
||||
@@ -35,7 +35,7 @@ const query = reactive({
|
||||
})
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const editing = ref<SectionField | null>(null)
|
||||
const editing = ref<TemplateFieldLibrary | null>(null)
|
||||
|
||||
const LEVEL_FILTERS = [
|
||||
{ value: null, label: '全部等级' },
|
||||
@@ -47,7 +47,7 @@ const LEVEL_FILTERS = [
|
||||
async function load(): Promise<void> {
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await listSectionFields(query)
|
||||
const result = await listTemplateFieldLibrary(query)
|
||||
rows.value = result.items
|
||||
total.value = result.total
|
||||
|
||||
@@ -81,12 +81,12 @@ function onCreate(): void {
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
function onEdit(row: SectionField): void {
|
||||
function onEdit(row: TemplateFieldLibrary): void {
|
||||
editing.value = row
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function onDelete(row: SectionField): Promise<void> {
|
||||
async function onDelete(row: TemplateFieldLibrary): Promise<void> {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定删除字段「${row.name}」?`, '删除字段', {
|
||||
type: 'warning',
|
||||
@@ -98,7 +98,7 @@ async function onDelete(row: SectionField): Promise<void> {
|
||||
}
|
||||
|
||||
try {
|
||||
await deleteSectionField(row.id)
|
||||
await deleteTemplateFieldLibrary(row.id)
|
||||
ElMessage.success('已删除')
|
||||
await load()
|
||||
} catch (error) {
|
||||
@@ -121,7 +121,7 @@ async function onBatchDelete(): Promise<void> {
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await batchDeleteSectionFields(ids)
|
||||
const result = await batchDeleteTemplateFieldLibrary(ids)
|
||||
ElMessage.success(`已删除 ${result.deleted} 个字段`)
|
||||
selection.value = []
|
||||
await load()
|
||||
@@ -194,7 +194,7 @@ onMounted(load)
|
||||
row-key="id"
|
||||
stripe
|
||||
class="table"
|
||||
@selection-change="(value: SectionField[]) => (selection = value)"
|
||||
@selection-change="(value: TemplateFieldLibrary[]) => (selection = value)"
|
||||
>
|
||||
<el-table-column type="selection" width="46" reserve-selection />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user