|
|
|
@ -1,9 +1,12 @@
|
|
|
|
|
package com.markma.leave_manager_spb.controller;
|
|
|
|
|
|
|
|
|
|
import com.markma.leave_manager_spb.repository.UserRepository;
|
|
|
|
|
import com.markma.leave_manager_spb.entity.User;
|
|
|
|
|
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.List;
|
|
|
|
|
|
|
|
|
@ -29,12 +32,23 @@ public class UserHandler {
|
|
|
|
|
for (int i = 0; i < users.size(); i++) {
|
|
|
|
|
if (users.get(i).getUsername().equals(username)) {
|
|
|
|
|
if (users.get(i).getPassword().equals(password)) {
|
|
|
|
|
return users.get(i).getId()+" "+users.get(i).getType();
|
|
|
|
|
} else{
|
|
|
|
|
return users.get(i).getId() + " " + users.get(i).getType();
|
|
|
|
|
} else {
|
|
|
|
|
return "error:wrong password";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "error:wrong username";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/checkUseridAndType/{userid}/{type}")
|
|
|
|
|
public String checkUseridAndType(@PathVariable("userid") Integer userid, @PathVariable("type") String type) {
|
|
|
|
|
List<User> users = userRepository.findAll();
|
|
|
|
|
for (int i = 0; i < users.size(); i++) {
|
|
|
|
|
if (users.get(i).getType().equals(type) && users.get(i).getId().equals(userid)) {
|
|
|
|
|
return "success";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "failed";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|