123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package logic
- import (
- "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/api/knowledge/internal/svc"
- "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/api/knowledge/internal/types"
- "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/knowledgeclient"
- "context"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type KnowledgeAddLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewKnowledgeAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) KnowledgeAddLogic {
- return KnowledgeAddLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *KnowledgeAddLogic) KnowledgeAdd(req types.AddKnowledgeReq) (*types.CommonRes, error) {
- resp, err := l.svcCtx.Knowledge.KnowledgeAdd(l.ctx, &knowledgeclient.AddRequest{
- Question: req.Question,
- Answer: req.Answer,
- EntUserId: req.EntUserId,
- EntId: req.EntId,
- AppId: req.AppId,
- })
- if err != nil {
- return nil, err
- }
- return &types.CommonRes{
- Error_msg: resp.ErrorMsg,
- Error_code: int(resp.ErrorCode),
- Data: resp.Data,
- }, nil
- }
|