作者 何书鹏
1 个管道 的构建 通过 耗费 0 秒

合并分支 'heshupeng' 到 'master'

论坛话题



查看合并请求 !6
... ... @@ -53,7 +53,6 @@ class Course extends Api
* @ApiTitle (课程-首页)
* @ApiSummary (课程-首页)
* @ApiMethod (POST)
* @ApiParams (name="forum_category_id", type="inter", required=false, description="话题分类ID")
* @ApiParams (name="order", type="inter", required=false, description="排序方式:0=综合排序,1=按学习人数,2=价格从低到高,3=价格从高到低")
* @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
* @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
... ...
... ... @@ -4,15 +4,15 @@ namespace app\mobile\controller;
use think\Validate;
use think\Db;
use app\common\controller\Api;
use app\mobile\model\Forum as ForumModel;
use app\mobile\model\ForumCategory;
use app\mobile\model\Topic as TopicModel;
use app\mobile\model\TopicCategory;
use app\common\model\Attachment;
/**
* 论坛接口
* @ApiWeigh (92)
*/
class Forum extends Api
class Topic extends Api
{
protected $noNeedLogin = ['index','info'];
protected $noNeedRight = ['*'];
... ... @@ -40,9 +40,9 @@ class Forum extends Api
}]
})
*/
public function forumCategory()
public function topicCategory()
{
$list = ForumCategory::order('createtime desc')
$list = TopicCategory::order('createtime desc')
->field('id,name')
->select();
$this->success('成功',$list);
... ... @@ -54,7 +54,7 @@ class Forum extends Api
* @ApiSummary (发帖)
* @ApiMethod (POST)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="forum_category_id", type="inter", required=false, description="话题分类ID")
* @ApiParams (name="topic_category_id", type="inter", required=false, description="话题分类ID")
* @ApiParams (name="title", type="string", required=false, description="标题")
* @ApiParams (name="content", type="string", required=false, description="话题内容")
* @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
... ... @@ -74,10 +74,10 @@ class Forum extends Api
public function topicAdd()
{
$post = $this->request->param();
empty($post['forum_category_id']) && $this->error('请选择话题分类');
empty($post['topic_category_id']) && $this->error('请选择话题分类');
empty($post['title']) && $this->error('请输入标题');
empty($post['content']) && $this->error('请填写话题内容');
ForumModel::create(array_merge([
TopicModel::create(array_merge([
'user_id' => $this->auth->id
],$post),true);
$this->success('发帖成功');
... ... @@ -87,7 +87,7 @@ class Forum extends Api
* @ApiTitle (论坛-首页)
* @ApiSummary (论坛-首页)
* @ApiMethod (POST)
* @ApiParams (name="forum_category_id", type="inter", required=false, description="话题分类ID")
* @ApiParams (name="topic_category_id", type="inter", required=false, description="话题分类ID")
* @ApiParams (name="order", type="inter", required=false, description="排序方式:0=最新,1=热门,2=下载量")
* @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
* @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
... ... @@ -106,12 +106,12 @@ class Forum extends Api
*/
public function index()
{
$forum_category_id = $this->request->param('forum_category_id');
$topic_category_id = $this->request->param('topic_category_id');
$order = $this->request->param('order',0);
$page = $this->request->param('page', 1, 'intval');
$page_num = $this->request->param('page_num', 10, 'intval');
if(empty($forum_category_id)){
$where['forum_category_id'] = $forum_category_id;
if(empty($topic_category_id)){
$where['topic_category_id'] = $topic_category_id;
}else{
$where['is_recommend'] = '1';
}
... ... @@ -126,7 +126,7 @@ class Forum extends Api
$order = ['download_num' => 'desc'];
break;
}
$data = ForumModel::with(['user'])
$data = TopicModel::with(['user'])
->where($where)
->order($order)
->paginate($page_num,false,['page'=>$page])
... ... @@ -163,11 +163,11 @@ class Forum extends Api
*/
public function searchKeyword()
{
$history_list = Db::name('mobile_forum_keyword')
$history_list = Db::name('mobile_topic_keyword')
->where('user_id',$this->auth->id)
->limit(10)
->select();
$hot_list = Db::name('mobile_forum_keyword_hot')
$hot_list = Db::name('mobile_topic_keyword_hot')
->limit(10)
->select();
$this->success('成功',compact('history_list','hot_list'));
... ... @@ -204,7 +204,7 @@ class Forum extends Api
$page = $this->request->param('page', 1, 'intval');
$page_num = $this->request->param('page_num', 10, 'intval');
empty($keyword) && $this->error('请输入关键词');
$data = ForumModel::with(['user'])
$data = TopicModel::with(['user'])
->where('title','like','%'.$keyword.'%')
->order(['hot_num'=>'desc'])
->paginate($page_num,false,['page'=>$page])
... ... @@ -221,7 +221,7 @@ class Forum extends Api
* @ApiSummary (话题详情)
* @ApiMethod (POST)
*
* @ApiParams (name="forum_id", type="int", required=true, description="话题ID")
* @ApiParams (name="topic_id", type="int", required=true, description="话题ID")
*
* @ApiReturn({
"code": 1,
... ... @@ -241,9 +241,9 @@ class Forum extends Api
*/
public function info()
{
$forum_id = $this->request->param('forum_id');
empty($forum_id) && $this->error('缺少必要参数');
$info = ForumModel::get($forum_id,['user']);
$topic_id = $this->request->param('topic_id');
empty($topic_id) && $this->error('缺少必要参数');
$info = TopicModel::get($topic_id,['user']);
if(!empty($info)){
$info->visible(['id','title','content','createtime','agree_num','download_num','user']);
$info->createtime = date('Y.m.d H:i',$info['createtime']);
... ... @@ -266,7 +266,7 @@ class Forum extends Api
* @ApiSummary (下载)
* @ApiMethod (POST)
*
* @ApiParams (name="forum_id", type="int", required=true, description="话题ID")
* @ApiParams (name="topic_id", type="int", required=true, description="话题ID")
*
* @ApiReturn({
"code": 1,
... ... @@ -286,6 +286,6 @@ class Forum extends Api
*/
public function download()
{
$forum_id = $this->request->param('forum_id');
$topic_id = $this->request->param('topic_id');
}
}
\ No newline at end of file
... ...
... ... @@ -1152,7 +1152,7 @@ class User extends Api
{
$page = $this->request->param('page', 1, 'intval');
$page_num = $this->request->param('page_num', 10, 'intval');
$data = Forum::with(['user'])
$data = Topic::with(['user'])
->where('user_id',$this->auth->id)
->order('createtime desc')
->paginate($page_num,false,['page'=>$page])
... ... @@ -1191,7 +1191,7 @@ class User extends Api
{
$page = $this->request->param('page', 1, 'intval');
$page_num = $this->request->param('page_num', 10, 'intval');
$data = Forum::with(['user'])
$data = Topic::with(['user'])
->where('user_id',$this->auth->id)
->order('createtime desc')
->paginate($page_num,false,['page'=>$page])
... ...
... ... @@ -3,10 +3,10 @@ namespace app\mobile\model;
use think\Model;
class Forum extends Model
class Topic extends Model
{
// 表名
protected $name = 'mobile_forum';
protected $name = 'mobile_topic';
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
... ...
... ... @@ -3,10 +3,10 @@ namespace app\mobile\model;
use think\Model;
class ForumCategory extends Model
class TopicCategory extends Model
{
// 表名
protected $name = 'mobile_forum_category';
protected $name = 'mobile_topic_category';
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
... ...