CommentController.php 1.7 KB
<?php
/**
 * @remark :
 * @name   :CommentController.php
 * @author :lyh
 * @method :post
 * @time   :2024/9/9 15:01
 */

namespace App\Http\Controllers\Bside\Comment;

use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Comment\Comment;

class CommentController extends BaseController
{
    /**
     * @remark :評論列表
     * @name   :lists
     * @author :lyh
     * @method :post
     * @time   :2024/9/9 15:02
     */
    public function lists(){
        $commentModel = new Comment();
        $lists = $commentModel->lists($this->map,$this->page,$this->row);
        $this->response('success',Code::SUCCESS,$lists);
    }

    /**
     * @remark :获取详情
     * @name   :info
     * @author :lyh
     * @method :post
     * @time   :2024/9/9 17:13
     */
    public function info(){
        $this->request->validate([
            'id' => 'required',
        ], [
            'id.required' => '主鍵不能为空',
        ]);
        $commentModel = new Comment();
        $info = $commentModel->read(['id'=>$this->param['id']]);
        $this->response('success',Code::SUCCESS,$info);
    }

    /**
     * @remark :修改審核狀態
     * @name   :status
     * @author :lyh
     * @method :post
     * @time   :2024/9/9 15:02
     */
    public function status(){
        $this->request->validate([
            'id' => 'required',
            'status'=>'required',
        ], [
            'id.required' => '主鍵不能为空',
            'status.required' => '审核状态不能为空',
        ]);
        $commentModel = new Comment();
        $commentModel->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);
        $this->response('success');
    }
}