|
@@ -52,54 +52,64 @@ class UserActionBar extends Model
|
|
|
return ["code" => SUCCESS, "data" => $new_data];
|
|
|
}
|
|
|
|
|
|
- private function checkActionBar($barId)
|
|
|
- {
|
|
|
- return SUCCESS;
|
|
|
- }
|
|
|
-
|
|
|
- private function checkOwner($ownerType, $ownerId)
|
|
|
- {
|
|
|
- return SUCCESS;
|
|
|
- }
|
|
|
-
|
|
|
- public function RemoveUserActionBar($id)
|
|
|
+ /**
|
|
|
+ * 根据多个类型,和多个id,加载菜单栏信息
|
|
|
+ *
|
|
|
+ * @param array $ownerTypes
|
|
|
+ * @param array $ownerIds
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function ListActionBarIds(array $ownerTypes, array $ownerIds)
|
|
|
{
|
|
|
- if ($id < 1) {
|
|
|
- return INVALID_U_A_ID;
|
|
|
+ $opera = $this->select("owner_type", "owner_id", "bar_id");
|
|
|
+ if (count($ownerTypes) > 0) {
|
|
|
+ $opera = $opera->whereIn("owner_type", $ownerTypes);
|
|
|
+ }
|
|
|
+ if (count($ownerIds) > 0) {
|
|
|
+ $opera = $opera->whereIn("owner_id", $ownerIds);
|
|
|
}
|
|
|
- // check the data if exist in system.
|
|
|
-// $item = $this->where("id", $id)->where("is_del", false)->first();
|
|
|
-// if (!$item) {
|
|
|
-// return INVALID_U_A_ID;
|
|
|
-// }
|
|
|
-
|
|
|
- $row = $this->where("id", $id)->where("is_del", false)->update(["is_del" => true]);
|
|
|
- if ($row == 0) {
|
|
|
- return INVALID_GROUP_ID;
|
|
|
+ $userBars = $opera->where("is_del", false)->get();
|
|
|
+ if (count($userBars) == 0) {
|
|
|
+ return ["useBars" => []];
|
|
|
}
|
|
|
- return SUCCESS;
|
|
|
+ $barIds = [];
|
|
|
+ foreach ($userBars as $bar) {
|
|
|
+ array_push($barIds, $bar["bar_id"]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 加载actionBar 的信息
|
|
|
+ $bar = new ActionBar();
|
|
|
+ $barInfo = $bar->LoadActionBarByIds_Format($barIds);
|
|
|
+
|
|
|
+ return ["userBars" => $userBars, "barInfo" => $barInfo];
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param $ownerType
|
|
|
- * @param $ownerId
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function ListActionBarIds($ownerType, $ownerId)
|
|
|
+ public function ListActionBarIds_Format(array $ownerTypes, array $ownerIds)
|
|
|
{
|
|
|
- $opera = $this->select("bar_id");
|
|
|
- if ($ownerType != "") {
|
|
|
- $opera = $opera->where("owner_type", $ownerType);
|
|
|
+ $data = $this->ListActionBarIds($ownerTypes, $ownerIds);
|
|
|
+
|
|
|
+ $userBars = $data["userBars"];
|
|
|
+ if (count($userBars) < 1) {
|
|
|
+ return ["userBars" => (object)[]];
|
|
|
}
|
|
|
- $bars = $opera->where("owner_id", $ownerId)->where("status", "normal")->where("is_del", false)->get();
|
|
|
- if (count($bars) == 0) {
|
|
|
- return [];
|
|
|
+
|
|
|
+ $userBarFormat = [];
|
|
|
+ foreach ($userBars as $userBar) {
|
|
|
+ $key = $userBar["owner_id"];
|
|
|
+ if (!key_exists($userBar["owner_id"], $userBarFormat)) {
|
|
|
+ $userBarFormat[$key] = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ $tempArr = $userBarFormat[$key];
|
|
|
+ array_push($tempArr, $userBar);
|
|
|
+ $userBarFormat[$key] = $tempArr;
|
|
|
}
|
|
|
- $bar_ids = [];
|
|
|
- foreach ($bars as $bar) {
|
|
|
- array_push($bar_ids, $bar["bar_id"]);
|
|
|
+
|
|
|
+ $result = ["userBars" => $userBarFormat, "barInfo" => (object)[]];
|
|
|
+ if (key_exists("barInfo", $data)) {
|
|
|
+ $result["barInfo"] = $data["barInfo"];
|
|
|
}
|
|
|
- Log::debug("========" . json_encode($bar_ids));
|
|
|
- return $bar_ids;
|
|
|
+
|
|
|
+ return $result;
|
|
|
}
|
|
|
}
|