MSP-8299 linter fix
This commit is contained in:
1 parent
18a554ddec
commit
f8ee02814d
11 files changed
+73
-56
No files matched your search
+18
-12
@@ -11,6 +11,12 @@ import (
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
roleDiffName = "Название"
|
||||
roleDiffExternalGroup = "Группа ЕСК"
|
||||
roleDiffPermissions = "Разрешения"
|
||||
)
|
||||
|
||||
type roleRoleRepo interface {
|
||||
All(ctx context.Context) ([]entity.Role, error)
|
||||
InsertRole(ctx context.Context, role entity.Role) (*entity.Role, error)
|
||||
@@ -69,13 +75,13 @@ func (u Role) Create(ctx context.Context, req domain.CreateRoleRequest, adminId
|
||||
|
||||
slices.Sort(role.Permissions)
|
||||
diff := diffToString(map[string]any{
|
||||
"Название": "",
|
||||
"Группа ЕСК": "",
|
||||
"Разрешения": []int{},
|
||||
roleDiffName: "",
|
||||
roleDiffExternalGroup: "",
|
||||
roleDiffPermissions: []int{},
|
||||
}, map[string]any{
|
||||
"Название": role.Name,
|
||||
"Группа ЕСК": role.ExternalGroup,
|
||||
"Разрешения": role.Permissions,
|
||||
roleDiffName: role.Name,
|
||||
roleDiffExternalGroup: role.ExternalGroup,
|
||||
roleDiffPermissions: role.Permissions,
|
||||
})
|
||||
u.auditService.SaveAuditAsync(ctx, adminId,
|
||||
fmt.Sprintf("Роль. Создание новой роли %s. Причина: %s. \n %s", req.Name, req.ChangeMessage, diff),
|
||||
@@ -119,13 +125,13 @@ func (u Role) Update(ctx context.Context, req domain.UpdateRoleRequest, adminId
|
||||
slices.Sort(oldRole.Permissions)
|
||||
slices.Sort(role.Permissions)
|
||||
diff := diffToString(map[string]any{
|
||||
"Название": oldRole.Name,
|
||||
"Группа ЕСК": oldRole.ExternalGroup,
|
||||
"Разрешения": oldRole.Permissions,
|
||||
roleDiffName: oldRole.Name,
|
||||
roleDiffExternalGroup: oldRole.ExternalGroup,
|
||||
roleDiffPermissions: oldRole.Permissions,
|
||||
}, map[string]any{
|
||||
"Название": role.Name,
|
||||
"Группа ЕСК": role.ExternalGroup,
|
||||
"Разрешения": role.Permissions,
|
||||
roleDiffName: role.Name,
|
||||
roleDiffExternalGroup: role.ExternalGroup,
|
||||
roleDiffPermissions: role.Permissions,
|
||||
})
|
||||
u.auditService.SaveAuditAsync(ctx, adminId,
|
||||
fmt.Sprintf("Роль. Изменение роли %s. Причина: %s. \n %s", req.Name, req.ChangeMessage, diff),
|
||||
|
||||
+23
-16
@@ -16,6 +16,13 @@ import (
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
const (
|
||||
userDiffFullName = "ФИО"
|
||||
userDiffDescription = "Описание"
|
||||
userDiffEmail = "Email"
|
||||
userDiffRoleIds = "Роли (ID)"
|
||||
)
|
||||
|
||||
type UserTransaction interface {
|
||||
UserRepo
|
||||
UserRoleRepo
|
||||
@@ -253,15 +260,15 @@ func (u User) CreateUser(ctx context.Context, req domain.CreateUserRequest, admi
|
||||
|
||||
slices.Sort(req.Roles)
|
||||
diff := diffToString(map[string]any{
|
||||
"ФИО": "",
|
||||
"Описание": "",
|
||||
"Email": "",
|
||||
"Роли (ID)": []int{},
|
||||
userDiffFullName: "",
|
||||
userDiffDescription: "",
|
||||
userDiffEmail: "",
|
||||
userDiffRoleIds: []int{},
|
||||
}, map[string]any{
|
||||
"ФИО": usr.FullName,
|
||||
"Описание": req.Description,
|
||||
"Email": req.Email,
|
||||
"Роли (ID)": req.Roles,
|
||||
userDiffFullName: usr.FullName,
|
||||
userDiffDescription: req.Description,
|
||||
userDiffEmail: req.Email,
|
||||
userDiffRoleIds: req.Roles,
|
||||
})
|
||||
u.auditService.SaveAuditAsync(ctx, adminId,
|
||||
fmt.Sprintf("Пользователь. Создание пользователя %d. \n %s", usr.Id, diff),
|
||||
@@ -342,15 +349,15 @@ func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, admi
|
||||
|
||||
slices.Sort(req.Roles)
|
||||
diff := diffToString(map[string]any{
|
||||
"ФИО": user.FullName,
|
||||
"Описание": user.Description,
|
||||
"Email": user.Email,
|
||||
"Роли (ID)": RolesIds(oldRoles),
|
||||
userDiffFullName: user.FullName,
|
||||
userDiffDescription: user.Description,
|
||||
userDiffEmail: user.Email,
|
||||
userDiffRoleIds: RolesIds(oldRoles),
|
||||
}, map[string]any{
|
||||
"ФИО": updatedUser.FullName,
|
||||
"Описание": req.Description,
|
||||
"Email": req.Email,
|
||||
"Роли (ID)": req.Roles,
|
||||
userDiffFullName: updatedUser.FullName,
|
||||
userDiffDescription: req.Description,
|
||||
userDiffEmail: req.Email,
|
||||
userDiffRoleIds: req.Roles,
|
||||
})
|
||||
u.auditService.SaveAuditAsync(ctx, adminId,
|
||||
fmt.Sprintf("Пользователь. Изменение пользователя %d.\n %s", updatedUser.Id, diff),
|
||||
|
||||
Reference in new issue
Block a user