123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- package roadshow
- import (
- "encoding/json"
- "hongze/hz_crm_api/models"
- "hongze/hz_crm_api/models/roadshow"
- "hongze/hz_crm_api/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() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- 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
- br.Msg = "系统处理中,请稍后重试!"
- br.ErrMsg = "系统处理中,请稍后重试!" + sysUser.RealName + ";data:" + string(this.Ctx.Input.RequestBody)
- return
- }
- var req roadshow.RoadShowQuestionSaveReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.RsCalendarId <= 0 || req.RsCalendarResearcherId <= 0 {
- br.Msg = "参数错误!"
- return
- }
- calendarResearcherItem, err := roadshow.GetRsCalendarResearcherById(req.RsCalendarResearcherId)
- if err != nil {
- br.Msg = "获取路演记录失败!"
- br.ErrMsg = "获取路演记录失败,Err:" + err.Error()
- return
- }
- if calendarResearcherItem.QuestionStatus == 1 {
- br.Msg = "问答已填写,不可重复提交!"
- return
- }
- err = roadshow.RoadShowQuestionSave(&req)
- if err != nil {
- br.Msg = "保存失败!"
- br.ErrMsg = "保存失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "保存成功"
- br.IsAddLog = true
- }
- // ResearcherList
- // @Title 获取路演客户问答信息接口
- // @Description 获取路演客户问答信息接口
- // @Param RsCalendarResearcherId query int true "路演研究员记录ID"
- // @Success 200 {object} roadshow.ResearcherGroup
- // @router /question/list [get]
- func (this *CalendarController) QuestionList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- rsCalendarResearcherId, _ := this.GetInt("RsCalendarResearcherId")
- if rsCalendarResearcherId <= 0 {
- br.Msg = "参数错误!"
- return
- }
- list, err := roadshow.GetRoadShowQuestionList(rsCalendarResearcherId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败!"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = list
- }
|