This commit is contained in:
2026-03-06 02:27:52 +08:00
parent f598cc8157
commit 70c4966aad
80 changed files with 796 additions and 1191 deletions
+8 -8
View File
@@ -2,14 +2,14 @@
debug = true debug = true
[server] [server]
port=8585 port=8585
domain=www.wenjb.com domain=www.shun777.com
https=false https=false
[mysql] [mysql]
host =127.0.0.1 host =127.0.0.1
port = 3307 port = 3306
database = questionnaire database = imadmin
username = questionnaire username = imadmin
password = ba9b492bda93ad4d password = ejkFmaAXAHXyNXd2
charset = utf8mb4 charset = utf8mb4
collation = utf8mb4_general_ci collation = utf8mb4_general_ci
prefix = wa_ prefix = wa_
@@ -18,13 +18,13 @@ engine =
[mongodb] [mongodb]
host = 127.0.0.1 host = 127.0.0.1
port = 27017 port = 27017
database = questionnaire_m database = imadmin_mongo
username = commie username = root
password = n1e5a6s6m7 password = n1e5a6s6m7
[redis] [redis]
host = 127.0.0.1 host = 127.0.0.1
port = 6379 port = 6379
database = 10 database = 0
password = n1e5a6s6m7 password = n1e5a6s6m7
prefix = q_ prefix = q_
-1
View File
@@ -2,7 +2,6 @@
namespace app\api\controller; namespace app\api\controller;
use support\Request; use support\Request;
use taoser\facade\Validate;
use app\model\Address as AddressModel; use app\model\Address as AddressModel;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
-1
View File
@@ -3,7 +3,6 @@ namespace app\api\controller;
use app\model\Archives as ArchivesModel; use app\model\Archives as ArchivesModel;
use support\Request; use support\Request;
use taoser\facade\Validate;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
/** /**
+2 -2
View File
@@ -5,7 +5,7 @@ use support\Response;
use Shopwwi\WebmanFilesystem\FilesystemFactory; use Shopwwi\WebmanFilesystem\FilesystemFactory;
use Shopwwi\WebmanFilesystem\Facade\Storage; use Shopwwi\WebmanFilesystem\Facade\Storage;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
use taoser\facade\Validate; use Tinywan\Validate\Facade\Validate;
/** /**
* 基础控制器 * 基础控制器
* @Apidoc\NotParse() * @Apidoc\NotParse()
@@ -40,7 +40,7 @@ class BaseController
*/ */
protected function json(int $code, string $msg = 'ok', array|object|null $data = []): Response protected function json(int $code, string $msg = 'ok', array|object|null $data = []): Response
{ {
return json(['code' => $code, 'data' => $data, 'msg' => $msg]); return json(['code' => $code, 'data' => $data, 'msg' => __($msg)]);
} }
protected function success(string $msg = '成功', array|object|null $data = []): Response protected function success(string $msg = '成功', array|object|null $data = []): Response
-1
View File
@@ -5,7 +5,6 @@ use app\model\Card as CardModel;
use app\model\Cdkey as CdkeyModel; use app\model\Cdkey as CdkeyModel;
use app\model\User as UserModel; use app\model\User as UserModel;
use support\think\Db; use support\think\Db;
use taoser\facade\Validate;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
/** /**
+2 -3
View File
@@ -1,7 +1,7 @@
<?php <?php
namespace app\api\controller; namespace app\api\controller;
use taoser\facade\Validate; use Tinywan\Validate\Facade\Validate;
use app\model\User as UserModel; use app\model\User as UserModel;
use support\Request; use support\Request;
@@ -29,7 +29,6 @@ class CommonController extends BaseController{
*/ */
public $noNeedLogin = ['*']; public $noNeedLogin = ['*'];
/** /**
* 加载初始化 * 加载初始化
* *
@@ -37,7 +36,7 @@ class CommonController extends BaseController{
*/ */
public function init(Request $request) public function init(Request $request)
{ {
$lang = input('lang','en-US'); $lang = $request->header('lang','zh-Hans');
locale( $lang); locale( $lang);
$config = Config('site'); $config = Config('site');
$disallowFields = [ $disallowFields = [
-1
View File
@@ -5,7 +5,6 @@ use app\model\UserRemark as UserRemarkModel;
use app\model\GroupRemark as GroupRemarkModel; use app\model\GroupRemark as GroupRemarkModel;
use support\Request; use support\Request;
use support\Response; use support\Response;
use taoser\facade\Validate;
use support\think\Db; use support\think\Db;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
/** /**
@@ -10,7 +10,6 @@ use app\model\FriendCircleLike as FriendCircleLikeModel;
use app\model\FriendCircleComment as FriendCircleCommentModel; use app\model\FriendCircleComment as FriendCircleCommentModel;
use support\Request; use support\Request;
use support\Response; use support\Response;
use taoser\facade\Validate;
use support\think\Db; use support\think\Db;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
-1
View File
@@ -5,7 +5,6 @@ use app\model\UserRemark as UserRemarkModel;
use app\model\GroupRemark as GroupRemarkModel; use app\model\GroupRemark as GroupRemarkModel;
use support\Request; use support\Request;
use support\Response; use support\Response;
use taoser\facade\Validate;
use support\think\Db; use support\think\Db;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
/** /**
-1
View File
@@ -5,7 +5,6 @@ use app\model\Gift as GiftModel;
use app\model\GiftOrder as GiftOrderModel; use app\model\GiftOrder as GiftOrderModel;
use app\model\User as UserModel; use app\model\User as UserModel;
use support\think\Db; use support\think\Db;
use taoser\facade\Validate;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
/** /**
-1
View File
@@ -3,7 +3,6 @@ namespace app\api\controller;
use app\model\User as UserModel; use app\model\User as UserModel;
use support\Request; use support\Request;
use support\Response; use support\Response;
use taoser\facade\Validate;
use support\think\Db; use support\think\Db;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
-1
View File
@@ -4,7 +4,6 @@ namespace app\api\controller;
use app\model\Product as ProductModel; use app\model\Product as ProductModel;
use app\model\ProductOrder as ProductOrderModel; use app\model\ProductOrder as ProductOrderModel;
use support\think\Db; use support\think\Db;
use taoser\facade\Validate;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
/** /**
@@ -5,7 +5,6 @@ use app\model\ProductOrder as ProductOrderModel;
use app\model\Product as ProductModel; use app\model\Product as ProductModel;
use app\model\User as UserModel; use app\model\User as UserModel;
use support\think\Db; use support\think\Db;
use taoser\facade\Validate;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
/** /**
@@ -3,7 +3,6 @@ namespace app\api\controller;
use support\Request; use support\Request;
use support\think\Db; use support\think\Db;
use taoser\facade\Validate;
use app\model\Recharge as RechargeModel; use app\model\Recharge as RechargeModel;
use app\model\User as UserModel; use app\model\User as UserModel;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
-1
View File
@@ -6,7 +6,6 @@ use app\model\User as UserModel;
use app\model\Realname as RealnameModel; use app\model\Realname as RealnameModel;
use support\Request; use support\Request;
use support\Response; use support\Response;
use taoser\facade\Validate;
use support\think\Db; use support\think\Db;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
-1
View File
@@ -3,7 +3,6 @@ namespace app\api\controller;
use app\model\User as UserModel; use app\model\User as UserModel;
use support\Request; use support\Request;
use app\model\Cdkey as CdkeyModel; use app\model\Cdkey as CdkeyModel;
use taoser\facade\Validate;
use support\think\Db; use support\think\Db;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
@@ -6,7 +6,6 @@ use app\model\User as UserModel;
use app\model\Withdrawl as WithdrawlModel; use app\model\Withdrawl as WithdrawlModel;
use support\Request; use support\Request;
use support\think\Db; use support\think\Db;
use taoser\facade\Validate;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
/** /**
+1 -1
View File
@@ -29,7 +29,7 @@ class Auth implements MiddlewareInterface
$response = response('',204,$headers); $response = response('',204,$headers);
return $response; return $response;
} }
$lang = $request->input('lang','zh-Hans'); $lang = $request->header('lang','zh-Hans');
locale($lang); locale($lang);
if ($request->controller) { if ($request->controller) {
$request->client = $request->header('client',"web"); $request->client = $request->header('client',"web");
+662
View File
@@ -14,15 +14,677 @@ class OpenIm extends Command
protected static $defaultName = 'openim'; protected static $defaultName = 'openim';
protected static $defaultDescription = 'OpenIm'; protected static $defaultDescription = 'OpenIm';
public $sdk= null; public $sdk= null;
function fixurl(){
$sdk = $this->getSdk();
$search = 'http://103.39.222.184:10002/object/';
$replace = 'https://s1.shun777.com/imapi/object/';
$users = Db::name('User')
->whereLike('avatar','%'.$search)
->field('avatar,id,userID')
->select();
foreach($users as $k=>$user){
$avatar = str_replace($search,$replace,$user['avatar']);
Db::name('User')
->where('id',$user['id'])
->update(['avatar'=>$avatar]);
$sdata = [
'faceURL' => $avatar
];
$sdk->user->updateUserInfo($user['userID'],$sdata);
}
$model = new \app\model\Openim\Group();
$list = $model->whereLike('face_url', '%'.$search)->select();
foreach($list as $k=>$group){
$avatar = str_replace($search,$replace,$group['face_url']);
$model->where('id',$group['id'])->update(['face_url'=>$avatar]);
}
$model = new \app\model\Openim\Msg();
$total = $model->count('id');
$count = 0;
for($i=0;$i<$total;$i+=1000){
$list = $model->limit($i,1000)->select();
foreach($list as $item){
if(!empty($item['msgs']) && is_array($item['msgs'])){
$msgs = [];
foreach($item['msgs'] as $key => $msg){
if(is_null($msg['msg'])){
continue;
}
$msgs[] = $msg;
}
$item->msgs = $msgs;
}
$item->save();
$count++;
}
}
return 0;
}
function convertUserID(InputInterface $input, OutputInterface $output): int
{
$userID = $input->getOption('userID');
$this->_convertUserID($userID,$output);
return 0;
}
function _convertUserID($userID,$output): int
{
$oldUserID = \support\Encrypt::userIDEncode($userID);
$newUserID = \support\Encrypt::intEncode($userID);
cp("开始转换用户ID: {$userID} -> {$oldUserID} -> {$newUserID}");
// $this->convertBlackTable($oldUserID, $newUserID, $output);
// $this->convertConversationTable($oldUserID, $newUserID, $output);
// $this->convertVersionTables($oldUserID, $newUserID, $output);
// $this->convertFriendTable($oldUserID, $newUserID, $output);
// $this->convertFriendRequestTable($oldUserID, $newUserID, $output);
// $this->convertGroupTable($oldUserID, $newUserID, $output);
// $this->convertGroupMemberTable($oldUserID, $newUserID, $output);
// $this->convertGroupRequestTable($oldUserID, $newUserID, $output);
// $this->convertMsgTable($oldUserID, $newUserID, $output);
// $this->convertSeqTable($oldUserID, $newUserID, $output);
// $this->convertSeqUserTable($oldUserID, $newUserID, $output);
// $this->convertUserTable($oldUserID, $newUserID, $output);
for ($i=100006;$i<102028;$i++){
$newUserID = \support\Encrypt::intEncode($i);
Db::name('User')->where('id',$i)->update(['userID'=>$newUserID]);
}
cp("用户ID:{$userID} -> {$newUserID} 转换完成");
return 0;
}
protected function convertFriendTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\Friend();
$list = $model->select();
$count = 0;
foreach($list as $item){
$savedata = [];
if($item['owner_user_id']){
$savedata['owner_user_id'] = $this->turnID($item['owner_user_id']);
}
if($item['friend_user_id']){
$savedata['friend_user_id'] = $this->turnID($item['friend_user_id']);
}
if($item['operator_user_id']){
$savedata['operator_user_id'] = $this->turnID($item['operator_user_id']);
}
if(!empty($savedata)){
$model->where('id',$item['id'])->update($savedata);
}
$count++;
}
$output->writeln("Friend 表转换完成,共 {$count} 条记录");
}
protected function convertFriendRequestTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\FriendRequest();
$list = $model->select();
$count = 0;
foreach($list as $item){
$savedata = [];
if($item['from_user_id']){
$savedata['from_user_id'] = $this->turnID($item['from_user_id']);
}
if($item['to_user_id']){
$savedata['to_user_id'] = $this->turnID($item['to_user_id']);
}
if($item['handler_user_id']){
$savedata['handler_user_id'] = $this->turnID($item['handler_user_id']);
}
if(!empty($savedata)){
$model->where('id',$item['id'])->update($savedata);
}
$count++;
}
$output->writeln("FriendRequest 表转换完成,共 {$count} 条记录");
}
protected function convertGroupTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\Group();
$list = $model->select();
$count = 0;
foreach($list as $item){
$savedata = [];
if($item['creator_user_id']){
$savedata['creator_user_id'] = $this->turnID($item['creator_user_id']);
}
if($item['notification_user_id']){
$savedata['notification_user_id'] = $this->turnID($item['notification_user_id']);
}
if(!empty($savedata)){
$model->where('id',$item['id'])->update($savedata);
}
$count++;
}
$output->writeln("Group 表转换完成,共 {$count} 条记录");
}
protected function convertGroupMemberTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\GroupMember();
$list = $model->select();
$count = 0;
foreach($list as $item){
$savedata = [];
if($item['user_id']){
$savedata['user_id'] = $this->turnID($item['user_id']);
}
if($item['inviter_user_id']){
$savedata['inviter_user_id'] = $this->turnID($item['inviter_user_id']);
}
if($item['operator_user_id']){
$savedata['operator_user_id'] = $this->turnID($item['operator_user_id']);
}
if(!empty($savedata)){
$model->where('id',$item['id'])->update($savedata);
}
$count++;
}
$output->writeln("GroupMember 表转换完成,共 {$count} 条记录");
}
protected function convertBlackTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\Black();
$list = $model->select();
$count = 0;
foreach($list as $item){
$savedata = [];
if($item['block_user_id']){
$savedata['block_user_id'] = $this->turnID($item['block_user_id']);
}
if($item['owner_user_id']){
$savedata['owner_user_id'] = $this->turnID($item['owner_user_id']);
}
if($item['operator_user_id']){
$savedata['operator_user_id'] = $this->turnID($item['operator_user_id']);
}
if(!empty($savedata)){
$model->where('id',$item['id'])->update($savedata);
}
$count++;
}
$output->writeln("Black 表转换完成,共 {$count} 条记录");
}
protected function convertConversationTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\Conversation();
$list = $model->select();
$count = 0;
foreach($list as $item){
$savedata = [];
if($item['user_id']){
$savedata['user_id'] = $this->turnID($item['user_id']);
}
if($item['owner_user_id']){
$savedata['owner_user_id'] = $this->turnID($item['owner_user_id']);
}
if($item['conversation_id']){
$savedata['conversation_id'] = $this->handlerConversationID($item['conversation_id']);
}
$model->where('id',$item['id'])->update($savedata);
//$item->save();
$count++;
}
$output->writeln("Conversation 表转换完成,共 {$count} 条记录");
}
protected function convertUserTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\User();
$list = $model->select();
foreach($list as $k=>$user){
$model->where('id',$user['id'])->update([
'user_id' => $this->turnID($user['user_id'])
]);
}
}
protected function convertGroupRequestTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\GroupRequest();
$list = $model->select();
$count = 0;
foreach($list as $item){
$savedata = [];
if($item['user_id']){
$savedata['user_id'] = $this->turnID($item['user_id']);
}
if($item['handle_user_id']){
$savedata['handle_user_id'] = $this->turnID($item['handle_user_id']);
}
if($item['inviter_user_id']){
$savedata['inviter_user_id'] = $this->turnID($item['inviter_user_id']);
}
$model->where('id',$item['id'])->update($savedata);
$count++;
}
$output->writeln("GroupRequest 表转换完成,共 {$count} 条记录");
}
protected function convertSeqTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\Seq();
$list = $model->select();
$count = 0;
foreach($list as $item){
$model->where('id',$item['id'])->update([
'conversation_id' => $this->handlerConversationID($item['conversation_id'])
]);
$count++;
}
$output->writeln("Seq 表转换完成,共 {$count} 条记录");
}
protected function convertSeqUserTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\SeqUser();
$list = $model->select();
//cp($model->getLastSql());
$count = 0;
foreach($list as $item){
$model->where('id',$item['id'])->update([
'user_id' => $this->turnID($item->user_id),
'conversation_id' => $this->handlerConversationID($item['conversation_id'])
]);
$count++;
}
if($count){
$output->writeln("SeqUser 表转换完成,共 {$count} 条记录");
}
}
protected function convertVersionTables($oldUserID, $newUserID, $output){
$this->convertConversationVersionTable($oldUserID, $newUserID, $output);
$this->convertFriendVersionTable($oldUserID, $newUserID, $output);
$this->convertGroupMemberVersionTable($oldUserID, $newUserID, $output);
$this->convertGroupJoinVersionTable($oldUserID, $newUserID, $output);
}
protected function convertConversationVersionTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\ConversationVersion();
$list = $model->select();
$count = 0;
foreach($list as $item){
$savedata = [];
$savedata['d_id'] = $this->turnID($item['d_id']);
if(!empty($item['logs']) && is_array($item['logs'])){
$logs = $item['logs'];
foreach($logs as $key => $log){
if(isset($log['e_id'])){
$logs[$key]['e_id'] = $this->handlerConversationID($log['e_id']);
}
}
$savedata['logs'] = $logs;
}
$model->where('id',$item['id'])->update($savedata);
$count++;
}
$output->writeln("ConversationVersion 表转换完成,共 {$count} 条记录");
}
protected function convertFriendVersionTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\FriendVersion();
$list = $model->select();
$count = 0;
foreach($list as $item){
$savedata = [];
$savedata['d_id'] = $this->turnID($item['d_id']);
if(!empty($item['logs']) && is_array($item['logs'])){
$logs = $item['logs'];
foreach($logs as $key => $log){
if(isset($log['e_id'])){
$logs[$key]['e_id'] = $this->handlerConversationID($log['e_id']);
}
}
$savedata['logs'] = $logs;
}
$model->where('id',$item['id'])->update($savedata);
$count++;
}
$output->writeln("FriendVersion 表转换完成,共 {$count} 条记录");
}
protected function convertGroupMemberVersionTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\GroupMemberVersion();
$list = $model->select();
$count = 0;
foreach($list as $item){
$savedata = [];
$savedata['d_id'] = $this->turnID($item['d_id']);
if(!empty($item['logs']) && is_array($item['logs'])){
$logs = $item['logs'];
foreach($logs as $key => $log){
if(isset($log['e_id'])){
$logs[$key]['e_id'] = $this->handlerConversationID($log['e_id']);
}
}
$savedata['logs'] = $logs;
}
$model->where('id',$item['id'])->update($savedata);
$count++;
}
$output->writeln("GroupMemberVersion 表转换完成,共 {$count} 条记录");
}
protected function convertGroupJoinVersionTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\GroupJoinVersion();
$list = $model->select();
$count = 0;
foreach($list as $item){
$savedata = [];
$savedata['d_id'] = $this->turnID($item['d_id']);
if(!empty($item['logs']) && is_array($item['logs'])){
$logs = $item['logs'];
foreach($logs as $key => $log){
if(isset($log['e_id'])){
$logs[$key]['e_id'] = $this->handlerConversationID($log['e_id']);
}
}
$savedata['logs'] = $logs;
}
$model->where('id',$item['id'])->update($savedata);
$count++;
}
$output->writeln("GroupJoinVersion 表转换完成,共 {$count} 条记录");
}
function turnID($id){
if($id == 'official_team' || $id == 'officialteam'){
return 'SystemOfficialTeam';
}
if($id == 'group_bot'){
return 'SystemGroupBot';
}
if($id == 'imAdmin'){
return 'SystemImAdmin';
}
if($id == 'system'){
return 'SystemAccount';
}
try{
return \support\Encrypt::intEncode(\support\Encrypt::userIDDecode($id));
}catch(\Exception $e){
return $id;
}
}
protected function convertMsgTable($oldUserID, $newUserID, $output){
$model = new \app\model\Openim\Msg();
$total = $model->count('id');
$count = 0;
for($i=0;$i<$total;$i+=1000){
$list = $model->limit($i,1000)->select();
foreach($list as $item){
$savedata = [];
$doc_id = explode(':',$item['doc_id']);
$doc_id[0] = $this->handlerConversationID($doc_id[0]);
$savedata['doc_id'] = $doc_id[0].':'.$doc_id[1];
foreach($item['msgs'] as $key => $msg){
if(isset($msg['msg']['send_id'])){
$savedata['msgs'][$key]['msg']['send_id'] = $this->turnID($msg['msg']['send_id']);
}
if(isset($msg['msg']['recv_id'])){
$savedata['msgs'][$key]['msg']['recv_id'] = $this->turnID($msg['msg']['recv_id']);
}
$content = [];
if($msg['msg']['content']){
$content = json_decode($msg['msg']['content'],true);
}
if($msg['msg']['content_type'] == '101'){
//cp($content);
//break 2;
}
if($msg['msg']['content_type'] == '102'){
$urlFields = ['sourcePath'];
$this->handlerUrl($content,$urlFields);
if(isset($content['sourcePicture'])){
$urlFields = ['url'];
$this->handlerUrl($content['sourcePicture'],$urlFields);
}
if(isset($content['bigPicture'])){
$urlFields = ['url'];
$this->handlerUrl($content['bigPicture'],$urlFields);
}
if(isset($content['snapshotPicture'])){
$urlFields = ['url'];
$this->handlerUrl($content['snapshotPicture'],$urlFields);
}
//cp($content);
//break 2;
}
if($msg['msg']['content_type'] == '103'){
$urlFields = ['soundPath','sourceUrl'];
$this->handlerUrl($content,$urlFields);
}
if($msg['msg']['content_type'] == '104'){
$urlFields = ['videoUrl','snapshotUrl','snapshotPath','videoPath'];
$this->handlerUrl($content,$urlFields);
//cp($content);
//break 2;
}
if($msg['msg']['content_type'] == '106'){
if(isset($content['atUserList'])){
foreach($content['atUserList'] as $k=>$userID){
$content['atUserList'][$k] = $this->turnID($userID);
}
}
if(isset($content['atUsersInfo'])){
foreach($content['atUsersInfo'] as $k=>$v){
$content['atUsersInfo'][$k]['atUserID'] = $this->turnID($v['atUserID']);
}
}
}
if($msg['msg']['content_type'] == '108'){
$this->handlerUserId($content,['userID']);
$this->handlerUrl($content,['faceURL']);
}
if($msg['msg']['content_type'] == '109'){
//cp($content);
//break 2;
}
if($msg['msg']['content_type'] == '114'){
if(isset($content['quoteMessage'])){
$userIDFields = ['sendID','recvID'];
$this->handlerUserId($detail['quoteMessage'],$userIDFields);
$urlFields = ['senderFaceUrl'];
$this->handlerUrl($detail['quoteMessage'],$urlFields);
}
}
if($msg['msg']['content_type'] == '1201'){
//cp($content['detail']);
$detail = json_decode($content['detail'],true);
if(isset($detail['fromToUserID'])){
$userIDFields = ['fromUserID','toUserID'];
$this->handlerUserId($detail['fromToUserID'],$userIDFields);
}
if(isset($detail['request'])){
$userIDFields = ['handlerUserID','fromUserID','toUserID'];
$this->handlerUserId($detail['request'],$userIDFields);
$urlFields = ['fromFaceURL','toFaceURL'];
$this->handlerUrl($detail['request'],$urlFields);
}
$content['detail'] = json_encode($detail,JSON_UNESCAPED_UNICODE);
//cp($detail);
//break 2;
}
if(in_array($msg['msg']['content_type'],['1501','1504','1507','1508','1509','1510','1512','1513','1514','1519','1515','1520'])){
$detail = json_decode($content['detail'],true);
if(isset($detail['memberList'])){
foreach($detail['memberList'] as $memberIndex => $member){
$userIDFields = ['userID','operatorUserID','inviterUserID'];
$this->handlerUserId($member,$userIDFields);
$urlFields = ['faceURL'];
$this->handlerUrl($member,$urlFields);
$detail['memberList'][$memberIndex] = $member;
}
}
if(isset($detail['invitedUserList'])){
foreach($detail['invitedUserList'] as $memberIndex => $member){
$userIDFields = ['userID','operatorUserID','inviterUserID'];
$this->handlerUserId($member,$userIDFields);
$urlFields = ['faceURL'];
$this->handlerUrl($member,$urlFields);
$detail['invitedUserList'][$memberIndex] = $member;
}
}
if(isset($detail['groupOwnerUser'])){
$userIDFields = ['userID','operatorUserID','inviterUserID'];
$this->handlerUserId($detail['groupOwnerUser'],$userIDFields);
$urlFields = ['faceURL'];
$this->handlerUrl($detail['groupOwnerUser'],$urlFields);
}
if(isset($detail['inviterUser'])){
$userIDFields = ['userID','operatorUserID','inviterUserID'];
$this->handlerUserId($detail['inviterUser'],$userIDFields);
$urlFields = ['faceURL'];
$this->handlerUrl($detail['inviterUser'],$urlFields);
}
if(isset($detail['oldGroupOwnerInfo'])){
$userIDFields = ['userID','operatorUserID','inviterUserID'];
$this->handlerUserId($detail['oldGroupOwnerInfo'],$userIDFields);
$urlFields = ['faceURL'];
$this->handlerUrl($detail['oldGroupOwnerInfo'],$urlFields);
}
if(isset($detail['newGroupOwner'])){
$userIDFields = ['userID','operatorUserID','inviterUserID'];
$this->handlerUserId($detail['newGroupOwner'],$userIDFields);
$urlFields = ['faceURL'];
$this->handlerUrl($detail['newGroupOwner'],$urlFields);
}
if(isset($detail['entrantUser'])){
$userIDFields = ['userID','operatorUserID','inviterUserID'];
$this->handlerUserId($detail['entrantUser'],$userIDFields);
$urlFields = ['faceURL'];
$this->handlerUrl($detail['entrantUser'],$urlFields);
}
if(isset($detail['mutedUser'])){
$userIDFields = ['userID','operatorUserID','inviterUserID'];
$this->handlerUserId($detail['mutedUser'],$userIDFields);
$urlFields = ['faceURL'];
$this->handlerUrl($detail['mutedUser'],$urlFields);
}
if(isset($detail['group'])){
$userIDFields = ['ownerUserID','creatorUserID'];
$this->handlerUserId($detail['group'],$userIDFields);
$urlFields = ['faceURL'];
$this->handlerUrl($detail['group'],$urlFields);
}
if(isset($detail['opUser'])){
$userIDFields = ['userID','operatorUserID','inviterUserID'];
$this->handlerUserId($detail['opUser'],$userIDFields);
$urlFields = ['faceURL'];
$this->handlerUrl($detail['opUser'],$urlFields);
}
if(isset($detail['quitUser'])){
$userIDFields = ['userID','operatorUserID','inviterUserID'];
$this->handlerUserId($detail['quitUser'],$userIDFields);
$urlFields = ['faceURL'];
$this->handlerUrl($detail['quitUser'],$urlFields);
}
if(isset($detail['kickedUserList'])){
foreach($detail['kickedUserList'] as $memberIndex => $member){
$userIDFields = ['userID','operatorUserID','inviterUserID'];
$this->handlerUserId($member,$userIDFields);
$urlFields = ['faceURL'];
$this->handlerUrl($member,$urlFields);
$detail['kickedUserList'][$memberIndex] = $member;
}
}
$content['detail'] = json_encode($detail,JSON_UNESCAPED_UNICODE);
//break 2;
}
if($msg['msg']['content_type'] == '1701'){
$detail = json_decode($content['detail'],true);
$userIDFields = ['recvID','sendID'];
$this->handlerUserId($detail,$userIDFields);
if(isset($detail['conversationID'])){
$detail['conversationID'] = $this->handlerConversationID($detail['conversationID']);
}
$content['detail'] = json_encode($detail,JSON_UNESCAPED_UNICODE);
}
if($msg['msg']['content_type'] == '2001'){
//cp($content);
//break 2;
}
if($msg['msg']['content_type'] == '2200'){
$detail = json_decode($content['detail'],true);
$userIDFields = ['markAsReadUserID'];
$this->handlerUserId($detail,$userIDFields);
if(isset($detail['conversationID'])){
$detail['conversationID'] = $this->handlerConversationID($detail['conversationID']);
}
//cp($detail);
$content['detail'] = json_encode($detail,JSON_UNESCAPED_UNICODE);
//break 2;
}
if($msg['msg']['content_type'] == '2101'){
$detail = json_decode($content['detail'],true);
$userIDFields = ['revokerUserID'];
$this->handlerUserId($detail,$userIDFields);
$detail['conversationID'] = $this->handlerConversationID($detail['conversationID']);
$content['detail'] = json_encode($detail,JSON_UNESCAPED_UNICODE);
}
$msg['msg']['content'] = json_encode($content,JSON_UNESCAPED_UNICODE);
$savedata['msgs'][$key] = $msg;
}
if(!empty($savedata)){
$model->where('id',$item['id'])->update($savedata);
$count++;
}
}
}
//log_alert($contentTypes,'cansnow');
//$output->writeln("Msg 表转换完成,共 {$count} 条记录");
}
function handlerConversationID($data){
$data = str_replace('official_team','officialteam',$data);
$cids = explode('_',$data);
$cids[1] = $this->turnID($cids[1]);
if(count($cids) >2){
$cids[2] = $this->turnID($cids[2]);
}
$data = implode('_',$cids);
return $data;
}
function handlerUserId(&$data,$userIDFields){
foreach($userIDFields as $userIDField){
if(isset($data[$userIDField]) && $data[$userIDField]){
$data[$userIDField] = $this->turnID($data[$userIDField]);
}
}
}
function handlerUrl(&$data,$urlFields){
foreach($urlFields as $urlField){
if(isset($data[$urlField])){
$data[$urlField] = $this->cdn($data[$urlField]);
}
}
}
function cdn($url){
if(substr(0,2) =='//'){
$url = 'https:'.$url;
}
if(substr(0,7) =='http://'){
$url = 'https://'.substr($url,7);
}
return $url;
}
function getUser(){
$im = $this->getSdk();
$data = $im->user->searchNotificationAccount('');
cp($data);
return 0;
}
/** /**
* @return void * @return void
*/ */
protected function configure() protected function configure()
{ {
$this->addOption('action','a', InputArgument::OPTIONAL, '操作类型'); $this->addOption('action','a', InputArgument::OPTIONAL, '操作类型');
$this->addOption('conversationID','c', InputArgument::OPTIONAL, '会话ID');
$this->addOption('userID','u', InputArgument::OPTIONAL, '用户ID');
} }
/** /**
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
+1 -1
View File
@@ -37,7 +37,7 @@ class Handler extends ExceptionHandler
public function render(Request $request, Throwable $exception): Response public function render(Request $request, Throwable $exception): Response
{ {
$code = $exception->getCode(); $code = $exception->getCode();
$json = ['code' => $code ?: 500, 'msg' => $exception->getMessage()]; $json = ['code' => $code ?: 500, 'msg' => __($exception->getMessage())];
return new Response(200, ['Content-Type' => 'application/json'], return new Response(200, ['Content-Type' => 'application/json'],
json_encode($json, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); json_encode($json, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
+1 -1
View File
@@ -281,7 +281,7 @@ class MetricsController extends Base
$metrics = []; $metrics = [];
try { try {
$redis = \Bilulanlv\ThinkCache\facade\ThinkCache::handler(); $redis = \support\think\Cache::handler();
$info = $redis->info(); $info = $redis->info();
// Redis连接状态 // Redis连接状态
+1
View File
@@ -44,6 +44,7 @@ class User{
* @var \support\OpenImSdk\Client $IM * @var \support\OpenImSdk\Client $IM
*/ */
$IM = request()->IM; $IM = request()->IM;
log_alert($data['userID']);
$imToken = $IM->auth->getUserToken($data['userID'],Input('platform')); $imToken = $IM->auth->getUserToken($data['userID'],Input('platform'));
$data['imToken'] = $imToken['token']; $data['imToken'] = $imToken['token'];
return $data; return $data;
+17 -5
View File
@@ -1,5 +1,4 @@
<?php <?php
use Bilulanlv\ThinkCache\facade\ThinkCache;
use support\Env; use support\Env;
if (!function_exists('admin_path')) { if (!function_exists('admin_path')) {
function admin_path(){ function admin_path(){
@@ -23,10 +22,10 @@ if (!function_exists('cache')) {
if ('' === $value) { if ('' === $value) {
// 获取缓存 // 获取缓存
return str_starts_with($name, '?') ? ThinkCache::has(substr($name, 1)) : ThinkCache::get($name); return str_starts_with($name, '?') ? \support\think\Cache::has(substr($name, 1)) : \support\think\Cache::get($name);
} elseif (is_null($value)) { } elseif (is_null($value)) {
// 删除缓存 // 删除缓存
return ThinkCache::delete($name); return \support\think\Cache::delete($name);
} }
// 缓存数据 // 缓存数据
@@ -37,9 +36,9 @@ if (!function_exists('cache')) {
} }
if (is_null($tag)) { if (is_null($tag)) {
return ThinkCache::set($name, $value, $expire); return \support\think\Cache::set($name, $value, $expire);
} else { } else {
return ThinkCache::tag($tag)->set($name, $value, $expire); return \support\think\Cache::tag($tag)->set($name, $value, $expire);
} }
} }
} }
@@ -80,6 +79,19 @@ if (!function_exists('get')) {
if (!function_exists('__')) { if (!function_exists('__')) {
function __(string $name = '', array $parameters = [], ?string $domain = null, ?string $locale = null) function __(string $name = '', array $parameters = [], ?string $domain = null, ?string $locale = null)
{ {
// $locale = $locale ?: locale();
// if(!$domain){
// $request = Request();
// $request->app.','.$request->plugin.','.get_controller_name();
// $fn = '/resource/translations/'.$locale.'/'.($request->app ? $request->app .'/' : '').strtolower(get_controller_name());
// if($request->plugin){
// $fn = base_path('plugin').'/'.$request->plugin.$fn;
// }else{
// $fn = base_path($fn);
// }
// $domain = $fn;
// }
return trans($name, $parameters, $domain, $locale); return trans($name, $parameters, $domain, $locale);
} }
} }
+3 -3
View File
@@ -430,7 +430,7 @@ class McpService
'database' => config('thinkorm.connections.mysql.database', ''), 'database' => config('thinkorm.connections.mysql.database', ''),
], ],
'cache' => [ 'cache' => [
'default' => config('plugin.bilulanlv.think-cache.app.default', 'redis'), 'default' => config('think-cache.app.default', 'redis'),
'stores' => array_keys(config('cache.stores', [])), 'stores' => array_keys(config('cache.stores', [])),
] ]
]; ];
@@ -650,7 +650,7 @@ class McpService
case 'cache': case 'cache':
return [ return [
'default_driver' => config('plugin.bilulanlv.think-cache.app.default', 'redis'), 'default_driver' => config('think-cache.app.default', 'redis'),
'opcache_enabled' => function_exists('opcache_get_status') && opcache_get_status() !== false, 'opcache_enabled' => function_exists('opcache_get_status') && opcache_get_status() !== false,
'redis_available' => extension_loaded('redis'), 'redis_available' => extension_loaded('redis'),
'memcached_available' => extension_loaded('memcached'), 'memcached_available' => extension_loaded('memcached'),
@@ -697,7 +697,7 @@ class McpService
'charset' => config('thinkorm.connections.mysql.charset', 'utf8mb4'), 'charset' => config('thinkorm.connections.mysql.charset', 'utf8mb4'),
'debug' => config('thinkorm.connections.mysql.trigger_sql', true), 'debug' => config('thinkorm.connections.mysql.trigger_sql', true),
], ],
'cache' => config('plugin.bilulanlv.think-cache.app', []), 'cache' => config('think-cache.app', []),
'session' => config('session', []), 'session' => config('session', []),
'log' => config('log', []), 'log' => config('log', []),
]; ];
+1 -1
View File
@@ -2,7 +2,7 @@
namespace app\api\controller; namespace app\api\controller;
use think\facade\Db; use think\facade\Db;
use support\Request; use support\Request;
use taoser\facade\Validate; use Tinywan\Validate\Facade\Validate;
use support\Jwt; use support\Jwt;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
/** /**
+1 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
namespace app\validate; namespace app\validate;
use taoser\Validate; use Tinywan\Validate\Validate;
class User extends Validate class User extends Validate
{ {
+1 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
namespace app\validate; namespace app\validate;
use taoser\Validate; use Tinywan\Validate\Validate;
class Withdrawl extends Validate class Withdrawl extends Validate
{ {
+4 -3
View File
@@ -34,9 +34,7 @@
"webman/captcha": "^1.0.5", "webman/captcha": "^1.0.5",
"webman/event": "^1.0.5", "webman/event": "^1.0.5",
"topthink/think-template": "^3.0.2", "topthink/think-template": "^3.0.2",
"bilulanlv/think-cache": "^1.0.9",
"symfony/var-dumper": "7.2.6", "symfony/var-dumper": "7.2.6",
"taoser/webman-validate": "^1.7.2",
"hg/apidoc": "^5.3.0", "hg/apidoc": "^5.3.0",
"isszz/webman-hashids": "^0.0.1", "isszz/webman-hashids": "^0.0.1",
"nette/mail": "^4.0.3", "nette/mail": "^4.0.3",
@@ -47,7 +45,10 @@
"php-mcp/server": "^3.3", "php-mcp/server": "^3.3",
"intervention/image": "^2.7.2", "intervention/image": "^2.7.2",
"guzzlehttp/guzzle": "^7.5.0", "guzzlehttp/guzzle": "^7.5.0",
"league/flysystem-aws-s3-v3": "^3.0" "league/flysystem-aws-s3-v3": "^3.0",
"webman/think-cache": "^2.1",
"symfony/translation": "^7.4",
"tinywan/validate": "^1.0"
}, },
"suggest": { "suggest": {
"ext-event": "For better performance. " "ext-event": "For better performance. "
+1 -1
View File
@@ -21,7 +21,7 @@ return [
//runtime_path() . '/logs/webman'.ceil(date('H')/6).'.log', //runtime_path() . '/logs/webman'.ceil(date('H')/6).'.log',
runtime_path() . '/logs/webman.log', runtime_path() . '/logs/webman.log',
7, //$maxFiles 7, //$maxFiles
Monolog\Logger::ALERT, Monolog\Logger::INFO,
], ],
'formatter' => [ 'formatter' => [
'class' => Monolog\Formatter\LineFormatter::class, 'class' => Monolog\Formatter\LineFormatter::class,
+4
View File
@@ -0,0 +1,4 @@
<?php
return [
'enable' => true,
];
@@ -0,0 +1,4 @@
<?php
return [
\Tinywan\Validate\Facade\Validate::class
];
+14 -8
View File
@@ -1,10 +1,5 @@
<?php <?php
// 如果ThinkORM需要使用缓存,请取消注释,或者在其他合适的地方引入
//\think\facade\Db::setCache(new \Bilulanlv\ThinkCache\CacheManager());
\support\think\Db::setCache(new \Bilulanlv\ThinkCache\CacheManager());
return [ return [
// 开启插件
'enable' => true,
// 默认缓存驱动 // 默认缓存驱动
'default' => 'redis', 'default' => 'redis',
// 缓存连接方式配置 // 缓存连接方式配置
@@ -15,17 +10,28 @@ return [
'type' => 'redis', 'type' => 'redis',
// 服务器地址 // 服务器地址
'host' => \support\Env::get('redis.host'), 'host' => \support\Env::get('redis.host'),
// 缓存端口
'port' => \support\Env::get('redis.port'),
// 缓存密码
'password' => \support\Env::get('redis.password',null), 'password' => \support\Env::get('redis.password',null),
'port' => \support\Env::get('redis.port',6379), // 缓存数据库
'database' => \support\Env::get('redis.database',0),
// 缓存前缀 // 缓存前缀
'prefix' => \support\Env::get('redis.prefix','cache:'), 'prefix' => \support\Env::get('redis.prefix','cache:'),
'select' => \support\Env::get('redis.database','0'),
// 默认缓存有效期 0表示永久缓存 // 默认缓存有效期 0表示永久缓存
'expire' => 0, 'expire' => 0,
// Thinkphp官方没有这个参数,由于生成的tag键默认不过期,如果tag键数量很大,避免长时间占用内存,可以设置一个超过其他缓存的过期时间,0为不设置 // Thinkphp官方没有这个参数,由于生成的tag键默认不过期,如果tag键数量很大,避免长时间占用内存,可以设置一个超过其他缓存的过期时间,0为不设置
'tag_expire' => 86400 * 7, 'tag_expire' => 86400 * 30,
// 缓存标签前缀 // 缓存标签前缀
'tag_prefix' => 'tag:', 'tag_prefix' => 'tag:',
// 连接池配置
'pool' => [
'max_connections' => 5, // 最大连接数
'min_connections' => 1, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔,需要小于60秒
],
], ],
// 文件缓存 // 文件缓存
'file' => [ 'file' => [
+1
View File
@@ -43,6 +43,7 @@ return [
'trigger_sql' => true, 'trigger_sql' => true,
'params' => [ 'params' => [
'persist' => 'mongodb_persist', // 持久化连接标识 'persist' => 'mongodb_persist', // 持久化连接标识
'authSource' => 'admin',
], ],
], ],
'immongodb' => [ 'immongodb' => [
-742
View File
File diff suppressed because one or more lines are too long
-49
View File
@@ -1,49 +0,0 @@
-- 朋友圈功能数据库表结构
-- 朋友圈动态表
CREATE TABLE IF NOT EXISTS `friend_circle` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`user_id` int(11) NOT NULL COMMENT '用户ID',
`body` text COMMENT '内容',
`files` text COMMENT '图片列表(JSON)',
`like_count` int(11) NOT NULL DEFAULT '0' COMMENT '点赞数',
`comment_count` int(11) NOT NULL DEFAULT '0' COMMENT '评论数',
`created_at` int(11) NOT NULL COMMENT '创建时间',
`updated_at` int(11) NOT NULL COMMENT '更新时间',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态(0:隐藏 1:正常)',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
KEY `status` (`status`),
KEY `created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='朋友圈动态表';
-- 朋友圈点赞表
CREATE TABLE IF NOT EXISTS `friend_circle_like` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`circle_id` int(11) NOT NULL COMMENT '朋友圈动态ID',
`user_id` int(11) NOT NULL COMMENT '用户ID',
`created_at` int(11) NOT NULL COMMENT '创建时间',
PRIMARY KEY (`id`),
UNIQUE KEY `circle_user` (`circle_id`,`user_id`),
KEY `circle_id` (`circle_id`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='朋友圈点赞表';
-- 朋友圈评论表
CREATE TABLE IF NOT EXISTS `friend_circle_comment` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`circle_id` int(11) NOT NULL COMMENT '朋友圈动态ID',
`user_id` int(11) NOT NULL COMMENT '用户ID',
`reply_user_id` int(11) NOT NULL DEFAULT '0' COMMENT '回复的用户ID(0表示直接评论)',
`body` text NOT NULL COMMENT '评论内容',
`created_at` int(11) NOT NULL COMMENT '创建时间',
`updated_at` int(11) NOT NULL COMMENT '更新时间',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态(0:隐藏 1:正常)',
PRIMARY KEY (`id`),
KEY `circle_id` (`circle_id`),
KEY `user_id` (`user_id`),
KEY `reply_user_id` (`reply_user_id`),
KEY `status` (`status`),
KEY `created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='朋友圈评论表';
Binary file not shown.
@@ -6,7 +6,7 @@ use Exception;
use support\Request; use support\Request;
use support\Response; use support\Response;
use support\think\Db; use support\think\Db;
use taoser\facade\Validate; use Tinywan\Validate\Facade\Validate;
use Shopwwi\WebmanFilesystem\Facade\Storage; use Shopwwi\WebmanFilesystem\Facade\Storage;
/** /**
-1
View File
@@ -1 +0,0 @@
open_basedir=/www/wwwroot/openim/admin/:/tmp/
+8 -1
View File
@@ -70,5 +70,12 @@ docker run -p 3306:3306 \
7b0fa3686a4f0adf 7b0fa3686a4f0adf
SELECT * FROM information_schema.`INNODB_TRX`; SELECT * FROM information_schema.`INNODB_TRX`;
``` ```
docker compose up -d
docker compose --profile m up -d
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
bash bootstrap.sh
mage
mage start
docker exec -it mongo mongorestore --uri="mongodb://openIM:n1e5a6s6m7@172.18.0.1:37017/openim_v3" /data/backup/3/openim_v3
@@ -1,5 +1,6 @@
<?php <?php
return array( return array(
"Account is incorrect" => "账号不正确",
'Email is incorrect' => '邮箱地址不正确', 'Email is incorrect' => '邮箱地址不正确',
'Mobile is incorrect' => '手机号不正确', 'Mobile is incorrect' => '手机号不正确',
'Invalid trade password' => '交易密码无效', 'Invalid trade password' => '交易密码无效',
+4 -2
View File
@@ -1,6 +1,7 @@
<?php <?php
$common = require 'common.php'; $common = require 'common.php';
$app = Request()->app; $request = Request();
$app = $request->app;
$controller =get_controller_name(); $controller =get_controller_name();
$langs = []; $langs = [];
$fn= __DIR__.'/'.($app?$app.'/' : '').strtolower($controller).'.php'; $fn= __DIR__.'/'.($app?$app.'/' : '').strtolower($controller).'.php';
@@ -10,4 +11,5 @@ if(file_exists($fn)){
$langs = []; $langs = [];
} }
} }
return array_merge($common,$langs); $res = array_merge($common,$langs);
return $res;
-147
View File
@@ -1,147 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c); 2006~2021 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 );
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// 核心中文语言包
return [
// 系统错误提示
'Undefined variable' => '未定义变量',
'Undefined index' => '未定义数组索引',
'Undefined offset' => '未定义数组下标',
'Parse error' => '语法解析错误',
'Type error' => '类型错误',
'Fatal error' => '致命错误',
'syntax error' => '语法错误',
// 框架核心错误提示
'dispatch type not support' => '不支持的调度类型',
'method param miss' => '方法参数错误',
'method not exists' => '方法不存在',
'function not exists' => '函数不存在',
'app not exists' => '应用不存在',
'controller not exists' => '控制器不存在',
'class not exists' => '类不存在',
'property not exists' => '类的属性不存在',
'template not exists' => '模板文件不存在',
'illegal controller name' => '非法的控制器名称',
'illegal action name' => '非法的操作名称',
'url suffix deny' => '禁止的URL后缀访问',
'Undefined cache config' => '缓存配置未定义',
'Route Not Found' => '当前访问路由未定义或不匹配',
'Undefined db config' => '数据库配置未定义',
'Undefined log config' => '日志配置未定义',
'Undefined db type' => '未定义数据库类型',
'variable type error' => '变量类型错误',
'PSR-4 error' => 'PSR-4 规范错误',
'not support type' => '不支持的分页索引字段类型',
'not support total' => '简洁模式下不能获取数据总数',
'not support last' => '简洁模式下不能获取最后一页',
'error session handler' => '错误的SESSION处理器类',
'not allow php tag' => '模板不允许使用PHP语法',
'not support' => '不支持',
'database config error' => '数据库配置信息错误',
'redisd master' => 'Redisd 主服务器错误',
'redisd slave' => 'Redisd 从服务器错误',
'must run at sae' => '必须在SAE运行',
'memcache init error' => '未开通Memcache服务,请在SAE管理平台初始化Memcache服务',
'KVDB init error' => '没有初始化KVDB,请在SAE管理平台初始化KVDB服务',
'fields not exists' => '数据表字段不存在',
'where express error' => '查询表达式错误',
'no data to update' => '没有任何数据需要更新',
'miss data to insert' => '缺少需要写入的数据',
'miss complex primary data' => '缺少复合主键数据',
'miss update condition' => '缺少更新条件',
'model data Not Found' => '模型数据不存在',
'table data not Found' => '表数据不存在',
'delete without condition' => '没有条件不会执行删除操作',
'miss relation data' => '缺少关联表数据',
'tag attr must' => '模板标签属性必须',
'tag error' => '模板标签错误',
'cache write error' => '缓存写入失败',
'sae mc write error' => 'SAE mc 写入错误',
'route name not exists' => '路由标识不存在(或参数不够)',
'invalid request' => '非法请求',
'bind attr has exists' => '模型的属性已经存在',
'relation data not exists' => '关联数据不存在',
'relation not support' => '关联不支持',
'chunk not support order' => 'Chunk不支持调用order方法',
'route pattern error' => '路由变量规则定义错误',
'route behavior will not support' => '路由行为废弃(使用中间件替代)',
'closure not support cache(true);' => '使用闭包查询不支持cache(true);,请指定缓存Key',
// 上传错误信息
'unknown upload error' => '未知上传错误!',
'file write error' => '文件写入失败!',
'upload temp dir not found' => '找不到临时文件夹!',
'no file to uploaded' => '没有文件被上传!',
'only the portion of file is uploaded' => '文件只有部分被上传!',
'upload File size exceeds the maximum value' => '上传文件大小超过了最大值!',
'upload write error' => '文件上传保存错误!',
'has the same filename: {:filename}' => '存在同名文件:{:filename}',
'upload illegal files' => '非法上传文件',
'illegal image files' => '非法图片文件',
'extensions to upload is not allowed' => '上传文件后缀不允许',
'mimetype to upload is not allowed' => '上传文件MIME类型不允许!',
'filesize not match' => '上传文件大小不符!',
'directory {:path} creation failed' => '目录 {:path} 创建失败!',
'The middleware must return Response instance' => '中间件方法必须返回Response对象实例',
'The queue was exhausted, with no response returned' => '中间件队列为空',
// Validate Error Message
':attribute require' => ':attribute不能为空',
':attribute must' => ':attribute必须',
':attribute must be numeric' => ':attribute必须是数字',
':attribute must be integer' => ':attribute必须是整数',
':attribute must be float' => ':attribute必须是浮点数',
':attribute must be bool' => ':attribute必须是布尔值',
':attribute not a valid email address' => ':attribute格式不符',
':attribute not a valid mobile' => ':attribute格式不符',
':attribute must be a array' => ':attribute必须是数组',
':attribute must be yes,on or 1' => ':attribute必须是yes、on或者1',
':attribute not a valid datetime' => ':attribute不是一个有效的日期或时间格式',
':attribute not a valid file' => ':attribute不是有效的上传文件',
':attribute not a valid image' => ':attribute不是有效的图像文件',
':attribute must be alpha' => ':attribute只能是字母',
':attribute must be alpha-numeric' => ':attribute只能是字母和数字',
':attribute must be alpha-numeric, dash, underscore' => ':attribute只能是字母、数字和下划线_及破折号-',
':attribute not a valid domain or ip' => ':attribute不是有效的域名或者IP',
':attribute must be chinese' => ':attribute只能是汉字',
':attribute must be chinese or alpha' => ':attribute只能是汉字、字母',
':attribute must be chinese,alpha-numeric' => ':attribute只能是汉字、字母和数字',
':attribute must be chinese,alpha-numeric,underscore, dash' => ':attribute只能是汉字、字母、数字和下划线_及破折号-',
':attribute not a valid url' => ':attribute不是有效的URL地址',
':attribute not a valid ip' => ':attribute不是有效的IP地址',
':attribute must be dateFormat of :rule' => ':attribute必须使用日期格式 :rule',
':attribute must be in :rule' => ':attribute必须在 :rule 范围内',
':attribute be notin :rule' => ':attribute不能在 :rule 范围内',
':attribute must between :1 - :2' => ':attribute只能在 :1 - :2 之间',
':attribute not between :1 - :2' => ':attribute不能在 :1 - :2 之间',
'size of :attribute must be :rule' => ':attribute长度不符合要求 :rule',
'max size of :attribute must be :rule' => ':attribute长度不能超过 :rule',
'min size of :attribute must be :rule' => ':attribute长度不能小于 :rule',
':attribute cannot be less than :rule' => ':attribute日期不能小于 :rule',
':attribute cannot exceed :rule' => ':attribute日期不能超过 :rule',
':attribute not within :rule' => '不在有效期内 :rule',
'access IP is not allowed' => '不允许的IP访问',
'access IP denied' => '禁止的IP访问',
':attribute out of accord with :2' => ':attribute和确认字段:2不一致',
':attribute cannot be same with :2' => ':attribute和比较字段:2不能相同',
':attribute must greater than or equal :rule' => ':attribute必须大于等于 :rule',
':attribute must greater than :rule' => ':attribute必须大于 :rule',
':attribute must less than or equal :rule' => ':attribute必须小于等于 :rule',
':attribute must less than :rule' => ':attribute必须小于 :rule',
':attribute must equal :rule' => ':attribute必须等于 :rule',
':attribute has exists' => ':attribute已存在',
':attribute not conform to the rules' => ':attribute不符合指定规则',
'invalid Request method' => '无效的请求类型',
'invalid token' => '令牌数据无效',
'not conform to the rules' => '规则错误',
'record has update' => '记录已经被更新了',
];
-147
View File
@@ -1,147 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// 核心中文语言包
return [
// 系统错误提示
'Undefined variable' => '未定义变量',
'Undefined index' => '未定义数组索引',
'Undefined offset' => '未定义数组下标',
'Parse error' => '语法解析错误',
'Type error' => '类型错误',
'Fatal error' => '致命错误',
'syntax error' => '语法错误',
// 框架核心错误提示
'dispatch type not support' => '不支持的调度类型',
'method param miss' => '方法参数错误',
'method not exists' => '方法不存在',
'function not exists' => '函数不存在',
'app not exists' => '应用不存在',
'controller not exists' => '控制器不存在',
'class not exists' => '类不存在',
'property not exists' => '类的属性不存在',
'template not exists' => '模板文件不存在',
'illegal controller name' => '非法的控制器名称',
'illegal action name' => '非法的操作名称',
'url suffix deny' => '禁止的URL后缀访问',
'Undefined cache config' => '缓存配置未定义',
'Route Not Found' => '当前访问路由未定义或不匹配',
'Undefined db config' => '数据库配置未定义',
'Undefined log config' => '日志配置未定义',
'Undefined db type' => '未定义数据库类型',
'variable type error' => '变量类型错误',
'PSR-4 error' => 'PSR-4 规范错误',
'not support type' => '不支持的分页索引字段类型',
'not support total' => '简洁模式下不能获取数据总数',
'not support last' => '简洁模式下不能获取最后一页',
'error session handler' => '错误的SESSION处理器类',
'not allow php tag' => '模板不允许使用PHP语法',
'not support' => '不支持',
'database config error' => '数据库配置信息错误',
'redisd master' => 'Redisd 主服务器错误',
'redisd slave' => 'Redisd 从服务器错误',
'must run at sae' => '必须在SAE运行',
'memcache init error' => '未开通Memcache服务,请在SAE管理平台初始化Memcache服务',
'KVDB init error' => '没有初始化KVDB,请在SAE管理平台初始化KVDB服务',
'fields not exists' => '数据表字段不存在',
'where express error' => '查询表达式错误',
'no data to update' => '没有任何数据需要更新',
'miss data to insert' => '缺少需要写入的数据',
'miss complex primary data' => '缺少复合主键数据',
'miss update condition' => '缺少更新条件',
'model data Not Found' => '模型数据不存在',
'table data not Found' => '表数据不存在',
'delete without condition' => '没有条件不会执行删除操作',
'miss relation data' => '缺少关联表数据',
'tag attr must' => '模板标签属性必须',
'tag error' => '模板标签错误',
'cache write error' => '缓存写入失败',
'sae mc write error' => 'SAE mc 写入错误',
'route name not exists' => '路由标识不存在(或参数不够)',
'invalid request' => '非法请求',
'bind attr has exists' => '模型的属性已经存在',
'relation data not exists' => '关联数据不存在',
'relation not support' => '关联不支持',
'chunk not support order' => 'Chunk不支持调用order方法',
'route pattern error' => '路由变量规则定义错误',
'route behavior will not support' => '路由行为废弃(使用中间件替代)',
'closure not support cache(true)' => '使用闭包查询不支持cache(true),请指定缓存Key',
// 上传错误信息
'unknown upload error' => '未知上传错误!',
'file write error' => '文件写入失败!',
'upload temp dir not found' => '找不到临时文件夹!',
'no file to uploaded' => '没有文件被上传!',
'only the portion of file is uploaded' => '文件只有部分被上传!',
'upload File size exceeds the maximum value' => '上传文件大小超过了最大值!',
'upload write error' => '文件上传保存错误!',
'has the same filename: {:filename}' => '存在同名文件:{:filename}',
'upload illegal files' => '非法上传文件',
'illegal image files' => '非法图片文件',
'extensions to upload is not allowed' => '上传文件后缀不允许',
'mimetype to upload is not allowed' => '上传文件MIME类型不允许!',
'filesize not match' => '上传文件大小不符!',
'directory {:path} creation failed' => '目录 {:path} 创建失败!',
'The middleware must return Response instance' => '中间件方法必须返回Response对象实例',
'The queue was exhausted, with no response returned' => '中间件队列为空',
// Validate Error Message
':attribute require' => ':attribute不能为空',
':attribute must' => ':attribute必须',
':attribute must be numeric' => ':attribute必须是数字',
':attribute must be integer' => ':attribute必须是整数',
':attribute must be float' => ':attribute必须是浮点数',
':attribute must be bool' => ':attribute必须是布尔值',
':attribute not a valid email address' => ':attribute格式不符',
':attribute not a valid mobile' => ':attribute格式不符',
':attribute must be a array' => ':attribute必须是数组',
':attribute must be yes,on or 1' => ':attribute必须是yes、on或者1',
':attribute not a valid datetime' => ':attribute不是一个有效的日期或时间格式',
':attribute not a valid file' => ':attribute不是有效的上传文件',
':attribute not a valid image' => ':attribute不是有效的图像文件',
':attribute must be alpha' => ':attribute只能是字母',
':attribute must be alpha-numeric' => ':attribute只能是字母和数字',
':attribute must be alpha-numeric, dash, underscore' => ':attribute只能是字母、数字和下划线_及破折号-',
':attribute not a valid domain or ip' => ':attribute不是有效的域名或者IP',
':attribute must be chinese' => ':attribute只能是汉字',
':attribute must be chinese or alpha' => ':attribute只能是汉字、字母',
':attribute must be chinese,alpha-numeric' => ':attribute只能是汉字、字母和数字',
':attribute must be chinese,alpha-numeric,underscore, dash' => ':attribute只能是汉字、字母、数字和下划线_及破折号-',
':attribute not a valid url' => ':attribute不是有效的URL地址',
':attribute not a valid ip' => ':attribute不是有效的IP地址',
':attribute must be dateFormat of :rule' => ':attribute必须使用日期格式 :rule',
':attribute must be in :rule' => ':attribute必须在 :rule 范围内',
':attribute be notin :rule' => ':attribute不能在 :rule 范围内',
':attribute must between :1 - :2' => ':attribute只能在 :1 - :2 之间',
':attribute not between :1 - :2' => ':attribute不能在 :1 - :2 之间',
'size of :attribute must be :rule' => ':attribute长度不符合要求 :rule',
'max size of :attribute must be :rule' => ':attribute长度不能超过 :rule',
'min size of :attribute must be :rule' => ':attribute长度不能小于 :rule',
':attribute cannot be less than :rule' => ':attribute日期不能小于 :rule',
':attribute cannot exceed :rule' => ':attribute日期不能超过 :rule',
':attribute not within :rule' => '不在有效期内 :rule',
'access IP is not allowed' => '不允许的IP访问',
'access IP denied' => '禁止的IP访问',
':attribute out of accord with :2' => ':attribute和确认字段:2不一致',
':attribute cannot be same with :2' => ':attribute和比较字段:2不能相同',
':attribute must greater than or equal :rule' => ':attribute必须大于等于 :rule',
':attribute must greater than :rule' => ':attribute必须大于 :rule',
':attribute must less than or equal :rule' => ':attribute必须小于等于 :rule',
':attribute must less than :rule' => ':attribute必须小于 :rule',
':attribute must equal :rule' => ':attribute必须等于 :rule',
':attribute has exists' => ':attribute已存在',
':attribute not conform to the rules' => ':attribute不符合指定规则',
'invalid Request method' => '无效的请求类型',
'invalid token' => '令牌数据无效',
'not conform to the rules' => '规则错误',
'record has update' => '记录已经被更新了',
];
+28 -15
View File
@@ -26,15 +26,40 @@ class Encrypt
*/ */
static function userIDencode($userID,$key=0):string{ static function userIDencode($userID,$key=0):string{
if(!is_numeric(($userID))){ if(!is_numeric(($userID))){
return $userID; return $userID.'';
} }
$userID = intval($userID); $userID = intval($userID);
if($userID<=100234){ if($userID<=100234){
return $userID.''; return $userID.'';
} }
if($userID == '100235'){
return 'JWrb5JPm3E';
}
if($userID<=102028){ if($userID<=102028){
return id_encode($userID); return id_encode($userID);
} }
return self::intEncode($userID,$key);
}
/**
* 解密非连续数字ID为原始连续ID
* @param int $encryptedId 加密后的非连续ID8位数)
* @param int $userKey 可选的额外密钥
* @return int 原始连续ID
*/
static function userIDDecode($userID,$key=0):string{
if($userID == 'JWrb5JPm3E'){
return '100235';
}
if(!is_numeric(($userID))){
return id_decode($userID.'');
}
if($userID<=100234){
return $userID.'';
}
return self::intDecode($userID,$key);
}
static function intEncode($userID,$key=0){
$key = intval($key); $key = intval($key);
$plainId = abs(intval($userID)) % self::$maxId; $plainId = abs(intval($userID)) % self::$maxId;
@@ -55,19 +80,8 @@ class Encrypt
// 确保结果是8位数(10000000 - 99999999 // 确保结果是8位数(10000000 - 99999999
return (self::$baseValue + $encrypted).''; return (self::$baseValue + $encrypted).'';
} }
/** static function intDecode($userID,$key=0): string{
* 解密非连续数字ID为原始连续ID
* @param int $encryptedId 加密后的非连续ID8位数)
* @param int $userKey 可选的额外密钥
* @return int 原始连续ID
*/
static function userIDDecode($userID,$key=0):string{
if(!is_numeric(($userID))){
return id_decode($userID.'');
}
if($userID<=100234){
return $userID.'';
}
$key = intval($key); $key = intval($key);
// 去除基数,得到原始混淆值 // 去除基数,得到原始混淆值
$cipherId = ($userID - self::$baseValue + self::$maxId) % self::$maxId; $cipherId = ($userID - self::$baseValue + self::$maxId) % self::$maxId;
@@ -88,7 +102,6 @@ class Encrypt
return $plainId.''; return $plainId.'';
} }
/** /**
* 使用扩展欧几里得算法计算模逆元 * 使用扩展欧几里得算法计算模逆元
* 返回 x 使得 (a * x) % m = 1 * 返回 x 使得 (a * x) % m = 1
-11
View File
@@ -9,18 +9,7 @@ declare(strict_types=1);
namespace support; namespace support;
use FastRoute\BadRouteException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use Throwable; use Throwable;
use Tinywan\ExceptionHandler\Event\DingTalkRobotEvent;
use Tinywan\ExceptionHandler\Exception\BaseException;
use Tinywan\ExceptionHandler\Exception\ServerErrorHttpException;
use Tinywan\Jwt\Exception\JwtRefreshTokenExpiredException;
use Tinywan\Jwt\Exception\JwtTokenException;
use Tinywan\Jwt\Exception\JwtTokenExpiredException;
use Tinywan\Validate\Exception\ValidateException;
use Webman\Exception\ExceptionHandler; use Webman\Exception\ExceptionHandler;
use Webman\Http\Request; use Webman\Http\Request;
use Webman\Http\Response; use Webman\Http\Response;
+7 -4
View File
@@ -69,7 +69,10 @@ class Utils
if ($token) { if ($token) {
$options[RequestOptions::HEADERS]['token'] = $token; $options[RequestOptions::HEADERS]['token'] = $token;
} }
return post($uri,$data,[
"token: {$token}",
"operationID: {$options[RequestOptions::HEADERS]['operationID']}",
]);
return $client->post($uri, $options)->getBody()->getContents(); return $client->post($uri, $options)->getBody()->getContents();
} }
@@ -88,10 +91,10 @@ class Utils
$token = $token ? $token : Utils::getAdminToken(); $token = $token ? $token : Utils::getAdminToken();
} }
$url = Url::buildUrl($path); $url = Url::buildUrl($path);
//log_alert($url); //cp($url);
//log_alert($data); //cp($data);
$res = self::request($url, $data, $token); $res = self::request($url, $data, $token);
//log_alert($res); //cp($res);
$res = json_decode($res, true); $res = json_decode($res, true);
if($res['errCode'] !==0 ){ if($res['errCode'] !==0 ){
throw new \Exception($res['errMsg'],$res['errCode']); throw new \Exception($res['errMsg'],$res['errCode']);