init
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace app\bootstrap;
|
||||
|
||||
use app\utils\Logger;
|
||||
use Throwable;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
|
||||
class Handler extends \support\exception\Handler
|
||||
{
|
||||
public function render(Request $request, Throwable $exception): Response
|
||||
{
|
||||
Logger::error($exception->getMessage(),$exception);
|
||||
$code = $exception->getCode();
|
||||
$debug = $this->_debug ?? $this->debug;
|
||||
if ($request->expectsJson()) {
|
||||
$json = ['code' => $code ?: 500, 'msg' => $debug ? $exception->getMessage() : 'Server internal error', 'type' => 'failed'];
|
||||
$debug && $json['traces'] = (string)$exception;
|
||||
return new Response(200, ['Content-Type' => 'application/json'],
|
||||
\json_encode($json, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
}
|
||||
$error = $debug ? \nl2br((string)$exception) : 'Server internal error';
|
||||
return new Response(500, [], $error);
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,9 @@ class SqlDebug implements Bootstrap
|
||||
}
|
||||
|
||||
$appPath = app_path();
|
||||
$pluginPath = dirname($appPath) . DIRECTORY_SEPARATOR . 'plugin';
|
||||
|
||||
if (Config::getInstance()->dbDebug) Db::connection()->listen(function (QueryExecuted $queryExecuted) use ($appPath) {
|
||||
if (Config::getInstance()->dbDebug) Db::connection()->listen(function (QueryExecuted $queryExecuted) use ($pluginPath, $appPath) {
|
||||
// 过滤掉 "select 1" 这类心跳检测SQL
|
||||
if (isset($queryExecuted->sql) && $queryExecuted->sql !== "select 1") {
|
||||
$bindings = $queryExecuted->bindings;
|
||||
@@ -60,7 +61,7 @@ class SqlDebug implements Bootstrap
|
||||
// 定位产生SQL的业务文件/行号/方法
|
||||
$traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
foreach ($traces as $trace) {
|
||||
if (isset($trace['file'], $trace['function']) && str_contains($trace['file'], $appPath)) {
|
||||
if (isset($trace['file'], $trace['function']) && (str_contains($trace['file'], $appPath) || str_contains($trace['file'], $pluginPath))) {
|
||||
// 格式化文件路径(去掉项目根目录,只保留相对路径)
|
||||
$file = str_replace(base_path(), '', $trace['file']);
|
||||
$file = ltrim($file, '/\\');
|
||||
|
||||
@@ -82,6 +82,9 @@ class Config
|
||||
public int $httpPort{
|
||||
get => $this->httpPort;
|
||||
}
|
||||
public bool $enableRequestTimeLog{
|
||||
get => $this->enableRequestTimeLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员检测回调函数
|
||||
@@ -112,6 +115,7 @@ class Config
|
||||
$this->httpPort = self::getIntEnv('HTTP_PORT', 8080);
|
||||
$this->zlm = new ZLMConfig();
|
||||
$this->personDetectionCallback = null;
|
||||
$this->enableRequestTimeLog = self::getBoolEnv('ENABLE_REQUEST_TIME_LOG', false);
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && $this->tcpServerProcessNum > 1) {
|
||||
$this->tcpServerProcessNum = 1;
|
||||
echo "Warning: TCP_SERVER_PROCESS_NUM set to 1 on Windows.\n";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace app\controller;
|
||||
|
||||
use app\config\Config;
|
||||
use app\utils\ModelAutoGenerator;
|
||||
use plugin\admin\app\common\ModelAutoGenerator;
|
||||
use app\zlm\ZLMClient;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
@@ -144,7 +144,7 @@ class IndexController
|
||||
|
||||
if ($httpCode !== 200 || empty($imageData)) {
|
||||
// 记录错误日志
|
||||
\app\utils\Logger::error("ZLM截图失败: HTTP {$httpCode}, 错误: {$error}, URL: {$url}");
|
||||
\plugin\admin\app\common\Logger::error("ZLM截图失败: HTTP {$httpCode}, 错误: {$error}, URL: {$url}");
|
||||
// 返回错误提示图
|
||||
return $this->generateErrorImage("截图失败: HTTP {$httpCode}");
|
||||
}
|
||||
@@ -165,7 +165,7 @@ class IndexController
|
||||
]);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
\app\utils\Logger::error("ZLM截图异常: " . $e->getMessage());
|
||||
\plugin\admin\app\common\Logger::error("ZLM截图异常: " . $e->getMessage());
|
||||
return $this->generateErrorImage("截图异常: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* AdminData 模型
|
||||
* 表说明:admin_data 数据表模型
|
||||
* 对应数据表:admin_data
|
||||
* @property int $id id(非空,主键)
|
||||
* @property int $uid uid 用户ID(非空)
|
||||
* @property string $hospital_id hospital_id 医院id(非空)
|
||||
* @property string $dept_id dept_id 科室id(非空)
|
||||
*/
|
||||
class AdminData extends Model
|
||||
{
|
||||
/**
|
||||
* 数据表名
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'admin_data';
|
||||
|
||||
/**
|
||||
* 主键字段名
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 关闭自动时间戳(如需开启请改为 true,需确保表有 create_time/update_time 字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
/**
|
||||
* 字段严格检查(false=允许操作未定义字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $strict = false;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* OpmMwDepartment 模型
|
||||
* 表说明:opm_mw_department 数据表模型
|
||||
* 对应数据表:opm_mw_department
|
||||
* @property string $id id(非空,主键)
|
||||
* @property int $organ_id organ_id
|
||||
* @property int $sort_id sort_id
|
||||
* @property string $dept_name dept_name
|
||||
* @property string $description description
|
||||
* @property string $dept_code dept_code
|
||||
* @property string $dept_det_code dept_det_code
|
||||
* @property string $dept_det_name dept_det_name
|
||||
* @property string $coll_type coll_type 归集方式 0:本院产生,1:外院归集(默认值:1)
|
||||
* @property string $handover_code handover_code 科室的交接码,每一个科室有一个交接码
|
||||
* @property string $created_at created_at
|
||||
* @property int $collection_id collection_id
|
||||
* @property int $card_id card_id
|
||||
* @property int $storey_id storey_id 属于那栋楼
|
||||
* @property int $floor_id floor_id 属于那一层
|
||||
* @property int $is_sync is_sync 是否同步(默认值:1)
|
||||
* @property string $type type
|
||||
* @property string $report_dep_id report_dep_id
|
||||
* @property int $is_report is_report(默认值:1)
|
||||
* @property string $deptId deptId
|
||||
* @property int $s_report s_report(默认值:1)
|
||||
*/
|
||||
class OpmMwDepartment extends Model
|
||||
{
|
||||
/**
|
||||
* 数据表名
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'opm_mw_department';
|
||||
|
||||
/**
|
||||
* 主键字段名
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 关闭自动时间戳(如需开启请改为 true,需确保表有 create_time/update_time 字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
/**
|
||||
* 字段严格检查(false=允许操作未定义字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $strict = false;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* OpmMwHospital 模型
|
||||
* 表说明:opm_mw_hospital 数据表模型
|
||||
* 对应数据表:opm_mw_hospital
|
||||
* @property string $id id(非空,主键)
|
||||
* @property int $area_id area_id
|
||||
* @property string $organ_name organ_name
|
||||
* @property string $former_name former_name
|
||||
* @property string $sql_host sql_host
|
||||
* @property string $sql_database sql_database
|
||||
* @property string $sql_port sql_port
|
||||
* @property string $sql_account sql_account
|
||||
* @property string $sql_password sql_password
|
||||
* @property string $organ_code organ_code
|
||||
* @property string $organ_level organ_level 0未定级 1一级 2二级 3三级
|
||||
* @property string $grade grade 0未定级 1甲级 2乙级
|
||||
* @property string $contacts_idcard contacts_idcard
|
||||
* @property string $phone phone
|
||||
* @property string $region_code region_code
|
||||
* @property string $address address
|
||||
* @property string $person_name person_name
|
||||
* @property string $created_at created_at
|
||||
* @property string $mobile mobile
|
||||
* @property string $push_url push_url
|
||||
* @property int $is_true is_true(默认值:1)
|
||||
* @property string $dealer dealer 经销商
|
||||
* @property string $dealer_mobile dealer_mobile 经销商联系电话
|
||||
* @property string $leader leader 医院负责人
|
||||
* @property string $leader_mobile leader_mobile 医院负责人电话
|
||||
* @property string $warranty_period warranty_period 质保期
|
||||
* @property int $is_report is_report(默认值:1)
|
||||
* @property string $url2 url2
|
||||
* @property int $is_push is_push(默认值:0)
|
||||
*/
|
||||
class OpmMwHospital extends Model
|
||||
{
|
||||
/**
|
||||
* 数据表名
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'opm_mw_hospital';
|
||||
|
||||
/**
|
||||
* 主键字段名
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 关闭自动时间戳(如需开启请改为 true,需确保表有 create_time/update_time 字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
/**
|
||||
* 字段严格检查(false=允许操作未定义字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $strict = false;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* WaAdminRoles 模型
|
||||
* 表说明:管理员角色表
|
||||
* 对应数据表:wa_admin_roles
|
||||
* @property int $id id 主键(非空,主键)
|
||||
* @property int $role_id role_id 角色id(非空)
|
||||
* @property int $admin_id admin_id 管理员id(非空)
|
||||
*/
|
||||
class WaAdminRoles extends Model
|
||||
{
|
||||
/**
|
||||
* 数据表名
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_admin_roles';
|
||||
|
||||
/**
|
||||
* 主键字段名
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 关闭自动时间戳(如需开启请改为 true,需确保表有 create_time/update_time 字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
/**
|
||||
* 字段严格检查(false=允许操作未定义字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $strict = false;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* WaAdmins 模型
|
||||
* 表说明:管理员表
|
||||
* 对应数据表:wa_admins
|
||||
* @property string $id id ID(非空,主键)
|
||||
* @property string $username username 用户名(非空)
|
||||
* @property string $nickname nickname 昵称(非空)
|
||||
* @property string $password password 密码(非空)
|
||||
* @property string $avatar avatar 头像(默认值:/app/admin/avatar.png)
|
||||
* @property string $email email 邮箱
|
||||
* @property string $mobile mobile 手机
|
||||
* @property string $created_at created_at 创建时间
|
||||
* @property string $updated_at updated_at 更新时间
|
||||
* @property string $login_at login_at 登录时间
|
||||
* @property int $status status 禁用
|
||||
*/
|
||||
class WaAdmins extends Model
|
||||
{
|
||||
/**
|
||||
* 数据表名
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_admins';
|
||||
|
||||
/**
|
||||
* 主键字段名
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 关闭自动时间戳(如需开启请改为 true,需确保表有 create_time/update_time 字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
/**
|
||||
* 字段严格检查(false=允许操作未定义字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $strict = false;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* WaOptions 模型
|
||||
* 表说明:选项表
|
||||
* 对应数据表:wa_options
|
||||
* @property string $id id(非空,主键)
|
||||
* @property string $name name 键(非空)
|
||||
* @property string $value value 值(非空)
|
||||
* @property string $created_at created_at 创建时间(非空,默认值:2022-08-15 00:00:00)
|
||||
* @property string $updated_at updated_at 更新时间(非空,默认值:2022-08-15 00:00:00)
|
||||
*/
|
||||
class WaOptions extends Model
|
||||
{
|
||||
/**
|
||||
* 数据表名
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_options';
|
||||
|
||||
/**
|
||||
* 主键字段名
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 关闭自动时间戳(如需开启请改为 true,需确保表有 create_time/update_time 字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
/**
|
||||
* 字段严格检查(false=允许操作未定义字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $strict = false;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* WaRoles 模型
|
||||
* 表说明:管理员角色
|
||||
* 对应数据表:wa_roles
|
||||
* @property string $id id 主键(非空,主键)
|
||||
* @property string $name name 角色组(非空)
|
||||
* @property string $rules rules 权限
|
||||
* @property string $created_at created_at 创建时间(非空)
|
||||
* @property string $updated_at updated_at 更新时间(非空)
|
||||
* @property string $pid pid 父级
|
||||
*/
|
||||
class WaRoles extends Model
|
||||
{
|
||||
/**
|
||||
* 数据表名
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_roles';
|
||||
|
||||
/**
|
||||
* 主键字段名
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 关闭自动时间戳(如需开启请改为 true,需确保表有 create_time/update_time 字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
/**
|
||||
* 字段严格检查(false=允许操作未定义字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $strict = false;
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* WaRules 模型
|
||||
* 表说明:权限规则
|
||||
* 对应数据表:wa_rules
|
||||
* @property string $id id 主键(非空,主键)
|
||||
* @property string $title title 标题(非空)
|
||||
* @property string $icon icon 图标
|
||||
* @property string $key key 标识(非空)
|
||||
* @property string $pid pid 上级菜单(默认值:0)
|
||||
* @property string $created_at created_at 创建时间(非空)
|
||||
* @property string $updated_at updated_at 更新时间(非空)
|
||||
* @property string $href href url
|
||||
* @property int $type type 类型(非空,默认值:1)
|
||||
* @property int $weight weight 排序(默认值:0)
|
||||
*/
|
||||
class WaRules extends Model
|
||||
{
|
||||
/**
|
||||
* 数据表名
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_rules';
|
||||
|
||||
/**
|
||||
* 主键字段名
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 关闭自动时间戳(如需开启请改为 true,需确保表有 create_time/update_time 字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
/**
|
||||
* 字段严格检查(false=允许操作未定义字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $strict = false;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* WaUploads 模型
|
||||
* 表说明:附件
|
||||
* 对应数据表:wa_uploads
|
||||
* @property int $id id 主键(非空,主键)
|
||||
* @property string $name name 名称(非空)
|
||||
* @property string $url url 文件(非空)
|
||||
* @property int $admin_id admin_id 管理员
|
||||
* @property int $file_size file_size 文件大小(非空)
|
||||
* @property string $mime_type mime_type mime类型(非空)
|
||||
* @property int $image_width image_width 图片宽度
|
||||
* @property int $image_height image_height 图片高度
|
||||
* @property string $ext ext 扩展名(非空)
|
||||
* @property string $storage storage 存储位置(非空,默认值:local)
|
||||
* @property string $created_at created_at 上传时间
|
||||
* @property string $category category 类别
|
||||
* @property string $updated_at updated_at 更新时间
|
||||
*/
|
||||
class WaUploads extends Model
|
||||
{
|
||||
/**
|
||||
* 数据表名
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_uploads';
|
||||
|
||||
/**
|
||||
* 主键字段名
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 关闭自动时间戳(如需开启请改为 true,需确保表有 create_time/update_time 字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
/**
|
||||
* 字段严格检查(false=允许操作未定义字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $strict = false;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* WaUsers 模型
|
||||
* 表说明:用户表
|
||||
* 对应数据表:wa_users
|
||||
* @property string $id id 主键(非空,主键)
|
||||
* @property string $username username 用户名(非空)
|
||||
* @property string $nickname nickname 昵称(非空)
|
||||
* @property string $password password 密码(非空)
|
||||
* @property string $sex sex 性别(非空,默认值:1)
|
||||
* @property string $avatar avatar 头像
|
||||
* @property string $email email 邮箱
|
||||
* @property string $mobile mobile 手机
|
||||
* @property int $level level 等级(非空,默认值:0)
|
||||
* @property string $birthday birthday 生日
|
||||
* @property float $money money 余额(元)(非空,默认值:0.00)
|
||||
* @property int $score score 积分(非空,默认值:0)
|
||||
* @property string $last_time last_time 登录时间
|
||||
* @property string $last_ip last_ip 登录ip
|
||||
* @property string $join_time join_time 注册时间
|
||||
* @property string $join_ip join_ip 注册ip
|
||||
* @property string $token token token
|
||||
* @property string $created_at created_at 创建时间
|
||||
* @property string $updated_at updated_at 更新时间
|
||||
* @property int $role role 角色(非空,默认值:1)
|
||||
* @property int $status status 禁用(非空,默认值:0)
|
||||
*/
|
||||
class WaUsers extends Model
|
||||
{
|
||||
/**
|
||||
* 数据表名
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_users';
|
||||
|
||||
/**
|
||||
* 主键字段名
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 关闭自动时间戳(如需开启请改为 true,需确保表有 create_time/update_time 字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
/**
|
||||
* 字段严格检查(false=允许操作未定义字段)
|
||||
* @var bool
|
||||
*/
|
||||
protected $strict = false;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace app\zlm;
|
||||
|
||||
use app\config\Config;
|
||||
use app\utils\Logger;
|
||||
use plugin\admin\app\common\Logger;
|
||||
|
||||
/**
|
||||
* ZLMediaKit API 客户端
|
||||
|
||||
Reference in New Issue
Block a user