|
@@ -135,7 +135,7 @@ class ActionBar extends Model
|
|
|
$uid = $params["uid"];
|
|
|
|
|
|
// 收集当前用户有权限的bar_id
|
|
|
- $userActionBar = new UserActionBar();
|
|
|
+ $userActionBar = new UserActionBarController();
|
|
|
$bar_ids = $userActionBar->ListActionBarIds($uid);
|
|
|
if (count($bar_ids) == 0) {
|
|
|
return [];
|
|
@@ -151,74 +151,4 @@ class ActionBar extends Model
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class UserActionBar extends Model
|
|
|
-{
|
|
|
- protected $table = "user_action_bars";
|
|
|
- public $timestamps = false;
|
|
|
-
|
|
|
- public function AddUserActionBar($uid, $barId)
|
|
|
- {
|
|
|
- if ($uid == "") {
|
|
|
- return "empty user id";
|
|
|
- }
|
|
|
- if ($barId == "") {
|
|
|
- return "empty action bar id";
|
|
|
- }
|
|
|
-
|
|
|
- //INSERT INTO demo_in(a,b,c) SELECT 123, 2, 4 FROM DUAL WHERE NOT EXISTS(SELECT c FROM demo_in WHERE c = 4);
|
|
|
- $sql = sprintf("insert into user_action_bars(user_id, bar_id)
|
|
|
- select ?, ? from temp_uab
|
|
|
- where not exists(
|
|
|
- select id from user_action_bars
|
|
|
- where user_id = ? and bar_id = ? and is_del = false);");
|
|
|
-
|
|
|
- $result = DB::insert($sql, [$uid, $barId, $uid, $barId]);
|
|
|
- Log::debug("AddUserActionBar " . $result);
|
|
|
- return "success";
|
|
|
- }
|
|
|
-
|
|
|
- public function RemoveUserActionBar($uid, $barId)
|
|
|
- {
|
|
|
- if ($uid == "") {
|
|
|
- return "empty user id";
|
|
|
- }
|
|
|
- if ($barId == "") {
|
|
|
- return "empty action bar id";
|
|
|
- }
|
|
|
-
|
|
|
- $data = $this->where("user_id", $uid)
|
|
|
- ->where("bar_id", $barId)
|
|
|
- ->where("is_del", false)
|
|
|
- ->first();
|
|
|
- if (!$data) {
|
|
|
- return "nothing to remove";
|
|
|
- }
|
|
|
- $this->is_del = true;
|
|
|
- $this->where("user_id", $uid)
|
|
|
- ->where("bar_id", $barId)
|
|
|
- ->where("is_del", false)
|
|
|
- ->update(["is_del" => true]);
|
|
|
- return "success";
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * @param $uid
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function ListActionBarIds($uid)
|
|
|
- {
|
|
|
- $bars = $this->select("bar_id")
|
|
|
- ->where("user_id", $uid)
|
|
|
- ->where("status", "normal")
|
|
|
- ->where("is_del", false)
|
|
|
- ->get();
|
|
|
- if (count($bars) == 0) {
|
|
|
- return [];
|
|
|
- }
|
|
|
- $bar_ids = [];
|
|
|
- foreach ($bar_ids as $bar_id) {
|
|
|
- array_push($bar_ids, $bar_id->bar_id);
|
|
|
- }
|
|
|
- return $bar_ids;
|
|
|
- }
|
|
|
-}
|