feat: customer list
This commit is contained in:
@@ -72,6 +72,38 @@ func (p *UserParam) ToEntity(ctx mycontext.Context) entity.UserSearch {
|
||||
Offset: p.Offset,
|
||||
}
|
||||
}
|
||||
type CustomerParam struct {
|
||||
Search string `form:"search" json:"search" example:"admin,branch1"`
|
||||
Name string `form:"name" json:"name" example:"Admin 1"`
|
||||
RoleID int64 `form:"role_id" json:"role_id" example:"1"`
|
||||
PartnerID int64 `form:"partner_id" json:"partner_id" example:"1"`
|
||||
SiteID int64 `form:"site_id" json:"site_id" example:"1"`
|
||||
Limit int `form:"limit,default=10" json:"limit" example:"10"`
|
||||
Offset int `form:"offset,default=0" json:"offset" example:"0"`
|
||||
}
|
||||
|
||||
func (p *CustomerParam) ToEntity(ctx mycontext.Context) entity.CustomerSearch {
|
||||
partnerID := p.PartnerID
|
||||
siteID := p.SiteID
|
||||
|
||||
if !ctx.IsAdmin() {
|
||||
partnerID = *ctx.GetPartnerID()
|
||||
}
|
||||
|
||||
if ctx.GetSiteID() != nil {
|
||||
siteID = *ctx.GetSiteID()
|
||||
}
|
||||
|
||||
return entity.CustomerSearch{
|
||||
Search: p.Search,
|
||||
Name: p.Name,
|
||||
RoleID: p.RoleID,
|
||||
PartnerID: partnerID,
|
||||
SiteID: siteID,
|
||||
Limit: p.Limit,
|
||||
Offset: p.Offset,
|
||||
}
|
||||
}
|
||||
|
||||
type UserRegister struct {
|
||||
Name string `json:"name" validate:"required" binding:"required"`
|
||||
|
||||
Reference in New Issue
Block a user