09 权限管理

master
markma 4 years ago
parent 5835cab256
commit 6ffb4ccf2e

@ -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;
@ -37,4 +40,15 @@ public class UserHandler {
}
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";
}
}

Loading…
Cancel
Save