project

package
v1.0.49 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProjectService

type ProjectService struct {
	// contains filtered or unexported fields
}

func NewProjectService

func NewProjectService(ctx *context.ERPContext) *ProjectService

NewProjectService creates a new instance of ProjectService with the given ERP context.

It fetches the whatsmeow service from the context and panics if it is not found. It also fetches the CustomerRelationshipService from the context, but won't panic if it is not found. It then returns the newly created ProjectService with the given database connection, context, whatsmeow service and customer relationship service.

func (*ProjectService) AddActivity

func (s *ProjectService) AddActivity(projectID, memberID string, columnID, taskID *string, activityType string, notes *string) (*models.ProjectActivityModel, error)

AddActivity adds an activity to a project with the given ID.

It takes a project ID, a member ID, a column ID, a task ID, an activity type, and an optional notes string as parameters. It creates a new project activity entry in the project_activities table.

func (*ProjectService) AddMemberToProject

func (s *ProjectService) AddMemberToProject(projectID string, memberID string) error

AddMemberToProject adds a member to a project with the given ID and member ID.

It creates a new project member entry in the project_members table.

func (*ProjectService) CheckIdleColumn

func (s *ProjectService) CheckIdleColumn(callback func(models.ScheduledMessage)) error

CheckIdleColumn checks for idle columns and sends a message to the column's tasks if the idle time has been reached.

It takes a callback function as a parameter, which is called with the scheduled message data.

The function queries for all column actions with the action trigger set to "IDLE" and preloads the associated Column, Tasks, and User data. For each column action, it checks if the action is set to "send_whatsapp_message" and if the task's ref type is set to "whatsapp_session". If so, it checks if the task's last action trigger at is older than the idle time and if the action status is set to "READY". If both conditions are met, it sets the action status to "WAITING", updates the task, and calls the callback function with the scheduled message data. The callback function is expected to send the message to the task's contact phone number.

func (*ProjectService) CreateColumn

func (s *ProjectService) CreateColumn(data *models.ColumnModel) error

CreateColumn creates a new column with the given data.

It uses the Omit clause to avoid creating associations.

func (*ProjectService) CreateColumnAction

func (s *ProjectService) CreateColumnAction(data *models.ColumnAction) error

CreateColumnAction creates a new column action with the given data.

It uses the Omit clause to avoid creating associations.

func (*ProjectService) CreateProject

func (s *ProjectService) CreateProject(data *models.ProjectModel) error

CreateProject creates a new project with the given data.

It uses the Omit clause to avoid creating associations.

func (*ProjectService) DeleteColumn

func (s *ProjectService) DeleteColumn(id string) error

DeleteColumn deletes the column with the given ID.

It uses the Delete method to delete the column.

func (*ProjectService) DeleteColumnAction

func (s *ProjectService) DeleteColumnAction(id string) error

DeleteColumnAction deletes the column action with the given ID.

It uses the Delete method to delete the column action.

func (*ProjectService) DeleteProject

func (s *ProjectService) DeleteProject(id string) error

DeleteProject deletes the project with the given ID.

It uses the Delete method to delete the project.

func (*ProjectService) GetColumnActionsByColumnID

func (s *ProjectService) GetColumnActionsByColumnID(id string) ([]models.ColumnAction, error)

GetColumnActionsByColumnID retrieves actions associated with a specific column ID.

It takes a column ID as a parameter and returns a slice of ColumnAction and an error, if any. The function preloads the associated Column data, selecting only the ID and name fields.

func (*ProjectService) GetColumnByID

func (s *ProjectService) GetColumnByID(id string) (*models.ColumnModel, error)

GetColumnByID retrieves a column by its ID, optionally filtering by a project ID.

It takes a column ID as a parameter and returns a pointer to a ColumnModel and an error, if any. The function preloads associated Actions, Project, and Column data.

func (*ProjectService) GetColumns

func (s *ProjectService) GetColumns(request http.Request, search string) (paginate.Page, error)

GetColumns retrieves a paginated list of columns, optionally filtering by search and project ID.

It takes an HTTP request, a search string, and an optional project ID. The search string is applied to the column's name field. If a project ID is present in the request header, the result is filtered by the project ID. The function supports ordering and pagination.

Returns a paginated page of ColumnModel and an error, if any.

func (*ProjectService) GetMembersByProjectID

func (s *ProjectService) GetMembersByProjectID(projectID string) ([]models.MemberModel, error)

GetMembersByProjectID retrieves a list of members associated with a project with the given ID.

It takes a project ID as a parameter and returns a slice of MemberModel and an error, if any. The function preloads associated User data.

func (*ProjectService) GetProjectByID

func (s *ProjectService) GetProjectByID(id string, memberID *string) (*models.ProjectModel, error)

GetProjectByID retrieves a project by its ID, optionally filtering by a member ID.

It takes a project ID and an optional member ID as parameters. If a member ID is provided, the project is filtered to include only those where the given member is associated. The function preloads associated Columns, Tasks, Actions, and Members.User data.

Returns a pointer to a ProjectModel and an error, if any.

func (*ProjectService) GetProjects

func (s *ProjectService) GetProjects(request http.Request, search string, memberID *string) (paginate.Page, error)

GetProjects retrieves a paginated list of projects, optionally filtering by search and member ID.

It takes an HTTP request, a search string, and an optional member ID. The search string is applied to the project's name and description fields. If a company ID is present in the request header, the result is filtered by the company ID. If a member ID is provided, the projects are filtered to include only those associated with the given member. The function supports ordering and pagination.

Returns a paginated page of ProjectModel and an error, if any.

func (*ProjectService) GetRecentActivities

func (s *ProjectService) GetRecentActivities(projectID string, limit int) ([]models.ProjectActivityModel, error)

GetRecentActivities retrieves a list of recent activities associated with a project with the given ID.

It takes a project ID and a limit as parameters and returns a slice of ProjectActivityModel and an error, if any. The function preloads associated Project, Member, Column, Task, and User data. The function supports ordering by the activity date in descending order.

func (*ProjectService) UpdateColumn

func (s *ProjectService) UpdateColumn(id string, data *models.ColumnModel) error

UpdateColumn updates the column with the given ID to the given data.

It uses the Updates method to update the columns of the column.

func (*ProjectService) UpdateColumnAction

func (s *ProjectService) UpdateColumnAction(id string, data *models.ColumnAction) error

UpdateColumnAction updates the column action with the given ID to the given data.

It uses the Updates method to update the columns of the column action.

func (*ProjectService) UpdateProject

func (s *ProjectService) UpdateProject(id string, data *models.ProjectModel) error

UpdateProject updates the project with the given ID to the given data.

It uses the Updates method to update the columns of the project.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL