package com.hssx.pcbms.controller;


import com.hssx.pcbms.entity.Task;
import com.hssx.pcbms.entity.TaskExamine;
import com.hssx.pcbms.service.TaskExamineService;
import com.hssx.pcbms.util.HttpRespMsg;
import com.hssx.pcbms.util.PageUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 吴涛涛
 * @since 2019-11-12
 */
@Controller
@RequestMapping("/taskexamine")
public class TaskExamineController {

    @Autowired
    private TaskExamineService taskExamineService;

    /**
     * 审核结果的发布
     * 发布时参数：
     * publisherId:发布审核结果的人
     * publishContent:发布的内容
     * taskId:任务id
     * 回复时的参数：
     * responderId:回复者的id
     * respondContent:回复内容
     * isPass:是否通过1-不通过，2-通过
     * score:评分（只有isPass=2时才传该参数）
     */
    @ApiOperation(value = "审核结果的发布/修改", notes = "审核结果的发布/修改方法")
    @RequestMapping("/addOrUpdate")
    @ResponseBody
    public HttpRespMsg addOrUpdate(TaskExamine taskExamine,@RequestParam(required = false) Integer type) {
        HttpRespMsg msg = taskExamineService.addOrUpdate(taskExamine,type);
        return msg;
    }

    /**
     * 审核结果列表
     * 参数：
     * taskId:任务id,pageNum:当前页，pageSize:每页多少条
     * @return
     */
    @ApiOperation(value = "审核结果列表", notes = "审核结果列表方法")
    @RequestMapping("/list")
    @ResponseBody
    public HttpRespMsg list(PageUtil page, String taskId) {
        HttpRespMsg msg = taskExamineService.getList(page,taskId);
        return msg;
    }
}

