From d6017ab11eef2467956d78c014ce3fe64370b26e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B9=BF=E6=98=8E?= Date: Fri, 27 May 2022 08:47:19 +0800 Subject: [PATCH] * Plan module order by path. --- module/story/model.php | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/module/story/model.php b/module/story/model.php index 81c32d912e..79e7c2a2a2 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2995,13 +2995,30 @@ class storyModel extends model */ public function getPlanStories($planID, $status = 'all', $orderBy = 'id_desc', $pager = null) { - $stories = $this->dao->select('distinct t1.story, t1.plan, t1.order, t2.*') - ->from(TABLE_PLANSTORY)->alias('t1') - ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') - ->where('t1.plan')->eq($planID) - ->beginIF($status and $status != 'all')->andWhere('t2.status')->in($status)->fi() - ->andWhere('t2.deleted')->eq(0) - ->orderBy($orderBy)->page($pager)->fetchAll('id'); + if(strpos($orderBy, 'module') !== false) + { + $orderBy = (strpos($orderBy, 'module_asc') !== false) ? 't3.path asc' : 't3.path desc'; + $stories = $this->dao->select('distinct t1.story, t1.plan, t1.order, t2.*') + ->from(TABLE_PLANSTORY)->alias('t1') + ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') + ->leftJoin(TABLE_MODULE)->alias('t3')->on('t2.module = t3.id') + ->where('t1.plan')->eq($planID) + ->beginIF($status and $status != 'all')->andWhere('t2.status')->in($status)->fi() + ->andWhere('t2.deleted')->eq(0) + ->orderBy($orderBy)->page($pager) + ->fetchAll('id'); + } + else + { + $stories = $this->dao->select('distinct t1.story, t1.plan, t1.order, t2.*') + ->from(TABLE_PLANSTORY)->alias('t1') + ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') + ->where('t1.plan')->eq($planID) + ->beginIF($status and $status != 'all')->andWhere('t2.status')->in($status)->fi() + ->andWhere('t2.deleted')->eq(0) + ->orderBy($orderBy)->page($pager) + ->fetchAll('id'); + } $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story', false);