|
@@ -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, "获取成功")
|
|
|
+}
|