|
@@ -51,75 +51,91 @@ func (l *GetWxAllowBlockListLogic) GetWxAllowBlockList(req *types.IDReq) (resp *
|
|
resp = &types.AllowBlockListResp{}
|
|
resp = &types.AllowBlockListResp{}
|
|
resp.Data = types.AllowBlockListRespData{}
|
|
resp.Data = types.AllowBlockListRespData{}
|
|
|
|
|
|
- if data.AllowList != nil {
|
|
|
|
- allowList, err := l.svcCtx.DB.Contact.Query().Where(contact.WxWxidEQ(wxid), contact.WxidIn(data.AllowList...)).All(l.ctx)
|
|
|
|
- if err != nil {
|
|
|
|
- return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
|
|
|
|
+ allowListData := make([]*types.AllowBlockData, 0)
|
|
|
|
+ if data.AllowList == nil || len(data.AllowList) == 0 || data.AllowList[0] == "ALL" {
|
|
|
|
+ allowListData = append(allowListData,
|
|
|
|
+ &types.AllowBlockData{
|
|
|
|
+ Wxid: "ALL",
|
|
|
|
+ Nickname: "全部允许",
|
|
|
|
+ })
|
|
|
|
+ } else if len(data.AllowList) > 0 {
|
|
|
|
+ allowList, _ := l.svcCtx.DB.Contact.Query().Where(contact.WxWxidEQ(wxid), contact.WxidIn(data.AllowList...)).All(l.ctx)
|
|
|
|
+ if allowList != nil {
|
|
|
|
+ for _, av := range allowList {
|
|
|
|
+ allowListData = append(allowListData,
|
|
|
|
+ &types.AllowBlockData{
|
|
|
|
+ Wxid: av.Wxid,
|
|
|
|
+ Nickname: av.Nickname,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- // 将 allowList 转换为[]*ContactInfo
|
|
|
|
- allowListData := make([]*types.AllowBlockData, 0)
|
|
|
|
- for _, av := range allowList {
|
|
|
|
- allowListData = append(allowListData,
|
|
|
|
- &types.AllowBlockData{
|
|
|
|
- Wxid: &av.Wxid,
|
|
|
|
- Nickname: &av.Nickname,
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- resp.Data.AllowList = allowListData
|
|
|
|
}
|
|
}
|
|
|
|
+ resp.Data.AllowList = allowListData
|
|
|
|
|
|
- if data.GroupAllowList != nil {
|
|
|
|
- groupAllowList, err := l.svcCtx.DB.Contact.Query().Where(contact.WxWxidEQ(wxid), contact.WxidIn(data.GroupAllowList...)).All(l.ctx)
|
|
|
|
-
|
|
|
|
- if err != nil {
|
|
|
|
- return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
|
|
- }
|
|
|
|
- // 将 allowList 转换为[]*ContactInfo
|
|
|
|
- groupAllowListData := make([]*types.AllowBlockData, 0)
|
|
|
|
- for _, av := range groupAllowList {
|
|
|
|
- groupAllowListData = append(groupAllowListData,
|
|
|
|
- &types.AllowBlockData{
|
|
|
|
- Wxid: &av.Wxid,
|
|
|
|
- Nickname: &av.Nickname,
|
|
|
|
- })
|
|
|
|
|
|
+ groupAllowListData := make([]*types.AllowBlockData, 0)
|
|
|
|
+ if data.GroupAllowList == nil || len(data.GroupAllowList) == 0 || data.GroupAllowList[0] == "ALL" {
|
|
|
|
+ groupAllowListData = append(groupAllowListData,
|
|
|
|
+ &types.AllowBlockData{
|
|
|
|
+ Wxid: "ALL",
|
|
|
|
+ Nickname: "全部允许",
|
|
|
|
+ })
|
|
|
|
+ } else if len(data.GroupAllowList) > 0 {
|
|
|
|
+ groupAllowList, _ := l.svcCtx.DB.Contact.Query().Where(contact.WxWxidEQ(wxid), contact.WxidIn(data.GroupAllowList...)).All(l.ctx)
|
|
|
|
+ if groupAllowList != nil {
|
|
|
|
+ for _, av := range groupAllowList {
|
|
|
|
+ groupAllowListData = append(groupAllowListData,
|
|
|
|
+ &types.AllowBlockData{
|
|
|
|
+ Wxid: av.Wxid,
|
|
|
|
+ Nickname: av.Nickname,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- resp.Data.GroupAllowList = groupAllowListData
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- if data.BlockList != nil {
|
|
|
|
- blockList, err := l.svcCtx.DB.Contact.Query().Where(contact.WxWxidEQ(wxid), contact.WxidIn(data.BlockList...)).All(l.ctx)
|
|
|
|
-
|
|
|
|
- if err != nil {
|
|
|
|
- return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
|
|
- }
|
|
|
|
- // 将 allowList 转换为[]*ContactInfo
|
|
|
|
- blockListData := make([]*types.AllowBlockData, 0)
|
|
|
|
- for _, av := range blockList {
|
|
|
|
|
|
+ resp.Data.GroupAllowList = groupAllowListData
|
|
|
|
+ blockListData := make([]*types.AllowBlockData, 0)
|
|
|
|
+ if data.BlockList != nil && len(data.BlockList) > 0 {
|
|
|
|
+ if data.BlockList[0] == "ALL" {
|
|
blockListData = append(blockListData,
|
|
blockListData = append(blockListData,
|
|
&types.AllowBlockData{
|
|
&types.AllowBlockData{
|
|
- Wxid: &av.Wxid,
|
|
|
|
- Nickname: &av.Nickname,
|
|
|
|
|
|
+ Wxid: "ALL",
|
|
|
|
+ Nickname: "全部禁用",
|
|
})
|
|
})
|
|
|
|
+ } else {
|
|
|
|
+ blockList, _ := l.svcCtx.DB.Contact.Query().Where(contact.WxWxidEQ(wxid), contact.WxidIn(data.BlockList...)).All(l.ctx)
|
|
|
|
+ if blockList != nil {
|
|
|
|
+ for _, av := range blockList {
|
|
|
|
+ blockListData = append(blockListData,
|
|
|
|
+ &types.AllowBlockData{
|
|
|
|
+ Wxid: av.Wxid,
|
|
|
|
+ Nickname: av.Nickname,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- resp.Data.BlockList = blockListData
|
|
|
|
}
|
|
}
|
|
|
|
+ resp.Data.BlockList = blockListData
|
|
|
|
|
|
- if data.GroupBlockList != nil {
|
|
|
|
- groupBlockList, err := l.svcCtx.DB.Contact.Query().Where(contact.WxWxidEQ(wxid), contact.WxidIn(data.GroupBlockList...)).All(l.ctx)
|
|
|
|
-
|
|
|
|
- if err != nil {
|
|
|
|
- return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
|
|
- }
|
|
|
|
- groupBlockListData := make([]*types.AllowBlockData, 0)
|
|
|
|
- for _, av := range groupBlockList {
|
|
|
|
|
|
+ groupBlockListData := make([]*types.AllowBlockData, 0)
|
|
|
|
+ if data.GroupBlockList != nil && len(data.GroupBlockList) > 0 {
|
|
|
|
+ if data.GroupBlockList[0] == "ALL" {
|
|
groupBlockListData = append(groupBlockListData,
|
|
groupBlockListData = append(groupBlockListData,
|
|
&types.AllowBlockData{
|
|
&types.AllowBlockData{
|
|
- Wxid: &av.Wxid,
|
|
|
|
- Nickname: &av.Nickname,
|
|
|
|
|
|
+ Wxid: "ALL",
|
|
|
|
+ Nickname: "全部禁用",
|
|
})
|
|
})
|
|
|
|
+ } else {
|
|
|
|
+ groupBlockList, _ := l.svcCtx.DB.Contact.Query().Where(contact.WxWxidEQ(wxid), contact.WxidIn(data.GroupBlockList...)).All(l.ctx)
|
|
|
|
+ if groupBlockList != nil {
|
|
|
|
+ for _, av := range groupBlockList {
|
|
|
|
+ groupBlockListData = append(groupBlockListData,
|
|
|
|
+ &types.AllowBlockData{
|
|
|
|
+ Wxid: av.Wxid,
|
|
|
|
+ Nickname: av.Nickname,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- resp.Data.GroupBlockList = groupBlockListData
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ resp.Data.GroupBlockList = groupBlockListData
|
|
return resp, nil
|
|
return resp, nil
|
|
}
|
|
}
|