package com.example.demo.controller.wx;

import com.example.demo.dto.request.wrongbook.AddWrongBookStemRequest;
import com.example.demo.dto.request.wrongbook.WrongBookRequest;
import com.example.demo.dto.response.WrongBookDto;
import com.example.demo.service.WrongBookService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author hxh
 * @Date 2020-09-16 17:46
 * @Descrption TODO
 */
@Api(tags = "错题本管理")
@RequestMapping("/wx/wrongbook")
@RestController
public class WrongBookController {
    @Autowired
    private WrongBookService wrongBookService;

    @ApiOperation(value = "提交用户id和年级学科查看错题本")
    @PostMapping("/get")
    public WrongBookDto get(@RequestBody WrongBookRequest request){
        return wrongBookService.getWrongBook(request);
    }

    @ApiOperation(value = "提交用户id，年级学科和错题id来存储该错题")
    @PostMapping("/add")
    public boolean addStem(@RequestBody AddWrongBookStemRequest request){
        return wrongBookService.add(request);
    }

    @ApiOperation(value = "提交用户id，年级学科和错题id来查看错题本下题目数")
    @PostMapping("/count")
    public int countStem(@RequestBody WrongBookRequest request){
        return wrongBookService.count(request);
    }
}
