Commit d4f04b14 authored by issei.miyajima's avatar issei.miyajima

Merge branch '管理機能(ユーザー権限変更)' into 'master'

管理機能(ユーザー権限変更)

See merge request !46
parents 190f9c8d 6d6eb650
......@@ -9,6 +9,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.example.domain.Shoes;
import com.example.domain.User;
import com.example.repository.UserRepository;
......@@ -39,4 +40,6 @@ public class LoginUserDetailsService implements UserDetailsService {
public List<User> findAll(){
return userRepository.findAll();
}
}
......@@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.multipart.MultipartFile;
......@@ -147,5 +146,19 @@ public class ManagementController {
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";
}
}
......@@ -8,11 +8,11 @@ $('#user_button').on('click', function(){
})
//権限変更の確認アラート
$('#roleBtn').on('click', function(){
$('.roleBtn').on('click', function(){
if(!confirm('本当に権限を変更しますか?')) {
return false;
}else{
//権限書き換え機能
//user権限変更
}
})
......@@ -28,5 +28,6 @@ $('.shoeDeleteBtn').on('click', function(){
return false;
}else{
//削除機能への遷移
}
})
\ No newline at end of file
......@@ -37,10 +37,17 @@
<th>名前</th>
<th>権限</th>
</tr>
<tr>
<td>1</td>
<td>demo</td>
<td><input name="roles" th:text="admin"/><button id="roleBtn">権限変更</button></td>
<tr th:each="user : ${user}">
<td th:text="${user.id}">1</td>
<td th:text="${user.name}">demo</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>
</table>
</div>
......@@ -132,7 +139,7 @@
<input type="submit" name="form" value="編集"/>
<input type="hidden" name="id" th:value="${shoe.id}"/>
</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>
<form th:action="@{/limited/admin/management//{id}(id=${shoe.id})}" th:method="delete">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment