123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package logic
- import (
- "context"
- <<<<<<< HEAD
- "database/sql"
- "github.com/zeromicro/go-zero/core/logx"
- "knowledgeBase/rpc/knowledge/init"
- "knowledgeBase/rpc/knowledge/knowledgeclient"
- "time"
- "knowledgeBase/rpc/knowledge/internal/svc"
- "log"
- =======
- "knowledgeBase/rpc/knowledge/knowledgeclient"
- "github.com/tal-tech/go-zero/core/logx"
- "knowledgeBase/rpc/knowledge/internal/svc"
- >>>>>>> origin/master
- )
- type KnowledgeAddLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewKnowledgeAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *KnowledgeAddLogic {
- return &KnowledgeAddLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- <<<<<<< HEAD
- type Question struct {
- Question string `json:"question"`
- KeyWords string `json:"keyWords"`
- }
- // 知识新增
- func (l *KnowledgeAddLogic) KnowledgeAdd(in *knowledgeclient.AddRequest) (*knowledgeclient.AddResponse, bool) {
- // todo: add your logic here and delete this line
- result := &knowledgeclient.AddResponse{}
- //先查找知识库Id
- query := map[string]interface{}{"state": 1, "appid": in.AppId, "tenant_id": in.TenantId}
- datalist := init.Mysql.Find(init.KNOWLEDGE, query, "id", "", -1, -1)
- if datalist != nil && *datalist != nil && len(*datalist) > 0 {
- return result, init.Mysql.ExecTx("创建其他订单生成订单信息和合同信息", func(tx *sql.Tx) bool {
- //插入答案
- answerData := map[string]interface{}{
- "knowledge_id": (*datalist)[0]["id"],
- "status": 1,
- "create_time": time.Now().Local().Format(init.Date_Full_Layout),
- "update_time": time.Now().Local().Format(init.Date_Full_Layout),
- "create_person": in.Person,
- "content": in.Answer,
- }
- answer_id := init.Mysql.Insert(init.ANSWER, answerData)
- if answer_id <= 0 {
- return false
- }
- //插入问题
- questionData := map[string]interface{}{
- "answer_id": answer_id,
- "content": 1,
- "keywords": "",
- }
- question_id := init.Mysql.Insert(init.QUESTION, questionData)
- if question_id <= 0 {
- return false
- }
- return true
- })
- } else {
- log.Println("租户不存在")
- result.ErrorCode = -1
- result.ErrorMsg = "租户不存在"
- }
- return result, true
- =======
- // 知识新增
- func (l *KnowledgeAddLogic) KnowledgeAdd(in *knowledgeclient.AddRequest) (*knowledgeclient.AddResponse, error) {
- // todo: add your logic here and delete this line
- return &knowledgeclient.AddResponse{}, nil
- >>>>>>> origin/master
- }
|