148 lines
4.1 KiB
Go
148 lines
4.1 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/golang-jwt/jwt/v5"
|
|
"time"
|
|
)
|
|
|
|
type TimeEntry struct {
|
|
ID int `json:"id"`
|
|
UserID int `json:"user_id"`
|
|
ScheduleID int `json:"schedule_id"`
|
|
Date string `json:"date"`
|
|
Type string `json:"type"`
|
|
StartTime string `json:"start_time"`
|
|
EndTime string `json:"end_time"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
Username string `json:"username"`
|
|
}
|
|
|
|
type WeeklyHours struct {
|
|
UserID int `json:"user_id"`
|
|
Username string `json:"username"`
|
|
Week int `json:"week"`
|
|
Year int `json:"year"`
|
|
TotalHours float64 `json:"total_hours"`
|
|
YearlyTarget float64 `json:"yearly_target"`
|
|
YearlyActual float64 `json:"yearly_actual"`
|
|
WeeklyTarget float64 `json:"weekly_target"`
|
|
RemainingYearly float64 `json:"remaining_yearly"`
|
|
}
|
|
|
|
type User struct {
|
|
ID int `json:"id"`
|
|
Username string `json:"username"`
|
|
Password string `json:"-"`
|
|
IsAdmin bool `json:"is_admin"`
|
|
YearlyHours float64 `json:"yearly_hours"`
|
|
}
|
|
|
|
type Schedule struct {
|
|
ID int `json:"id"`
|
|
DayOfWeek int `json:"day_of_week"`
|
|
StartTime string `json:"start_time"`
|
|
EndTime string `json:"end_time"`
|
|
Type string `json:"type"`
|
|
Title string `json:"title"`
|
|
}
|
|
|
|
type LoginRequest struct {
|
|
Username string `json:"username" validate:"required"`
|
|
Password string `json:"password" validate:"required"`
|
|
}
|
|
|
|
type LoginResponse struct {
|
|
Token string `json:"token"`
|
|
Username string `json:"username"`
|
|
IsAdmin bool `json:"is_admin"`
|
|
}
|
|
|
|
type CreateUserRequest struct {
|
|
Username string `json:"username" validate:"required"`
|
|
Password string `json:"password" validate:"required,min=6"`
|
|
IsAdmin bool `json:"is_admin"`
|
|
YearlyHours float64 `json:"yearly_hours"`
|
|
}
|
|
|
|
type SchoolYear struct {
|
|
ID int `json:"id"`
|
|
Name string `json:"name"`
|
|
StartDate string `json:"start_date"`
|
|
EndDate string `json:"end_date"`
|
|
IsActive bool `json:"is_active"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type CreateSchoolYearRequest struct {
|
|
Name string `json:"name" validate:"required"`
|
|
StartDate string `json:"start_date" validate:"required"`
|
|
EndDate string `json:"end_date" validate:"required"`
|
|
}
|
|
|
|
type UpdateUserRequest struct {
|
|
Username string `json:"username"`
|
|
YearlyHours float64 `json:"yearly_hours"`
|
|
}
|
|
|
|
type ResetPasswordRequest struct {
|
|
NewPassword string `json:"new_password" validate:"required,min=6"`
|
|
}
|
|
|
|
type UpdateTimeEntryRequest struct {
|
|
Date string `json:"date"`
|
|
StartTime string `json:"start_time"`
|
|
EndTime string `json:"end_time"`
|
|
Type string `json:"type"`
|
|
}
|
|
|
|
type Claims struct {
|
|
UserID int `json:"user_id"`
|
|
Username string `json:"username"`
|
|
IsAdmin bool `json:"is_admin"`
|
|
jwt.RegisteredClaims
|
|
}
|
|
|
|
type ChangePasswordRequest struct {
|
|
OldPassword string `json:"old_password"`
|
|
NewPassword string `json:"new_password"`
|
|
}
|
|
|
|
type LicenseData struct {
|
|
SchoolName string `json:"school_name"`
|
|
MaxUsers int `json:"max_users"`
|
|
ExpiresAt string `json:"expires_at"`
|
|
}
|
|
|
|
type LicenseFile struct {
|
|
Data LicenseData `json:"data"`
|
|
Signature string `json:"signature"`
|
|
}
|
|
|
|
type LicenseStatus struct {
|
|
IsValid bool `json:"is_valid"`
|
|
SchoolName string `json:"school_name"`
|
|
ExpiresAt string `json:"expires_at"`
|
|
MaxUsers int `json:"max_users"`
|
|
UserCount int `json:"user_count"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
type Substitution struct {
|
|
ID int `json:"id"`
|
|
Date string `json:"date"`
|
|
StartTime string `json:"start_time"`
|
|
EndTime string `json:"end_time"`
|
|
Title string `json:"title"`
|
|
Notes string `json:"notes"`
|
|
TakenByUserID *int `json:"taken_by_user_id,omitempty"`
|
|
TakenByUsername string `json:"taken_by_username,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type CreateSubstitutionRequest struct {
|
|
Date string `json:"date" validate:"required"`
|
|
StartTime string `json:"start_time" validate:"required"`
|
|
EndTime string `json:"end_time" validate:"required"`
|
|
Title string `json:"title" validate:"required"`
|
|
Notes string `json:"notes"`
|
|
}
|