Documentation
¶
Index ¶
- func Migrate(db *gorm.DB) error
- type WorkShiftService
- func (a *WorkShiftService) CreateWorkShift(m *models.WorkShiftModel) error
- func (a *WorkShiftService) DeleteWorkShift(id string) error
- func (a *WorkShiftService) FindAllWorkShift(request *http.Request) (paginate.Page, error)
- func (a *WorkShiftService) FindWorkShiftByID(id string) (*models.WorkShiftModel, error)
- func (a *WorkShiftService) UpdateWorkShift(id string, m *models.WorkShiftModel) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type WorkShiftService ¶
type WorkShiftService struct {
// contains filtered or unexported fields
}
func NewWorkShiftService ¶
func NewWorkShiftService(ctx *context.ERPContext, employeeService *employee.EmployeeService) *WorkShiftService
NewWorkShiftService creates a new instance of WorkShiftService.
The service is initialized with an ERP context and an EmployeeService. The ERP context is used for authentication and authorization, while the EmployeeService is used to manage employee-related operations.
func (*WorkShiftService) CreateWorkShift ¶
func (a *WorkShiftService) CreateWorkShift(m *models.WorkShiftModel) error
CreateWorkShift creates a new work shift record in the database.
The function takes a WorkShiftModel pointer as input and attempts to insert a new record into the work_shifts table using GORM. If the insertion is successful, it returns nil; otherwise, it returns an error indicating the cause of the failure.
func (*WorkShiftService) DeleteWorkShift ¶
func (a *WorkShiftService) DeleteWorkShift(id string) error
DeleteWorkShift deletes a work shift record from the database.
It takes a work shift ID as input and attempts to delete the work shift with the given ID from the database. If the deletion is successful, the function returns nil; otherwise, it returns an error indicating the cause of the failure.
func (*WorkShiftService) FindAllWorkShift ¶
FindAllWorkShift retrieves a paginated list of work shift records from the database.
It takes an http.Request as input and applies various filters based on the request parameters such as company ID, search term, date range, and employee IDs. The results can be ordered based on a specified order parameter or defaults to ordering by start_date in descending order.
The function returns a paginated page of WorkShiftModel and an error if the operation fails.
func (*WorkShiftService) FindWorkShiftByID ¶
func (a *WorkShiftService) FindWorkShiftByID(id string) (*models.WorkShiftModel, error)
FindWorkShiftByID retrieves a work shift record by ID from the database.
The function takes a work shift ID as input and uses it to query the database for the work shift record. The associated Employee model is preloaded.
The function returns the work shift record and an error if the operation fails. If the work shift record is not found, a nil pointer is returned together with a gorm.ErrRecordNotFound error.
func (*WorkShiftService) UpdateWorkShift ¶
func (a *WorkShiftService) UpdateWorkShift(id string, m *models.WorkShiftModel) error
UpdateWorkShift updates a work shift record in the database.
The function takes a work shift ID and a WorkShiftModel pointer as input and attempts to update the work shift record with the given ID in the work_shifts table using GORM. If the update is successful, it returns nil; otherwise, it returns an error indicating the cause of the failure.