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
6d6eb650
Commit
6d6eb650
authored
Oct 21, 2020
by
issei.miyajima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
管理機能(ユーザー権限変更)
parent
190f9c8d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
8 deletions
+33
-8
LoginUserDetailsService.java
...ain/java/com/example/service/LoginUserDetailsService.java
+3
-0
ManagementController.java
src/main/java/com/example/web/ManagementController.java
+14
-1
management.js
src/main/resources/static/js/management.js
+4
-2
management.html
src/main/resources/templates/management.html
+12
-5
No files found.
src/main/java/com/example/service/LoginUserDetailsService.java
View file @
6d6eb650
...
@@ -9,6 +9,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
...
@@ -9,6 +9,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.example.domain.Shoes
;
import
com.example.domain.User
;
import
com.example.domain.User
;
import
com.example.repository.UserRepository
;
import
com.example.repository.UserRepository
;
...
@@ -39,4 +40,6 @@ public class LoginUserDetailsService implements UserDetailsService {
...
@@ -39,4 +40,6 @@ public class LoginUserDetailsService implements UserDetailsService {
public
List
<
User
>
findAll
(){
public
List
<
User
>
findAll
(){
return
userRepository
.
findAll
();
return
userRepository
.
findAll
();
}
}
}
}
src/main/java/com/example/web/ManagementController.java
View file @
6d6eb650
...
@@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.DeleteMapping;
...
@@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.DeleteMapping;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -147,5 +146,19 @@ public class ManagementController {
...
@@ -147,5 +146,19 @@ public class ManagementController {
return
"redirect:/limited/admin/management"
;
return
"redirect:/limited/admin/management"
;
}
}
//user権限変更
@PostMapping
(
path
=
"{id}"
)
String
changeRoles
(
Integer
id
){
User
user
=
loginUserDetailsService
.
findOne
(
id
);
String
role
=
user
.
getRoles
();
if
(
role
.
equals
(
"ADMIN"
)){
user
.
setRoles
(
"USER"
);
}
else
{
user
.
setRoles
(
"ADMIN"
);
}
loginUserDetailsService
.
create
(
user
);
return
"redirect:/limited/admin/management"
;
}
}
}
src/main/resources/static/js/management.js
View file @
6d6eb650
...
@@ -8,11 +8,11 @@ $('#user_button').on('click', function(){
...
@@ -8,11 +8,11 @@ $('#user_button').on('click', function(){
})
})
//権限変更の確認アラート
//権限変更の確認アラート
$
(
'
#
roleBtn'
).
on
(
'click'
,
function
(){
$
(
'
.
roleBtn'
).
on
(
'click'
,
function
(){
if
(
!
confirm
(
'本当に権限を変更しますか?'
))
{
if
(
!
confirm
(
'本当に権限を変更しますか?'
))
{
return
false
;
return
false
;
}
else
{
}
else
{
//
権限書き換え機能
//
user権限変更
}
}
})
})
...
@@ -28,5 +28,6 @@ $('.shoeDeleteBtn').on('click', function(){
...
@@ -28,5 +28,6 @@ $('.shoeDeleteBtn').on('click', function(){
return
false
;
return
false
;
}
else
{
}
else
{
//削除機能への遷移
//削除機能への遷移
}
}
})
})
\ No newline at end of file
src/main/resources/templates/management.html
View file @
6d6eb650
...
@@ -37,10 +37,17 @@
...
@@ -37,10 +37,17 @@
<th>
名前
</th>
<th>
名前
</th>
<th>
権限
</th>
<th>
権限
</th>
</tr>
</tr>
<tr>
<tr
th:each=
"user : ${user}"
>
<td>
1
</td>
<td
th:text=
"${user.id}"
>
1
</td>
<td>
demo
</td>
<td
th:text=
"${user.name}"
>
demo
</td>
<td><input
name=
"roles"
th:text=
"admin"
/><button
id=
"roleBtn"
>
権限変更
</button></td>
<td
name=
"roles"
th:text=
"${user.roles}"
></td>
<td>
<!-- <button type="button" class="roleBtn">権限変更</button> -->
<form
th:action=
"@{/limited/admin/management/{id}(id=${user.id})}"
th:method=
"post"
>
<input
type=
"submit"
name=
"form"
value=
"権限変更"
class=
"roleBtn"
/>
<input
type=
"hidden"
name=
"id"
th:value=
"${user.id}"
/>
</form>
</td>
</tr>
</tr>
</table>
</table>
</div>
</div>
...
@@ -132,7 +139,7 @@
...
@@ -132,7 +139,7 @@
<input type="submit" name="form" value="編集"/>
<input type="submit" name="form" value="編集"/>
<input type="hidden" name="id" th:value="${shoe.id}"/>
<input type="hidden" name="id" th:value="${shoe.id}"/>
</form>-->
</form>-->
<a
th:href=
"@{/limited/admin/management/{id}/edit(id=${shoe.id})}"
class=
"btn
btn-primary
"
>
編集
</a>
<a
th:href=
"@{/limited/admin/management/{id}/edit(id=${shoe.id})}"
class=
"btn"
>
編集
</a>
</td>
</td>
<td>
<td>
<form
th:action=
"@{/limited/admin/management//{id}(id=${shoe.id})}"
th:method=
"delete"
>
<form
th:action=
"@{/limited/admin/management//{id}(id=${shoe.id})}"
th:method=
"delete"
>
...
...
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