package com.lovecoding.mvc;

import com.lovecoding.mvc.doman.Book;
import com.lovecoding.mvc.mapper.BookMapper;
import com.lovecoding.mvc.service.BookService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@Api(value= "MybatisController", description = "这个控制器是用来测试Mybatis接口的")
public class MybatisTestController {

    @Autowired
    BookService bookService;

    @GetMapping("/mybatis")
    @ResponseBody
    @ApiOperation(
            value = "测试获取书本信息",
            notes = "获取书本信息",
            httpMethod = "GET",
            produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE
    )
    @ApiImplicitParams({})
    public Book test(@ApiParam(value = "这个bookID是用来获取书本的ID， 为Long类型") Long bookId){
        Book book = bookService.get(bookId);
        System.out.println( book );
        return book;
    }

}
