<?php
/**
 * Created by PhpStorm.
 * User: 中闽 < 1464674022@qq.com >
 * Date: 2019/12/5
 * Time: 17:44
 */

namespace app\api\controller;


use app\common\model\Feedback;
use app\api\controller\base\Permissions;

class User extends Permissions
{
    //个人资料接口
    public function info()
    {
        $this->json_success('success', $this->getUser());
    }

    //提交反馈接口
    public function feedback()
    {
        $post = $this->request->param();
        //验证
        $validate = new \think\Validate([
            ['content|内容', 'require|max:500'],
        ]);
        if (!$validate->check($post)) {
            $this->error('提交失败：' . $validate->getError());
        }

        $model = new Feedback();
        $post['user_id'] = $this->getUserId();
        $res = $model->allowField(true)->save($post);
        if ($res) {
            $this->json_success("成功");
        } else {
            $this->json_error("失败");
        }
    }
}
