Browse Source

优化返回错误提示

master
wanghongjun 3 years ago
parent
commit
3189186527
  1. 5
      source/application/api/controller/pass/Passcc.php
  2. 2
      source/application/common/logic/PassFlow.php

5
source/application/api/controller/pass/Passcc.php

@ -28,7 +28,7 @@ class Passcc extends Controller
$granularity = $this->request->param('granularity');
$type = $this->request->param('type');
$res = PassFlow::allGroupTimeNum(['granularity' => $granularity, 'type' => $type]);
if (empty($res['code'])) $this->renderError($res['msg']);
if (empty($res['code'])) return $this->renderError($res['msg']);
$data = $res['data'];
return $this->renderSuccess(compact('data'));
}
@ -44,6 +44,7 @@ class Passcc extends Controller
{
$type = $this->request->param('type') ?: '';
$returnData = PassFlow::allGroupNum(null,['type' => $type]);
if (isset($returnData['code'])) return $this->renderError($returnData['msg']);
return $this->renderSuccess(compact('returnData'));
}
@ -71,6 +72,7 @@ class Passcc extends Controller
{
$type = $this->request->param('type') ?: '';
$data = PassFlow::toDayGroupsEnterNum(null,['type' => $type]);
if (isset($data['code'])) return $this->renderError($data['msg']);
return $this->renderSuccess(compact('data'));
}
@ -95,6 +97,7 @@ class Passcc extends Controller
{
$type = $this->request->param('type') ?: '';
$data = PassFlow::getPassHoursData(null,['type' => $type]);
if (isset($data['code'])) return $this->renderError($data['msg']);
return $this->renderSuccess(compact('data'));
}
}

2
source/application/common/logic/PassFlow.php

@ -35,6 +35,7 @@ class PassFlow
if (!in_array($granularity,self::$granularity)) return ['code' => 0, 'msg' => '参数错误:granularity'];
$where = '';
$groupsId = '';
if (empty($dm)) $dm = new Dm();
if (!empty($type)) {
if (!in_array($type,self::$groupType)) return ['code' => 0, 'msg' => 'type字段参数错误'];
$groupsIdArr = self::getGroupIds($dm,$type);
@ -45,7 +46,6 @@ class PassFlow
$allTimeData = [];
$groupsData = [];
$dkeys = [];
if (empty($dm)) $dm = new Dm();
if ($granularity == 'daily') {
$date = self::getDateData('day');
$start_time = $date['day']['start_time'];

Loading…
Cancel
Save