BookController.java 958 字节
Newer Older
Q
qinyingjie 已提交
1 2
package com.kwan.springbootkwan.controller;

Q
qinyingjie 已提交
3 4
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
Q
qinyingjie 已提交
5 6 7 8 9 10 11 12 13
import org.springframework.web.bind.annotation.*;

/**
 * 方法上跨域配置
 *
 * @author : qinyingjie
 * @version : 2.2.0
 * @date : 2022/12/19 16:10
 */
Q
qinyingjie 已提交
14
@Api(description = "书籍信息", tags = "BookController")
Q
qinyingjie 已提交
15 16 17
@RestController
public class BookController {

Q
qinyingjie 已提交
18
    @ApiOperation(value = "添加书籍", notes = "添加书籍")
Q
qinyingjie 已提交
19 20 21 22 23 24
    @CrossOrigin(value = "http://localhost:8081", maxAge = 1800, allowedHeaders = "*")
    @PostMapping("addBook")
    public String addBook(String name) {
        return "receive:" + name;
    }

Q
qinyingjie 已提交
25
    @ApiOperation(value = "删除书籍", notes = "删除书籍")
Q
qinyingjie 已提交
26 27 28 29 30 31
    @CrossOrigin(value = "http://localhost:8081", maxAge = 1800, allowedHeaders = "*")
    @DeleteMapping("deleteBook/{id}")
    public String deleteBook(@PathVariable(value = "id") String id) {
        return "receive:" + id;
    }
}