数据库第二次大作业boostore
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

196 linhas
8.8 KiB

<!DOCTYPE html>
<html id="htmlId">
<head>
<title>Coverage Report > BookController</title>
<style type="text/css">
@import "../../css/coverage.css";
@import "../../css/idea.min.css";
</style>
<script type="text/javascript" src="../../js/highlight.min.js"></script>
<script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>
<body>
<div class="content">
<div class="breadCrumbs">
Current scope: <a href="../../index.html">all classes</a>
<span class="separator">|</span>
<a href="../index.html">cn.edu.ecnu.stu.bookstore.controller</a>
</div>
<h1>Coverage Summary for Class: BookController (cn.edu.ecnu.stu.bookstore.controller)</h1>
<table class="coverageStats">
<tr>
<th class="name">Class</th>
<th class="coverageStat
">
Class, %
</th>
<th class="coverageStat
">
Method, %
</th>
<th class="coverageStat
">
Line, %
</th>
</tr>
<tr>
<td class="name">BookController</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(9/9)
</span>
</td>
<td class="coverageStat">
<span class="percent">
68%
</span>
<span class="absValue">
(17/25)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package cn.edu.ecnu.stu.bookstore.controller;
&nbsp;
&nbsp;import cn.edu.ecnu.stu.bookstore.component.AppException;
&nbsp;import cn.edu.ecnu.stu.bookstore.component.Constants;
&nbsp;import cn.edu.ecnu.stu.bookstore.component.Result;
&nbsp;import cn.edu.ecnu.stu.bookstore.service.impl.BookService;
&nbsp;import org.springframework.beans.factory.annotation.Autowired;
&nbsp;import org.springframework.util.StringUtils;
&nbsp;import org.springframework.web.bind.annotation.*;
&nbsp;
&nbsp;@RestController
&nbsp;@RequestMapping(&quot;/book&quot;)
<b class="fc">&nbsp;public class BookController {</b>
&nbsp;
&nbsp; @Autowired
&nbsp; private BookService bookService;
&nbsp;
&nbsp; @GetMapping(&quot;/title&quot;)
&nbsp; public Result getBookByTitle(@RequestParam(&quot;title&quot;) String title,
&nbsp; @RequestParam(value = &quot;pageNum&quot;, required = false, defaultValue = &quot;1&quot;) Integer pageNum,
&nbsp; @RequestParam(value = &quot;pageSize&quot;, required = false, defaultValue = &quot;5&quot;) Integer pageSize) {
<b class="fc">&nbsp; if(!StringUtils.hasText(title))</b>
<b class="nc">&nbsp; throw new AppException(Constants.CLIENT_ERROR, Constants.PARAMETER_ERROR_MESSAGE);</b>
<b class="fc">&nbsp; return Result.success(bookService.getBookByTitle(title, null, pageNum, pageSize));</b>
&nbsp; }
&nbsp;
&nbsp; @GetMapping(&quot;/title_in_store&quot;)
&nbsp; public Result getBookByTitleInStore(@RequestParam(&quot;title&quot;) String title,
&nbsp; @RequestParam(&quot;storeId&quot;) String storeId,
&nbsp; @RequestParam(value = &quot;pageNum&quot;, required = false, defaultValue = &quot;1&quot;) Integer pageNum,
&nbsp; @RequestParam(value = &quot;pageSize&quot;, required = false, defaultValue = &quot;5&quot;) Integer pageSize) {
<b class="fc">&nbsp; if(!StringUtils.hasText(title))</b>
<b class="nc">&nbsp; throw new AppException(Constants.CLIENT_ERROR, Constants.PARAMETER_ERROR_MESSAGE);</b>
<b class="fc">&nbsp; return Result.success(bookService.getBookByTitle(title, storeId, pageNum, pageSize));</b>
&nbsp; }
&nbsp;
&nbsp; @GetMapping(&quot;/author&quot;)
&nbsp; public Result getBookByAuthor(@RequestParam(&quot;author&quot;) String author,
&nbsp; @RequestParam(value = &quot;pageNum&quot;, required = false, defaultValue = &quot;1&quot;) Integer pageNum,
&nbsp; @RequestParam(value = &quot;pageSize&quot;, required = false, defaultValue = &quot;5&quot;) Integer pageSize) {
<b class="fc">&nbsp; if(!StringUtils.hasText(author))</b>
<b class="nc">&nbsp; throw new AppException(Constants.CLIENT_ERROR, Constants.PARAMETER_ERROR_MESSAGE);</b>
<b class="fc">&nbsp; return Result.success(bookService.getBookByAuthor(author, null, pageNum, pageSize));</b>
&nbsp; }
&nbsp;
&nbsp; @GetMapping(&quot;/author_in_store&quot;)
&nbsp; public Result getBookByAuthorInStore(@RequestParam(&quot;author&quot;) String author,
&nbsp; @RequestParam(&quot;storeId&quot;) String storeId,
&nbsp; @RequestParam(value = &quot;pageNum&quot;, required = false, defaultValue = &quot;1&quot;) Integer pageNum,
&nbsp; @RequestParam(value = &quot;pageSize&quot;, required = false, defaultValue = &quot;5&quot;) Integer pageSize) {
<b class="fc">&nbsp; if(!StringUtils.hasText(author))</b>
<b class="nc">&nbsp; throw new AppException(Constants.CLIENT_ERROR, Constants.PARAMETER_ERROR_MESSAGE);</b>
<b class="fc">&nbsp; return Result.success(bookService.getBookByAuthor(author, storeId, pageNum, pageSize));</b>
&nbsp; }
&nbsp;
&nbsp; @GetMapping(&quot;/tag&quot;)
&nbsp; public Result getBookByTag(@RequestParam(&quot;tag&quot;) String tag,
&nbsp; @RequestParam(value = &quot;pageNum&quot;, required = false, defaultValue = &quot;1&quot;) Integer pageNum,
&nbsp; @RequestParam(value = &quot;pageSize&quot;, required = false, defaultValue = &quot;5&quot;) Integer pageSize) {
<b class="fc">&nbsp; if(!StringUtils.hasText(tag))</b>
<b class="nc">&nbsp; throw new AppException(Constants.CLIENT_ERROR, Constants.PARAMETER_ERROR_MESSAGE);</b>
<b class="fc">&nbsp; return Result.success(bookService.getBookByTag(tag, null, pageNum, pageSize));</b>
&nbsp; }
&nbsp;
&nbsp; @GetMapping(&quot;/tag_in_store&quot;)
&nbsp; public Result getBookByTagInStore(@RequestParam(&quot;tag&quot;) String tag,
&nbsp; @RequestParam(&quot;storeId&quot;) String storeId,
&nbsp; @RequestParam(value = &quot;pageNum&quot;, required = false, defaultValue = &quot;1&quot;) Integer pageNum,
&nbsp; @RequestParam(value = &quot;pageSize&quot;, required = false, defaultValue = &quot;5&quot;) Integer pageSize) {
<b class="fc">&nbsp; if(!StringUtils.hasText(tag))</b>
<b class="nc">&nbsp; throw new AppException(Constants.CLIENT_ERROR, Constants.PARAMETER_ERROR_MESSAGE);</b>
<b class="fc">&nbsp; return Result.success(bookService.getBookByTag(tag, storeId, pageNum, pageSize));</b>
&nbsp; }
&nbsp;
&nbsp; @GetMapping(&quot;/content_in_store&quot;)
&nbsp; public Result getBookByContentInStore(@RequestParam(&quot;content&quot;) String content,
&nbsp; @RequestParam(&quot;storeId&quot;) String storeId,
&nbsp; @RequestParam(value = &quot;pageNum&quot;, required = false, defaultValue = &quot;1&quot;) Integer pageNum,
&nbsp; @RequestParam(value = &quot;pageSize&quot;, required = false, defaultValue = &quot;5&quot;) Integer pageSize) {
<b class="fc">&nbsp; if(!StringUtils.hasText(content))</b>
<b class="nc">&nbsp; throw new AppException(Constants.CLIENT_ERROR, Constants.PARAMETER_ERROR_MESSAGE);</b>
<b class="fc">&nbsp; return Result.success(bookService.getBookByContent(content, storeId, pageNum, pageSize));</b>
&nbsp; }
&nbsp;
&nbsp; @GetMapping(&quot;/content&quot;)
&nbsp; public Result getBookByContent(@RequestParam(&quot;content&quot;) String content,
&nbsp; @RequestParam(value = &quot;pageNum&quot;, required = false, defaultValue = &quot;1&quot;) Integer pageNum,
&nbsp; @RequestParam(value = &quot;pageSize&quot;, required = false, defaultValue = &quot;5&quot;) Integer pageSize) {
<b class="fc">&nbsp; if(!StringUtils.hasText(content))</b>
<b class="nc">&nbsp; throw new AppException(Constants.CLIENT_ERROR, Constants.PARAMETER_ERROR_MESSAGE);</b>
<b class="fc">&nbsp; return Result.success(bookService.getBookByContent(content, null, pageNum, pageSize));</b>
&nbsp; }
&nbsp;}
</code>
</pre>
</div>
<script type="text/javascript">
(function() {
var msie = false, msie9 = false;
/*@cc_on
msie = true;
@if (@_jscript_version >= 9)
msie9 = true;
@end
@*/
if (!msie || msie && msie9) {
hljs.highlightAll()
hljs.initLineNumbersOnLoad();
}
})();
</script>
<div class="footer">
<div style="float:right;">generated on 2023-12-12 18:32</div>
</div>
</body>
</html>