|
|
|
@ -1,10 +1,17 @@
|
|
|
|
|
package com.markma.leave_manager_spb.controller;
|
|
|
|
|
|
|
|
|
|
import com.markma.leave_manager_spb.repository.UserDetailRepository;
|
|
|
|
|
import com.markma.leave_manager_spb.entity.User;
|
|
|
|
|
import com.markma.leave_manager_spb.entity.UserAllDetail;
|
|
|
|
|
import com.markma.leave_manager_spb.entity.UserDetail;
|
|
|
|
|
import com.markma.leave_manager_spb.repository.UserDetailRepository;
|
|
|
|
|
import com.markma.leave_manager_spb.repository.UserRepository;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@ -12,6 +19,8 @@ import java.util.List;
|
|
|
|
|
public class UserDetailHandler {
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserDetailRepository userDetailRepository;
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserRepository userRepository;
|
|
|
|
|
|
|
|
|
|
@GetMapping("/hello")
|
|
|
|
|
public String hello() {
|
|
|
|
@ -22,10 +31,30 @@ public class UserDetailHandler {
|
|
|
|
|
public List<UserDetail> findAll() {
|
|
|
|
|
return userDetailRepository.findAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/findById/{id}")
|
|
|
|
|
public UserDetail findById(@PathVariable("id") Integer id){
|
|
|
|
|
public UserDetail findById(@PathVariable("id") Integer id) {
|
|
|
|
|
return userDetailRepository.findById(id).get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/findAllUser")
|
|
|
|
|
public List<UserAllDetail> findAllUser() {
|
|
|
|
|
List<UserAllDetail> UADs = new ArrayList<UserAllDetail>();
|
|
|
|
|
List<UserDetail> UDs = userDetailRepository.findAll();
|
|
|
|
|
List<User> Users = userRepository.findAll();
|
|
|
|
|
for (int i = 0; i < Users.size(); i++) {
|
|
|
|
|
UserAllDetail UAD = new UserAllDetail();
|
|
|
|
|
UserDetail UD = UDs.get(i);
|
|
|
|
|
User user = Users.get(i);
|
|
|
|
|
UAD.setId(i + 1);
|
|
|
|
|
UAD.setUsername(user.getUsername());
|
|
|
|
|
UAD.setPassword(user.getPassword());
|
|
|
|
|
UAD.setType(user.getType());
|
|
|
|
|
UAD.setName(UD.getName());
|
|
|
|
|
UAD.setSchool_id(UD.getSchool_id());
|
|
|
|
|
UADs.add(UAD);
|
|
|
|
|
}
|
|
|
|
|
return UADs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|