作者 杨育虎

ok

@@ -76,8 +76,10 @@ class Article extends Api @@ -76,8 +76,10 @@ class Article extends Api
76 public function getArticleList() 76 public function getArticleList()
77 { 77 {
78 $myId = $this->auth->id; 78 $myId = $this->auth->id;
  79 + $myId = 25;
79 80
80 $universityId = $this->request->param('university_id', 0, 'int'); 81 $universityId = $this->request->param('university_id', 0, 'int');
  82 + $universityId = 892;
81 83
82 $collegeId = $this->request->param('college_id', 0, 'int'); 84 $collegeId = $this->request->param('college_id', 0, 'int');
83 85
@@ -97,22 +99,18 @@ class Article extends Api @@ -97,22 +99,18 @@ class Article extends Api
97 $type = bcadd($studentInfo['vip_level'], 1, 0); 99 $type = bcadd($studentInfo['vip_level'], 1, 0);
98 $schoolIds = []; 100 $schoolIds = [];
99 // 获取学长 101 // 获取学长
100 - if($type = 1) { 102 + if($type == 1) {
101 $schoolIds = [$studentInfo['school_id']]; 103 $schoolIds = [$studentInfo['school_id']];
102 - } elseif ($type = 2) { 104 + } elseif ($type == 2) {
103 $school = new School(); 105 $school = new School();
104 $schoolInfo = $school->infoById($studentInfo['school_id']); 106 $schoolInfo = $school->infoById($studentInfo['school_id']);
105 $schoolIds = $school->listByCityId($schoolInfo['city_id']); 107 $schoolIds = $school->listByCityId($schoolInfo['city_id']);
106 - } elseif ($type = 3) { 108 + } elseif ($type == 3) {
107 $school = new School(); 109 $school = new School();
108 $schoolInfo = $school->infoById($studentInfo['school_id']); 110 $schoolInfo = $school->infoById($studentInfo['school_id']);
109 $schoolIds = $school->listByProvinceId($schoolInfo['province_id']); 111 $schoolIds = $school->listByProvinceId($schoolInfo['province_id']);
110 } 112 }
111 113
112 - if($schoolIds) {  
113 - $where['b.school_id'] = ['in', $schoolIds];  
114 - }  
115 -  
116 if($universityId) { 114 if($universityId) {
117 $where['b.university_id'] = ['=', $universityId]; 115 $where['b.university_id'] = ['=', $universityId];
118 } 116 }
@@ -129,9 +127,11 @@ class Article extends Api @@ -129,9 +127,11 @@ class Article extends Api
129 $where['a.user_id'] = ['=', $userId]; 127 $where['a.user_id'] = ['=', $userId];
130 } 128 }
131 129
  130 + $where['a.deletetime'] = null;
  131 +
132 // 获取文章 132 // 获取文章
133 $article = new ArticleModel(); 133 $article = new ArticleModel();
134 - $articleList = $article->listByWhere($where, $page, $size, $studentInfo['school_id']); 134 + $articleList = $article->listByWhere($where, $page, $size, $schoolIds);
135 if(!$articleList) { 135 if(!$articleList) {
136 $this->success('获取大学或学院的文章成功', $articleList); 136 $this->success('获取大学或学院的文章成功', $articleList);
137 } 137 }
@@ -17,18 +17,17 @@ class Article extends Model @@ -17,18 +17,17 @@ class Article extends Model
17 17
18 18
19 // 根据条件获取文章 19 // 根据条件获取文章
20 - public function listByWhere($where, $page, $size, $schoolId) 20 + public function listByWhere($where, $page, $size, $schoolIds)
21 { 21 {
  22 + $schoolIds = implode(',', $schoolIds);
22 $data = $this 23 $data = $this
23 ->alias('a') 24 ->alias('a')
24 ->field('a.*, b.user_id, b.level, b.nickname, b.head_image, b.school_id, b.subject_ids, b.up_id, b.college_id, b.university_id, b.graduated_id, b.starttime, b.endtime, b.show_switch, b.email, b.vip_level, b.vip_endtime') 25 ->field('a.*, b.user_id, b.level, b.nickname, b.head_image, b.school_id, b.subject_ids, b.up_id, b.college_id, b.university_id, b.graduated_id, b.starttime, b.endtime, b.show_switch, b.email, b.vip_level, b.vip_endtime')
25 ->join('student b', 'a.user_id = b.user_id') 26 ->join('student b', 'a.user_id = b.user_id')
26 - ->where(function ($query) use ($schoolId) {  
27 - $query  
28 - ->where(' (a.show_type = 1 and b.school_id = '.$schoolId.') or a.show_type = 2');  
29 - })  
30 ->where($where) 27 ->where($where)
31 - ->useSoftDelete('a.'.$this->deleteTime) 28 + ->where(' (b.school_id in ('.$schoolIds.') and a.show_type = 1) or a.show_type = 2 ')
  29 +// ->where(['b.school_id' => ['in', $schoolIds], 'a.show_type' => ['=', 1]])
  30 +// ->whereor('1=1')
32 ->order('a.createtime', 'desc') 31 ->order('a.createtime', 'desc')
33 ->page($page, $size) 32 ->page($page, $size)
34 ->select(); 33 ->select();