From 02653fd7aa94d02894deff7c1d99472faf94533a Mon Sep 17 00:00:00 2001 From: Hoang Date: Wed, 10 Nov 2021 15:00:36 +0700 Subject: [PATCH] fix comment --- action.go | 4 ++-- internal/helper.go | 7 ++++--- role/handle.go | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/action.go b/action.go index f8b46a2..9348a19 100644 --- a/action.go +++ b/action.go @@ -58,7 +58,7 @@ func (s Service) UpdateRole(roleID string, payload model.RoleUpdateOptions) erro return role.Update(roleID, payload) } -// GetAllRole ... -func (s Service) GetAllRole(query model.RoleAllQuery) model.RoleAll { +// GetAllRoles ... +func (s Service) GetAllRoles(query model.RoleAllQuery) model.RoleAll { return role.All(query) } diff --git a/internal/helper.go b/internal/helper.go index 399c48f..31e8f60 100644 --- a/internal/helper.go +++ b/internal/helper.go @@ -38,10 +38,11 @@ func GetSearchString(fieldList ...string) string { return fmt.Sprintf(format, searchList...) } -// GetCode ... -func GetCode(s string) string { +// GenerateCode ... +func GenerateCode(s string) string { var ( underscore = "_" + emptySpace = " " ) - return strings.ReplaceAll(mongodb.NonAccentVietnamese(s), " ", underscore) + return strings.ReplaceAll(mongodb.NonAccentVietnamese(s), emptySpace, underscore) } diff --git a/role/handle.go b/role/handle.go index 4d31191..e4145a6 100644 --- a/role/handle.go +++ b/role/handle.go @@ -39,7 +39,7 @@ func newRole(payload model.RoleCreateOptions) model.DBRole { return model.DBRole{ ID: mongodb.NewObjectID(), Name: payload.Name, - Code: internal.GetCode(payload.Name), + Code: internal.GenerateCode(payload.Name), CreatedAt: timeNow, UpdatedAt: timeNow, } @@ -71,7 +71,7 @@ func Update(roleID string, payload model.RoleUpdateOptions) error { updateData := bson.M{ "$set": bson.M{ "name": payload.Name, - "code": internal.GetCode(payload.Name), + "code": internal.GenerateCode(payload.Name), "updatedAt": internal.Now(), }, }