File size: 3,862 Bytes
3ddcd86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e30b161
 
3ddcd86
 
 
 
d236183
 
 
 
f4c7416
d236183
 
 
 
 
 
 
 
 
 
f4c7416
 
d236183
 
 
f47883b
 
 
 
 
 
 
e30b161
f47883b
 
 
 
 
 
 
 
 
9591a68
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package entity

import (
	"time"

	"github.com/google/uuid"
	"gorm.io/gorm"
)

type User struct {
	ID        uuid.UUID      `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	Username  string         `gorm:"type:varchar(100);not null;unique" json:"username"`
	Fullname  string         `gorm:"column:name;type:varchar(100);not null" json:"fullname"`
	Email     string         `gorm:"type:varchar(100);not null;unique" json:"email"`
	Role      string         `gorm:"type:varchar(20);not null;default:'user'" json:"role"` // user, admin, worker
	Password  string         `gorm:"type:varchar(255);not null" json:"-"`
	Verified  bool           `gorm:"default:false" json:"verified"`
	TotalXP   int            `gorm:"default:0" json:"total_xp"`
	Level     int            `gorm:"default:1" json:"level"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
}

type Report struct {
	ID             string         `gorm:"type:text;primary_key" json:"id"`
	UserID         uuid.UUID      `gorm:"type:uuid" json:"user_id"`
	WorkerID       *uuid.UUID     `gorm:"type:uuid" json:"worker_id"`
	Longitude      float64        `gorm:"type:numeric" json:"longitude"`
	Latitude       float64        `gorm:"type:numeric" json:"latitude"`
	RoadName       string         `gorm:"column:road_name;type:text" json:"road_name"`
	BeforeImageURL string         `gorm:"column:before_image_url;type:text" json:"before_image_url"`
	AfterImageURL  string         `gorm:"column:after_image_url;type:text" json:"after_image_url"`
	Description    string         `gorm:"type:text" json:"description"`
	DestructClass  string         `gorm:"column:destruct_class;type:text" json:"destruct_class"`
	LocationScore  float64        `gorm:"column:location_score;type:numeric" json:"location_score"`
	TotalScore     float64        `gorm:"column:total_score;type:numeric" json:"total_score"`
	Status         string         `gorm:"type:text" json:"status"`
	AdminNotes     string         `gorm:"column:admin_notes;type:text" json:"admin_notes"`
	Deadline       *time.Time     `gorm:"column:deadline;type:timestamp" json:"deadline"`
	CreatedAt      time.Time      `json:"created_at"`
	DeletedAt      gorm.DeletedAt `gorm:"index" json:"deleted_at"`
}

type Achievement struct {
	ID          string `gorm:"type:text;primary_key" json:"id"`
	Name        string `gorm:"type:varchar(100);not null" json:"name"`
	Description string `gorm:"type:text" json:"description"`
	BadgeURL    string `gorm:"column:badge_url;type:text" json:"badge_url"`
	Category    string `gorm:"type:varchar(50)" json:"category"` // milestone, quality, explorer, streak
	XPReward    int    `gorm:"column:xp_reward;default:0" json:"xp_reward"`
}

type UserAchievement struct {
	ID            uuid.UUID   `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	UserID        uuid.UUID   `gorm:"type:uuid;not null" json:"user_id"`
	AchievementID string      `gorm:"type:text;not null" json:"achievement_id"`
	Achievement   Achievement `gorm:"foreignKey:AchievementID" json:"achievement"`
	UnlockedAt    time.Time   `json:"unlocked_at"`
}

// Notification represents a user notification
type Notification struct {
	ID        uuid.UUID      `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	UserID    uuid.UUID      `gorm:"type:uuid;not null;index" json:"user_id"`
	Type      string         `gorm:"type:varchar(50);not null" json:"type"`
	Title     string         `gorm:"type:varchar(200);not null" json:"title"`
	Message   string         `gorm:"type:text;not null" json:"message"`
	Data      string         `gorm:"type:text" json:"data"`
	IsRead    bool           `gorm:"default:false" json:"is_read"`
	CreatedAt time.Time      `json:"created_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}