317699326@qq.com 1 долоо хоног өмнө
parent
commit
364e4ecfc2

+ 2 - 1
.gitignore

@@ -9,4 +9,5 @@
 /hongze_mobile_admin.exe
 /*.exe
 hongze_mobile_admin.exe
-hongze_mobile_admin.exe~
+hongze_mobile_admin.exe~
+/etalogs

+ 86 - 0
controllers/roadshow/calendar_researcher_question.go

@@ -0,0 +1,86 @@
+package roadshow
+
+import (
+	"encoding/json"
+	"hongze/hongze_mobile_admin/models/roadshow"
+	"hongze/hongze_mobile_admin/utils"
+	"strconv"
+	"time"
+)
+
+// @Title 路演客户问答保存接口
+// @Description 路演客户问答保存接口
+// @Param	request	body roadshow.RoadShowQuestionSaveReq true "type json string"
+// @Success Ret=200 保存成功
+// @router /question/save [post]
+func (this *CalendarController) QuestionAdd() {
+	sysUser := this.AdminWx
+	if sysUser == nil {
+		this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
+		return
+	}
+
+	deleteCache := true
+	cacheKey := "CACHE_RS_ACTIVITY_QUESTION_SAVE_" + strconv.Itoa(sysUser.AdminId)
+	defer func() {
+		if deleteCache {
+			utils.Rc.Delete(cacheKey)
+		}
+	}()
+
+	if !utils.Rc.SetNX(cacheKey, 1, 5*time.Second) {
+		deleteCache = false
+		this.FailWithMessage("系统处理中,请稍后重试!", "系统处理中,请稍后重试!"+sysUser.RealName+";data:"+string(this.Ctx.Input.RequestBody))
+		return
+	}
+	var req roadshow.RoadShowQuestionSaveReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		this.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
+		return
+	}
+
+	if req.RsCalendarId <= 0 || req.RsCalendarResearcherId <= 0 {
+		this.FailWithMessage("参数错误!", "参数错误")
+		return
+	}
+
+	calendarResearcherItem, err := roadshow.GetRsCalendarResearcherById(req.RsCalendarResearcherId)
+	if err != nil {
+		this.FailWithMessage("获取路演记录失败!", "获取路演记录失败,Err:"+err.Error())
+		return
+	}
+
+	if calendarResearcherItem.QuestionStatus == 1 {
+		this.FailWithMessage("问答已填写,不可重复提交!", "问答已填写,不可重复提交!")
+		return
+	}
+
+	err = roadshow.RoadShowQuestionSave(&req)
+	if err != nil {
+		this.FailWithMessage("保存失败!", "保存失败,Err:"+err.Error())
+		return
+	}
+	this.OkDetailed(nil, "保存成功")
+}
+
+// ResearcherList
+// @Title 获取路演客户问答信息接口
+// @Description 获取路演客户问答信息接口
+// @Param   RsCalendarResearcherId   query   int  true       "路演研究员记录ID"
+// @Success 200 {object} roadshow.ResearcherGroup
+// @router /question/list [get]
+func (this *CalendarController) QuestionList() {
+
+	rsCalendarResearcherId, _ := this.GetInt("RsCalendarResearcherId")
+	if rsCalendarResearcherId <= 0 {
+		this.FailWithMessage("参数错误!", "参数错误")
+		return
+	}
+	list, err := roadshow.GetRoadShowQuestionList(rsCalendarResearcherId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		this.FailWithMessage("获取失败!", "获取失败,Err:"+err.Error())
+		return
+	}
+	this.OkDetailed(list, "获取成功")
+}

+ 62 - 0
models/roadshow/calendar_researcher_question.go

@@ -0,0 +1,62 @@
+package roadshow
+
+import (
+	"context"
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type RsCalendarResearcherQuestion struct {
+	RsCalendarResearcherQuestionId int       `orm:"column(rs_calendar_researcher_question_id);pk"`
+	RsCalendarResearcherId         int       `description:"路演研究员记录ID"`
+	QuestionContent                string    `description:"提问内容"`
+	ReplyContent                   string    `description:"回复内容"`
+	CreateTime                     time.Time `description:"创建时间"`
+	ModifyTime                     time.Time `description:"更新时间"`
+}
+
+type RoadShowQuestionSaveReq struct {
+	RsCalendarId           int                                    `description:"路演ID"`
+	RsCalendarResearcherId int                                    `description:"路演研究员记录ID"`
+	CompanyIndustry        string                                 `description:"客户行业"`
+	CompanyClassify        string                                 `description:"客户分类"`
+	QuestionList           []*RsCalendarResearcherQuestionSaveReq `description:"问答列表"`
+}
+
+type RsCalendarResearcherQuestionSaveReq struct {
+	QuestionContent string `description:"提问内容"`
+	ReplyContent    string `description:"回复内容"`
+}
+
+func RoadShowQuestionSave(req *RoadShowQuestionSaveReq) (err error) {
+	o := orm.NewOrm()
+	tx, err := o.BeginWithCtx(context.Background())
+	if err != nil {
+		return err
+	}
+
+	sql := ` UPDATE rs_calendar_researcher SET company_industry = ?,company_classify = ?,question_status=1 WHERE rs_calendar_researcher_id = ? `
+	_, err = tx.Raw(sql, req.CompanyIndustry, req.CompanyClassify, req.RsCalendarResearcherId).Exec()
+	if err != nil {
+		return err
+	}
+	list := make([]*RsCalendarResearcherQuestion, 0)
+	for _, v := range req.QuestionList {
+		item := new(RsCalendarResearcherQuestion)
+		item.RsCalendarResearcherId = req.RsCalendarResearcherId
+		item.QuestionContent = v.QuestionContent
+		item.ReplyContent = v.ReplyContent
+		item.ModifyTime = time.Now()
+		item.CreateTime = time.Now()
+		list = append(list, item)
+	}
+	_, err = tx.InsertMulti(len(list), &list)
+	return err
+}
+
+func GetRoadShowQuestionList(rsCalendarResearcherId int) (item []*RsCalendarResearcherQuestion, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM rs_calendar_researcher_question WHERE rs_calendar_researcher_id = ? ORDER BY create_time DESC `
+	_, err = o.Raw(sql, rsCalendarResearcherId).QueryRows(&item)
+	return
+}