Browse Source

Merge branch 'service_evaluate' of ssh://120.24.33.109:11022/hyzjshwo/lanzu_api_hyperf into service_evaluate

master
weigang 5 years ago
parent
commit
4d8b5a0869
  1. 28
      app/Service/ServiceEvaluateService.php
  2. 4
      app/Service/ServiceEvaluateServiceInterface.php
  3. 3
      composer.json

28
app/Service/ServiceEvaluateService.php

@ -6,6 +6,7 @@ use App\Model\ServiceEvaluate;
use Hyperf\DbConnection\Db;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\Di\Annotation\Inject;
use Hyperf\Paginator\Paginator;
class ServiceEvaluateService implements ServiceEvaluateServiceInterface
{
@ -26,22 +27,35 @@ class ServiceEvaluateService implements ServiceEvaluateServiceInterface
return ServiceEvaluate::create($data);
}
public function getPersonnelInfo()
public function getPersonnelInfo($user_id)
{
$data = $this->request->all();
$res = Db::table('lanzu_service_personnel')
->where(['user_id' => $data['user_id']])
->where(['user_id' => $user_id])
->first();
return $res;
}
public function getEvaluateList()
public function getEvaluateList($service_personnel_id)
{
$data = $this->request->all();
$res = Db::table('lanzu_service_evaluate')
->where(['service_personnel_id' => $data['service_personnel_id']])
->where(['service_personnel_id' => $service_personnel_id])
->limit(4)
->get();
return $res;
// return $res;
$currentPage = 1;
$perPage = 2;
// 这里根据 $currentPage 和 $perPage 进行数据查询,以下使用 Collection 代替
// $collection = new Collection([
// ['id' => 1, 'name' => 'Tom'],
// ['id' => 2, 'name' => 'Sam'],
// ['id' => 3, 'name' => 'Tim'],
// ['id' => 4, 'name' => 'Joe'],
// ]);
//
// $users = array_values($collection->forPage($currentPage, $perPage)->toArray());
return new Paginator($res, $perPage, $currentPage);
}
}

4
app/Service/ServiceEvaluateServiceInterface.php

@ -9,8 +9,8 @@ interface ServiceEvaluateServiceInterface
public function evaluate();
public function getPersonnelInfo();
public function getPersonnelInfo($user_id);
public function getEvaluateList();
public function getEvaluateList($service_personnel_id);
}

3
composer.json

@ -27,7 +27,8 @@
"hyperf/redis": "~2.0.0",
"hyperf/constants": "~2.0.0",
"hyperf/model-cache": "~2.0.0",
"hyperf/validation": "^2.0"
"hyperf/validation": "^2.0",
"hyperf/paginator": "^2.0"
},
"require-dev": {
"swoole/ide-helper": "^4.5",

Loading…
Cancel
Save