feat: update user response
This commit is contained in:
parent
a17fd04a35
commit
5dfcfe0560
|
|
@ -2,11 +2,18 @@ package mapper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go-humas-be/app/database/entity"
|
"go-humas-be/app/database/entity"
|
||||||
|
userLevelsRepository "go-humas-be/app/module/user_levels/repository"
|
||||||
res "go-humas-be/app/module/users/response"
|
res "go-humas-be/app/module/users/response"
|
||||||
)
|
)
|
||||||
|
|
||||||
func UsersResponseMapper(usersReq *entity.Users) (usersRes *res.UsersResponse) {
|
func UsersResponseMapper(usersReq *entity.Users, userLevelsRepo userLevelsRepository.UserLevelsRepository) (usersRes *res.UsersResponse) {
|
||||||
if usersReq != nil {
|
if usersReq != nil {
|
||||||
|
findUserLevel, _ := userLevelsRepo.FindOne(usersReq.UserLevelId)
|
||||||
|
userLevelGroup := ""
|
||||||
|
if findUserLevel != nil {
|
||||||
|
userLevelGroup = findUserLevel.AliasName
|
||||||
|
}
|
||||||
|
|
||||||
usersRes = &res.UsersResponse{
|
usersRes = &res.UsersResponse{
|
||||||
ID: usersReq.ID,
|
ID: usersReq.ID,
|
||||||
Username: usersReq.Username,
|
Username: usersReq.Username,
|
||||||
|
|
@ -22,6 +29,7 @@ func UsersResponseMapper(usersReq *entity.Users) (usersRes *res.UsersResponse) {
|
||||||
LastEducation: usersReq.LastEducation,
|
LastEducation: usersReq.LastEducation,
|
||||||
KeycloakId: usersReq.KeycloakId,
|
KeycloakId: usersReq.KeycloakId,
|
||||||
UserRoleId: usersReq.UserRoleId,
|
UserRoleId: usersReq.UserRoleId,
|
||||||
|
UserLevelGroup: userLevelGroup,
|
||||||
StatusId: usersReq.StatusId,
|
StatusId: usersReq.StatusId,
|
||||||
UserLevelId: usersReq.UserLevelId,
|
UserLevelId: usersReq.UserLevelId,
|
||||||
CreatedById: usersReq.CreatedById,
|
CreatedById: usersReq.CreatedById,
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ type UsersResponse struct {
|
||||||
KeycloakId *string `json:"keycloakId"`
|
KeycloakId *string `json:"keycloakId"`
|
||||||
UserRoleId uint `json:"userRoleId"`
|
UserRoleId uint `json:"userRoleId"`
|
||||||
UserLevelId uint `json:"userLevelId"`
|
UserLevelId uint `json:"userLevelId"`
|
||||||
|
UserLevelGroup string `json:"userLevelGroup"`
|
||||||
StatusId *int `json:"statusId"`
|
StatusId *int `json:"statusId"`
|
||||||
CreatedById *uint `json:"createdById"`
|
CreatedById *uint `json:"createdById"`
|
||||||
ProfilePicturePath *string `json:"profilePicturePath"`
|
ProfilePicturePath *string `json:"profilePicturePath"`
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue