You've already forked qlg.tsgz.moe
							
							
		
			
				
	
	
		
			62 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
<?php
 | 
						|
namespace wstmart\app\model;
 | 
						|
use think\Db;
 | 
						|
/**
 | 
						|
 * ============================================================================
 | 
						|
 *  文章类
 | 
						|
 */
 | 
						|
class Articles extends Base{
 | 
						|
	/**
 | 
						|
	* 获取资讯中心的子集分类id
 | 
						|
	*/
 | 
						|
	public function getChildIds(){
 | 
						|
		$ids = cache('NEW_IDS');
 | 
						|
		if(!$ids){
 | 
						|
			$data = Db::name('article_cats')->cache(true)->select();
 | 
						|
			foreach($data as $k=>$v){
 | 
						|
				if($v['parentId']!=7 && $v['catId']!=7 && $v['parentId']!=0 ){
 | 
						|
					$ids[] = $v['catId'];
 | 
						|
				}
 | 
						|
			}
 | 
						|
            cache('NEW_IDS',$ids);
 | 
						|
		}
 | 
						|
		return $ids;
 | 
						|
	}
 | 
						|
 | 
						|
	/**
 | 
						|
	* 获取咨询中中心所有文章
 | 
						|
	*/
 | 
						|
	public function getArticles(){
 | 
						|
		// 获取咨询中心下的所有分类id
 | 
						|
		$ids = $this->getChildIds();
 | 
						|
		$rs = $this->alias('a')
 | 
						|
			  ->field('a.*')
 | 
						|
			  ->join('__ARTICLE_CATS__ ac','a.catId=ac.catId','inner')
 | 
						|
			  ->where(['a.catId'=>['in',$ids],
 | 
						|
			  	       'a.isShow'=>1,
 | 
						|
			  	       'a.dataFlag'=>1,
 | 
						|
			  		   'ac.dataFlag'=>1,
 | 
						|
			  		   'ac.isShow'=>1,
 | 
						|
			  		   'ac.catType'=>0,
 | 
						|
			  		   ])
 | 
						|
			  ->order('createTime desc')
 | 
						|
			  ->paginate((int)input('pagesize'));
 | 
						|
		return $rs;
 | 
						|
	}
 | 
						|
 | 
						|
 | 
						|
	/**
 | 
						|
	*  根据id获取资讯文章
 | 
						|
	*/
 | 
						|
	public function getNewsById(){
 | 
						|
		$id = (int)input('id');
 | 
						|
		WSTArticleVisitorNum($id);// 统计文章访问量
 | 
						|
		return $this->alias('a')
 | 
						|
					->field('a.*')
 | 
						|
					->join('__ARTICLE_CATS__ ac','a.catId=ac.catId','inner')
 | 
						|
					->where('ac.catType=0 and a.dataFlag=1 and a.isShow=1')
 | 
						|
					->cache(true)
 | 
						|
					->find($id);
 | 
						|
	}
 | 
						|
}
 |