fix comment

This commit is contained in:
Hoang 2021-11-10 15:00:36 +07:00
parent 95ac63e287
commit 02653fd7aa
3 changed files with 8 additions and 7 deletions

View File

@ -58,7 +58,7 @@ func (s Service) UpdateRole(roleID string, payload model.RoleUpdateOptions) erro
return role.Update(roleID, payload) return role.Update(roleID, payload)
} }
// GetAllRole ... // GetAllRoles ...
func (s Service) GetAllRole(query model.RoleAllQuery) model.RoleAll { func (s Service) GetAllRoles(query model.RoleAllQuery) model.RoleAll {
return role.All(query) return role.All(query)
} }

View File

@ -38,10 +38,11 @@ func GetSearchString(fieldList ...string) string {
return fmt.Sprintf(format, searchList...) return fmt.Sprintf(format, searchList...)
} }
// GetCode ... // GenerateCode ...
func GetCode(s string) string { func GenerateCode(s string) string {
var ( var (
underscore = "_" underscore = "_"
emptySpace = " "
) )
return strings.ReplaceAll(mongodb.NonAccentVietnamese(s), " ", underscore) return strings.ReplaceAll(mongodb.NonAccentVietnamese(s), emptySpace, underscore)
} }

View File

@ -39,7 +39,7 @@ func newRole(payload model.RoleCreateOptions) model.DBRole {
return model.DBRole{ return model.DBRole{
ID: mongodb.NewObjectID(), ID: mongodb.NewObjectID(),
Name: payload.Name, Name: payload.Name,
Code: internal.GetCode(payload.Name), Code: internal.GenerateCode(payload.Name),
CreatedAt: timeNow, CreatedAt: timeNow,
UpdatedAt: timeNow, UpdatedAt: timeNow,
} }
@ -71,7 +71,7 @@ func Update(roleID string, payload model.RoleUpdateOptions) error {
updateData := bson.M{ updateData := bson.M{
"$set": bson.M{ "$set": bson.M{
"name": payload.Name, "name": payload.Name,
"code": internal.GetCode(payload.Name), "code": internal.GenerateCode(payload.Name),
"updatedAt": internal.Now(), "updatedAt": internal.Now(),
}, },
} }