game2005api/webapp/controller/BaseController.class.php
2021-11-17 19:21:53 +08:00

68 lines
1.2 KiB
PHP

<?php
require 'phpcommon/sqlhelper.php';
class BaseController {
private $nowtime = 0;
function __construct()
{
$this->nowtime = phpcommon\getNowTime();
}
public function handlePre()
{
}
public function handlePost()
{
}
protected function getNowTime()
{
return $this->nowtime;
}
protected function getNowDaySeconds()
{
return phpcommon\getDaySeconds($this->nowtime);
}
protected function getTodayRemainSeconds()
{
return max(0, $this->getNowDaySeconds() + 3600 * 24 - $this->getNowTime());
}
protected function rspErr($errcode, $errmsg)
{
echo json_encode(array(
'errcode' => $errcode,
'errmsg' => $errmsg,
));
}
protected function rspOk()
{
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
));
}
protected function rspData($data)
{
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'data' => $data
));
}
protected function rspRawData($rawData)
{
echo json_encode($rawData);
}
}