ziwen 2 سال پیش
والد
کامیت
65d07dc239
3فایلهای تغییر یافته به همراه38 افزوده شده و 3 حذف شده
  1. 3 3
      controllers/base_auth.go
  2. 3 0
      models/page_history_record.go
  3. 32 0
      services/page_history_record.go

+ 3 - 3
controllers/base_auth.go

@@ -4,14 +4,13 @@ import (
 	"encoding/json"
 	"fmt"
 	beego "github.com/beego/beego/v2/adapter"
+	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
+	"hongze/hongze_cygx/utils"
 	"net/http"
 	"net/url"
 	"strconv"
 
-	"hongze/hongze_cygx/models"
-	"hongze/hongze_cygx/utils"
-
 	"github.com/rdlucklib/rdluck_tools/log"
 )
 
@@ -83,6 +82,7 @@ func (this *BaseAuthController) Prepare() {
 				return
 			}
 			this.User = wxUser
+			go services.AddCygxPageHistoryRecord(this.User, this.Ctx)
 		} else {
 			this.JSON(models.BaseResponse{Ret: 408, Msg: "请求异常,请联系客服!", ErrMsg: "POST之外的请求,暂不支持"}, false, false)
 			this.StopRun()

+ 3 - 0
models/page_history_record.go

@@ -17,6 +17,9 @@ type CygxPageHistoryRecord struct {
 	ChartPermissionId      int       `description:"行业ID"`
 	IndustrialManagementId string    `description:"产业ID"`
 	PageType               string    `description:"页面类型,纪要:Summary,纪要搜索:SummarySearch,报告:Report,报告搜索:ReportSearch,产业列表:IndustryList,活动:Activit,活动搜索:ActivitSearch,活动详情:ActivitParticulars,报告详情:ReportParticulars,已结束活动:OverActivity"`
+	Router                 string    `description:"路由"`
+	PageRouter             string    `description:"前端页面路径"`
+	Parameter              string    `description:"参数"`
 }
 
 type CygxPageHistoryRecordRep struct {

+ 32 - 0
services/page_history_record.go

@@ -0,0 +1,32 @@
+package services
+
+import (
+	"fmt"
+	"github.com/beego/beego/v2/server/web/context"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strings"
+	"time"
+)
+
+func AddCygxPageHistoryRecord(user *models.WxUserItem, Ctx *context.Context)  {
+	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.Router = Ctx.Request.RequestURI
+	item.PageRouter = Ctx.Input.Query("PageRouter")
+	index := strings.Index(item.Router, "?")
+	if index != -1 {
+		item.Parameter = item.Router[index+1:]
+	}
+	_, err := models.AddCygxPageHistoryRecord(item)
+	if err != nil {
+		fmt.Println(err)
+		utils.FileLog.Info(err.Error())
+		return
+	}
+}