1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\mainapp\controller;
- use think\facade\Session;
- use app\mainapp\BaseController;
- use app\common\model\Question as QuestionModel;
- use app\common\model\QuestionCate as QuestionCateModel;
- class Question extends BaseController
- {
- // 详情
- public function getQuestion()
- {
- $questionid = input('questionid/d', 0);
- $question = QuestionModel::with('questionCate')->append(['createtime_text'])->findOrEmpty($questionid);
- if ($question->isEmpty()){
- page_result(1, "通知公告信息不存在");
- }
- $question->volume += 1;
- $question->save();
- page_result(0, "", array(
- 'question' => $question
- ));
- }
-
- // 列表
- public function listQuestion()
- {
- $ppage = input('ppage/d', 1);
- $psize = input('psize/d', 20);
- $map[] = ['status','=',1];
- $cateid = input('cateid/d');
- if ($cateid!=0){
- $map[] = ['cateid', '=', $cateid];
- }
- $plist = QuestionModel::with('questionCate')->where($map)->order(['priority'=>'desc','id'=>'desc'])->page($ppage)->limit($psize)->append(['createtime_text'])->select();
- page_result(0, "", array(
- 'plist' => $plist,
- 'pstatus' => $psize > count($plist) ? 'noMore' : 'more'
- ));
- }
- // 全部分类
- public function allCate()
- {
- $allcate = QuestionCateModel::where('status',1)->order(['priority'=>'desc','id'=>'desc'])->select()->toArray();
- array_unshift( $allcate, array('id'=>0,'title'=>'全部') );
- page_result(0, "", array('allcate'=>$allcate));
- }
- }
|