Update Partner ID
This commit is contained in:
parent
2de5669167
commit
065cfc4df6
@ -166,12 +166,7 @@ func (h *Handler) GetAll(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
if !ctx.IsSuperAdmin() {
|
||||
response.ErrorWrapper(c, errors.ErrorUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
users, total, err := h.service.GetAll(ctx, req.ToEntity())
|
||||
users, total, err := h.service.GetAll(ctx, req.ToEntity(ctx))
|
||||
if err != nil {
|
||||
response.ErrorWrapper(c, err)
|
||||
return
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"furtuna-be/internal/common/mycontext"
|
||||
"furtuna-be/internal/constants/role"
|
||||
"furtuna-be/internal/entity"
|
||||
|
||||
@ -48,12 +49,18 @@ type UserParam struct {
|
||||
Offset int `form:"offset,default=0" json:"offset" example:"0"`
|
||||
}
|
||||
|
||||
func (p *UserParam) ToEntity() entity.UserSearch {
|
||||
func (p *UserParam) ToEntity(ctx mycontext.Context) entity.UserSearch {
|
||||
partnerID := p.PartnerID
|
||||
|
||||
if !ctx.IsAdmin() {
|
||||
partnerID = *ctx.GetPartnerID()
|
||||
}
|
||||
|
||||
return entity.UserSearch{
|
||||
Search: p.Search,
|
||||
Name: p.Name,
|
||||
RoleID: p.RoleID,
|
||||
PartnerID: p.PartnerID,
|
||||
PartnerID: partnerID,
|
||||
Limit: p.Limit,
|
||||
Offset: p.Offset,
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user