1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
 
namespace app\api\controller\plus\release;
 
use app\api\controller\Controller;
use app\api\model\plus\release\Evaluate as EvaluateModel;
 
 
/**
 * 模型
 */
class Evaluate extends Controller
{
    // 当前用户
    private $user;
 
    /**
     * 构造方法
     */
    public function initialize()
    {
        // 用户信息
        $this->user = $this->getUser();;
    }
 
    /**
     * 列表
     */
    public function lists($project_id, $scoreType = -1)
    {
        $model = new EvaluateModel;
        $list = $model->getEvaluateList($project_id, $scoreType, $this->postData());
        $total = $model->getTotal($project_id);
        return $this->renderSuccess('', compact('list', 'total'));
    }
 
 
 
    /**
     *评论
     */
    public function evaluate()
    {
        $params = $this->request->param();
        $model = new EvaluateModel;
        $params['user_id'] = $this->user['user_id'];
        $params['image_list'] = json_decode($params['image_list'],true);
        $result = $model->evaluate($params);
        if(!$result){
            return $this->renderError($model->getError() ?: '评论失败');
        }
        return $this->renderSuccess('评论成功');
    }
 
}