瀏覽代碼

fix:修改通道列表和号码列表 增加筛选

jimmyyem 3 周之前
父節點
當前提交
ad50eda0df

+ 1 - 0
desc/wechat/whatsapp_channel.api

@@ -56,6 +56,7 @@ type (
 
 		OrganizationId  *uint64 `json:"organizationId,optional"`
 		WaName  *string `json:"waName,optional"`
+		WaID  *string `json:"waID,optional"`
 		WabaId  *uint64 `json:"wabaId,optional"`
 		VerifyAccount  *string `json:"verifyAccount,optional"`
     }

+ 9 - 2
internal/logic/whatsapp/get_whatsapp_list_logic.go

@@ -34,17 +34,24 @@ func NewGetWhatsappListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *G
 }
 
 func (l *GetWhatsappListLogic) GetWhatsappList(req *types.WhatsappListReq) (*types.WhatsappListResp, error) {
+	isAdmin := l.ctx.Value("isAdmin").(bool)
+	organizationId := l.ctx.Value("organizationId").(uint64)
+
 	var predicates []predicate.Whatsapp
-	if req.OrganizationId != nil {
+
+	if isAdmin && req.OrganizationId != nil {
 		predicates = append(predicates, whatsapp.OrganizationID(*req.OrganizationId))
 	}
+	if !isAdmin {
+		predicates = append(predicates, whatsapp.OrganizationID(organizationId))
+	}
 	if req.Phone != nil {
 		predicates = append(predicates, whatsapp.Phone(*req.Phone))
 	}
 	if req.PhoneName != nil {
 		predicates = append(predicates, whatsapp.PhoneName(*req.PhoneName))
 	}
-
+	
 	ids := make([]string, 0)
 	if req.WaId != nil && *req.WaId != "" {
 		ids = append(ids, *req.WaId)

+ 14 - 1
internal/logic/whatsapp_channel/get_whatsapp_channel_list_logic.go

@@ -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 {

+ 1 - 0
internal/types/types.go

@@ -3985,6 +3985,7 @@ type WhatsappChannelListReq struct {
 	PageInfo
 	OrganizationId *uint64 `json:"organizationId,optional"`
 	WaName         *string `json:"waName,optional"`
+	WaID           *string `json:"waID,optional"`
 	WabaId         *uint64 `json:"wabaId,optional"`
 	VerifyAccount  *string `json:"verifyAccount,optional"`
 }