1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package chatsession
- import (
- "context"
- "fmt"
- "github.com/zeromicro/go-zero/core/errorx"
- "wechat-api/ent/chatsession"
- "wechat-api/internal/utils/dberrorhandler"
- "wechat-api/internal/svc"
- "wechat-api/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type DeleteChatSessionLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewDeleteChatSessionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteChatSessionLogic {
- return &DeleteChatSessionLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx}
- }
- func (l *DeleteChatSessionLogic) DeleteChatSession(req *types.IDsReq) (resp *types.BaseMsgResp, err error) {
- if len(req.Ids) == 0 {
- return nil, errorx.NewInvalidArgumentError("Ids参数不能为空")
- }
- rows, err := l.svcCtx.DB.ChatSession.Delete().Where(chatsession.IDIn(req.Ids...)).Exec(l.ctx)
- if err != nil {
- return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
- }
- msg := fmt.Sprintf("delete %d rows", rows)
- return &types.BaseMsgResp{
- Code: 0,
- Msg: msg,
- }, nil
- }
|