package com.app.controller.admin;

import com.app.dto.PageResult;
import com.app.dto.Result;
import com.app.dto.basics.operation.ResponseCommentDto;
import com.app.dto.basics.search.SearchCommentDto;
import com.app.service.basics.OpenCourseCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 功能描述：学校
 *
 * @Auther: 梁展鹏
 * @Date: 2018/7/24 11:38
 */
@Api(description = "学校")
@Slf4j
@Validated
@RestController("AdminCommentController")
@RequestMapping("/admin/comment")
public class CommentController {

    @Autowired
    private OpenCourseCommentService service;

    /**
     * 功能描述：查询所有[学校]
     *
     * @param params 查询对象
     * @return
     */
    @ApiOperation(value = "查询所有[学校]")
    @PostMapping("/page")
    public ResponseEntity<Result<PageResult<ResponseCommentDto>>> page(@Valid @RequestBody SearchCommentDto params) {
        return new ResponseEntity(new Result().ok(service.page(params)), HttpStatus.OK);
    }

    @ApiOperation(value = "查询所有[课程]")
    @PostMapping("/audit/{commentId}")
    public ResponseEntity<Result<?>> audit(@PathVariable("commentId") String commentId) {
        service.audit2Pass(commentId);
        return new ResponseEntity(new Result().ok(), HttpStatus.OK);
    }

}
