瀏覽代碼

统计增加插入

xuzhiheng 4 年之前
父節點
當前提交
c8556d1dc3
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      services/stdlib/docStatistics.go

+ 5 - 0
services/stdlib/docStatistics.go

@@ -10,6 +10,11 @@ import (
 func DocStatistics(docId, appId string, dtype int) bool {
 func DocStatistics(docId, appId string, dtype int) bool {
 	sqlStr := ""
 	sqlStr := ""
 	state := false
 	state := false
+	var count int64
+	jyDocsRpcUtil.GetJyDocsDB().Table("doc_statistics").Where("docId = ? and appId = ?", docId, appId).Count(&count)
+	if count < 1 {
+		jyDocsRpcUtil.GetJyDocsDB().Exec("insert into doc_statistics (docId,appId,updateDate,score,downTimes,viewTimes) values (?,?,?,?,?,?)", docId, appId, time.Now().Format("2006-01-02 15:04:05"), 0, 0, 0)
+	}
 	if dtype == 1 { //下载次数增加1
 	if dtype == 1 { //下载次数增加1
 		sqlStr = "update doc_statistics set downTimes = downTimes + 1,updateDate = ? where docId = ? and appId = ?"
 		sqlStr = "update doc_statistics set downTimes = downTimes + 1,updateDate = ? where docId = ? and appId = ?"
 	} else if dtype == 2 { //浏览次数增加1
 	} else if dtype == 2 { //浏览次数增加1