R59 A1-A6:极简考勤打卡
- 新增 AttendanceRecord 与 AttendancePolicy 模型 - 上下班打卡、今日状态、月度统计端点 - 考勤管理页面(我的/团队/设置三 Tab) - 移动端快速打卡入口 - 管理员补卡与审计日志 - 单测覆盖打卡幂等、迟到计算、工时计算、权限边界
这个提交包含在:
@@ -0,0 +1,45 @@
|
||||
CREATE TABLE "attendance_records" (
|
||||
"id" UUID NOT NULL,
|
||||
"employee_id" UUID NOT NULL,
|
||||
"work_date" DATE NOT NULL,
|
||||
"clock_in_at" TIMESTAMP(3),
|
||||
"clock_out_at" TIMESTAMP(3),
|
||||
"work_minutes" INTEGER,
|
||||
"is_late" BOOLEAN NOT NULL DEFAULT false,
|
||||
"late_minutes" INTEGER NOT NULL DEFAULT 0,
|
||||
"is_early_leave" BOOLEAN NOT NULL DEFAULT false,
|
||||
"early_minutes" INTEGER NOT NULL DEFAULT 0,
|
||||
"note" TEXT,
|
||||
"source" VARCHAR(16) NOT NULL DEFAULT 'web',
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_by" UUID,
|
||||
|
||||
CONSTRAINT "attendance_records_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE TABLE "attendance_policies" (
|
||||
"id" UUID NOT NULL,
|
||||
"work_start_time" VARCHAR(5) NOT NULL DEFAULT '09:00',
|
||||
"work_end_time" VARCHAR(5) NOT NULL DEFAULT '18:00',
|
||||
"lunch_start_time" VARCHAR(5) NOT NULL DEFAULT '12:00',
|
||||
"lunch_end_time" VARCHAR(5) NOT NULL DEFAULT '13:00',
|
||||
"late_tolerance_minutes" INTEGER NOT NULL DEFAULT 0,
|
||||
"enabled" BOOLEAN NOT NULL DEFAULT true,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_by" UUID,
|
||||
|
||||
CONSTRAINT "attendance_policies_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX "attendance_records_employee_date_ux"
|
||||
ON "attendance_records"("employee_id", "work_date");
|
||||
|
||||
CREATE INDEX "idx_attendance_records_work_date"
|
||||
ON "attendance_records"("work_date");
|
||||
|
||||
ALTER TABLE "attendance_records"
|
||||
ADD CONSTRAINT "attendance_records_employee_id_fkey"
|
||||
FOREIGN KEY ("employee_id") REFERENCES "employees"("id")
|
||||
ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -636,6 +636,7 @@ model Employee {
|
||||
lifecycle_events EmployeeLifecycleEvent[]
|
||||
checklist_tasks EmployeeChecklistTask[]
|
||||
presence_records EmployeePresence[]
|
||||
attendance_records AttendanceRecord[]
|
||||
weekly_reports WeeklyReport[]
|
||||
todo_items_assigned TodoItem[] @relation("TodoAssignee")
|
||||
todo_items_created TodoItem[] @relation("TodoCreator")
|
||||
@@ -1836,6 +1837,47 @@ model EmployeePresence {
|
||||
@@map("employee_presence")
|
||||
}
|
||||
|
||||
model AttendanceRecord {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
employee_id String @db.Uuid
|
||||
work_date DateTime @db.Date
|
||||
clock_in_at DateTime?
|
||||
clock_out_at DateTime?
|
||||
work_minutes Int?
|
||||
is_late Boolean @default(false)
|
||||
late_minutes Int @default(0)
|
||||
is_early_leave Boolean @default(false)
|
||||
early_minutes Int @default(0)
|
||||
note String?
|
||||
source String @default("web") @db.VarChar(16)
|
||||
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @default(now()) @updatedAt
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
employee Employee @relation(fields: [employee_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([employee_id, work_date], map: "attendance_records_employee_date_ux")
|
||||
@@index([work_date], map: "idx_attendance_records_work_date")
|
||||
@@map("attendance_records")
|
||||
}
|
||||
|
||||
model AttendancePolicy {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
work_start_time String @default("09:00") @db.VarChar(5)
|
||||
work_end_time String @default("18:00") @db.VarChar(5)
|
||||
lunch_start_time String @default("12:00") @db.VarChar(5)
|
||||
lunch_end_time String @default("13:00") @db.VarChar(5)
|
||||
late_tolerance_minutes Int @default(0)
|
||||
enabled Boolean @default(true)
|
||||
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @default(now()) @updatedAt
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
@@map("attendance_policies")
|
||||
}
|
||||
|
||||
model WeeklyReport {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
employee_id String @db.Uuid
|
||||
|
||||
在新工单中引用
屏蔽一个用户