fix:member
This commit is contained in:
53
app/Service/Admin/User/MemberService.php
Normal file
53
app/Service/Admin/User/MemberService.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\User;
|
||||
|
||||
use App\Constants\Admin\MemberCode;
|
||||
use App\Model\User;
|
||||
use App\Service\Admin\BaseService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
class MemberService extends BaseService{
|
||||
|
||||
#[Inject]
|
||||
protected User $userModel;
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
private array $filed = ['id','mobile','nickname','password','salt','avatar_id','gender','age','birthday','city','token','last_ip','reg_ip','last_time','create_time','update_time'];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$limit = (int)$this->request->input('limit', 10);
|
||||
|
||||
$id = (int)$this->request->input('query_id');
|
||||
$name = $this->request->input('query_name');
|
||||
$mobile = $this->request->input('query_mobile');
|
||||
$cityId = $this->request->input('query_city_id');
|
||||
|
||||
$list = $this->userModel
|
||||
->where('is_del',MemberCode::IS_NO_DEL)
|
||||
->when(!empty($id), function ($query) use ($id) {
|
||||
$query->where('id', $id);
|
||||
})
|
||||
->when(!empty($name), function ($query) use ($name) {
|
||||
$query->where('nickname', 'like', "$name%");
|
||||
})
|
||||
->when(!empty($mobile), function ($query) use ($mobile) {
|
||||
$query->where('mobile', $mobile);
|
||||
})
|
||||
->when(!empty($cityId), function ($query) use ($cityId) {
|
||||
$query->where('city_id', $cityId);
|
||||
})
|
||||
->paginate($limit,$this->filed)
|
||||
->toArray();
|
||||
|
||||
return $this->return->success('success',$list);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user