|
@@ -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
|
|
|
+}
|