init push
This commit is contained in:
5
internal/domain/contact/errors.go
Normal file
5
internal/domain/contact/errors.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package contact
|
||||
|
||||
import "errors"
|
||||
|
||||
var ErrUsernameAlreadyExists = errors.New("username already exists")
|
||||
190
internal/domain/contact/model.go
Normal file
190
internal/domain/contact/model.go
Normal file
@@ -0,0 +1,190 @@
|
||||
package contact
|
||||
|
||||
import "time"
|
||||
|
||||
type ListFilter struct {
|
||||
Role string
|
||||
PilotCategory string
|
||||
ChiefDoctor *bool
|
||||
ChiefTechnician *bool
|
||||
ResponsibleComplaint *bool
|
||||
ChiefPilot *bool
|
||||
IFRQualified *bool
|
||||
Search string
|
||||
Sort string
|
||||
Limit int
|
||||
Offset int
|
||||
}
|
||||
|
||||
type UserPatch struct {
|
||||
Email *string
|
||||
SSOEmail *string
|
||||
IsAdmin *bool
|
||||
Username *string
|
||||
FirstName *string
|
||||
LastName *string
|
||||
MobilePhone *string
|
||||
Timezone *string
|
||||
SortKey *int
|
||||
SortKeySet bool
|
||||
IsActive *bool
|
||||
ProfileAttachmentID *[]byte
|
||||
}
|
||||
|
||||
type ProfilePatch struct {
|
||||
PilotCategory *string
|
||||
ShortName *string
|
||||
LicenseNo *string
|
||||
LicenseIssuedAt *time.Time
|
||||
LicenseExpiredAt *time.Time
|
||||
TechnicianLicenseNo *string
|
||||
HasIFRQualification *bool
|
||||
IsChiefPilot *bool
|
||||
IsDUL *bool
|
||||
DULBaseIDs [][]byte
|
||||
DULBaseIDsSet bool
|
||||
ResponsibleFlightRescuer *bool
|
||||
TotalFlightMinutes *int
|
||||
ResponsiblePilotMinutes *int
|
||||
SecondPilotMinutes *int
|
||||
DoubleCommandMinutes *int
|
||||
FlightInstructorMinutes *int
|
||||
NightFlightMinutes *int
|
||||
IFRFlightMinutes *int
|
||||
Specialization *string
|
||||
SubSpecialization *string
|
||||
IsChiefPhysician *bool
|
||||
IsChiefTechnician *bool
|
||||
IsResponsibleComplaints *bool
|
||||
RoleLabel *string
|
||||
Note *string
|
||||
Location *string
|
||||
Postcode *string
|
||||
StreetLine *string
|
||||
WeightKG *float64
|
||||
PhotoFileID *string
|
||||
}
|
||||
|
||||
type CreateInput struct {
|
||||
RoleID []byte
|
||||
RoleIDs [][]byte
|
||||
User UserPatch
|
||||
Profile ProfilePatch
|
||||
Profiles []CreateRoleProfile
|
||||
}
|
||||
|
||||
type CreateRoleProfile struct {
|
||||
RoleCode string
|
||||
Patch ProfilePatch
|
||||
}
|
||||
|
||||
type UpdateInput struct {
|
||||
UserID []byte
|
||||
User UserPatch
|
||||
RoleID []byte
|
||||
RoleIDs [][]byte
|
||||
UpdateRoles bool
|
||||
Profile ProfilePatch
|
||||
Profiles []CreateRoleProfile
|
||||
TargetProfileRole string
|
||||
}
|
||||
|
||||
type ContactListItem struct {
|
||||
UserID []byte `gorm:"column:user_id"`
|
||||
CreatedBy []byte `gorm:"column:created_by"`
|
||||
UpdatedBy []byte `gorm:"column:updated_by"`
|
||||
RoleCode string `gorm:"column:role_code"`
|
||||
RoleName string `gorm:"column:role_name"`
|
||||
PilotCategory string `gorm:"column:pilot_category"`
|
||||
Username string `gorm:"column:username"`
|
||||
Email string `gorm:"column:email"`
|
||||
SSOEmail *string `gorm:"column:sso_email"`
|
||||
IsAdmin bool `gorm:"column:is_admin"`
|
||||
FirstName string `gorm:"column:first_name"`
|
||||
LastName string `gorm:"column:last_name"`
|
||||
ShortName string `gorm:"column:short_name"`
|
||||
LicenseNo string `gorm:"column:license_no"`
|
||||
Location string `gorm:"column:location"`
|
||||
MobilePhone string `gorm:"column:mobile_phone"`
|
||||
ProfileAttachmentID []byte `gorm:"column:profile_attachment_id"`
|
||||
HasPassword bool `gorm:"column:has_password"`
|
||||
SortKey *int `gorm:"column:sortkey"`
|
||||
Note string `gorm:"column:note"`
|
||||
IsActive bool `gorm:"column:is_active"`
|
||||
CreatedAt time.Time `gorm:"column:created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at"`
|
||||
LastLoginAt *time.Time `gorm:"column:last_login_at"`
|
||||
BaseRolesRaw *string `gorm:"column:base_roles_raw"`
|
||||
RolesRaw *string `gorm:"column:roles_raw"`
|
||||
|
||||
PilotShortName *string `gorm:"column:pilot_short_name"`
|
||||
PilotLicenseNo *string `gorm:"column:pilot_license_no"`
|
||||
PilotLicenseIssuedAt *time.Time `gorm:"column:pilot_license_issued_at"`
|
||||
PilotLicenseExpiredAt *time.Time `gorm:"column:pilot_license_expired_at"`
|
||||
PilotTechnicianLicenseNo *string `gorm:"column:pilot_technician_license_no"`
|
||||
PilotHasIFRQualification *bool `gorm:"column:pilot_has_ifr_qualification"`
|
||||
PilotIsChiefPilot *bool `gorm:"column:pilot_is_chief_pilot"`
|
||||
PilotIsDUL *bool `gorm:"column:pilot_is_dul"`
|
||||
PilotTotalFlightMinutes *int `gorm:"column:pilot_total_flight_minutes"`
|
||||
PilotResponsiblePilotMinutes *int `gorm:"column:pilot_responsible_pilot_minutes"`
|
||||
PilotSecondPilotMinutes *int `gorm:"column:pilot_second_pilot_minutes"`
|
||||
PilotDoubleCommandMinutes *int `gorm:"column:pilot_double_command_minutes"`
|
||||
PilotFlightInstructorMinutes *int `gorm:"column:pilot_flight_instructor_minutes"`
|
||||
PilotNightFlightMinutes *int `gorm:"column:pilot_night_flight_minutes"`
|
||||
PilotIFRFlightMinutes *int `gorm:"column:pilot_ifr_flight_minutes"`
|
||||
PilotLocation *string `gorm:"column:pilot_location"`
|
||||
PilotPostcode *string `gorm:"column:pilot_postcode"`
|
||||
PilotStreetLine *string `gorm:"column:pilot_street_line"`
|
||||
PilotNote *string `gorm:"column:pilot_note"`
|
||||
PilotWeightKG *float64 `gorm:"column:pilot_weight_kg"`
|
||||
PilotPhotoFileID *string `gorm:"column:pilot_photo_file_id"`
|
||||
|
||||
DoctorShortName *string `gorm:"column:doctor_short_name"`
|
||||
DoctorSpecialization *string `gorm:"column:doctor_specialization"`
|
||||
DoctorSubSpecialization *string `gorm:"column:doctor_sub_specialization"`
|
||||
DoctorIsChiefPhysician *bool `gorm:"column:doctor_is_chief_physician"`
|
||||
DoctorLocation *string `gorm:"column:doctor_location"`
|
||||
DoctorPostcode *string `gorm:"column:doctor_postcode"`
|
||||
DoctorStreetLine *string `gorm:"column:doctor_street_line"`
|
||||
DoctorNote *string `gorm:"column:doctor_note"`
|
||||
DoctorPhotoFileID *string `gorm:"column:doctor_photo_file_id"`
|
||||
|
||||
AirRescuerShortName *string `gorm:"column:air_rescuer_short_name"`
|
||||
AirRescuerResponsibleFlightRescuer *bool `gorm:"column:air_rescuer_responsible_flight_rescuer"`
|
||||
AirRescuerLocation *string `gorm:"column:air_rescuer_location"`
|
||||
AirRescuerPostcode *string `gorm:"column:air_rescuer_postcode"`
|
||||
AirRescuerStreetLine *string `gorm:"column:air_rescuer_street_line"`
|
||||
AirRescuerNote *string `gorm:"column:air_rescuer_note"`
|
||||
AirRescuerPhotoFileID *string `gorm:"column:air_rescuer_photo_file_id"`
|
||||
|
||||
TechnicianShortName *string `gorm:"column:technician_short_name"`
|
||||
TechnicianLicenseNo *string `gorm:"column:technician_license_no"`
|
||||
TechnicianIsChiefTechnician *bool `gorm:"column:technician_is_chief_technician"`
|
||||
TechnicianIsResponsibleComplaints *bool `gorm:"column:technician_is_responsible_complaints"`
|
||||
TechnicianLocation *string `gorm:"column:technician_location"`
|
||||
TechnicianPostcode *string `gorm:"column:technician_postcode"`
|
||||
TechnicianStreetLine *string `gorm:"column:technician_street_line"`
|
||||
TechnicianNote *string `gorm:"column:technician_note"`
|
||||
TechnicianPhotoFileID *string `gorm:"column:technician_photo_file_id"`
|
||||
|
||||
FlightAssistantShortName *string `gorm:"column:flight_assistant_short_name"`
|
||||
FlightAssistantLocation *string `gorm:"column:flight_assistant_location"`
|
||||
FlightAssistantPostcode *string `gorm:"column:flight_assistant_postcode"`
|
||||
FlightAssistantStreetLine *string `gorm:"column:flight_assistant_street_line"`
|
||||
FlightAssistantNote *string `gorm:"column:flight_assistant_note"`
|
||||
FlightAssistantPhotoFileID *string `gorm:"column:flight_assistant_photo_file_id"`
|
||||
|
||||
StaffShortName *string `gorm:"column:staff_short_name"`
|
||||
StaffRoleLabel *string `gorm:"column:staff_role_label"`
|
||||
StaffLocation *string `gorm:"column:staff_location"`
|
||||
StaffPostcode *string `gorm:"column:staff_postcode"`
|
||||
StaffStreetLine *string `gorm:"column:staff_street_line"`
|
||||
StaffNote *string `gorm:"column:staff_note"`
|
||||
StaffPhotoFileID *string `gorm:"column:staff_photo_file_id"`
|
||||
}
|
||||
|
||||
type ContactBaseRole struct {
|
||||
BaseID []byte
|
||||
BaseName string
|
||||
RoleCode string
|
||||
}
|
||||
20
internal/domain/contact/repository.go
Normal file
20
internal/domain/contact/repository.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package contact
|
||||
|
||||
import "context"
|
||||
|
||||
type Repository interface {
|
||||
ListContacts(ctx context.Context, filter ListFilter) ([]ContactListItem, int64, error)
|
||||
GetContactByID(ctx context.Context, userID []byte) (*ContactListItem, error)
|
||||
IsActorAdmin(ctx context.Context) (bool, error)
|
||||
ResolveRoleCodeByID(ctx context.Context, roleID []byte) (string, error)
|
||||
CreateContact(ctx context.Context, in CreateInput) ([]byte, error)
|
||||
UpdateContact(ctx context.Context, in UpdateInput) error
|
||||
DeleteContact(ctx context.Context, userID []byte) error
|
||||
UpdateContactStatus(ctx context.Context, userID []byte, isActive bool) error
|
||||
UpdateContactRole(ctx context.Context, userID []byte, roleCode string) error
|
||||
UpdatePilotCategory(ctx context.Context, userID []byte, category string) error
|
||||
UpdateLicense(ctx context.Context, userID []byte, licenseNo *string) error
|
||||
UpdateChiefFlags(ctx context.Context, userID []byte, patch ProfilePatch) error
|
||||
UpdateResponsibleComplaints(ctx context.Context, userID []byte, value bool) error
|
||||
BulkUpdateStatus(ctx context.Context, userIDs [][]byte, isActive bool) (int64, error)
|
||||
}
|
||||
21
internal/domain/contact/service.go
Normal file
21
internal/domain/contact/service.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package contact
|
||||
|
||||
import "context"
|
||||
|
||||
type Service interface {
|
||||
ListContacts(ctx context.Context, filter ListFilter) ([]ContactListItem, int64, error)
|
||||
GetContactByID(ctx context.Context, userID []byte) (*ContactListItem, error)
|
||||
IsActorAdmin(ctx context.Context) (bool, error)
|
||||
ResolveRoleCodeByID(ctx context.Context, roleID []byte) (string, error)
|
||||
CreateContact(ctx context.Context, in CreateInput) ([]byte, error)
|
||||
UpdateContact(ctx context.Context, in UpdateInput) error
|
||||
DeleteContact(ctx context.Context, userID []byte) error
|
||||
UpdateContactStatus(ctx context.Context, userID []byte, isActive bool) error
|
||||
UpdateContactRole(ctx context.Context, userID []byte, roleCode string) error
|
||||
UpdatePilotCategory(ctx context.Context, userID []byte, category string) error
|
||||
UpdateLicense(ctx context.Context, userID []byte, licenseNo *string) error
|
||||
UpdateChiefFlags(ctx context.Context, userID []byte, patch ProfilePatch) error
|
||||
UpdateResponsibleComplaints(ctx context.Context, userID []byte, value bool) error
|
||||
BulkUpdateStatus(ctx context.Context, userIDs [][]byte, isActive bool) (int64, error)
|
||||
CheckSensitiveAction(ctx context.Context, userID []byte, actionToken string, action string) error
|
||||
}
|
||||
Reference in New Issue
Block a user