tag

package
v1.0.68 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TagService

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

TagService provides methods for managing tags within the application.

NewTagService creates a new instance of TagService.

CreateTag creates a new tag in the database.

GetTagByID retrieves a tag by its ID.

GetTagByName retrieves a tag by its name.

UpdateTag updates an existing tag in the database.

DeleteTag deletes a tag from the database by its ID.

ListTags retrieves a paginated list of tags from the database.

The service is initialized with a GORM database instance and an ERP context.

func NewTagService

func NewTagService(ctx *context.ERPContext) *TagService

NewTagService creates a new instance of TagService.

It requires a GORM database instance and an ERP context for initialization. The TagService provides methods for managing tags within the application. The database instance is used for executing CRUD operations, while the ERP context is utilized for handling authentication and other context-related functionality.

Returns a pointer to a newly created TagService.

func (*TagService) CreateTag

func (s *TagService) CreateTag(tag *models.TagModel) error

CreateTag creates a new tag in the database.

It takes a pointer to a TagModel as input and creates a new record in the tags table. If the creation fails, the method returns an error. Otherwise, it returns nil.

func (*TagService) DeleteTag

func (s *TagService) DeleteTag(id string) error

DeleteTag deletes a tag from the database by its ID.

It takes a string id as a parameter and attempts to delete the corresponding TagModel record. The function returns an error if the deletion fails, otherwise it returns nil indicating the operation was successful.

func (*TagService) GetTagByID

func (s *TagService) GetTagByID(id string) (*models.TagModel, error)

GetTagByID retrieves a tag by its ID.

It takes a string id as a parameter and returns a pointer to a TagModel and an error. The function uses GORM to retrieve the tag data from the tags table. If the operation fails, an error is returned.

func (*TagService) GetTagByName

func (s *TagService) GetTagByName(name string) (*models.TagModel, error)

GetTagByName retrieves a tag by its name.

It takes a string name as a parameter and returns a pointer to a TagModel and an error. The function uses GORM to retrieve the tag data from the tags table. If the operation fails, an error is returned.

func (*TagService) ListTags

func (s *TagService) ListTags(request http.Request, search string) (paginate.Page, error)

ListTags retrieves a paginated list of tags from the database.

It takes an http.Request and an optional search query string as input. The method uses GORM to query the database for tags, applying the search query to the tag name field. The function utilizes pagination to manage the result set and applies any necessary request modifications using the utils.FixRequest utility.

The function returns a paginated page of TagModel and an error if the operation fails.

func (*TagService) UpdateTag

func (s *TagService) UpdateTag(id string, tag *models.TagModel) error

UpdateTag updates an existing tag in the database.

It takes a string id and a pointer to a TagModel as parameters and returns an error. The function uses GORM to update the tag data in the database where the tag ID matches. If the update is successful, the error is nil. Otherwise, the error contains information about what went wrong.

Jump to

Keyboard shortcuts

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