permit_hub

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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PermitHubService

type PermitHubService struct {
	MasterPermitHubService *permit_hub_master.MasterPermitHubService
	CitizenService         *citizen.CitizenService
	// contains filtered or unexported fields
}

func NewPermitHubService

func NewPermitHubService(ctx *context.ERPContext) *PermitHubService

NewPermitHubService creates a new instance of PermitHubService with the given database connection and context. It also calls Migrate() if the SkipMigration flag is not set.

func (*PermitHubService) ApprovePermitRequestStep

func (s *PermitHubService) ApprovePermitRequestStep(requestID string, approvedBy *models.UserModel, note string, approved bool) error

ApprovePermitRequestStep handles the approval process for a permit request step.

It checks if the user is authorized based on their role, logs the approval decision, updates the request status, and progresses to the next step if applicable. If the approval is rejected, the request status is marked as rejected. The function returns an error if the user is unauthorized, if the request or approval step is not found, or if there is a failure in logging the approval or updating the request.

func (*PermitHubService) CreateCitizenIfNotExists

func (s *PermitHubService) CreateCitizenIfNotExists(citizen *models.Citizen) error

CreateCitizenIfNotExists creates a new citizen if one with the same NIK doesn't exist. It returns an error if the citizen already exists, or if there's an error creating a new one.

func (*PermitHubService) CreatePermitRequest

func (s *PermitHubService) CreatePermitRequest(citizenID, subDistrictID, permitTypeSlug string, dyn *models.PermitDynamicRequestData, uploadedDocuments []models.PermitUploadedDocument) (*models.PermitRequest, error)

CreatePermitRequest initiates a new permit request for a given citizen and permit type. It validates dynamic request data against the required field definitions of the permit type.

func (*PermitHubService) DeleteRequest

func (s *PermitHubService) DeleteRequest(requestID string) error

DeleteRequest deletes a permit request.

The function takes a permit request ID and returns an error.

func (*PermitHubService) GetAllRequests

func (s *PermitHubService) GetAllRequests(request *http.Request) (paginate.Page, error)

GetAllRequests returns a paginated list of permit requests.

The function takes an HTTP request as a parameter and supports ordering based on query parameters. It returns a Paginate object containing the permit requests. The result is filtered based on the following query parameters: - ID-SubDistrict: filter by sub district ID - citizen_ids: filter by citizen IDs - citizen_id: filter by citizen ID - start_date: filter by submitted at date range - end_date: filter by submitted at date range - order: order by submitted at date range

func (*PermitHubService) GetPermitRequestByCode

func (s *PermitHubService) GetPermitRequestByCode(code string) (*models.PermitRequest, error)

GetPermitRequestByCode returns a permit request by code.

The function takes a code and returns a permit request object, its permit type, citizen, current step roles, approval logs, documents, and dynamic request data.

If the permit request doesn't exist, it returns gorm.ErrRecordNotFound.

func (*PermitHubService) GetPermitRequestListByRefID

func (s *PermitHubService) GetPermitRequestListByRefID(request *http.Request, refID string) (paginate.Page, error)

GetPermitRequestListByRefID returns a paginated list of permit requests by reference ID.

The function takes an HTTP request and a reference ID as parameters. It returns a Paginate object containing the permit requests.

func (*PermitHubService) GetPermitTypeBySlug

func (s *PermitHubService) GetPermitTypeBySlug(slug string) (*models.PermitType, error)

GetPermitTypeBySlug returns a permit type by slug.

The function takes a permit type slug and returns a permit type object, its field definitions, approval flow, and permit requirements.

If the permit type doesn't exist, it returns gorm.ErrRecordNotFound.

func (*PermitHubService) GetRequestByID

func (s *PermitHubService) GetRequestByID(requestID string) (*models.PermitRequest, error)

GetRequestByID returns a permit request by its ID.

The function takes a permit request ID and returns a permit request object, its permit type, citizen, current step roles, approval logs, documents, and dynamic request data.

If the permit request doesn't exist, it returns gorm.ErrRecordNotFound.

func (*PermitHubService) Migrate

func (s *PermitHubService) Migrate() error

Migrate runs database migrations for permit hub module.

It creates all tables used by permit hub module, and sets up foreign key constraints.

Migrate should be called only once when the application starts.

func (*PermitHubService) UpdateRequest

func (s *PermitHubService) UpdateRequest(requestID string, data *models.PermitRequest) error

UpdateRequest updates a permit request.

The function takes a permit request ID and a permit request object as parameters. It returns an error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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