think-orm

This commit is contained in:
ASUS 2025-08-15 10:51:00 +08:00
parent b461dab6fb
commit dc60b38526
27 changed files with 169 additions and 49 deletions

View File

@ -75,7 +75,7 @@ class Ajax extends Backend
public function getDatabaseConnectionList(): void
{
$quickSearch = $this->request->get("quickSearch/s", '');
$connections = config('database.connections');
$connections = config('think-orm.connections');
$desensitization = [];
foreach ($connections as $key => $connection) {
$connection = TableManager::getConnectionConfig($key);

View File

@ -22,7 +22,7 @@ class Alioss extends Backend
if(empty($file)) {
$this->error('参数不能为空');
}
$commoninfo = Db::connect(config('database.search_library'));
$commoninfo = Db::connect(config('think-orm.search_library'));
$endpoint = $commoninfo->name('common_info')->where(['type' => 68])->find()['value'];
$accessKeyId = $commoninfo->name('common_info')->where(['type' => 69])->find()['value'];
$secretAccessKey = $commoninfo->name('common_info')->where(['type' => 70])->find()['value'];
@ -54,7 +54,7 @@ class Alioss extends Backend
'Content-Encoding' => 'binary',
];
$res = $ossClient->putObject($bucket, $object, $content, $options);
Log::write('上传文件结果' . json_encode($res));
Log::info('上传文件结果' . json_encode($res));
if(!empty($res['info'])) {
return $this->ApiDataReturn(['data' => $befor_url . '/' . $object, 'msg' => 'success', 'code' => 0]);
}else {
@ -68,7 +68,7 @@ class Alioss extends Backend
// 获取阿里云oss存储相关配置
public function getCredentials()
{
$commoninfo = Db::connect(config('database.search_library'));
$commoninfo = Db::connect(config('think-orm.search_library'));
$configItems = $commoninfo->name('common_info')->whereIn('type', [66, 67, 69, 70])
->column('value', 'type');
AlibabaCloud::accessKeyClient($configItems[69], $configItems[70])

View File

@ -38,7 +38,7 @@ class Common extends Backend
if(empty($get['num'])) {
$this->error('type 不能为空');
}
$data = convertToCamelCase(Db::connect(config('database.search_library'))->name('common_info')->where('type', $get['num'])->find());
$data = convertToCamelCase(Db::connect(config('think-orm.search_library'))->name('common_info')->where('type', $get['num'])->find());
$this->success('ok', $data);
}
}

View File

@ -139,7 +139,7 @@ class Sys extends Backend
->where('t.title', '签到奖励')
->group('t.by_user_id');
})->count();
$v_db_name = config('database.connections.' . get_slave_connect_name() . '.database');
$v_db_name = config('think-orm.connections.' . get_slave_connect_name() . '.database');
$result = DatabaseRoute::paginateAllDbBySqlAutoCount(function () use($userId, $v_db_name) {
return "select
t1.by_user_id as userId,
@ -181,7 +181,7 @@ class Sys extends Backend
{
$params = $this->request->get();
$keywords = $params['keywords'];
$v_db_name = config('database.connections.' . get_slave_connect_name() . '.database');
$v_db_name = config('think-orm.connections.' . get_slave_connect_name() . '.database');
$result = DatabaseRoute::paginateAllDb('tb_user', function ($query) use($keywords, $v_db_name) {
return $query->alias('t1')
->field([
@ -219,7 +219,7 @@ class Sys extends Backend
from v_disc_spinning_record t1
where t1.user_id = ".$userId);
$count = $count[0]['count'];
$v_db_name = config('database.connections.' . get_slave_connect_name() . '.database');
$v_db_name = config('think-orm.connections.' . get_slave_connect_name() . '.database');
$result = DatabaseRoute::paginateAllDbBySqlAutoCount(function () use($userId, $v_db_name) {
return "select
t1.id,

View File

@ -486,7 +486,7 @@ class Crud extends Backend
{
$table = $this->request->get('table');
$connection = $this->request->get('connection');
$connection = $connection ?: config('database.default');
$connection = $connection ?: config('think-orm.default');
$crudLog = Db::name('crud_log')
->where('table_name', $table)

View File

@ -283,7 +283,7 @@ class Helper
return $data['id'];
}
$connection = $data['table']['databaseConnection'] ?: config('database.default');
$connection = $data['table']['databaseConnection'] ?: config('think-orm.default');
$log = CrudLog::create([
'table_name' => $data['table']['name'],
'comment' => $data['table']['comment'],

View File

@ -139,7 +139,7 @@ class AdminLog extends Model
$title = $title ?: $this->title;
if (!$title) {
$slave_db = Db::connect(config('database.search_library'));
$slave_db = Db::connect(config('think-orm.search_library'));
$admin_rule = $slave_db->name('sys_menu');
$controllerTitle = $admin_rule->where('url', $controller)->value('name');
$title = $admin_rule->where('url', $path)->value('name');
@ -148,7 +148,7 @@ class AdminLog extends Model
}
// 主库写入
$master_db = Db::connect(config('database.z_library'));
$master_db = Db::connect(config('think-orm.z_library'));
$master_db->name('sys_log')->insert([
'username' => $username,
'method' => substr(request()->url(), 0, 1500),

View File

@ -5,7 +5,7 @@ namespace app\admin\model;
use app\common\library\DatabaseRoute;
use ba\Exception;
use think\facade\Db;
use think\facade\Log;
use support\Log;
use think\Model;
/**
@ -69,7 +69,7 @@ class DiscSpinning extends Model
->value('value');
// 校验是否超过限制
if ($drawCount > $maxDraws) {
Log::write('超过限制' . $receive['id'] . '/' . $drawCount);
Log::info('超过限制' . $receive['id'] . '/' . $drawCount);
return false; // 超过次数限制,终止处理
}
@ -79,7 +79,7 @@ class DiscSpinning extends Model
$record = $db->name('disc_spinning_record')->find($recordId);
// 校验记录是否已处理
if (!empty($record['target_id'])) {
Log::write('记录已处理无需继续处理' . $record['id'] . '/' . $record['target_id']);
Log::info('记录已处理无需继续处理' . $record['id'] . '/' . $record['target_id']);
return false; // 已处理,终止处理
}
self::receiveAsync($record);
@ -94,7 +94,7 @@ class DiscSpinning extends Model
public static function receiveAsync($receive)
{
Log::write('正式补偿' . $receive['id']);
Log::info('正式补偿' . $receive['id']);
// 校验奖励类型必须为2
if (($receive['type'] ?? 0) != 2) {
Log::info("非现金转盘奖励type={$receive['type']}");
@ -135,7 +135,7 @@ class DiscSpinning extends Model
'target' => "2",
'target_id' => $detailId
]);
Log::write('更新奖励' . $a);
Log::info('更新奖励' . $a);
Cash::updateAmount(1, $receive['user_id'], $receive['number'], $db);
// 提交事务
$db->commit();

View File

@ -58,7 +58,7 @@ class AlibabaSms extends Model
}
// 如有需要,请打印 error
Utils::assertAsString($error->message);
Log::write('短信发送错误--' . $error->message);
Log::info('短信发送错误--' . $error->message);
return false;
}
}

View File

@ -13,7 +13,7 @@ class Announcement extends Model
public static function list($type)
{
$res_data = Db::connect(config('database.search_library'))->name('announcement')->where(['type' => $type, 'state' => 1])->select()->toArray();
$res_data = Db::connect(config('think-orm.search_library'))->name('announcement')->where(['type' => $type, 'state' => 1])->select()->toArray();
$res_data = convertToCamelCase($res_data);
return returnSuccessData($res_data);
}

View File

@ -402,7 +402,7 @@ class Course extends Model
];
return returnSuccessData($map);
} catch (\Exception $e) {
Log::write("请求剧集异常: " . $e->getMessage() . '/' . $e->getLine() . '/');
Log::info("请求剧集异常: " . $e->getMessage() . '/' . $e->getLine() . '/');
return returnErrorData($e->getMessage());
}
}

View File

@ -28,7 +28,7 @@ class DiscSpinningRecord
return 0;
}
$db_name = \think\facade\Db::connect(config('database.search_library'));
$db_name = \think\facade\Db::connect(config('think-orm.search_library'));
$task = $db_name->name('task_center')->where(['type' => 2]);
// 构建查询条件
$sourceType = null;

View File

@ -4,9 +4,9 @@ namespace app\api\model;
use app\common\library\DatabaseRoute;
use app\common\model\Common;
use ba\Random;
use extend\ba\Random;
use think\facade\Db;
use think\facade\Log;
use support\Log;
use think\Model;
class Invite extends Model
@ -139,20 +139,20 @@ class Invite extends Model
}
// 下级user_id集合
$junior_user_list = extract_user_ids($junior_list);
Log::write('下级user_id集合'. json_encode($junior_user_list));
Log::info('下级user_id集合'. json_encode($junior_user_list));
$ach_select = DatabaseRoute::getDb('invite_achievement', $user['user_id'])
->where('count', '>=', 3)
->where(['user_id' => $user['user_id']])
->whereIn('target_user_id', $junior_user_list)
->select()
->toArray();
Log::write('签到集合'. json_encode($ach_select));
Log::info('签到集合'. json_encode($ach_select));
foreach ($ach_select as $k => &$v) {
$v['user_id'] = (string) $v['user_id'];
}
// 下级user_id集合
$ach_user_list = extract_target_user_ids($ach_select);
Log::write('签到user_id集合---'. json_encode($ach_user_list));
Log::info('签到user_id集合---'. json_encode($ach_user_list));
$commonInfoCount = CommonInfo::where(['type' => 913])->find()->value;
$date = date('Y-m-d 00:00:00');

View File

@ -20,7 +20,7 @@ class MessageInfo extends Model
return returnErrorData('参数不完整');
}
$page = ($data['page'] - 1) * $data['limit'];
$db = Db::connect(config('database.search_library'))->name('message_info');
$db = Db::connect(config('think-orm.search_library'))->name('message_info');
if(!empty($data['user_id'])) {
$where = [
'state' => $data['state'],

View File

@ -18,7 +18,7 @@ class TaskCenterRecord extends Model
public static function selectTaskCenter($user_id, $target_user_id)
{
// 查找任务
$db = Db::connect(config('database.search_library'));
$db = Db::connect(config('think-orm.search_library'));
$rask_arr = $db->name('task_center')->where(['shows' => 1])->order('type', 'asc')->order('sort', 'asc')->select()->toArray();
$data = [];
$day_date = date('Y-m-d 00:00:00');

View File

@ -3,11 +3,10 @@
namespace app\api\model;
use app\common\library\DatabaseRoute;
use ba\Random;
use think\cache\driver\Redis;
use think\facade\Cache;
use support\Redis;
use support\think\Cache;
use think\facade\Db;
use think\facade\Log;
use support\Log;
use think\Model;
class UniAdCallbackRecord extends Model
@ -32,14 +31,14 @@ class UniAdCallbackRecord extends Model
{
$respData = [];
$db = Db::connect(config('database.search_library'));
$db = Db::connect(config('think-orm.search_library'));
// 检查是否重复回调
$record = $db->name('uni_ad_callback_record')
->where('trans_id', $callBackDTO['trans_id'])
->find();
if ($record) {
Log::write("回调重复, trans_id: {$record['trans_id']}");
Log::info("回调重复, trans_id: {$record['trans_id']}");
$respData['isValid'] = false;
return $respData;
}
@ -61,7 +60,7 @@ class UniAdCallbackRecord extends Model
$flag = self::validateSign($security, $callBackDTO['trans_id'], $callBackDTO['sign']);
if (!$flag) {
$recordData['err_msg'] = "签名验证失败";
Log::write(json_encode($recordData));
Log::info(json_encode($recordData));
Db::name('uni_ad_callback_record')->insert($recordData);
$respData['isValid'] = false;
return $respData;

View File

@ -20,7 +20,7 @@ class UserPrizeExchange extends Model
$beginDate = $params['beginDate'] ?? '';
$endDate = $params['endDate'] ?? '';
$db = Db::connect(config('database.search_library'));
$db = Db::connect(config('think-orm.search_library'));
// 构建查询条件
$query = $db->name('user_prize_exchange');

View File

@ -58,7 +58,7 @@ class SpinningTask3 extends Command
}
}
$output->writeln("大转盘到账补偿机制结束");
Log::write("大转盘到账补偿机制结束");
Log::info("大转盘到账补偿机制结束");
$output->writeln('Hello SpinningTask3');
return self::SUCCESS;
}

View File

@ -22,9 +22,9 @@ class SysUser extends BaseModel
public static function GetByusername($username)
{
// 全表扫描username
$dbmap = config('database.db_map');
$dbmap = config('think-orm.db_map');
foreach ($dbmap as $dbname) {
if(!in_array($dbname, config('database.unset_db_map'))) {
if(!in_array($dbname, config('think-orm.unset_db_map'))) {
$connect = Db::connect($dbname);
$data = $connect->name('sys_user')->where(['username' => $username])->find();
if($data) {

View File

@ -21,7 +21,7 @@ class AliossController extends Frontend
if(empty($file)) {
$this->error('参数不能为空');
}
$commoninfo = Db::connect(config('database.search_library'));
$commoninfo = Db::connect(config('think-orm.search_library'));
$endpoint = $commoninfo->name('common_info')->where(['type' => 68])->find()['value'];
$accessKeyId = $commoninfo->name('common_info')->where(['type' => 69])->find()['value'];
$secretAccessKey = $commoninfo->name('common_info')->where(['type' => 70])->find()['value'];
@ -53,7 +53,7 @@ class AliossController extends Frontend
'Content-Encoding' => 'binary',
];
$res = $ossClient->putObject($bucket, $object, $content, $options);
Log::write('上传文件结果' . json_encode($res));
Log::info('上传文件结果' . json_encode($res));
if(!empty($res['info'])) {
return $this->ApiDataReturn(['data' => $befor_url . '/' . $object, 'msg' => 'success', 'code' => 0]);
}else {

View File

@ -288,7 +288,7 @@ class DiscSpinningController extends Frontend
}
$page = 1;
$limit = 20;
$db = Db::connect(config('database.search_library'));
$db = Db::connect(config('think-orm.search_library'));
$list = $db->name('disc_spinning')
->where(['disc_type' => $get['source']]);
$count = $list->count();

View File

@ -28,7 +28,7 @@ class UniCallBackController extends Frontend
'extra' => $this->request->param('extra', '') // 可选参数,默认空字符串
];
// 记录日志
Log::write("接收到uni-ad广告完播回调回调信息: " . json_encode($params));
Log::info("接收到uni-ad广告完播回调回调信息: " . json_encode($params));
// 调用服务处理回调
$result = UniAdCallbackRecord::adCallBack($params);
// 返回成功响应

View File

@ -1322,14 +1322,14 @@ function shiro_simple_hash_hex_salt(string $algorithm, string $source, ?string $
if(!function_exists('get_master_connect_name')) {
function get_master_connect_name()
{
return config('database.z_library');
return config('think-orm.z_library');
}
}
if(!function_exists('get_slave_connect_name')) {
function get_slave_connect_name()
{
return config('database.search_library');
return config('think-orm.search_library');
}
}

View File

@ -10,7 +10,7 @@ class DiscCompensateJob extends BaseQueue implements Consumer
{
public function run( $data) {
Log::write('准备处理DiscCompensateJob' . json_encode($data, JSON_UNESCAPED_UNICODE));
Log::info('准备处理DiscCompensateJob' . json_encode($data, JSON_UNESCAPED_UNICODE));
DiscSpinning::receive1($data);
}
}

View File

@ -35,7 +35,7 @@
"webman/redis": "^2.1",
"illuminate/events": "^11.45",
"webman/redis-queue": "^2.1",
"webman/console": "^2.1"
"webman/console": "^2.1.0"
},
"suggest": {
"ext-event": "For better performance. "

123
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b513a600f1b1dbb2119a8038831ab9e0",
"content-hash": "3b0b855bb81b001e0c6ede85576addf4",
"packages": [
{
"name": "carbonphp/carbon-doctrine-types",
@ -3115,6 +3115,43 @@
},
"time": "2025-02-14T11:36:24+00:00"
},
{
"name": "webman/redis-queue",
"version": "v1.3.1",
"source": {
"type": "git",
"url": "https://github.com/webman-php/redis-queue.git",
"reference": "6fd491b19acb006d60931724aa2577a046ccb612"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webman-php/redis-queue/zipball/6fd491b19acb006d60931724aa2577a046ccb612",
"reference": "6fd491b19acb006d60931724aa2577a046ccb612",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"workerman/redis-queue": "^1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Webman\\RedisQueue\\": "./src"
}
},
"notification-url": "https://packagist.org/downloads/",
"description": "Redis message queue plugin for webman.",
"support": {
"issues": "https://github.com/webman-php/redis-queue/issues",
"source": "https://github.com/webman-php/redis-queue/tree/v1.3.1"
},
"time": "2024-02-28T07:21:52+00:00"
},
{
"name": "webman/think-cache",
"version": "v2.1.1",
@ -3245,6 +3282,90 @@
},
"time": "2025-02-17T03:34:21+00:00"
},
{
"name": "workerman/redis",
"version": "v2.0.4",
"source": {
"type": "git",
"url": "https://github.com/walkor/redis.git",
"reference": "82b398c5bdd5d683a3458aaf645b159b7b39b84e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/walkor/redis/zipball/82b398c5bdd5d683a3458aaf645b159b7b39b84e",
"reference": "82b398c5bdd5d683a3458aaf645b159b7b39b84e",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=7",
"workerman/workerman": "^4.1.0||^5.0.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Workerman\\Redis\\": "./src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"homepage": "http://www.workerman.net",
"support": {
"issues": "https://github.com/walkor/redis/issues",
"source": "https://github.com/walkor/redis/tree/v2.0.4"
},
"time": "2025-04-05T07:45:12+00:00"
},
{
"name": "workerman/redis-queue",
"version": "v1.2.1",
"source": {
"type": "git",
"url": "https://github.com/walkor/redis-queue.git",
"reference": "75dbf7ed2ea228c45dc0df82c0fea35879b715d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/walkor/redis-queue/zipball/75dbf7ed2ea228c45dc0df82c0fea35879b715d0",
"reference": "75dbf7ed2ea228c45dc0df82c0fea35879b715d0",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=7.0",
"workerman/redis": "^1.0||^2.0",
"workerman/workerman": ">=4.0.20"
},
"type": "library",
"autoload": {
"psr-4": {
"Workerman\\RedisQueue\\": "./src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Message queue system written in PHP based on workerman and backed by Redis.",
"homepage": "http://www.workerman.net",
"support": {
"issues": "https://github.com/walkor/redis-queue/issues",
"source": "https://github.com/walkor/redis-queue/tree/v1.2.1"
},
"time": "2025-01-02T09:21:45+00:00"
},
{
"name": "workerman/webman-framework",
"version": "v2.1.2",

View File

@ -36,7 +36,7 @@ class Auth
public function __construct(array $config = [])
{
$this->config = array_merge($this->config, $config);
$this->db = Db::connect(config('database.search_library'));
$this->db = Db::connect(config('think-orm.search_library'));
}
/**