Sửa đổi dữ liệu của hệ thống theo ARCHITECTURE.md
This commit is contained in:
@@ -2,6 +2,7 @@ import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
import { Pool } from 'pg';
|
||||
import 'dotenv/config';
|
||||
import * as bcrypt from 'bcrypt';
|
||||
|
||||
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
||||
const adapter = new PrismaPg(pool);
|
||||
@@ -20,7 +21,9 @@ async function main() {
|
||||
data: {
|
||||
email: 'owner@travel.com',
|
||||
name: 'Lộc Phạm (Chủ Tour)',
|
||||
passwordHash: 'hashed_password_123',
|
||||
// Hash mật khẩu '123456' để có thể đăng nhập thực tế
|
||||
passwordHash: await bcrypt.hash('123456', 10),
|
||||
isAdmin: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -28,7 +31,7 @@ async function main() {
|
||||
data: {
|
||||
email: 'photomember@travel.com',
|
||||
name: 'Nguyễn Văn Ảnh (Chỉ xem ảnh)',
|
||||
passwordHash: 'hashed_password_456',
|
||||
passwordHash: await bcrypt.hash('123456', 10),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -38,11 +41,11 @@ async function main() {
|
||||
title: 'Hành trình khám phá TP.HCM',
|
||||
startDate: new Date('2023-11-20'),
|
||||
endDate: new Date('2023-11-21'),
|
||||
creatorId: owner.id,
|
||||
members: {
|
||||
createdById: owner.id,
|
||||
participants: {
|
||||
create: [
|
||||
{ userId: owner.id, role: 'OWNER' },
|
||||
{ userId: photoMember.id, role: 'MEMBER_PHOTO_ONLY' },
|
||||
{ userId: photoMember.id, role: 'VIEWER_ONLY' },
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -52,25 +55,23 @@ async function main() {
|
||||
const leg1 = await prisma.leg.create({
|
||||
data: {
|
||||
tourId: tour.id,
|
||||
sequenceNumber: 1,
|
||||
notes: 'Khám phá lịch sử trung tâm',
|
||||
places: {
|
||||
sequence: 1,
|
||||
note: 'Khám phá lịch sử trung tâm',
|
||||
locations: {
|
||||
create: [
|
||||
{
|
||||
name: 'Dinh Độc Lập',
|
||||
address: '135 Nam Kỳ Khởi Nghĩa, Quận 1',
|
||||
latitude: 10.777,
|
||||
longitude: 106.695,
|
||||
sequenceInLeg: 1,
|
||||
arrivalTime: new Date('2023-11-20T08:00:00Z'),
|
||||
plannedStart: new Date('2023-11-20T08:00:00Z'),
|
||||
},
|
||||
{
|
||||
name: 'Bưu điện Thành phố',
|
||||
address: '02 Công xã Paris, Quận 1',
|
||||
latitude: 10.779,
|
||||
longitude: 106.699,
|
||||
sequenceInLeg: 2,
|
||||
arrivalTime: new Date('2023-11-20T10:00:00Z'),
|
||||
plannedStart: new Date('2023-11-20T10:00:00Z'),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -81,7 +82,7 @@ async function main() {
|
||||
await prisma.expense.create({
|
||||
data: {
|
||||
legId: leg1.id,
|
||||
category: 'DINING',
|
||||
category: 'FOOD',
|
||||
amount: 500000,
|
||||
currency: 'VND',
|
||||
description: 'Ăn trưa đặc sản Quận 1',
|
||||
|
||||
Reference in New Issue
Block a user