9
This commit is contained in:
@@ -38,6 +38,7 @@ class UserController extends BaseController{
|
||||
$gender = input('gender',null);
|
||||
$faceURL = input('faceURL',null);
|
||||
$birth = input('birth',null);
|
||||
$bio = input('bio',null);
|
||||
$save_data =[];
|
||||
if($nickname){
|
||||
$save_data['nickname'] = $nickname;
|
||||
@@ -46,7 +47,10 @@ class UserController extends BaseController{
|
||||
$save_data['sex'] = $gender;
|
||||
}
|
||||
if($faceURL){
|
||||
$save_data['avatar'] = $faceURL;
|
||||
$save_data['faceURL'] = $faceURL;
|
||||
}
|
||||
if($bio){
|
||||
$save_data['bio'] = $bio;
|
||||
}
|
||||
if($birth){
|
||||
$save_data['birthday'] = datetime($birth/1000,'Y-m-d');
|
||||
@@ -133,21 +137,15 @@ class UserController extends BaseController{
|
||||
public function avatar(Request $request)
|
||||
{
|
||||
//单文件上传
|
||||
$file = $request->file('file0');
|
||||
try {
|
||||
$result = Storage::adapter('public')->path('upload/avatar')->size(1024*1024*5)->extYes(['image/jpeg','image/png'])->processUpload($file,function ($image){
|
||||
$image->resize(200,200);
|
||||
return $image;
|
||||
},true);
|
||||
\support\Jwt::getUser()->save([
|
||||
'avatar' => '/'.$result->file_name,
|
||||
]);
|
||||
//$result->ss = cdnurl($result->url);
|
||||
//P($result);
|
||||
return $this->success(__('successful'),$result);
|
||||
}catch (\Exception $e){
|
||||
return $this->error($e->getMessage());
|
||||
$res = $this->_upload($request);
|
||||
if(is_string($res)){
|
||||
return $this->fail( $res);
|
||||
}
|
||||
$data = [
|
||||
'avatar' => $res[0]['file_name'],
|
||||
];
|
||||
\support\Jwt::getUser()->save($data);
|
||||
return $this->success(__('successful'),$data);
|
||||
}
|
||||
function realname(Request $request): Response
|
||||
{
|
||||
@@ -198,7 +196,11 @@ class UserController extends BaseController{
|
||||
*/
|
||||
function find(Request $request): Response
|
||||
{
|
||||
$userIDs = Input('userIDs');
|
||||
$ids = Input('userIDs');
|
||||
if(is_string($ids)){
|
||||
$ids = explode(',',$ids);
|
||||
}
|
||||
$userIDs = array_map('idDecode',$ids);
|
||||
//$res = $request->IM->user->getUsersInfo($userIDs);
|
||||
$list = Db::name('user')->
|
||||
whereIn('id',$userIDs)
|
||||
@@ -240,12 +242,18 @@ class UserController extends BaseController{
|
||||
$searchtype = Input('searchtype');
|
||||
$fields = 'id,avatar,username,nickname,avatar,sex,email,mobile,birthday,bio';
|
||||
$model = Db::name('user')->field($fields)->where('status',1);
|
||||
if($searchtype =='id'){
|
||||
$model = $model->where('id',$keyword);
|
||||
}else{
|
||||
$model = $model->whereLike('username','%'.$keyword.'%');
|
||||
}
|
||||
$model = $model->where('id',idDecode($keyword));
|
||||
// if($searchtype =='id'){
|
||||
// $model = $model->where('id',$keyword);
|
||||
// }else{
|
||||
// $model = $model->whereLike('username|id','%'.$keyword.'%');
|
||||
// }
|
||||
$list = $model->paginate(Input('limit',10));
|
||||
$list->each(function ($item){
|
||||
$item['id'] = idEncode($item['id']);
|
||||
return $item;
|
||||
});
|
||||
//log_alert($list->toArray());
|
||||
return $this->success('ok',$list);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user