Quellcode durchsuchen

执行添加好友的列表

lichangdong vor 3 Tagen
Ursprung
Commit
f82d7b9c83
1 geänderte Dateien mit 43 neuen und 0 gelöschten Zeilen
  1. 43 0
      internal/logic/add_friend/cancel_by_ids_logic.go

+ 43 - 0
internal/logic/add_friend/cancel_by_ids_logic.go

@@ -0,0 +1,43 @@
+package add_friend
+
+import (
+	"context"
+	"github.com/zeromicro/go-zero/core/errorx"
+	"wechat-api/ent/addwechatfriendlog"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CancelByIdsLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewCancelByIdsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CancelByIdsLogic {
+	return &CancelByIdsLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *CancelByIdsLogic) CancelByIds(req *types.CancelByIdsReq) (resp *types.BaseMsgResp, err error) {
+	if req.Ids == nil {
+		return nil, errorx.NewInvalidArgumentError("参数ids不能为空")
+	}
+	if len(req.Ids) == 0 {
+		return nil, errorx.NewInvalidArgumentError("参数ids不能为空")
+	}
+	var isCanAdd []int
+	isCanAdd = append(isCanAdd, 0, 1)
+	err = l.svcCtx.DB.AddWechatFriendLog.Update().Where(addwechatfriendlog.IDIn(req.Ids...), addwechatfriendlog.IsCanAddIn(isCanAdd...)).Exec(l.ctx)
+	if err != nil {
+		return nil, errorx.NewInvalidArgumentError("取消失败")
+	}
+	return &types.BaseMsgResp{
+		Code: 0,
+		Msg:  "取消成功",
+	}, nil
+}