Browse Source

合并冲突

xingzai 3 years ago
parent
commit
89aaf39d70
2 changed files with 96 additions and 0 deletions
  1. 62 0
      controllers/config.go
  2. 34 0
      models/page_history_record.go

+ 62 - 0
controllers/config.go

@@ -1,7 +1,9 @@
 package controllers
 
 import (
+	"encoding/json"
 	"hongze/hongze_cygx/models"
+	"time"
 )
 
 type ConfigController struct {
@@ -33,6 +35,66 @@ func (this *ConfigController) BrowseHistoryList() {
 	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"}
+	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

+ 34 - 0
models/page_history_record.go

@@ -0,0 +1,34 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"time"
+)
+
+type CygxPageHistoryRecord struct {
+	Id                     int       `orm:"column(id);pk"`
+	UserId                 int       `description:"用户ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	Mobile                 string    `description:"手机号"`
+	Email                  string    `description:"邮箱"`
+	CompanyId              int       `description:"公司id"`
+	CompanyName            string    `description:"公司名称"`
+	DetailId               string    `description:"详情ID"`
+	ChartPermissionId      int       `description:"行业ID"`
+	IndustrialManagementId string    `description:"产业ID"`
+	PageType               string    `description:"页面类型,纪要:Summary,纪要搜索:SummarySearch,报告:Report,报告搜索:ReportSearch,产业列表:IndustryList,活动:Activit,活动搜索:ActivitSearch,活动详情:ActivitParticulars,报告详情:ReportParticulars"`
+}
+
+type CygxPageHistoryRecordRep struct {
+	DetailId               string `description:"详情ID"`
+	ChartPermissionId      int    `description:"行业ID"`
+	IndustrialManagementId string `description:"产业ID"`
+	PageType               string `description:"页面类型,纪要:Summary,纪要搜索:SummarySearch,报告:Report,报告搜索:ReportSearch,产业列表:IndustryList,活动:Activit,活动搜索:ActivitSearch,活动详情:ActivitParticulars,报告详情:ReportParticulars"`
+}
+
+//添加
+func AddCygxPageHistoryRecord(item *CygxPageHistoryRecord) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}