fix: add build script for server, fix duplicate index in user_ding_mapping entity
This commit is contained in:
52
apps/server/src/entities/user-ding-mapping.entity.ts
Normal file
52
apps/server/src/entities/user-ding-mapping.entity.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user