fix: add build script for server, fix duplicate index in user_ding_mapping entity

This commit is contained in:
2026-07-08 14:18:41 +08:00
parent baa01a910a
commit 8c791ec4f3
2 changed files with 55 additions and 2 deletions

View File

@@ -6,8 +6,9 @@
"license": "UNLICENSED",
"author": "",
"scripts": {
"dev": "nest start --watch -p tsconfig.build.json",
"build": "nest build",
"dev": "SEED_DEV=true nest start --watch -p tsconfig.build.json",
"build": "nest build -p tsconfig.build.json",
"start:dev": "SEED_DEV=true nest start --watch",
"format": "oxfmt",
"start": "nest start",
"start:dev": "nest start --watch",

View File

@@ -0,0 +1,52 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
Index,
ManyToOne,
JoinColumn,
} from 'typeorm';
import { User } from './user.entity';
/**
* Maps DingTalk user IDs to local User records.
* Used for incremental sync and attendance auto-matching.
*
* Mapping chain:
* dingtalk userid → UserDingMapping.dingUserId → UserDingMapping.userId
* → User.id → Student.userId → Student.id
* → DingAttendanceRaw.dingUserId → UserDingMapping.dingUserId → auto-match
*/
@Entity('user_ding_mapping')
export class UserDingMapping {
@PrimaryGeneratedColumn()
id: number;
/** DingTalk user ID (from DingTalk API) */
@Column({ name: 'ding_user_id', length: 100, unique: true })
dingUserId: string;
/** Local User ID */
@Column({ name: 'user_id', type: 'integer', unique: true })
userId: number;
@ManyToOne(() => User, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'user_id' })
user: User;
/** DingTalk user name (cached for display) */
@Column({ name: 'ding_name', length: 100, nullable: true })
dingName: string;
/** DingTalk mobile (cached for display) */
@Column({ name: 'ding_mobile', length: 20, nullable: true })
dingMobile: string;
@CreateDateColumn({ name: 'created_at' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt: Date;
}