...
|
...
|
@@ -15,13 +15,12 @@ class Article extends Model |
|
|
protected $deleteTime = 'deletetime';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据条件获取文章
|
|
|
public function listByWhere($where, $page, $size, $schoolId)
|
|
|
{
|
|
|
return $this
|
|
|
->alias('a')
|
|
|
->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')
|
|
|
->join('student b', 'a.user_id = b.user_id')
|
|
|
->where(function ($query) use ($schoolId) {
|
|
|
$query
|
...
|
...
|
@@ -34,33 +33,12 @@ class Article extends Model |
|
|
->select();
|
|
|
}
|
|
|
|
|
|
// 根据用户ID获取文章
|
|
|
public function listByUserIdAndShowType($page, $size, $userId, $showType)
|
|
|
{
|
|
|
return $this
|
|
|
->where(['show_switch' => ['=', 1], 'show_type' => ['in', $showType], 'user_id' => ['=', $userId]])
|
|
|
->order('createtime', 'desc')
|
|
|
->useSoftDelete($this->deleteTime)
|
|
|
->page($page, $size)
|
|
|
->select();
|
|
|
}
|
|
|
|
|
|
// 根据用户ID获取文章
|
|
|
public function listByUserIdAndShowTypeAndTypeId($page, $size, $userId, $showType, $typeId)
|
|
|
{
|
|
|
return $this
|
|
|
->where(['show_switch' => ['=', 1], 'show_type' => ['in', $showType], 'user_id' => ['=', $userId], 'article_type_id' => ['=', $typeId]])
|
|
|
->order('createtime', 'desc')
|
|
|
->useSoftDelete($this->deleteTime)
|
|
|
->page($page, $size)
|
|
|
->select();
|
|
|
}
|
|
|
|
|
|
// 获取文章详细
|
|
|
public function infoById($id)
|
|
|
{
|
|
|
return $this
|
|
|
->alias('a')
|
|
|
->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')
|
|
|
->join('student b', 'a.user_id = b.user_id')
|
|
|
->where(['a.id' => ['=', $id], 'a.show_switch' => ['=', 1]])
|
|
|
->useSoftDelete('a.'.$this->deleteTime)->find();
|
...
|
...
|
@@ -77,4 +55,16 @@ class Article extends Model |
|
|
{
|
|
|
return $this->where(['user_id' => ['=', $userId]])->page($page, $size)->order($this->createTime, 'desc')->select();
|
|
|
}
|
|
|
|
|
|
// 获取
|
|
|
public function infoByIdNoWhere($articleId)
|
|
|
{
|
|
|
return $this->where(['id' => ['=', $articleId]])->find();
|
|
|
}
|
|
|
|
|
|
// 删除某个文章
|
|
|
public function delOne($articleId, $data)
|
|
|
{
|
|
|
return $this->where(['id' => ['=', $articleId]])->update($data);
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|