12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package chatsession
- import (
- "context"
- "github.com/suyuan32/simple-admin-common/msg/errormsg"
- "wechat-api/internal/utils/dberrorhandler"
- "wechat-api/internal/svc"
- "wechat-api/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type CreateChatSessionLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewCreateChatSessionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateChatSessionLogic {
- return &CreateChatSessionLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx}
- }
- func (l *CreateChatSessionLogic) CreateChatSession(req *types.ChatSessionInfo) (*types.BaseMsgResp, error) {
- err := l.svcCtx.DB.ChatSession.Create().
- SetNotNilName(req.Name).
- SetNotNilUserID(req.UserId).
- SetNotNilBotID(req.BotId).
- SetNotNilBotType(req.BotType).
- Exec(l.ctx)
- if err != nil {
- return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
- }
- return &types.BaseMsgResp{
- Code: 0,
- Msg: errormsg.Success,
- }, nil
- }
|