diff --git a/app/Http/Controllers/CronController.php b/app/Http/Controllers/CronController.php index 39f19b44..0c7f8314 100755 --- a/app/Http/Controllers/CronController.php +++ b/app/Http/Controllers/CronController.php @@ -44,7 +44,7 @@ class CronController // $h = "00"; //// test end - if ($h == "00") { + if ($h == "00" && $i== "00") { $iFireWarningLine = ModelBookOption::_hit("fire_warning_line"); diff --git a/app/Http/Controllers/SakaiController.php b/app/Http/Controllers/SakaiController.php index 31edaac0..d3e50bf5 100755 --- a/app/Http/Controllers/SakaiController.php +++ b/app/Http/Controllers/SakaiController.php @@ -319,7 +319,15 @@ class SakaiController $s = "/book#main"; $s = "/book#up__3"; $s = "/book#main"; - $s = "firel"; + $s = "/book#unlike"; +// $s = "firel"; +// $s = "likeg__4 s"; +// $s = "like ss"; +// $s = "checkId 20"; + + + + // $s = "war 8"; // $s = "no 9"; // $s = "detail__all 1"; diff --git a/app/Models/Book.php b/app/Models/Book.php index 98577d6a..206c0f4f 100755 --- a/app/Models/Book.php +++ b/app/Models/Book.php @@ -83,43 +83,88 @@ class Book extends Model // where if ($iPage !== "all") { - // sort覆盖特殊规则 + // dir特殊 if ($oParentRag->type == "dir") { if (!empty($oParentRag->sort)) { $aSort = explode("_", $oParentRag->sort); -// tomd($aSort, 1); -// self::where("path", $sPath)->where("is_del", $iIsDel); $oSelf = $oSelf->orWhere("path", $oParentRag->path); $oSelf = $oSelf->where($aSort[0], $aSort[1]); } - } else if ($oParentRag->sort) { + } else if ($oParentRag->type == "todo") { - $aSort = explode("_", $oParentRag->sort); - $oSelf = $oSelf->where($aSort[0], $aSort[1]); + $sTodoShowRank = BookOption::_hit("todo_show_rank"); + $aTodoShowRank = explode(",", $sTodoShowRank); + $oSelf = $oSelf->where(function($query) use ($aTodoShowRank) { + $query->whereIn("rank", $aTodoShowRank) + ->orWhereNull("rank"); + }); + + } + + if (isset($aRagOption["where"])) { + + $oSelf = $oSelf->whereRaw($aRagOption["where"]); } else { - if (isset($aRagOption["where"])) { - $oSelf = $oSelf->whereRaw($aRagOption["where"]); - } - - if ($oParentRag->type == "todo") { + if ($oParentRag->sort) { - $sTodoShowRank = BookOption::_hit("todo_show_rank"); - $aTodoShowRank = explode(",", $sTodoShowRank); - $oSelf = $oSelf->where(function($query) use ($aTodoShowRank) { - $query->whereIn("rank", $aTodoShowRank) - ->orWhereNull("rank"); - }); + $aSort = explode("_", $oParentRag->sort); + $oSelf = $oSelf->where($aSort[0], $aSort[1]); + + } if ($oParentRag->like) { + + $oSelf = $oSelf->where("rag", "like", "%".$oParentRag->like."%"); } } + + + + + + + // sort覆盖特殊规则 +// if ($oParentRag->type == "dir") { +// +// if (!empty($oParentRag->sort)) { +// +// $aSort = explode("_", $oParentRag->sort); +// $oSelf = $oSelf->orWhere("path", $oParentRag->path); +// $oSelf = $oSelf->where($aSort[0], $aSort[1]); +// +// } +// +// } else if ($oParentRag->sort) { +// +// $aSort = explode("_", $oParentRag->sort); +// $oSelf = $oSelf->where($aSort[0], $aSort[1]); +// +// } else { +// +// if (isset($aRagOption["where"])) { +// $oSelf = $oSelf->whereRaw($aRagOption["where"]); +// } +// +// if ($oParentRag->type == "todo") { +// +// $sTodoShowRank = BookOption::_hit("todo_show_rank"); +// $aTodoShowRank = explode(",", $sTodoShowRank); +// $oSelf = $oSelf->where(function($query) use ($aTodoShowRank) { +// $query->whereIn("rank", $aTodoShowRank) +// ->orWhereNull("rank"); +// }); +// +// } +// +// } + } @@ -127,25 +172,14 @@ class Book extends Model if ($oParentRag->order == "rank_todo") { $sOrderRank = BookOption::_hit("order_rank_todo"); -// $aTodoOrder = explode(",", $sTodoOrder); -// $sTodoOrder = implode(",", array_reverse($aTodoOrder)); -// -// $oSelf = $oSelf->orderByRaw("FIELD(rank, " . $sTodoOrder . ") DESC, (rank IS NULL) ASC"); -// $oSelf = $oSelf->orderByRaw("fire DESC, (fire IS NULL) ASC"); -// -// $sOrder = "no"; -// $sOrderType = "asc"; // 默认也rank排序 } else { $sOrderRank = BookOption::_hit("order_rank"); - -// tomd($sOrderRank, 1); } -// $sOrderRank = BookOption::_hit("order_rank_todo"); $aOrderRank = explode(",", $sOrderRank); $sOrderRank = implode(",", array_reverse($aOrderRank)); @@ -159,7 +193,7 @@ class Book extends Model $oSelf = $oSelf->orderBy($sOrder, $sOrderType); $oSelf = $oSelf->orderBy("updated_at", "desc"); - +// tomd($oSelf->toSql(), 1); if ($iPage == "all") { $oSelf = $oSelf->get(); @@ -169,7 +203,7 @@ class Book extends Model $oSelf = $oSelf->paginate($iLimit, ['*'], 'page', $iPage); } - + return $oSelf; } diff --git a/app/Services/TG/Hook/Mod/Book.php b/app/Services/TG/Hook/Mod/Book.php index bf2440ac..2480befc 100644 --- a/app/Services/TG/Hook/Mod/Book.php +++ b/app/Services/TG/Hook/Mod/Book.php @@ -156,15 +156,6 @@ class Book extends Base { } //// 展开 系列 end - //// like 系列 - public function like($aParam) - { - $this->_cd("like"); - - return $this->open(); - } - //// like 系列 end - //// 全局option 系列 public function g_option($aParam) { @@ -341,7 +332,8 @@ class Book extends Base { // tomd($sPath); $aMap = [ "mian" => 1, - "firel" => 2, + "firel" => 2, + "like" => 3, "/" => 1, ]; // tomd($aMap[$sPath], 1); @@ -1610,7 +1602,7 @@ class Book extends Base { $sWarningLine = ModelBookOption::_hit("fire_warning_line"); - $this->aOption["show_id"] = true; + $this->aRagOption["show_id"] = true; $this->aRagOption["is_shadow_list"] = true; @@ -1807,6 +1799,55 @@ class Book extends Base { $this->_noToId([1, 2]); } + //// like 系列 + public function like($aParam) + { + $v = $aParam["aArg"][1]; + + $oRagParent = $this->_getParentRag(); + $oRagParent->like = $v; + $oRagParent->save(); + + return $this->openRe(); + } + + public function unlike() + { + $oRagParent = $this->_getParentRag(); + $oRagParent->like = NULL; + $oRagParent->save(); + + return $this->openRe(); + } + + public function _like($k, $v) + { +// $oBook = ModelBook::where($k, "like", "%".$v."%")->get(); + +// $this->_cd("like"); +// +// return $this->open(); + } + + public function likeg($aParam) + { + $iPage = $aParam["aOption"][1] ?? 1; + $sValue = $aParam["aArg"][1] ?? false; + + $iOptionLimit = ModelBookOption::_hit("global_like_limit"); + + $iRowStart = ($iPage - 1) * $iOptionLimit; + + $oBook = ModelBook::where("rag", "like", "%".$sValue."%")->offset($iRowStart)->limit($iOptionLimit)->get(); + + $this->aRagOption["is_shadow_list"] = true; + + $this->aRagOption["show_id"] = true; + + return $this->bookToStr($oBook); + } + //// like 系列 end + //// rank系列 // book#rank__1__3 2 // book#rank 2 @@ -2121,7 +2162,7 @@ class Book extends Base { $sStr .= "\n"; - if ($iDeep == 0) { + if ($iDeep == 0 || isset($this->aRagOption["is_shadow_list"])) { $sStr .= "\n"; } @@ -2129,12 +2170,12 @@ class Book extends Base { $sStr .= $this->_deepToStr($iDeep); } - if (@$this->aOption["show_id"]) { - $sStr .= $oRag->id."-"; + if (isset($this->aRagOption["show_id"])) { + $sStr .= "i".$oRag->id; + } else { + $sStr .= $oRag->no; } - $sStr .= $oRag->no; - if ($oRag->checked >= 1) { $sStr .= ":🎯"; }