ruoyi-vue-server/ruoyi-system/src/main/java/com/ruoyi/book/controller/BookInfoController.java

109 lines
3.8 KiB
Java

package com.ruoyi.book.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.book.domain.BookInfo;
import com.ruoyi.book.service.BookInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 书籍信息Controller
*
* @author DongZeLiang
* @date 2023-10-10
*/
@Api("书籍信息")
@RestController
@RequestMapping("/book/info")
public class BookInfoController extends BaseController {
@Autowired
private BookInfoService bookInfoService;
/**
* 查询书籍信息列表
*/
@ApiOperation("获取书籍信息列表")
@PreAuthorize("@ss.hasPermi('book:info:list')")
@GetMapping("/list")
public Result<TableDataInfo> list(BookInfo bookInfo) {
startPage();
List<BookInfo> list = bookInfoService.list(bookInfo);
return getDataTable(list);
}
/**
* 导出书籍信息列表
*/
@ApiOperation("导出书籍信息列表")
@PreAuthorize("@ss.hasPermi('book:info:export')")
@Log(title = "书籍信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BookInfo bookInfo) {
List<BookInfo> list = bookInfoService.list(bookInfo);
ExcelUtil<BookInfo> util = new ExcelUtil<BookInfo>(BookInfo.class);
util.exportExcel(response, list, "书籍信息数据");
}
/**
* 获取书籍信息详细信息
*/
@ApiOperation("获取书籍信息详细信息")
@PreAuthorize("@ss.hasPermi('book:info:query')")
@GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result getInfo(@PathVariable("id") Long id) {
return success(bookInfoService.getById(id));
}
/**
* 新增书籍信息
*/
@PreAuthorize("@ss.hasPermi('book:info:add')")
@Log(title = "书籍信息", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增书籍信息")
public Result add(@RequestBody BookInfo bookInfo) {
return toAjax(bookInfoService.save(bookInfo));
}
/**
* 修改书籍信息
*/
@PreAuthorize("@ss.hasPermi('book:info:edit')")
@Log(title = "书籍信息", businessType = BusinessType.UPDATE)
@PutMapping
@ApiOperation("修改书籍信息")
public Result edit(@RequestBody BookInfo bookInfo) {
return toAjax(bookInfoService.updateById(bookInfo));
}
/**
* 删除书籍信息
*/
@PreAuthorize("@ss.hasPermi('book:info:remove')")
@Log(title = "书籍信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@ApiOperation("删除书籍信息")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result remove(@PathVariable List<Long> ids) {
return toAjax(bookInfoService.removeBatchByIds(ids));
}
}