123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package chatsession
- import (
- "context"
- "github.com/suyuan32/simple-admin-common/msg/errormsg"
- "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 GetChatSessionByIdLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewGetChatSessionByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetChatSessionByIdLogic {
- return &GetChatSessionByIdLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx}
- }
- func (l *GetChatSessionByIdLogic) GetChatSessionById(req *types.IDReq) (resp *types.ChatSessionInfoResp, err error) {
- if req.Id == 0 {
- return nil, errorx.NewDefaultError("参数错误")
- }
- data, err := l.svcCtx.DB.ChatSession.Query().Where(chatsession.ID(req.Id)).Only(l.ctx)
- if err != nil {
- return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
- }
- return &types.ChatSessionInfoResp{
- BaseDataInfo: types.BaseDataInfo{
- Code: 0,
- Msg: errormsg.Success,
- },
- Data: types.ChatSessionInfo{
- Name: &data.Name,
- UserId: &data.UserID,
- BotId: &data.BotID,
- BotType: &data.BotType,
- },
- }, nil
- }
|