package com.app.service.basics;

import com.app.dto.PageResult;
import com.app.dto.basics.operation.ResponseCommentDto;
import com.app.dto.basics.search.SearchCommentDto;
import com.app.entity.basics.OpenCourseComment;
import com.app.mapper.basics.OpenCourseCommentMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 功能描述：学校
 *
 * @Auther: 梁展鹏
 * @Date: 2018/7/24 11:38
 */
@Slf4j
@Service
public class OpenCourseCommentService {

    @Autowired
    private OpenCourseCommentMapper mapper;

    /**
     * 功能描述：获取[学校]的年级班级
     *
     * @param params
     * @return
     */
    public PageResult<ResponseCommentDto> page(SearchCommentDto params) {
        Page<OpenCourseComment> _page = new Page<>(params.getPage(), params.getSize());
        IPage<ResponseCommentDto> list = mapper.getList(_page, params);
        return new PageResult(params.getPage(), params.getSize(), list.getTotal(), _page.getRecords());
    }

    public void audit2Pass(String id) {
        OpenCourseComment comment = mapper.selectById(id);
        comment.setIsPassed(Boolean.TRUE);
        mapper.updateById(comment);
    }

}
