Blame view

API/Analysls.go 1.13 KB
483ade81   aarongao   v1.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package Api

import (
	"github.com/aarongao/tools"
	"github.com/gin-gonic/gin"
	"go.mongodb.org/mongo-driver/bson"
	"letu/DB"
)

// @Title 数据统计
// @Description 数据统计
// @Accept  json
// @Produce  json
// @Param   ScenicId     wgergejfwe    string     true        "景区id"
// @Param   StartTime     1    int     false        "时间戳"
// @Param   StopTime     1    int     false        "时间戳"
// @Success 200 {object} tools.ResponseSeccess "userTotal=用户总数registerTotal=注册用户总数nonRegisterTotal非注册用户总数"
// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
// @Router /Analysls/Count? [get]
func Analysls(c *gin.Context) {
	c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
	c.Header("Access-Control-Allow-Credentials", "true")

	_map := make(map[string]int64)
	_map["registerTotal"], _ = DB.CMember.CountDocuments(tools.GetContext(), bson.M{})
	_map["userTotal"], _ = DB.CDevice.CountDocuments(tools.GetContext(), bson.M{})
	_map["nonRegisterTotal"] = _map["userTotal"] - _map["registerTotal"]


	c.JSON(200, tools.ResponseSeccess{
		0,
		_map,
	})
}