调整代码格式及使用常量去替换常用值
This commit is contained in:
@@ -4,6 +4,7 @@ namespace app\cunkebao\controller\device;
|
||||
|
||||
use app\common\model\DeviceHandleLog;
|
||||
use app\common\model\DeviceUser as DeviceUserModel;
|
||||
use app\common\model\User as UserModel;
|
||||
use app\cunkebao\controller\BaseController;
|
||||
use library\ResponseHelper;
|
||||
|
||||
@@ -21,15 +22,15 @@ class GetDeviceHandleLogsV1Controller extends BaseController
|
||||
protected function checkUserDevicePermission(int $deviceId): void
|
||||
{
|
||||
$where = [
|
||||
'deviceId' => $deviceId,
|
||||
'userId' => $this->getUserInfo('id'),
|
||||
'deviceId' => $deviceId,
|
||||
'userId' => $this->getUserInfo('id'),
|
||||
'companyId' => $this->getUserInfo('companyId')
|
||||
];
|
||||
|
||||
$hasPermission = DeviceUserModel::where($where)->count() > 0;
|
||||
|
||||
if (!$hasPermission) {
|
||||
throw new \Exception('您没有权限查看该设备', '403');
|
||||
throw new \Exception('您没有权限查看该设备', 403);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,9 +44,7 @@ class GetDeviceHandleLogsV1Controller extends BaseController
|
||||
{
|
||||
return DeviceHandleLog::alias('l')
|
||||
->field([
|
||||
'l.id',
|
||||
'l.content',
|
||||
'l.createTime',
|
||||
'l.id', 'l.content', 'l.createTime',
|
||||
'u.username'
|
||||
])
|
||||
->leftJoin('users u', 'l.userId = u.id')
|
||||
@@ -64,7 +63,7 @@ class GetDeviceHandleLogsV1Controller extends BaseController
|
||||
try {
|
||||
$deviceId = $this->request->param('id/d');
|
||||
|
||||
if ($this->getUserInfo('isAdmin') != 1) {
|
||||
if ($this->getUserInfo('isAdmin') != UserModel::ADMIN_STP) {
|
||||
$this->checkUserDevicePermission($deviceId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user