Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
Ecsite
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shoei.kanno
Ecsite
Commits
0eac338a
Commit
0eac338a
authored
Oct 23, 2020
by
shoei.kanno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商品管理画面、重複商品は個数を変更
parent
9eeaf4ab
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
0 deletions
+34
-0
ShoesRepository.java
src/main/java/com/example/repository/ShoesRepository.java
+6
-0
ShoesService.java
src/main/java/com/example/service/ShoesService.java
+5
-0
ManagementController.java
src/main/java/com/example/web/ManagementController.java
+23
-0
スニーカー3.jpg
src/main/resources/static/upload/スニーカー3.jpg
+0
-0
No files found.
src/main/java/com/example/repository/ShoesRepository.java
View file @
0eac338a
...
...
@@ -12,4 +12,9 @@ import com.example.domain.Shoes;
public
interface
ShoesRepository
extends
JpaRepository
<
Shoes
,
Integer
>{
@Query
(
value
=
"SELECT * FROM shoes WHERE product_status = ?1 ORDER BY id DESC"
,
nativeQuery
=
true
)
public
List
<
Shoes
>
findAllByStatus
(
Integer
status
);
//管理画面で使用
@Query
(
value
=
"SELECT * FROM shoes WHERE name = ?1 && size = ?2"
,
nativeQuery
=
true
)
public
Shoes
findOneAddStock
(
String
name
,
Integer
size
);
}
\ No newline at end of file
src/main/java/com/example/service/ShoesService.java
View file @
0eac338a
...
...
@@ -49,4 +49,9 @@ public class ShoesService {
public
List
<
Shoes
>
findAllLimitedShoes
()
{
return
shoesRepository
.
findAllByStatus
(
1
);
}
//管理画面、重複商品のバリデーション
public
Shoes
findOneAddStock
(
String
name
,
Integer
size
)
{
return
shoesRepository
.
findOneAddStock
(
name
,
size
);
};
}
src/main/java/com/example/web/ManagementController.java
View file @
0eac338a
...
...
@@ -62,7 +62,23 @@ public class ManagementController {
if
(
result
.
hasErrors
())
{
return
"management"
;
}
multipartFile
=
form
.
getMultipartFile
();
System
.
out
.
println
(
multipartFile
);
//以前に登録されている商品の場合に登録できないバリデーション
Shoes
sameShoes
=
shoesService
.
findOneAddStock
(
form
.
getName
(),
form
.
getSize
());
System
.
out
.
println
(
sameShoes
);
if
(!(
sameShoes
==
null
))
{
Integer
sumStock
=
form
.
getStock
()
+
sameShoes
.
getStock
();
if
(
sumStock
>=
10
)
{
sameShoes
.
setStock
(
10
);
shoesService
.
update
(
sameShoes
);
}
else
{
sameShoes
.
setStock
(
sumStock
);
shoesService
.
update
(
sameShoes
);
}
}
else
{
Shoes
shoes
=
new
Shoes
();
if
(!
multipartFile
.
isEmpty
())
{
try
{
...
...
@@ -112,12 +128,19 @@ public class ManagementController {
}
else
{
shoes
.
setPhoto
(
"noimage.jpg"
);
}
shoes
.
setName
(
form
.
getName
());
shoes
.
setPrice
(
form
.
getPrice
());
shoes
.
setStock
(
form
.
getStock
());
shoes
.
setSize
(
form
.
getSize
());
shoes
.
setProductStatus
(
form
.
getProductStatus
());
shoesService
.
update
(
shoes
);
}
//遷移先
return
"redirect:/limited/admin/management"
;
}
...
...
src/main/resources/static/upload/スニーカー3.jpg
View replaced file @
9eeaf4ab
View file @
0eac338a
4.93 KB
|
W:
|
H:
4.92 KB
|
W:
|
H:
2-up
Swipe
Onion skin
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment