|
@@ -477,10 +477,15 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
*/
|
|
|
public function getDepartment(array $data): array
|
|
|
{
|
|
|
- $where = [
|
|
|
- 'pid' => $data['pid'] ?? 0,
|
|
|
- ];
|
|
|
- $result = Department::where($where)->orderBy("sort", "desc")->get();
|
|
|
+ $where = [];
|
|
|
+ if(isset($data['pid'])){
|
|
|
+ $where = [
|
|
|
+ 'pid'=>$data['pid']??0
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $result = Department::when(!empty($where),function ($query) use ($where){
|
|
|
+ $query->where($where);
|
|
|
+ })->orderBy("sort","desc")->get();
|
|
|
if (empty($result)) {
|
|
|
return Result::error("查询失败", 0);
|
|
|
} else {
|