Commit cd107fe0 authored by zhoujun's avatar zhoujun

图片上传

parent 16233d1f
......@@ -278,6 +278,8 @@ class CardController extends Controller
public function getUploadImg(Request $request)
{
$userId = $request->session()->get("uid");
$roleId = $request->input('roleId');
$serverId = $request->input('serverId');
$result = $this->getVerityLogin($userId);
if($result['code'] != 200) return $this->jsonReturn($result['code'], $result['msg']);
$postData = $request->all();
......@@ -286,8 +288,10 @@ class CardController extends Controller
$upload = new UploadServer();
$result = $upload->getUpload($postData,$file);
if($result['code'] != 200) return $this->jsonReturn($result['code'], $result['msg']);
$img = $this->getUpdateImg($result['data'],$userId);
$tableName = 'wx_card_role_'.$serverId;
$role = DB::connection('wx_mysql')->table($tableName)->where('uid',$userId)->where('role_id',$roleId)->select('id')->first();
$img = $this->getUpdateImg($result['data'],$userId,$role->id);
if($img) return $this->jsonReturn(0, '上传成功',['src'=>$result['data']]);
return $this->jsonReturn(10060, '上传失败');
}
......@@ -299,9 +303,9 @@ class CardController extends Controller
* @date 2021/06/01
* @author live
*/
public function getUpdateImg($data,$userId)
public function getUpdateImg($data,$userId,$roleId)
{
$img = WxUserImg::where('uid',$userId)->first();
$img = WxUserImg::where('uid',$userId)->where('role_id',$roleId)->first();
if($img){
$img->loacl_url = $data['url'];
$img->img_url = $data['yunUrl'];
......@@ -310,6 +314,7 @@ class CardController extends Controller
}else{
$row = new WxUserImg();
$row->uid = $userId;
$row->role_id = $roleId;
$row->loacl_url = $data['url'];
$row->img_url = $data['yunUrl'];
$row->status = 0;
......@@ -338,7 +343,7 @@ class CardController extends Controller
$user = User::where('uid',$userId)->select('uid','account')->first();
$data['userName'] = $user->account ?? '';
$img = WxUserImg::where('uid',$userId)->select('id','img_url','status')->first();
$img = WxUserImg::where('uid',$userId)->where('role_id',$info->id)->select('id','img_url','status')->first();
if($img){
$data['userImgStatus'] = $img->status;
$data['userImg'] = $img->img_url;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment