init: 项目初始代码
This commit is contained in:
59
app/api/controller/v1/Comment.php
Normal file
59
app/api/controller/v1/Comment.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\api\controller\v1;
|
||||
|
||||
use app\api\model\Comment as CommentModel;
|
||||
use app\api\validate\Comment as CommentValidate;
|
||||
/**
|
||||
* 用户评价类
|
||||
* Class Comment
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class Comment extends Base
|
||||
{
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->model = new CommentModel();
|
||||
$this->validate = new CommentValidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function index():\think\Response\Json
|
||||
{
|
||||
$inputData = $this->request->param();
|
||||
$inputData['platform_id'] = $this->platformId;
|
||||
|
||||
if (isset($inputData['language_id']) && $inputData['language_id'] != 0 && $inputData['language_id'] != '') {
|
||||
$this->focus['site_id'] = $inputData['site_id'] = $inputData['language_id'];
|
||||
unset($inputData['language_id']);
|
||||
}
|
||||
|
||||
if (isset($inputData['nickname']) && $inputData['nickname'] != '') {
|
||||
$this->simple['nickname'] = $inputData['nickname'];
|
||||
}
|
||||
|
||||
if (isset($inputData['comment']) && $inputData['comment'] != '') {
|
||||
$this->simple['comment'] = $inputData['comment'];
|
||||
}
|
||||
|
||||
//正常数据验证器验证
|
||||
if (!$this->commonValidate(__FUNCTION__,$inputData)) {
|
||||
return $this->msg(-1,$this->validate->getError());
|
||||
}
|
||||
|
||||
if (!empty($this->focus)) {
|
||||
if (!$this->commonValidate(__FUNCTION__,$this->focus)) {
|
||||
return $this->msg(-1,$this->validate->getError());
|
||||
}
|
||||
}
|
||||
$this->order['create_time'] = 'desc';
|
||||
//过滤字段
|
||||
$this->field = ['id','platform_id','language_id','site_id','avatar','name','nickname','comment','url','sort','create_time'];
|
||||
|
||||
$result = $this->model->getAllList($inputData,$this->simple,$this->focus,$this->order,$this->field);
|
||||
return $this->msg(200,'获取列表成功',$result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user