From 2a25917e412a24a429c8f07f985624bbb8b03dad Mon Sep 17 00:00:00 2001 From: kuaifan Date: Mon, 26 May 2025 23:04:00 +0800 Subject: [PATCH] no message --- app/Http/Controllers/Api/SystemController.php | 30 +++++++++++-------- app/Http/Controllers/Api/UsersController.php | 3 +- app/Models/UserCheckinFace.php | 23 +++++++------- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/app/Http/Controllers/Api/SystemController.php b/app/Http/Controllers/Api/SystemController.php index ef9a60bf1..310457c99 100755 --- a/app/Http/Controllers/Api/SystemController.php +++ b/app/Http/Controllers/Api/SystemController.php @@ -1529,11 +1529,13 @@ class SystemController extends AbstractController } // 添加office资源 $officePath = ''; - $officeApi = 'http://office/web-apps/apps/api/documents/api.js'; - $content = @file_get_contents($officeApi); - if ($content) { - if (preg_match("/const\s+ver\s*=\s*'\/*([^']+)'/", $content, $matches)) { - $officePath = $matches[1]; + if (Apps::isInstalled('office')) { + $officeApi = 'http://office/web-apps/apps/api/documents/api.js'; + $content = @file_get_contents($officeApi); + if ($content) { + if (preg_match("/const\s+ver\s*=\s*'\/*([^']+)'/", $content, $matches)) { + $officePath = $matches[1]; + } } } if ($officePath) { @@ -1549,14 +1551,16 @@ class SystemController extends AbstractController }); } // 添加OKR资源 - $okrContent = @file_get_contents("http://nginx/apps/okr/"); - preg_match_all('/]*src=["\']([^"\']+)["\'][^>]*>/i', $okrContent, $scriptMatches); - foreach ($scriptMatches[1] as $src) { - $array[] = $src; - } - preg_match_all('/]*rel=["\']stylesheet["\'][^>]*href=["\']([^"\']+)["\'][^>]*>/i', $okrContent, $linkMatches); - foreach ($linkMatches[1] as $href) { - $array[] = $href; + if (Apps::isInstalled('okr')) { + $okrContent = @file_get_contents("http://nginx/apps/okr/"); + preg_match_all('/]*src=["\']([^"\']+)["\'][^>]*>/i', $okrContent, $scriptMatches); + foreach ($scriptMatches[1] as $src) { + $array[] = $src; + } + preg_match_all('/]*rel=["\']stylesheet["\'][^>]*href=["\']([^"\']+)["\'][^>]*>/i', $okrContent, $linkMatches); + foreach ($linkMatches[1] as $href) { + $array[] = $href; + } } } diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 3cdd3c0d7..c8a46fcd3 100755 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -942,8 +942,7 @@ class UsersController extends AbstractController return UserCheckinMac::saveMac($userInfo->userid, $array); case 'checkin_face': - $faceimg = $data['checkin_face'] ? $data['checkin_face'] : ''; - + $faceimg = $data['checkin_face'] ?: ''; return UserCheckinFace::saveFace($userInfo->userid, $userInfo->nickname, $faceimg, "管理员上传"); case 'department': diff --git a/app/Models/UserCheckinFace.php b/app/Models/UserCheckinFace.php index 1fc2d0b97..788ce5352 100644 --- a/app/Models/UserCheckinFace.php +++ b/app/Models/UserCheckinFace.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Exceptions\ApiException; +use App\Module\Apps; use App\Module\Base; use App\Module\Ihttp; @@ -37,8 +38,9 @@ use App\Module\Ihttp; class UserCheckinFace extends AbstractModel { - public static function saveFace($userid, $nickname, $faceimg, $remark='') + public static function saveFace($userid, $nickname, $faceimg, $remark = '') { + Apps::isInstalledThrow('face'); // 取上传图片的URL $faceimg = Base::unFillUrl($faceimg); $record = ""; @@ -59,14 +61,14 @@ class UserCheckinFace extends AbstractModel } $res = Ihttp::ihttp_post($url, json_encode($data), 15); - if($res['data'] && $data = json_decode($res['data'])){ - if($data->ret != 1 && $data->msg){ + if ($res['data'] && $data = json_decode($res['data'])) { + if ($data->ret != 1 && $data->msg) { throw new ApiException($data->msg); } } - return AbstractModel::transaction(function() use ($userid, $faceimg, $remark) { + return AbstractModel::transaction(function () use ($userid, $faceimg, $remark) { $checkinFace = self::query()->whereUserid($userid)->first(); if ($checkinFace) { self::updateData(['id' => $checkinFace->id], [ @@ -82,16 +84,14 @@ class UserCheckinFace extends AbstractModel $checkinFace->save(); } if ($faceimg == '') { - $res = UserCheckinFace::deleteDeviceUser($userid); - if ($res) { - return $res; - } + UserCheckinFace::deleteDeviceUser($userid); } return Base::retSuccess('设置成功'); }); } - public static function deleteDeviceUser($userid) { + private static function deleteDeviceUser($userid) + { $url = "http://face:7788/user/delete"; $data = [ 'enrollid' => $userid, @@ -99,10 +99,9 @@ class UserCheckinFace extends AbstractModel ]; $res = Ihttp::ihttp_post($url, json_encode($data)); - if($res['data'] && $data = json_decode($res['data'])){ - if($data->ret != 1 && $data->msg){ + if ($res['data'] && $data = json_decode($res['data'])) { + if ($data->ret != 1 && $data->msg) { throw new ApiException($data->msg); - // return Base::retError($data->msg); } } }