20260622214432

This commit is contained in:
oneao committed 2026-06-22 21:44:33 +08:00
1 parent b5f6fafd74
commit e9e3371be7
19 files changed
+1068 -121

No files matched your search

+48
View File
@@ -85,6 +85,7 @@ Important endpoints:
```text
POST /app/auth/login/qq
POST /app/auth/login/wechat
POST /app/auth/login/test
POST /app/bind/qq
POST /app/bind/wechat
@@ -326,6 +327,7 @@ b_family_member
b_finance
b_finance_category
b_finance_category_default
b_app_favorite
```
Views:
@@ -429,3 +431,49 @@ Backend:
- Main tab route `/space` is missing.
- Some pages are placeholders or demos.
## Development Conventions
These rules MUST be followed. They exist to keep the codebase consistent and avoid unnecessary
duplication.
### API — No New Dedicated Endpoints
The project already has a set of generic data APIs. Do NOT create dedicated REST endpoints for
CRUD operations. Always use the existing generic APIs instead:
| Generic API | Usage |
|---|---|
| `POST /data/loadData` | Query with `view_name` (table/view), `search_condition`, `order_by`, `search_columns`, `args` |
| `POST /data/loadDataBySql` | Raw SQL query with `sql` and `args` |
| `POST /data/saveData` | Batch insert/update/delete by `table_name` and `key_field` |
| `POST /data/getUniqueId` | Get snowflake IDs, `count` param (1–100) |
If you genuinely believe a new endpoint is needed, **ask the user first**. Even then, new endpoints
should be generic (e.g. a new generic helper), not dedicated to a single feature.
### Database — Standard Audit Columns
All business tables MUST include these four standard columns:
```sql
create_time TIMESTAMPTZ -- auto-set by applyMetaFields on insert
update_time TIMESTAMPTZ -- auto-set by applyMetaFields on insert & update
create_by BIGINT -- auto-set by applyMetaFields on insert (from JWT user_id)
update_by BIGINT -- auto-set by applyMetaFields on update (from JWT user_id)
```
The `applyMetaFields` function in `pkg/db/meta_field.go` injects these automatically for all tables
except those in the `auditExcludeTables` list (`b_user`, `b_user_oauth`).
When creating a new table:
1. Include all four columns
2. Do NOT add the table to `auditExcludeTables` unless it is a system-level table (user/auth)
3. Primary key `id` should be a snowflake BIGINT, obtained via `getUniqueIdApi` on the frontend or
`uniqueid.NextId()` on the backend
### Frontend State — Reuse Existing Stores
Before creating a new Zustand store or API wrapper, check whether the data can be fetched via the
existing `loadDataApi` / `saveDataApi` from the `@/request/api` module. New API wrapper functions
should only wrap these generic endpoints — never introduce feature-specific RPC-style endpoints.