<?php

namespace App\Http\Controllers\API\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\Admin\UserService;

class UserController extends Controller
{
    public function GetInfoList(){
        $page =request('page');
        $pagesize =request('pageSize');
        $s=app()->make(UserService::class);
        return  $s->GetInfoList(['page'=>$page,'pagesize'=>$pagesize]);
    }
    public function Save(){
        $userInfo =request('userInfo');
        $s=app()->make(UserService::class);
        return  $s->Save(['info'=>$userInfo]);
    }
    public function GetDetail(){
        $id =request('id');
        $s=app()->make(UserService::class);
        return  $s->GetDetail(['id'=>$id]);
    }
    public function ChangePwd(Request $request){  //admin修改密码
        $userid = $request->get('userid');//中间件产生的参数
        $oldpwd =request('oldpwd');
        $newpwd =request('newpwd');
        if($oldpwd and $newpwd){
            $s=app()->make(UserService::class);
            return  $s->ChangePwd(['id'=>$userid,'oldpwd'=>$oldpwd,'newpwd'=>$newpwd]);
        }else{
            return \Yz::echoError("参数不完整");
        }

    }
}
