Documentation
¶
Index ¶
- Variables
- type Admin
- type AdminResponse
- type AdminRole
- type Company
- type CompanyAddress
- type CompanySizeRange
- type CompanyStatus
- type DB
- func (db *DB) ActivateAdmin(id uuid.UUID) error
- func (db *DB) CreateAdmin(userID string, role AdminRole, isActive bool) (string, error)
- func (db *DB) CreateCompany(tx *sqlx.Tx, company *Company) (*Company, bool, error)
- func (db *DB) CreateCompanyAddress(tx *sqlx.Tx, address *CompanyAddress) (*CompanyAddress, bool, error)
- func (db *DB) CreateJobSeeker(tx *sqlx.Tx, jobSeeker *JobSeeker) (uuid.UUID, error)
- func (db *DB) DeactivateAdmin(id uuid.UUID) error
- func (db *DB) GetAdmin(id uuid.UUID) (*Admin, bool, error)
- func (db *DB) GetAdminByUserID(id uuid.UUID) (*AdminResponse, bool, error)
- func (db *DB) GetCompany(userID uuid.UUID) (*Company, bool, error)
- func (db *DB) GetCompanyAddressByID(tx *sqlx.Tx, id uuid.UUID) (*CompanyAddress, error)
- func (db *DB) GetCompanyByID(id uuid.UUID) (*Company, bool, error)
- func (db *DB) GetJobSeekerByID(id uuid.UUID) (*JobSeeker, bool, error)
- func (db *DB) GetUser(id uuid.UUID) (*User, bool, error)
- func (db *DB) GetUserByEmail(ctx context.Context, email string) (*User, bool, error)
- func (db *DB) GetUserByUsername(ctx context.Context, username string) (*User, bool, error)
- func (db *DB) InsertUser(email, password, userType, username string) (string, error)
- func (db *DB) ListAdmins() ([]AdminResponse, error)
- func (db *DB) UpdateCompany(tx *sqlx.Tx, companyID, userID uuid.UUID, input *Company) (*Company, error)
- func (db *DB) UpdateCompanyAddress(tx *sqlx.Tx, companyID, addressID uuid.UUID, input *CompanyAddress) (*CompanyAddress, error)
- func (db *DB) UpdateCompanyAddressID(tx *sqlx.Tx, companyID, addressID uuid.UUID) error
- func (db *DB) UpdateUserHashedPassword(id uuid.UUID, hashedPassword string) error
- func (db *DB) WithTransaction(ctx context.Context, fn func(*sqlx.Tx) error) error
- type JobSeeker
- type JobSeekerEducation
- type JobSeekerExperience
- type JobSeekerLink
- type JobSeekerPreference
- type JobSeekerProject
- type JobSeekerSkill
- type Permissions
- type User
- type UserType
Constants ¶
This section is empty.
Variables ¶
var (
ErrRecordNotFound = errors.New("record not found")
)
Error
var RolePermissions = map[AdminRole]Permissions{ AdminRoleSuper: { ViewUsers: true, EditUsers: true, DeleteUsers: true, ViewRoles: true, EditRoles: true, DeleteRoles: true, }, AdminRoleAdmin: { ViewUsers: true, EditUsers: true, DeleteUsers: false, ViewRoles: false, EditRoles: false, DeleteRoles: false, }, AdminRoleViewer: { ViewUsers: true, EditUsers: false, DeleteUsers: false, ViewRoles: false, EditRoles: false, DeleteRoles: false, }, }
Functions ¶
This section is empty.
Types ¶
type Admin ¶
type Admin struct { AdminID uuid.UUID `db:"admin_id" json:"admin_id"` UserID uuid.UUID `db:"user_id" json:"user_id"` Role AdminRole `db:"role" json:"role"` LastLogin *time.Time `db:"last_login" json:"last_login,omitempty"` // Nullable field IsActive bool `db:"is_active" json:"is_active"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
Admin represents the admins table.
type AdminResponse ¶
type AdminResponse struct { UserID uuid.UUID `json:"user_id" db:"user_id"` AdminID uuid.UUID `json:"admin_id" db:"admin_id"` Username string `json:"username" db:"username"` Email string `json:"email" db:"email"` Role string `json:"admin_role" db:"role"` LastLogin *time.Time `json:"last_login,omitempty" db:"last_login"` // Nullable field IsActive bool `json:"is_active" db:"is_active"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
type Company ¶
type Company struct { ID uuid.UUID `json:"id" db:"id"` UserID uuid.UUID `json:"user_id" db:"user_id"` // Foreign key to users table Name string `json:"name" db:"name"` Description *string `json:"description,omitempty" db:"description"` // Use pointer for nullable fields Industry *string `json:"industry,omitempty" db:"industry"` Website *string `json:"website,omitempty" db:"website"` Email string `json:"email" db:"email"` Phone *string `json:"phone,omitempty" db:"phone"` LogoURL *string `json:"logo_url,omitempty" db:"logo_url"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` Status CompanyStatus `json:"status" db:"status"` Size CompanySizeRange `json:"size" db:"size"` IsVerified bool `json:"is_verified" db:"is_verified"` AddressID uuid.UUID `json:"address_id" db:"address_id"` // Foreign key to company_addresses Address *CompanyAddress `json:"address,omitempty"` // One-to-one relationship }
Company represents a company entity
type CompanyAddress ¶
type CompanyAddress struct { ID uuid.UUID `json:"id" db:"id"` CompanyID uuid.UUID `json:"company_id" db:"company_id"` // Foreign key to company table AddressLine1 string `json:"address_line_1" db:"address_line_1"` AddressLine2 *string `json:"address_line_2,omitempty" db:"address_line_2"` // Use pointer for nullable fields City string `json:"city" db:"city"` State string `json:"state" db:"state"` ZipCode string `json:"zip_code" db:"zip_code"` Country string `json:"country" db:"country"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
CompanyAddress represents a company's address entity
type CompanySizeRange ¶
type CompanySizeRange string
CompanySizeRange is an enum-like type for company size range
const ( Size1To5 CompanySizeRange = "1-5" Size5To10 CompanySizeRange = "5-10" Size10To25 CompanySizeRange = "10-25" Size25To50 CompanySizeRange = "25-50" Size50To100 CompanySizeRange = "50-100" Size100To500 CompanySizeRange = "100-500" Size500To1000 CompanySizeRange = "500-1000" Size1000Plus CompanySizeRange = "1000+" )
type CompanyStatus ¶
type CompanyStatus string
CompanyStatus is an enum-like type for company status
const ( Active CompanyStatus = "active" Inactive CompanyStatus = "inactive" )
type DB ¶
func (*DB) ActivateAdmin ¶
ActivateAdmin Activate Admin
func (*DB) CreateAdmin ¶
CreateAdmin Create Admin and admin viewer
func (*DB) CreateCompany ¶
func (*DB) CreateCompanyAddress ¶
func (db *DB) CreateCompanyAddress(tx *sqlx.Tx, address *CompanyAddress) (*CompanyAddress, bool, error)
func (*DB) CreateJobSeeker ¶
CreateJobSeeker create new JobSeeker
func (*DB) DeactivateAdmin ¶
DeactivateAdmin Deactivate Admin
func (*DB) GetAdminByUserID ¶
GetAdminByUserID Get Admin by UserID
func (*DB) GetCompany ¶
GetCompany retrieves a company and address by its user ID
func (*DB) GetCompanyAddressByID ¶
func (*DB) GetJobSeekerByID ¶
GetJobSeekerByID get job-seeker by id
func (*DB) GetUserByEmail ¶
func (*DB) GetUserByUsername ¶
GetUserByUsername retrieves a user by their username
func (*DB) InsertUser ¶
func (*DB) ListAdmins ¶
func (db *DB) ListAdmins() ([]AdminResponse, error)
ListAdmins gets a list of admins
func (*DB) UpdateCompany ¶
func (*DB) UpdateCompanyAddress ¶
func (db *DB) UpdateCompanyAddress(tx *sqlx.Tx, companyID, addressID uuid.UUID, input *CompanyAddress) (*CompanyAddress, error)
func (*DB) UpdateCompanyAddressID ¶
func (*DB) UpdateUserHashedPassword ¶
type JobSeeker ¶
type JobSeeker struct { ID uuid.UUID `db:"id" json:"id"` UserID uuid.UUID `db:"user_id" json:"user_id"` FirstName string `db:"first_name" json:"first_name"` LastName string `db:"last_name" json:"last_name"` DateOfBirth time.Time `db:"date_of_birth" json:"date_of_birth"` Bio string `db:"bio" json:"bio"` ProfilePictureURL *string `db:"profile_picture_url" json:"profile_picture_url"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
JobSeeker represents the job-seekers table
type JobSeekerEducation ¶
type JobSeekerEducation struct { ID uuid.UUID `db:"id" json:"id"` JobSeekerID uuid.UUID `db:"job_seeker_id" json:"job_seeker_id"` InstitutionName string `db:"institution_name" json:"institution_name"` Degree string `db:"degree" json:"degree"` FieldOfStudy string `db:"field_of_study" json:"field_of_study"` StartDate time.Time `db:"start_date" json:"start_date"` EndDate *time.Time `db:"end_date" json:"end_date"` // Use a pointer to allow null Grade string `db:"grade" json:"grade"` Description string `db:"description" json:"description"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
JobSeekerEducation represents the job_seeker_educations table
type JobSeekerExperience ¶
type JobSeekerExperience struct { ID uuid.UUID `db:"id" json:"id"` JobSeekerID uuid.UUID `db:"job_seeker_id" json:"job_seeker_id"` JobTitle string `db:"job_title" json:"job_title"` CompanyName string `db:"company_name" json:"company_name"` StartDate time.Time `db:"start_date" json:"start_date"` EndDate *time.Time `db:"end_date" json:"end_date"` // Use a pointer to allow null Description string `db:"description" json:"description"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
JobSeekerExperience represents the job_seeker_experiences table
type JobSeekerLink ¶
type JobSeekerLink struct { ID uuid.UUID `db:"id" json:"id"` JobSeekerID uuid.UUID `db:"job_seeker_id" json:"job_seeker_id"` LinkType string `db:"link_type" json:"link_type"` URL string `db:"url" json:"url"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
JobSeekerLink represents the job_seeker_links table
type JobSeekerPreference ¶
type JobSeekerPreference struct { ID uuid.UUID `db:"id" json:"id"` JobSeekerID uuid.UUID `db:"job_seeker_id" json:"job_seeker_id"` PreferredJobType string `db:"preferred_job_type" json:"preferred_job_type"` PreferredIndustry string `db:"preferred_industry" json:"preferred_industry"` PreferredLocation string `db:"preferred_location" json:"preferred_location"` SalaryExpectation *int `db:"salary_expectation" json:"salary_expectation"` // Use a pointer to allow null RemotePreference bool `db:"remote_preference" json:"remote_preference"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
JobSeekerPreference represents the job_seeker_preferences table
type JobSeekerProject ¶
type JobSeekerProject struct { ID uuid.UUID `db:"id" json:"id"` JobSeekerID uuid.UUID `db:"job_seeker_id" json:"job_seeker_id"` Title string `db:"title" json:"title"` Description string `db:"description" json:"description"` StartDate time.Time `db:"start_date" json:"start_date"` EndDate *time.Time `db:"end_date" json:"end_date"` // Use a pointer to allow null Link string `db:"link" json:"link"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
JobSeekerProject represents the job_seeker_projects table
type JobSeekerSkill ¶
type JobSeekerSkill struct { ID uuid.UUID `db:"id" json:"id"` JobSeekerID uuid.UUID `db:"job_seeker_id" json:"job_seeker_id"` SkillName string `db:"skill_name" json:"skill_name"` ProficiencyLevel string `db:"proficiency_level" json:"proficiency_level"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
JobSeekerSkill represents the job_seeker_skills table
type Permissions ¶
type User ¶
type User struct { UserID uuid.UUID `db:"user_id" json:"user_id"` // UUID for user UserID Username string `db:"username" json:"username"` // User's username Email string `db:"email" json:"email"` // User's email address Password string `db:"password" json:"-"` // User's password (hashed) UserType UserType `db:"type" json:"type"` // User type (employee, employer, admin) CreatedAt time.Time `db:"created_at" json:"created_at"` // Timestamp for when the user was created UpdatedAt time.Time `db:"updated_at" json:"updated_at"` // Timestamp for when the user was last updated }
User represents the user table in the database