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, }) }