Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
library_demo
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
xuyang
library_demo
Commits
dc168aaf
提交
dc168aaf
authored
4月 22, 2020
作者:
xuyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完善程序4.22.1
上级
4c52d621
隐藏空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
230 行增加
和
44 行删除
+230
-44
README.md
README.md
+12
-2
pom.xml
pom.xml
+26
-0
Demo1Application.java
src/main/java/com/springboot/demo1/Demo1Application.java
+1
-0
BooksController.java
...java/com/springboot/demo1/controller/BooksController.java
+21
-2
BorrowInfoController.java
...com/springboot/demo1/controller/BorrowInfoController.java
+15
-4
UserController.java
.../java/com/springboot/demo1/controller/UserController.java
+22
-2
BooksRepository.java
src/main/java/com/springboot/demo1/dao/BooksRepository.java
+3
-3
BorrowInfoRepository.java
...n/java/com/springboot/demo1/dao/BorrowInfoRepository.java
+2
-2
UserRepository.java
src/main/java/com/springboot/demo1/dao/UserRepository.java
+4
-4
Books.java
src/main/java/com/springboot/demo1/entity/Books.java
+3
-2
BorrowInfo.java
src/main/java/com/springboot/demo1/entity/BorrowInfo.java
+5
-4
User.java
src/main/java/com/springboot/demo1/entity/User.java
+2
-1
ExceptionHandle.java
...ava/com/springboot/demo1/interceptor/ExceptionHandle.java
+48
-0
SwaggerConfig.java
.../java/com/springboot/demo1/interceptor/SwaggerConfig.java
+48
-0
BooksService.java
src/main/java/com/springboot/demo1/service/BooksService.java
+6
-6
BorrowInfoService.java
.../java/com/springboot/demo1/service/BorrowInfoService.java
+5
-5
UserService.java
src/main/java/com/springboot/demo1/service/UserService.java
+3
-3
BooksServiceImpl.java
...a/com/springboot/demo1/service/impl/BooksServiceImpl.java
+2
-2
BorrowInfoServiceImpl.java
.../springboot/demo1/service/impl/BorrowInfoServiceImpl.java
+1
-1
UserServiceImpl.java
...va/com/springboot/demo1/service/impl/UserServiceImpl.java
+1
-1
没有找到文件。
README.md
浏览文件 @
dc168aaf
# Introduction
# 介绍
简单的图书馆系统
功能:
上传书籍、删除书籍、根据ID获取书籍信息、获取书籍列表
借书、还书、获取借书还书列表
新增用户、根据ID查找用户、获取用户列表
A library demo for test 1111111
...
...
pom.xml
浏览文件 @
dc168aaf
...
...
@@ -38,6 +38,17 @@
<artifactId>
lombok
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
<version>
2.6
</version>
</dependency>
<!-- faster json -->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.7
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
...
@@ -49,6 +60,21 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
2.7.0
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
2.7.0
</version>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
4.6.4
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/springboot/demo1/Demo1Application.java
浏览文件 @
dc168aaf
...
...
@@ -2,6 +2,7 @@ package com.springboot.demo1;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.annotation.ComponentScan
;
@SpringBootApplication
public
class
Demo1Application
{
...
...
src/main/java/com/springboot/demo1/controller/BooksController.java
浏览文件 @
dc168aaf
...
...
@@ -4,6 +4,9 @@ import com.springboot.demo1.entity.BaseException;
import
com.springboot.demo1.entity.Books
;
import
com.springboot.demo1.entity.Response
;
import
com.springboot.demo1.service.BooksService
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
...
...
@@ -19,6 +22,7 @@ public class BooksController {
/**
* 获取图书列表
*/
@ApiOperation
(
value
=
"获取图书列表"
)
@GetMapping
public
Response
getBooksList
(){
List
<
Books
>
booksList
=
booksService
.
getBooksList
();
...
...
@@ -30,8 +34,13 @@ public class BooksController {
* @param bookId
* @return
*/
@ApiOperation
(
value
=
"根据书本ID查找书籍"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"bookId"
,
value
=
"书籍ID"
,
paramType
=
"path"
,
required
=
true
,
dataType
=
"Long"
)
})
@GetMapping
(
value
=
"/{bookId}"
)
public
Response
getBookById
(
@PathVariable
Integer
bookId
)
throws
BaseException
{
public
Response
getBookById
(
@PathVariable
Long
bookId
)
throws
BaseException
{
Books
books
=
booksService
.
getBookById
(
bookId
);
return
new
Response
().
normalResponse
(
books
);
}
...
...
@@ -42,6 +51,11 @@ public class BooksController {
* @return
* @throws BaseException
*/
@ApiOperation
(
value
=
"添加书籍"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"bookName"
,
value
=
"书名"
,
paramType
=
"path"
,
required
=
true
,
dataType
=
"String"
)
})
@PostMapping
(
value
=
"/{bookName}"
)
public
Response
addBook
(
@PathVariable
String
bookName
)
throws
BaseException
{
Response
response
=
new
Response
();
...
...
@@ -54,8 +68,13 @@ public class BooksController {
* @param bookId
* @return
*/
@ApiOperation
(
value
=
"删除书籍"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"bookId"
,
value
=
"书籍ID"
,
paramType
=
"path"
,
required
=
true
,
dataType
=
"Long"
)
})
@DeleteMapping
(
value
=
"/{bookId}"
)
public
Response
deleteBook
(
@PathVariable
Integer
bookId
)
throws
BaseException
{
public
Response
deleteBook
(
@PathVariable
Long
bookId
)
throws
BaseException
{
Response
response
=
new
Response
();
booksService
.
deleteBook
(
bookId
);
return
response
.
normalResponse
();
...
...
src/main/java/com/springboot/demo1/controller/BorrowInfoController.java
浏览文件 @
dc168aaf
...
...
@@ -3,10 +3,12 @@ package com.springboot.demo1.controller;
import
com.springboot.demo1.entity.BaseException
;
import
com.springboot.demo1.entity.Response
;
import
com.springboot.demo1.service.BorrowInfoService
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.List
;
@RestController
@RequestMapping
(
value
=
"/borrowInfos"
)
...
...
@@ -18,7 +20,7 @@ public class BorrowInfoController {
/**
* 获取借阅信息列表
*/
@PostMapping
(
value
=
"/get"
)
@PostMapping
public
Response
getBorrowInfoList
()
{
return
new
Response
().
normalResponse
(
borrowInfoService
.
getBorrowInfoList
());
}
...
...
@@ -26,8 +28,17 @@ public class BorrowInfoController {
/**
* 借书/还书
*/
@PostMapping
(
value
=
"/update/{userId}/{bookId}/{type}"
)
public
Response
updateBorrowInfo
(
@PathVariable
Integer
userId
,
@PathVariable
Integer
bookId
,
@PathVariable
Integer
type
)
throws
BaseException
{
@ApiOperation
(
value
=
"借书/还书"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户ID"
,
paramType
=
"path"
,
required
=
true
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"bookId"
,
value
=
"书籍ID"
,
paramType
=
"path"
,
required
=
true
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"type"
,
value
=
"操作方式0/1"
,
paramType
=
"path"
,
required
=
true
,
dataType
=
"Long"
)
})
@PostMapping
(
value
=
"/{userId}/{bookId}/{type}"
)
public
Response
updateBorrowInfo
(
@PathVariable
Long
userId
,
@PathVariable
Long
bookId
,
@PathVariable
Long
type
)
throws
BaseException
{
borrowInfoService
.
updateBorrowInfoList
(
userId
,
bookId
,
type
);
return
new
Response
().
normalResponse
();
}
...
...
src/main/java/com/springboot/demo1/controller/UserController.java
浏览文件 @
dc168aaf
...
...
@@ -3,6 +3,9 @@ package com.springboot.demo1.controller;
import
com.springboot.demo1.entity.BaseException
;
import
com.springboot.demo1.entity.Response
;
import
com.springboot.demo1.service.UserService
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
...
...
@@ -17,7 +20,8 @@ public class UserController {
/**
* 获取用户列表
*/
@PostMapping
(
value
=
"/get"
)
@ApiOperation
(
value
=
"获取用户列表"
)
@GetMapping
public
Response
getUserList
(){
return
new
Response
().
normalResponse
(
userService
.
getUserList
());
}
...
...
@@ -25,14 +29,30 @@ public class UserController {
/**
* 根据用户ID获取用户
*/
@ApiOperation
(
value
=
"根据用户ID获取用户"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户ID"
,
paramType
=
"path"
,
required
=
true
,
dataType
=
"Long"
)
})
@PostMapping
(
value
=
"/{userId}"
)
public
Response
getUserById
(
@PathVariable
Integer
userId
){
public
Response
getUserById
(
@PathVariable
Long
userId
){
return
new
Response
().
normalResponse
(
userService
.
getUserByUserId
(
userId
));
}
/**
* 添加用户
*/
@ApiOperation
(
value
=
"添加用户"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"userName"
,
value
=
"用户ID"
,
paramType
=
"path"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"passWord"
,
value
=
"密码"
,
paramType
=
"path"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"email"
,
value
=
"邮箱"
,
paramType
=
"path"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"nickName"
,
value
=
"昵称"
,
paramType
=
"path"
,
required
=
true
,
dataType
=
"String"
)
})
@PostMapping
(
value
=
"/{userName}/{passWord}/{email}/{nickName}"
)
public
Response
addUser
(
@PathVariable
String
userName
,
@PathVariable
String
passWord
,
@PathVariable
String
email
,
@PathVariable
String
nickName
)
throws
BaseException
{
...
...
src/main/java/com/springboot/demo1/dao/BooksRepository.java
浏览文件 @
dc168aaf
...
...
@@ -3,10 +3,10 @@ package com.springboot.demo1.dao;
import
com.springboot.demo1.entity.Books
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
BooksRepository
extends
JpaRepository
<
Books
,
Integer
>
{
public
interface
BooksRepository
extends
JpaRepository
<
Books
,
Long
>
{
Books
findBooksByBookId
(
Integer
bookId
);
Books
findBooksByBookId
(
Long
bookId
);
Integer
countBooksByBookName
(
String
bookName
);
Long
countBooksByBookName
(
String
bookName
);
}
src/main/java/com/springboot/demo1/dao/BorrowInfoRepository.java
浏览文件 @
dc168aaf
...
...
@@ -3,8 +3,8 @@ package com.springboot.demo1.dao;
import
com.springboot.demo1.entity.BorrowInfo
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
BorrowInfoRepository
extends
JpaRepository
<
BorrowInfo
,
Integer
>
{
public
interface
BorrowInfoRepository
extends
JpaRepository
<
BorrowInfo
,
Long
>
{
BorrowInfo
getBorrowInfoByUserIdAndBookId
(
Integer
userId
,
Integer
bookId
);
BorrowInfo
getBorrowInfoByUserIdAndBookId
(
Long
userId
,
Long
bookId
);
}
src/main/java/com/springboot/demo1/dao/UserRepository.java
浏览文件 @
dc168aaf
...
...
@@ -7,12 +7,12 @@ import org.springframework.data.repository.query.Param;
import
java.util.List
;
public
interface
UserRepository
extends
JpaRepository
<
User
,
Integer
>
{
public
interface
UserRepository
extends
JpaRepository
<
User
,
Long
>
{
User
getUserByUserId
(
Integer
userId
);
User
getUserByUserId
(
Long
userId
);
Integer
countUserByEmail
(
String
email
);
Long
countUserByEmail
(
String
email
);
Integer
countUserByUserName
(
String
userName
);
Long
countUserByUserName
(
String
userName
);
}
src/main/java/com/springboot/demo1/entity/Books.java
浏览文件 @
dc168aaf
package
com
.
springboot
.
demo1
.
entity
;
import
lombok.Data
;
import
lombok.NonNull
;
import
lombok.experimental.Accessors
;
import
javax.persistence.*
;
...
...
@@ -14,7 +15,7 @@ public class Books {
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Integer
bookId
;
private
Long
bookId
;
/**
* 书名
...
...
@@ -26,6 +27,6 @@ public class Books {
* 书籍状态 ==0表示书籍未被借阅 ==1表示书籍已被借阅
*/
@Column
(
nullable
=
false
)
private
Integer
bookState
;
private
Long
bookState
;
}
src/main/java/com/springboot/demo1/entity/BorrowInfo.java
浏览文件 @
dc168aaf
package
com
.
springboot
.
demo1
.
entity
;
import
lombok.Data
;
import
lombok.NonNull
;
import
lombok.experimental.Accessors
;
import
org.hibernate.annotations.DynamicUpdate
;
...
...
@@ -17,25 +18,25 @@ public class BorrowInfo {
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Integer
borrowId
;
private
Long
borrowId
;
/**
* 用户ID
*/
@Column
(
nullable
=
false
)
private
Integer
userId
;
private
Long
userId
;
/**
* 书籍ID
*/
@Column
(
nullable
=
false
)
private
Integer
bookId
;
private
Long
bookId
;
/**
* 借阅状态 ==1表示借书 ==0表示还书
*/
@Column
(
nullable
=
false
)
private
Integer
type
;
private
Long
type
;
@Column
private
Date
borrowTime
;
...
...
src/main/java/com/springboot/demo1/entity/User.java
浏览文件 @
dc168aaf
package
com
.
springboot
.
demo1
.
entity
;
import
lombok.Data
;
import
lombok.NonNull
;
import
lombok.experimental.Accessors
;
import
javax.persistence.*
;
...
...
@@ -14,7 +15,7 @@ public class User {
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Integer
userId
;
private
Long
userId
;
/**
* 用户名
...
...
src/main/java/com/springboot/demo1/interceptor/ExceptionHandle.java
0 → 100644
浏览文件 @
dc168aaf
package
com
.
springboot
.
demo1
.
interceptor
;
import
com.alibaba.fastjson.JSONObject
;
import
com.springboot.demo1.entity.BaseException
;
import
com.springboot.demo1.entity.Response
;
import
org.springframework.web.bind.MissingServletRequestParameterException
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.net.ConnectException
;
@ControllerAdvice
public
class
ExceptionHandle
{
//处理异常
@ExceptionHandler
({
Exception
.
class
})
@ResponseBody
public
static
Object
handle
(
HttpServletRequest
req
,
HttpServletResponse
resp
,
Exception
e
){
Response
response
=
new
Response
();
resp
.
setContentType
(
"text/json;charset=UTF-8"
);
if
(
e
instanceof
NullPointerException
){
response
.
setMsg
(
"参数异常"
);
response
.
setResult
(
"901"
);
}
else
if
(
e
instanceof
BaseException
){
BaseException
baseException
=
((
BaseException
)
e
);
response
.
setMsg
(
baseException
.
getMessage
());
response
.
setResult
(
baseException
.
getCode
()
+
""
);
}
else
if
(
e
instanceof
ConnectException
){
response
.
setMsg
(
"数据库连接失败"
);
response
.
setResult
(
"888"
);
}
else
if
(
e
instanceof
MissingServletRequestParameterException
){
//不处理
response
.
setMsg
(
"缺少请求参数!"
);
response
.
setResult
(
"899"
);
}
else
{
response
.
setMsg
(
"网络异常,请稍后再试!"
);
response
.
setResult
(
"898"
);
}
return
response
;
}
}
src/main/java/com/springboot/demo1/interceptor/SwaggerConfig.java
0 → 100644
浏览文件 @
dc168aaf
package
com
.
springboot
.
demo1
.
interceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.context.request.async.DeferredResult
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
@EnableSwagger2
@ComponentScan
(
basePackages
=
{
"com.springboot.demo1.controller"
})
@Configuration
public
class
SwaggerConfig
{
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
genericModelSubstitutes
(
DeferredResult
.
class
)
.
useDefaultResponseMessages
(
false
)
.
forCodeGeneration
(
false
)
.
apiInfo
(
apiInfo
())
//请求头路径
.
pathMapping
(
"/"
)
.
select
()
//swagger注解扫描api路径
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.springboot.demo1.controller"
))
.
paths
(
PathSelectors
.
any
())
.
build
().
groupName
(
"library_api"
);
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
"Api document"
)
.
termsOfServiceUrl
(
"http://localhost:8080/"
)
.
description
(
"springboot swagger2"
)
//.contact(new Contact("lin", "", "490456661@qq.com"))
.
version
(
"1.0"
)
.
build
();
}
}
src/main/java/com/springboot/demo1/service/BooksService.java
浏览文件 @
dc168aaf
...
...
@@ -4,6 +4,7 @@ import com.springboot.demo1.dao.BooksRepository;
import
com.springboot.demo1.entity.BaseException
;
import
com.springboot.demo1.entity.Books
;
import
com.springboot.demo1.service.impl.BooksServiceImpl
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -19,30 +20,29 @@ public class BooksService implements BooksServiceImpl {
return
booksRepository
.
findAll
();
}
public
Books
getBookById
(
Integer
bookId
)
throws
BaseException
{
public
Books
getBookById
(
Long
bookId
)
throws
BaseException
{
if
(!
booksRepository
.
findById
(
bookId
).
isPresent
())
{
throw
new
BaseException
(
"书籍不存在"
,
506
);
}
return
booksRepository
.
findBooksByBookId
(
bookId
);
}
public
void
addBook
(
String
bookName
)
throws
BaseException
{
if
(
bookName
==
null
||
bookName
.
length
()
<
1
)
{
if
(
StringUtils
.
isBlank
(
bookName
)
)
{
throw
new
BaseException
(
"书名信息有误"
,
506
);
}
Integer
numByBookName
=
booksRepository
.
countBooksByBookName
(
bookName
);
Long
numByBookName
=
booksRepository
.
countBooksByBookName
(
bookName
);
if
(
numByBookName
>
0
)
{
throw
new
BaseException
(
"该书籍已经存在"
,
506
);
}
else
{
Books
books
=
new
Books
();
books
.
setBookName
(
bookName
);
books
.
setBookState
(
0
);
//bookState为0表示书籍未被借出
books
.
setBookState
(
0
L
);
//bookState为0表示书籍未被借出
booksRepository
.
save
(
books
);
}
}
public
void
deleteBook
(
Integer
bookId
)
throws
BaseException
{
public
void
deleteBook
(
Long
bookId
)
throws
BaseException
{
if
(!
booksRepository
.
findById
(
bookId
).
isPresent
())
{
throw
new
BaseException
(
"书籍不存在"
,
506
);
}
...
...
src/main/java/com/springboot/demo1/service/BorrowInfoService.java
浏览文件 @
dc168aaf
...
...
@@ -25,7 +25,7 @@ public class BorrowInfoService implements BorrowInfoServiceImpl {
return
borrowInfoRepository
.
findAll
();
}
public
void
updateBorrowInfoList
(
Integer
userId
,
Integer
bookId
,
Integer
type
)
throws
BaseException
{
public
void
updateBorrowInfoList
(
Long
userId
,
Long
bookId
,
Long
type
)
throws
BaseException
{
if
(
userId
==
null
||
bookId
==
null
||
type
==
null
)
{
throw
new
BaseException
(
"参数为空"
,
506
);
}
...
...
@@ -45,12 +45,12 @@ public class BorrowInfoService implements BorrowInfoServiceImpl {
if
(
type
==
1
&&
books
.
getBookState
()
==
0
)
{
//借书
borrowInfo
.
setBorrowId
(
borrowInfo1
.
getBorrowId
());
//将对应借书记录进行修改
borrowInfo
.
setBorrowTime
(
new
Date
());
books
.
setBookState
(
1
);
books
.
setBookState
(
1
L
);
}
else
if
(
type
==
0
&&
books
.
getBookState
()
==
1
)
{
//还书
borrowInfo
.
setBorrowId
(
borrowInfo1
.
getBorrowId
());
borrowInfo
.
setBorrowTime
(
borrowInfo1
.
getBorrowTime
());
borrowInfo
.
setReturnTime
(
new
Date
());
books
.
setBookState
(
0
);
books
.
setBookState
(
0
L
);
}
else
if
(
type
==
1
&&
books
.
getBookState
()
==
1
)
{
throw
new
BaseException
(
"该书籍已被借出"
,
506
);
}
else
{
...
...
@@ -64,9 +64,9 @@ public class BorrowInfoService implements BorrowInfoServiceImpl {
}
else
{
borrowInfo
.
setBorrowTime
(
new
Date
());
if
(
books
.
getBookState
()
==
0
)
{
books
.
setBookState
(
1
);
books
.
setBookState
(
1
L
);
}
else
{
books
.
setBookState
(
0
);
books
.
setBookState
(
0
L
);
}
}
}
...
...
src/main/java/com/springboot/demo1/service/UserService.java
浏览文件 @
dc168aaf
...
...
@@ -19,7 +19,7 @@ public class UserService implements UserServiceImpl {
return
userRepository
.
findAll
();
}
public
User
getUserByUserId
(
Integer
userId
)
{
public
User
getUserByUserId
(
Long
userId
)
{
return
userRepository
.
getUserByUserId
(
userId
);
}
...
...
@@ -30,8 +30,8 @@ public class UserService implements UserServiceImpl {
if
(
email
==
null
||
email
.
length
()
<
6
)
{
throw
new
BaseException
(
"邮箱格式有误"
,
506
)
;
}
Integer
numByEmail
=
userRepository
.
countUserByEmail
(
email
);
Integer
numByUserName
=
userRepository
.
countUserByUserName
(
userName
);
Long
numByEmail
=
userRepository
.
countUserByEmail
(
email
);
Long
numByUserName
=
userRepository
.
countUserByUserName
(
userName
);
if
(
numByEmail
>
0
)
{
throw
new
BaseException
(
"该邮箱已被使用"
,
506
);
}
...
...
src/main/java/com/springboot/demo1/service/impl/BooksServiceImpl.java
浏览文件 @
dc168aaf
...
...
@@ -9,10 +9,10 @@ public interface BooksServiceImpl {
public
List
<
Books
>
getBooksList
();
public
Books
getBookById
(
Integer
bookId
)
throws
BaseException
;
public
Books
getBookById
(
Long
bookId
)
throws
BaseException
;
public
void
addBook
(
String
bookName
)
throws
BaseException
;
public
void
deleteBook
(
Integer
bookId
)
throws
BaseException
;
public
void
deleteBook
(
Long
bookId
)
throws
BaseException
;
}
src/main/java/com/springboot/demo1/service/impl/BorrowInfoServiceImpl.java
浏览文件 @
dc168aaf
...
...
@@ -9,6 +9,6 @@ public interface BorrowInfoServiceImpl {
public
List
<
BorrowInfo
>
getBorrowInfoList
();
public
void
updateBorrowInfoList
(
Integer
userId
,
Integer
bookId
,
Integer
type
)
throws
BaseException
;
public
void
updateBorrowInfoList
(
Long
userId
,
Long
bookId
,
Long
type
)
throws
BaseException
;
}
src/main/java/com/springboot/demo1/service/impl/UserServiceImpl.java
浏览文件 @
dc168aaf
...
...
@@ -9,7 +9,7 @@ public interface UserServiceImpl {
public
List
<
User
>
getUserList
();
public
User
getUserByUserId
(
Integer
userId
);
public
User
getUserByUserId
(
Long
userId
);
public
void
addUser
(
String
userName
,
String
passWord
,
String
email
,
String
nickName
)
throws
BaseException
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论