123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- package controllers
- import (
- "encoding/json"
- "hongze/hongze_cygx/models"
- "time"
- )
- type ConfigController struct {
- BaseAuthController
- }
- // @Title 获取搜索推荐词
- // @Description 获取搜索推荐词
- // @Success 200 {object} models.ConfigResp
- // @router /detail [get]
- func (this *ConfigController) BrowseHistoryList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- detail := new(models.CygxConfig)
- //configCode := "hot_search"
- //detail, err := models.GetConfigByCode(configCode)
- hotSearch, err := models.GetHotSearch()
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- detail.ConfigValue = hotSearch
- resp := new(models.ConfigResp)
- resp.Item = detail
- br.Msg = "获取成功!"
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 页面访问统计
- // @Description 上传页面访问统计
- // @Param request body models.CygxPageHistoryRecordRep true "type json string"
- // @Success Ret=200 新增成功
- // @router /pageHistory [post]
- func (this *ConfigController) PageHistory() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req models.CygxPageHistoryRecordRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- pageType := req.PageType
- var havePageType bool
- PageType := []string{"Summary", "SummarySearch", "Report", "ReportSearch", "IndustryList", "Activit", "ActivitSearch", "ActivitParticulars", "ReportParticulars", "MySchedule", "LabelMore", "ArticleCopy"}
- for _, v := range PageType {
- if pageType == v {
- havePageType = true
- }
- }
- if !havePageType {
- br.Msg = "新增失败"
- br.ErrMsg = "PageType参数类型错误:" + pageType
- return
- }
- item := new(models.CygxPageHistoryRecord)
- item.UserId = user.UserId
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.DetailId = req.DetailId
- item.ChartPermissionId = req.ChartPermissionId
- item.IndustrialManagementId = req.IndustrialManagementId
- item.PageType = req.PageType
- _, err = models.AddCygxPageHistoryRecord(item)
- if err != nil {
- br.Msg = "新增访问记录失败"
- br.ErrMsg = "新增访问记录失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "新增成功"
- }
- // @Title 获取研选说明
- // @Description 获取研选说明接口
- // @Success 200 {object} models.ConfigResp
- // @router /descriptionOfResearch [get]
- func (this *ConfigController) DescriptionOfResearch() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- configCode := "description_of_research"
- detail, err := models.GetConfigByCode(configCode)
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.ConfigResp)
- resp.Item = detail
- br.Msg = "获取成功!"
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
|