Merge branch 'main' of http://156.238.245.175:10086/commie/im
This commit is contained in:
@@ -15,6 +15,7 @@ class User extends Command
|
|||||||
{
|
{
|
||||||
protected static $defaultName = 'User';
|
protected static $defaultName = 'User';
|
||||||
protected static $defaultDescription = '用户';
|
protected static $defaultDescription = '用户';
|
||||||
|
public $sdk= null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
@@ -94,6 +95,7 @@ class User extends Command
|
|||||||
cp($totp->now());
|
cp($totp->now());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
//重建user_team
|
||||||
function build_team(){
|
function build_team(){
|
||||||
Db::name('user_team')->where('ancestor_id','>',0)->delete();
|
Db::name('user_team')->where('ancestor_id','>',0)->delete();
|
||||||
$list = Db::name('user')->field('id,parent_id')->order('id','asc')->select();
|
$list = Db::name('user')->field('id,parent_id')->order('id','asc')->select();
|
||||||
@@ -103,4 +105,51 @@ class User extends Command
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function register(InputInterface $input, OutputInterface $output){
|
||||||
|
$im = $this->getSdk();
|
||||||
|
try {
|
||||||
|
for($i=313;$i<333;$i++){
|
||||||
|
$mobile = '12600000000'+$i;
|
||||||
|
$password = \support\Random::build('23456789abcdefghjklmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ',8);
|
||||||
|
$data = [
|
||||||
|
'mobile' => $mobile,
|
||||||
|
'username' => $mobile,
|
||||||
|
'region' => '86',
|
||||||
|
'nickname' => $mobile,
|
||||||
|
'role_id' => 1,
|
||||||
|
'group_id' => 0,
|
||||||
|
'password' => \plugin\admin\app\common\Util::passwordHash(md5($password)),
|
||||||
|
'avatar' => '/static/img/avatar.png',
|
||||||
|
'created_at' => time(),
|
||||||
|
'updated_at' => time(),
|
||||||
|
'status' => 1,
|
||||||
|
];
|
||||||
|
$user_id = Db::name('user')->insertGetId($data);
|
||||||
|
$userID = \support\Encrypt::userIDencode($user_id);
|
||||||
|
Db::name('user')->where('id',$user_id)->update([
|
||||||
|
'userID'=>$userID
|
||||||
|
]);
|
||||||
|
$im->user->userRegister($userID,$data['nickname'],cdnurl($data['avatar']));
|
||||||
|
$user = Db::name('user')->where('id',$user_id)->find();
|
||||||
|
Hook('user.register_successed',$user);
|
||||||
|
cp($user_id,$data['mobile'],$password);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
//throw $th;
|
||||||
|
cp($e->getMessage());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected function getSdk(){
|
||||||
|
if($this->sdk){
|
||||||
|
return $this->sdk;
|
||||||
|
}
|
||||||
|
$this->sdk = new \support\OpenImSdk\Client([
|
||||||
|
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
|
||||||
|
'secret' => 'n1e5a6s6m7', // OpenIM密钥
|
||||||
|
]);
|
||||||
|
return $this->sdk;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user