Documentation
¶
Index ¶
- Variables
- func AddChangelog[T any](fieldName string, oldValue, newValue *T, changes *[]models.ChangeLog)
- func AddChangelogForObligationClassification(tx *gorm.DB, userId uuid.UUID, ...) error
- func AddChangelogForObligationType(tx *gorm.DB, userId uuid.UUID, oldObType, newObType *models.ObligationType) error
- func AddChangelogsForLicense(tx *gorm.DB, userId uuid.UUID, newLicense, oldLicense *models.LicenseDB) error
- func AddChangelogsForUser(tx *gorm.DB, userId uuid.UUID, newUser, oldUser *models.User) error
- func GetAuditEntity(c *gin.Context, audit *models.Audit) error
- func GetKid(token string) (string, error)
- func HashPassword(user *models.User) error
- func ParseIdToInt(c *gin.Context, id string, idType string) (int64, error)
- func PerformLicenseMapActions(tx *gorm.DB, userId uuid.UUID, license *models.LicenseDB, ...) []error
- func PerformObligationMapActions(tx *gorm.DB, userId uuid.UUID, obligation *models.Obligation, ...) []error
- func Populatedb(datafile string)
- func PreparePaginateResponse(c *gin.Context, query *gorm.DB, responseModel interface{}) models.PaginationInput
- func SetSimilarityThreshold()
- func ToggleObligationClassificationActiveStatus(userId uuid.UUID, tx *gorm.DB, ...) error
- func ToggleObligationTypeActiveStatus(userId uuid.UUID, tx *gorm.DB, obType *models.ObligationType) error
- func VerifyPassword(inputPassword, dbPassword string) error
- type LicenseImportStatusCode
- type ObligationFieldCreateStatusCode
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultPage Set default page to 1 DefaultPage int64 = 1 // DefaultLimit Set default max limit to 20 DefaultLimit int64 = 20 )
Functions ¶
func AddChangelog ¶
func AddChangelogsForLicense ¶
func AddChangelogsForLicense(tx *gorm.DB, userId uuid.UUID, newLicense, oldLicense *models.LicenseDB) error
AddChangelogsForLicense adds changelogs for the updated fields on license update
func AddChangelogsForUser ¶
AddChangelogsForUser adds changelogs for the updated fields on user update
func GetAuditEntity ¶
GetAuditEntity is an utility function to fetch obligation or license associated with an audit
func GetKid ¶
https://github.com/lestrrat-go/jwx/discussions/547 Get kid field value from JWS Header
func HashPassword ¶
HashPassword hashes the password of the user using bcrypt. It also trims the username and escapes the HTML characters.
func ParseIdToInt ¶
ParseIdToInt convert the string ID from gin.Context to an integer and throw error if conversion fails. Also, update the gin.Context with REST API error.
func PerformLicenseMapActions ¶
func PerformLicenseMapActions(tx *gorm.DB, userId uuid.UUID, license *models.LicenseDB, newObligationIds []uuid.UUID) []error
PerformLicenseMapActions replaces current associated obligations with the list of obligations whose ids are provided in the newObligationIds
func PerformObligationMapActions ¶
func PerformObligationMapActions(tx *gorm.DB, userId uuid.UUID, obligation *models.Obligation, newLicenseIds []uuid.UUID) []error
PerformObligationMapActions replaces current associated licenses with the list of licenses whose ids are provided in the newLicenseIds.
func Populatedb ¶
func Populatedb(datafile string)
Populatedb populates the database with license data from a JSON file.
func PreparePaginateResponse ¶
func PreparePaginateResponse(c *gin.Context, query *gorm.DB, responseModel interface{}) models.PaginationInput
PreparePaginateResponse prepares the pagination response for the API. It gets the count of total rows and sets the pagination parameters, also updates the query limit and offset and update the "paginationMeta" and "responseModel" in gin.Context for middleware to process.
func SetSimilarityThreshold ¶
func SetSimilarityThreshold()
SetSimilarityThreshold parses the env var and sets the threshold in Postgres.
func VerifyPassword ¶
VerifyPassword compares the input password with the password stored in the database. Returns nil on success, or an error on failure.
Types ¶
type LicenseImportStatusCode ¶
type LicenseImportStatusCode int
LicenseImportStatusCode is internally used for checking status of a license import
const ( IMPORT_FAILED LicenseImportStatusCode = iota + 1 IMPORT_LICENSE_CREATED IMPORT_LICENSE_UPDATED IMPORT_LICENSE_CREATE_OBLIGATION_ASSOCIATION_FAILED IMPORT_LICENSE_UPDATE_OBLIGATION_ASSOCIATION_FAILED )
Status codes covering various scenarios that can occur on a license import
func InsertOrUpdateLicenseOnImport ¶
func InsertOrUpdateLicenseOnImport(lic *models.LicenseImportDTO, userId uuid.UUID) (string, LicenseImportStatusCode)
type ObligationFieldCreateStatusCode ¶
type ObligationFieldCreateStatusCode int
ObligationTypeStatusCode is internally used for checking status of a obligation type creation
const ( CREATE_FAILED ObligationFieldCreateStatusCode = iota + 1 VALIDATION_FAILED CONFLICT CONFLICT_ACTIVATION_FAILED CREATED )
Status codes covering various scenarios that can occur on a license import
func CreateObClassification ¶
func CreateObClassification(obClassification *models.ObligationClassification, userId uuid.UUID) (error, ObligationFieldCreateStatusCode)
func CreateObType ¶
func CreateObType(obType *models.ObligationType, userId uuid.UUID) (error, ObligationFieldCreateStatusCode)