Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_45598856
white-jotter
提交
c3cabb35
W
white-jotter
项目概览
qq_45598856
/
white-jotter
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
white-jotter
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c3cabb35
编写于
4月 10, 2019
作者:
E
Evan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update: 更新后端 API
上级
7a7f4016
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
156 addition
and
36 deletion
+156
-36
wj-vue/src/components/library/Books.vue
wj-vue/src/components/library/Books.vue
+1
-5
wj-vue/src/components/library/EditForm.vue
wj-vue/src/components/library/EditForm.vue
+1
-1
wj-vue/src/components/library/LibraryIndex.vue
wj-vue/src/components/library/LibraryIndex.vue
+22
-9
wj-vue/src/components/library/SideMenu.vue
wj-vue/src/components/library/SideMenu.vue
+29
-19
wj/src/main/java/com/gm/wj/controller/LibraryController.java
wj/src/main/java/com/gm/wj/controller/LibraryController.java
+9
-2
wj/src/main/java/com/gm/wj/dao/BookDAO.java
wj/src/main/java/com/gm/wj/dao/BookDAO.java
+2
-0
wj/src/main/java/com/gm/wj/dao/CategoryDAO.java
wj/src/main/java/com/gm/wj/dao/CategoryDAO.java
+9
-0
wj/src/main/java/com/gm/wj/pojo/Book.java
wj/src/main/java/com/gm/wj/pojo/Book.java
+12
-0
wj/src/main/java/com/gm/wj/pojo/Category.java
wj/src/main/java/com/gm/wj/pojo/Category.java
+37
-0
wj/src/main/java/com/gm/wj/service/BookService.java
wj/src/main/java/com/gm/wj/service/BookService.java
+9
-0
wj/src/main/java/com/gm/wj/service/CategoryService.java
wj/src/main/java/com/gm/wj/service/CategoryService.java
+25
-0
未找到文件。
wj-vue/src/components/library/Books.vue
浏览文件 @
c3cabb35
...
...
@@ -58,13 +58,9 @@
methods
:
{
loadBooks
()
{
var
_this
=
this
this
.
$axios
.
get
(
'
/
library
'
).
then
(
resp
=>
{
this
.
$axios
.
get
(
'
/
books
'
).
then
(
resp
=>
{
if
(
resp
&&
resp
.
status
===
200
)
{
_this
.
books
=
resp
.
data
var
length
=
resp
.
data
.
length
_this
.
cardLoading
=
Array
.
apply
(
null
,
Array
(
length
)).
map
(
function
(
item
,
i
)
{
return
false
})
}
})
},
...
...
wj-vue/src/components/library/EditForm.vue
浏览文件 @
c3cabb35
...
...
@@ -70,7 +70,7 @@
onSubmit
()
{
console
.
log
(
'
submit!
'
)
this
.
$axios
.
post
(
'
/
library
'
,
{
.
post
(
'
/
books
'
,
{
id
:
this
.
form
.
id
,
cover
:
this
.
form
.
cover
,
title
:
this
.
form
.
title
,
...
...
wj-vue/src/components/library/LibraryIndex.vue
浏览文件 @
c3cabb35
<
template
>
<el-container>
<el-aside
style=
"width: 200px;margin-top: 20px"
>
<SideMenu
></SideMenu>
<SideMenu
@
indexSelect=
"listByCategory"
ref=
"sideMenu"
></SideMenu>
</el-aside>
<el-main>
<el-row>
<books
class=
"books-area"
></books>
<books
class=
"books-area"
ref=
"booksArea"
></books>
</el-row>
</el-main>
</el-container>
</
template
>
<
script
>
import
SideMenu
from
'
./SideMenu
'
import
Tag
from
'
./Tag
'
import
Pagination
from
'
./Pagination
'
import
Books
from
'
./Books
'
export
default
{
name
:
'
AppLibrary
'
,
components
:
{
Books
,
Pagination
,
Tag
,
SideMenu
}
import
SideMenu
from
'
./SideMenu
'
import
Tag
from
'
./Tag
'
import
Pagination
from
'
./Pagination
'
import
Books
from
'
./Books
'
export
default
{
name
:
'
AppLibrary
'
,
components
:
{
Books
,
Pagination
,
Tag
,
SideMenu
},
methods
:
{
listByCategory
()
{
var
_this
=
this
var
cid
=
this
.
$refs
.
sideMenu
.
cid
var
url
=
'
categories/
'
+
cid
+
'
/books
'
this
.
$axios
.
get
(
url
).
then
(
resp
=>
{
if
(
resp
&&
resp
.
status
===
200
)
{
_this
.
$refs
.
booksArea
.
books
=
resp
.
data
}
})
}
}
}
</
script
>
<
style
scoped
>
...
...
wj-vue/src/components/library/SideMenu.vue
浏览文件 @
c3cabb35
...
...
@@ -2,30 +2,33 @@
<el-menu
default-active=
"2"
class=
"el-menu-vertical-demo"
@
open=
"handleOpen"
@
close=
"handleClose"
@
select=
"handleSelect"
background-color=
"#545c64"
text-color=
"#fff"
active-text-color=
"#ffd04b"
>
<el-submenu
index=
"1"
>
<template
slot=
"title"
>
<i
class=
"el-icon-location"
></i>
<span>
分类一
</span>
</
template
>
<el-menu-item
index=
"1-1"
>
子类1
</el-menu-item>
<el-menu-item
index=
"1-2"
>
子类2
</el-menu-item>
</el-submenu>
<el-menu-item
index=
"1"
>
<i
class=
"el-icon-menu"
></i>
<span
slot=
"title"
>
文学
</span>
</el-menu-item>
<el-menu-item
index=
"2"
>
<i
class=
"el-icon-menu"
></i>
<span
slot=
"title"
>
分类二
</span>
<span
slot=
"title"
>
流行
</span>
</el-menu-item>
<el-menu-item
index=
"3"
>
<i
class=
"el-icon-
document
"
></i>
<span
slot=
"title"
>
分类三
</span>
<i
class=
"el-icon-
menu
"
></i>
<span
slot=
"title"
>
文化
</span>
</el-menu-item>
<el-menu-item
index=
"4"
>
<i
class=
"el-icon-setting"
></i>
<span
slot=
"title"
>
分类四
</span>
<i
class=
"el-icon-menu"
></i>
<span
slot=
"title"
>
生活
</span>
</el-menu-item>
<el-menu-item
index=
"5"
>
<i
class=
"el-icon-menu"
></i>
<span
slot=
"title"
>
经管
</span>
</el-menu-item>
<el-menu-item
index=
"6"
>
<i
class=
"el-icon-menu"
></i>
<span
slot=
"title"
>
科技
</span>
</el-menu-item>
</el-menu>
</
template
>
...
...
@@ -33,12 +36,19 @@
<
script
>
export
default
{
name
:
'
SideMenu
'
,
data
()
{
return
{
cid
:
''
}
},
methods
:
{
handleOpen
(
key
,
keyPath
)
{
console
.
log
(
key
,
keyPath
)
},
handle
Close
(
key
,
keyPath
)
{
//
handleOpen (key, keyPath) {
//
console.log(key, keyPath)
//
},
handle
Select
(
key
,
keyPath
)
{
console
.
log
(
key
,
keyPath
)
this
.
cid
=
key
this
.
$emit
(
'
indexSelect
'
)
}
}
}
...
...
wj/src/main/java/com/gm/wj/controller/LibraryController.java
浏览文件 @
c3cabb35
...
...
@@ -14,13 +14,13 @@ public class LibraryController {
BookService
bookService
;
@CrossOrigin
@GetMapping
(
value
=
"/api/
library
"
)
@GetMapping
(
value
=
"/api/
books
"
)
public
List
<
Book
>
list
()
throws
Exception
{
return
bookService
.
list
();
}
@CrossOrigin
@PostMapping
(
value
=
"/api/
library
"
)
@PostMapping
(
value
=
"/api/
books
"
)
public
Book
addOrUpdate
(
@RequestBody
Book
book
)
throws
Exception
{
bookService
.
addOrUpdate
(
book
);
return
book
;
...
...
@@ -42,4 +42,11 @@ public class LibraryController {
return
bookService
.
Search
(
s
.
getKeywords
());
}
}
@CrossOrigin
@GetMapping
(
"/categories/{cid}/books"
)
public
List
<
Book
>
listByCategory
(
@PathVariable
(
"cid"
)
int
cid
)
throws
Exception
{
System
.
out
.
println
(
"test"
);
return
bookService
.
listByCategory
(
cid
);
}
}
wj/src/main/java/com/gm/wj/dao/BookDAO.java
浏览文件 @
c3cabb35
package
com.gm.wj.dao
;
import
com.gm.wj.pojo.Book
;
import
com.gm.wj.pojo.Category
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
BookDAO
extends
JpaRepository
<
Book
,
Integer
>
{
List
<
Book
>
findAllByCategory
(
Category
category
);
List
<
Book
>
findAllByTitleLikeOrAuthorLike
(
String
keyword1
,
String
keyword2
);
}
wj/src/main/java/com/gm/wj/dao/CategoryDAO.java
0 → 100644
浏览文件 @
c3cabb35
package
com.gm.wj.dao
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
com.gm.wj.pojo.Category
;
public
interface
CategoryDAO
extends
JpaRepository
<
Category
,
Integer
>
{
}
wj/src/main/java/com/gm/wj/pojo/Book.java
浏览文件 @
c3cabb35
...
...
@@ -13,6 +13,10 @@ public class Book {
@Column
(
name
=
"id"
)
int
id
;
@ManyToOne
@JoinColumn
(
name
=
"cid"
)
private
Category
category
;
String
cover
;
String
title
;
String
author
;
...
...
@@ -20,6 +24,14 @@ public class Book {
String
press
;
String
abs
;
public
Category
getCategory
()
{
return
category
;
}
public
void
setCategory
(
Category
category
)
{
this
.
category
=
category
;
}
public
String
getDate
()
{
return
date
;
}
...
...
wj/src/main/java/com/gm/wj/pojo/Category.java
0 → 100644
浏览文件 @
c3cabb35
package
com.gm.wj.pojo
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
@Entity
@Table
(
name
=
"category"
)
@JsonIgnoreProperties
({
"handler"
,
"hibernateLazyInitializer"
})
public
class
Category
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"id"
)
int
id
;
String
name
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
}
wj/src/main/java/com/gm/wj/service/BookService.java
浏览文件 @
c3cabb35
...
...
@@ -2,6 +2,7 @@ package com.gm.wj.service;
import
com.gm.wj.dao.BookDAO
;
import
com.gm.wj.pojo.Book
;
import
com.gm.wj.pojo.Category
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Service
;
...
...
@@ -12,6 +13,8 @@ import java.util.List;
public
class
BookService
{
@Autowired
BookDAO
bookDAO
;
@Autowired
CategoryService
categoryService
;
public
List
<
Book
>
list
()
{
Sort
sort
=
new
Sort
(
Sort
.
Direction
.
DESC
,
"id"
);
...
...
@@ -26,6 +29,12 @@ public class BookService {
bookDAO
.
deleteById
(
id
);
}
public
List
<
Book
>
listByCategory
(
int
cid
)
{
Category
category
=
categoryService
.
get
(
cid
);
Sort
sort
=
new
Sort
(
Sort
.
Direction
.
DESC
,
"id"
);
return
bookDAO
.
findAllByCategory
(
category
);
}
public
List
<
Book
>
Search
(
String
keywords
)
{
return
bookDAO
.
findAllByTitleLikeOrAuthorLike
(
'%'
+
keywords
+
'%'
,
'%'
+
keywords
+
'%'
);
}
...
...
wj/src/main/java/com/gm/wj/service/CategoryService.java
0 → 100644
浏览文件 @
c3cabb35
package
com.gm.wj.service
;
import
com.gm.wj.dao.CategoryDAO
;
import
com.gm.wj.pojo.Category
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
public
class
CategoryService
{
@Autowired
CategoryDAO
categoryDAO
;
public
List
<
Category
>
list
()
{
Sort
sort
=
new
Sort
(
Sort
.
Direction
.
DESC
,
"id"
);
return
categoryDAO
.
findAll
(
sort
);
}
public
Category
get
(
int
id
)
{
Category
c
=
categoryDAO
.
findById
(
id
).
orElse
(
null
);
return
c
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录