|
@@ -31,16 +31,29 @@ func NewGetWhatsappChannelListLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
|
|
}
|
|
|
|
|
|
func (l *GetWhatsappChannelListLogic) GetWhatsappChannelList(req *types.WhatsappChannelListReq) (*types.WhatsappChannelListResp, error) {
|
|
|
+ isAdmin := l.ctx.Value("isAdmin").(bool)
|
|
|
+ organizationId := l.ctx.Value("organizationId").(uint64)
|
|
|
+
|
|
|
var predicates []predicate.WhatsappChannel
|
|
|
- if req.OrganizationId != nil {
|
|
|
+
|
|
|
+ if isAdmin && req.OrganizationId != nil {
|
|
|
predicates = append(predicates, whatsappchannel.OrganizationID(*req.OrganizationId))
|
|
|
}
|
|
|
+ if !isAdmin {
|
|
|
+ predicates = append(predicates, whatsappchannel.OrganizationID(organizationId))
|
|
|
+ }
|
|
|
if req.WaName != nil && *req.WaName != "" {
|
|
|
predicates = append(predicates, whatsappchannel.WaNameContains(*req.WaName))
|
|
|
}
|
|
|
+ if req.WaID != nil && *req.WaID != "" {
|
|
|
+ predicates = append(predicates, whatsappchannel.WaID(*req.WaID))
|
|
|
+ }
|
|
|
if req.WabaId != nil {
|
|
|
predicates = append(predicates, whatsappchannel.WabaID(*req.WabaId))
|
|
|
}
|
|
|
+ if req.VerifyAccount != nil && *req.VerifyAccount != "" {
|
|
|
+ predicates = append(predicates, whatsappchannel.VerifyAccount(*req.VerifyAccount))
|
|
|
+ }
|
|
|
data, err := l.svcCtx.DB.WhatsappChannel.Query().Where(predicates...).Page(l.ctx, req.Page, req.PageSize)
|
|
|
|
|
|
if err != nil {
|