package cn.com.countrygarden.bi.main.controller.wcx;

import cn.com.countrygarden.bi.main.constant.wcx.WcxConstant;
import cn.com.countrygarden.bi.main.core.Response;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.dto.wcx.WcxReviewDto;
import cn.com.countrygarden.bi.main.model.PageData;
import cn.com.countrygarden.bi.main.service.wcx.WcxReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;

/**
 *  评论
 *
 *  @author ferren
 */
@RestController
@RequestMapping("/api/wcx/review")
public class WcxReviewController {
    @Autowired
    private WcxReviewService wcxReviewService;

    /**
     * 获取评论数据
     */
    @GetMapping("/pageList")
    public Result selectReviewPageList(WcxReviewDto dto) throws UnsupportedEncodingException {
        if (!StringUtils.hasText(dto.getInnovationId())) {
            return Response.responseFail("参数innovationId未传");
        }
        /*WcxInnovationDto conditionInnovation = new WcxInnovationDto();
        //conditionWcxInnDto.setUserId(wcxUser.getUserId());
        if(baselineid != null && !baselineid.equals(0)){
            conditionInnovation.setBaseline(baselineid + "");
        }
        if (classification != null && !classification.equals(0)) {
            conditionInnovation.setClassification(classification  + "");
        }
        conditionInnovation.setPageIndex(page);
        conditionInnovation.setPageSize(size);*/
        PageData pageData = wcxReviewService.selectPageList(dto);
        return Response.response(pageData);
    }

    /**
     * 删除评论数据
     */
    @DeleteMapping("/{reviewId}")
    public Result deleteReview(@PathVariable String reviewId) {
        if (!StringUtils.hasText(reviewId)) {
            return Response.responseFail("参数innovationId未传");
        }
        wcxReviewService.delete(reviewId);
        return Response.response(WcxConstant.DEAL_SUCCESS);
    }
}
