package com.hssx.pcbms.controller;


import com.hssx.pcbms.entity.Idea;
import com.hssx.pcbms.entity.IdeaComment;
import com.hssx.pcbms.service.IdeaCommentService;
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-02
 */
@Controller
@RequestMapping("/ideacomment")
public class IdeaCommentController {
    @Autowired
    private IdeaCommentService ideaCommentService;

    /**
     * 添加/修改回复建议（给建议打分）
     * 参数：ideaId:建议的id,content:回复的内容（没有内容默认传“暂无回复”）,
     * responderId:回复人的id,score 建议打分数（-10.0-10.0）
     *  注：修改时 id:回复建议的id（以上参数不修改的不传）
     * @return
     */
    @ApiOperation(value = "添加/修改回复建议", notes = "添加/修改回复建议方法")
    @RequestMapping("/addOrUpdate")
    @ResponseBody
    public HttpRespMsg addOrUpdate(IdeaComment ideaComment,@RequestParam(required = false) Double score,@RequestParam(required = false) Integer scoreId) {
        HttpRespMsg msg = ideaCommentService.addOrUpdate(ideaComment,score,scoreId);
        return msg;
    }
    /**
     * 删除建议回复
     * 参数：id:回复建议的id
     * @return
     */
    @ApiOperation(value = "删除建议回复", notes = "删除建议回复方法")
    @RequestMapping("/del")
    @ResponseBody
    public HttpRespMsg del(IdeaComment ideaComment) {
        HttpRespMsg msg = ideaCommentService.del(ideaComment);
        return msg;
    }

}

