feat: log staff sign-in and sign-out and force logout at a set time
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Membership" ADD COLUMN "logoutTime" TEXT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "AttendanceEvent" (
|
||||
"id" TEXT NOT NULL,
|
||||
"organizationId" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"kind" TEXT NOT NULL,
|
||||
"at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"afterHours" BOOLEAN NOT NULL DEFAULT false,
|
||||
"sessionStartedAt" TIMESTAMP(3),
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "AttendanceEvent_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "AttendanceEvent_organizationId_at_idx" ON "AttendanceEvent"("organizationId", "at");
|
||||
CREATE INDEX "AttendanceEvent_organizationId_userId_at_idx" ON "AttendanceEvent"("organizationId", "userId", "at");
|
||||
CREATE UNIQUE INDEX "AttendanceEvent_organizationId_userId_kind_sessionStartedAt_key" ON "AttendanceEvent"("organizationId", "userId", "kind", "sessionStartedAt");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "AttendanceEvent" ADD CONSTRAINT "AttendanceEvent_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE "AttendanceEvent" ADD CONSTRAINT "AttendanceEvent_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -161,6 +161,7 @@ model Organization {
|
||||
teams Team[]
|
||||
companies Company[]
|
||||
people Person[]
|
||||
attendanceEvents AttendanceEvent[]
|
||||
discAssessments DiscAssessment[]
|
||||
salesCopilotSessions SalesCopilotSession[]
|
||||
pipelines Pipeline[]
|
||||
@@ -312,6 +313,7 @@ model User {
|
||||
createdRoutineTasks RoutineTask[] @relation("RoutineTaskCreator")
|
||||
routineTaskEvents RoutineTaskEvent[]
|
||||
routineSettings RoutineUserSettings[]
|
||||
attendanceEvents AttendanceEvent[]
|
||||
deletionArchives DeletionArchive[] @relation("DeletionActor")
|
||||
discAssessments DiscAssessment[] @relation("DiscAssessor")
|
||||
salesCopilotSessions SalesCopilotSession[] @relation("CopilotAuthor")
|
||||
@@ -369,6 +371,8 @@ model Membership {
|
||||
priorArchiveEnabled Boolean @default(false)
|
||||
/// current | archive
|
||||
priorArchiveLens String @default("current")
|
||||
/// ساعت خروج روزانه به وقت تهران، مثل 18:00؛ خالی یعنی بدون محدودیت
|
||||
logoutTime String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -3417,3 +3421,24 @@ model SalesCopilotSession {
|
||||
@@index([organizationId, leadId])
|
||||
@@index([dealId])
|
||||
}
|
||||
|
||||
/// ورود و خروج کارمندان به سامانه
|
||||
model AttendanceEvent {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
/// login | logout | forced_logout
|
||||
kind String
|
||||
at DateTime @default(now())
|
||||
/// ورود بعد از ساعت خروج تعیینشده
|
||||
afterHours Boolean @default(false)
|
||||
/// شروع نشست؛ برای اینکه خروج اجباری هر نشست فقط یک بار ثبت شود
|
||||
sessionStartedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([organizationId, at])
|
||||
@@index([organizationId, userId, at])
|
||||
@@unique([organizationId, userId, kind, sessionStartedAt])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user