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() {
|
users, total, err := h.service.GetAll(ctx, req.ToEntity(ctx))
|
||||||
response.ErrorWrapper(c, errors.ErrorUnauthorized)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
users, total, err := h.service.GetAll(ctx, req.ToEntity())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response.ErrorWrapper(c, err)
|
response.ErrorWrapper(c, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package request
|
package request
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"furtuna-be/internal/common/mycontext"
|
||||||
"furtuna-be/internal/constants/role"
|
"furtuna-be/internal/constants/role"
|
||||||
"furtuna-be/internal/entity"
|
"furtuna-be/internal/entity"
|
||||||
|
|
||||||
@ -48,12 +49,18 @@ type UserParam struct {
|
|||||||
Offset int `form:"offset,default=0" json:"offset" example:"0"`
|
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{
|
return entity.UserSearch{
|
||||||
Search: p.Search,
|
Search: p.Search,
|
||||||
Name: p.Name,
|
Name: p.Name,
|
||||||
RoleID: p.RoleID,
|
RoleID: p.RoleID,
|
||||||
PartnerID: p.PartnerID,
|
PartnerID: partnerID,
|
||||||
Limit: p.Limit,
|
Limit: p.Limit,
|
||||||
Offset: p.Offset,
|
Offset: p.Offset,
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user