DiverseYouthNightSchool/application/api/controller/school/BigData.php

413 lines
13 KiB
PHP
Raw Normal View History

<?php
namespace app\api\controller\school;
use addons\epay\library\Service;
use app\admin\model\school\help\Cate;
use app\common\controller\Api;
use app\common\library\NightSchoolBigData;
use bw\UrlLock;
use think\Cache;
/**
* 数据驾驶舱接口
*/
class BigData extends Api
{
// 无需登录的接口,*表示全部
protected $noNeedLogin = '*';
// 无需鉴权的接口,*表示全部
protected $noNeedRight = ['test2'];
/**
* @ApiTitle(按区域统计接口)
* @ApiSummary(按区域统计接口)
* @ApiMethod(GET)
* @ApiParams(name = "province", type = "string",required=false,description = "省编号(非必填)")
* @ApiParams(name = "city", type = "string",required=false,description = "市编号(非必填)")
* @ApiParams(name = "district", type = "string",required=false,description = "区域编号(非必填)")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getAreaBaseData()
{
try{
$lock = new UrlLock(1,"area-base-data-lock-suffix",120,"您的请求过于频繁请您稍后再试请求最大锁定间隔5秒/一次!");
$lock->lock();
$province = $this->request->request("province/s","");
$city = $this->request->request("city/s","");
$district = $this->request->request("district/s","");
$res = NightSchoolBigData::getAreaBaseData($province,$city,$district);
}catch (\Throwable $e){
$lock->free();
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
$this->error($e->getMessage());
}
$lock->free();
$this->success('返回成功', $res);
}
/**
* @ApiTitle(按课程类型统计累计报名人数)
* @ApiSummary(按课程类型统计累计报名人数)
* @ApiMethod(GET)
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function accumulatedNumberOfApplicants()
{
try{
$lock = new UrlLock(1,"accumulatedNumberOfApplicants-data-lock-suffix",120,"您的请求过于频繁请您稍后再试请求最大锁定间隔5秒/一次!");
$lock->lock();
$res = NightSchoolBigData::accumulatedNumberOfApplicants();
}catch (\Throwable $e){
$lock->free();
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
$this->error($e->getMessage());
}
$lock->free();
$this->success('返回成功', $res);
}
/**
* @ApiTitle(各区域上课数量和上课人数)
* @ApiSummary(各区域上课数量和上课人数)
* @ApiParams(name = "province", type = "string",required=false,description = "省编号(非必填)")
* @ApiParams(name = "city", type = "string",required=false,description = "市编号(非必填)")
* @ApiParams(name = "time", type = "string",required=false,description = "复合时间查询:today今天,week本周,month本月,year本年,yesterday昨天,last year上一年,last week上周last month上個月lately7最近7天 lately30最近30天按开始时间区间查传值格式Y/m/d H:M:S-Y/m/d H:M:S")
* @ApiMethod(GET)
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function numberOfClassesInEachRegion()
{
try{
$lock = new UrlLock(1,"numberOfClassesInEachRegion-data-lock-suffix",120,"您的请求过于频繁请您稍后再试请求最大锁定间隔5秒/一次!");
$lock->lock();
$province = $this->request->request("province/s","");
$city = $this->request->request("city/s","");
$time = $this->request->request("time/s","");
$res = NightSchoolBigData::numberOfClassesInEachRegion($province,$city,$time);
}catch (\Throwable $e){
$lock->free();
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
$this->error($e->getMessage());
}
$lock->free();
$this->success('返回成功', $res);
}
/**
* @ApiTitle(按课程类型统计七天内报名人数)
* @ApiSummary(按课程类型统七天内报名人数)
* @ApiMethod(GET)
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function accumulatedSevenNumberOfApplicants()
{
try{
$lock = new UrlLock(1,"accumulatedSevenNumberOfApplicants-data-lock-suffix",120,"您的请求过于频繁请您稍后再试请求最大锁定间隔5秒/一次!");
$lock->lock();
$res = NightSchoolBigData::accumulatedSevenNumberOfApplicants();
}catch (\Throwable $e){
$lock->free();
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
$this->error($e->getMessage());
}
$lock->free();
$this->success('返回成功', $res);
}
/**
* @ApiTitle(前N名累计活跃课程)
* @ApiSummary(前N名累计活跃课程)
* @ApiParams(name = "number", type = "string",required=false,description = "前N名累计活跃课程")
* @ApiMethod(GET)
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function topNCumulativeActiveCourses()
{
try{
$lock = new UrlLock(1,"topNCumulativeActiveCourses-data-lock-suffix",120,"您的请求过于频繁请您稍后再试请求最大锁定间隔5秒/一次!");
$lock->lock();
$N = $this->request->request("number/d",20);
$res = NightSchoolBigData::topNCumulativeActiveCourses($N);
}catch (\Throwable $e){
$lock->free();
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
$this->error($e->getMessage());
}
$lock->free();
$this->success('返回成功', $res);
}
/**
* @ApiTitle(七天内活动报名人数和活跃热度)
* @ApiSummary(七天内活动报名人数和活跃热度)
* @ApiMethod(GET)
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function accumulatedSevenNumberOfActivity()
{
try{
$lock = new UrlLock(1,"accumulatedSevenNumberOfActivity-data-lock-suffix",120,"您的请求过于频繁请您稍后再试请求最大锁定间隔5秒/一次!");
$lock->lock();
$res = NightSchoolBigData::accumulatedSevenNumberOfActivity();
}catch (\Throwable $e){
$lock->free();
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
$this->error($e->getMessage());
}
$lock->free();
$this->success('返回成功', $res);
}
2025-01-13 18:03:44 +08:00
/**
* @ApiTitle(得到七天内日期)
* @ApiSummary(得到七天内日期)
* @ApiParams(name = "time", type = "string",required=false,description = "计算的当前时间戳")
* @ApiMethod(GET)
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getLastSevenDaysDate()
{
try{
$lock = new UrlLock(1,"getLastSevenDaysDate-data-lock-suffix",120,"您的请求过于频繁请您稍后再试请求最大锁定间隔5秒/一次!");
$lock->lock();
$N = $this->request->request("time/s",0);
$res = NightSchoolBigData::getLastSevenDaysDate($N);
}catch (\Throwable $e){
$lock->free();
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
$this->error($e->getMessage());
}
$lock->free();
$this->success('返回成功', $res);
}
/**
* @ApiTitle(得到上个月日期)
* @ApiSummary(得到上个月日期)
* @ApiParams(name = "time", type = "string",required=false,description = "计算的当前时间戳")
* @ApiMethod(GET)
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getLastMonthDate()
{
try{
$lock = new UrlLock(1,"getLastMonthDate-data-lock-suffix",120,"您的请求过于频繁请您稍后再试请求最大锁定间隔5秒/一次!");
$lock->lock();
$N = $this->request->request("time/s",0);
$res = NightSchoolBigData::getLastMonthDate($N);
}catch (\Throwable $e){
$lock->free();
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
$this->error($e->getMessage());
}
$lock->free();
$this->success('返回成功', $res);
}
/**
* @ApiTitle(得到上个天日期)
* @ApiSummary(得到上个天日期)
* @ApiParams(name = "time", type = "string",required=false,description = "计算的当前时间戳")
* @ApiMethod(GET)
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getLastDaysDate()
{
try{
$lock = new UrlLock(1,"getLastDaysDate-data-lock-suffix",120,"您的请求过于频繁请您稍后再试请求最大锁定间隔5秒/一次!");
$lock->lock();
$N = $this->request->request("time/s",0);
$res = NightSchoolBigData::getLastDaysDate($N);
}catch (\Throwable $e){
$lock->free();
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
$this->error($e->getMessage());
}
$lock->free();
$this->success('返回成功', $res);
}
/**
* @ApiTitle(得到上周日期)
* @ApiSummary(得到上周日期)
* @ApiParams(name = "time", type = "string",required=false,description = "计算的当前时间戳")
* @ApiMethod(GET)
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getLastWeekDate()
{
try{
$lock = new UrlLock(1,"getLastWeekDate-data-lock-suffix",120,"您的请求过于频繁请您稍后再试请求最大锁定间隔5秒/一次!");
$lock->lock();
$N = $this->request->request("time/s",0);
$res = NightSchoolBigData::getLastWeekDate($N);
}catch (\Throwable $e){
$lock->free();
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
$this->error($e->getMessage());
}
$lock->free();
$this->success('返回成功', $res);
}
2025-01-14 17:56:44 +08:00
/**
* @ApiTitle(得到前30天日期)
* @ApiSummary(得到前30天日期)
* @ApiParams(name = "time", type = "string",required=false,description = "计算的当前时间戳")
* @ApiMethod(GET)
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getLastThirtyDaysDate()
{
try{
$lock = new UrlLock(1,"getLastThirtyDaysDate-data-lock-suffix",120,"您的请求过于频繁请您稍后再试请求最大锁定间隔5秒/一次!");
$lock->lock();
$N = $this->request->request("time/s",0);
$res = NightSchoolBigData::getLastThirtyDaysDate($N);
}catch (\Throwable $e){
$lock->free();
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
$this->error($e->getMessage());
}
$lock->free();
$this->success('返回成功', $res);
}
/**
* @ApiTitle(访问来源统计)
* @ApiSummary(访问来源统计)
* @ApiParams(name = "start_time", type = "string",required=false,description = "开始时间")
* @ApiParams(name = "end_time", type = "string",required=false,description = "结束时间")
* @ApiMethod(GET)
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function visitDistribution()
{
try{
$lock = new UrlLock(1,"visitDistribution-data-lock-suffix",120,"您的请求过于频繁请您稍后再试请求最大锁定间隔5秒/一次!");
$lock->lock();
$start_time = $this->request->request("start_time/s",0);
$end_time = $this->request->request("end_time/s",0);
$res = NightSchoolBigData::visitDistribution($start_time,$end_time);
}catch (\Throwable $e){
$lock->free();
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
$this->error($e->getMessage());
}
$lock->free();
$this->success('返回成功', $res);
}
}