예제 #1
0
 public void addZone(Integer uid, List<Integer> zones) {
   // 给用户加权限
   Admin admin = dao.findOne(uid);
   if (admin != null) {
     admin.getFunctions().clear();
     for (Integer fid : zones) {
       admin.getZones().add(zoneDao.findOne(fid));
     }
     dao.save(admin);
   }
 }
예제 #2
0
 public void addFunction(Integer uid, List<Integer> functions) {
   // 给用户加权限
   Admin admin = dao.findOne(uid);
   if (admin != null) {
     admin.getFunctions().clear();
     for (Integer fid : functions) {
       admin.getFunctions().add(functionDao.findOne(fid));
     }
     dao.save(admin);
   }
 }
예제 #3
0
 public Admin createAdmin(String name, String password) {
   Admin admin = new Admin();
   admin.setName(name);
   admin.setPassword(password);
   admin.setStatus(1);
   dao.save(admin);
   return admin;
 }
예제 #4
0
 public Admin getById(Integer id) {
   Admin admin = dao.findOne(id);
   List<Function> functions = admin.getFunctions();
   for (Function function : functions) {
     // System.out.println(function.getName());
   }
   List<Zone> zones = admin.getZones();
   for (Zone zone : zones) {}
   return admin;
 }
예제 #5
0
 public Admin getByName(String name) {
   Admin admin = dao.findByName(name);
   List<Function> functions = admin.getFunctions();
   for (Function function : functions) {
     // System.out.println(function.getName());
   }
   List<Zone> zones = admin.getZones();
   for (Zone zone : zones) {}
   return admin;
 }
예제 #6
0
  public List<Admin> getAllAdmins(int page, int size) {
    List<Admin> admins = dao.getAll(new PageRequest(page, size));
    for (Admin admin : admins) {
      List<Function> functions = admin.getFunctions();
      for (Function function : functions) {}

      List<Zone> zones = admin.getZones();
      for (Zone zone : zones) {}
    }
    return admins;
  }
예제 #7
0
 public void delete(Integer id) {
   Admin admin = dao.findOne(id);
   admin.setStatus(-1);
   dao.save(admin);
 }
예제 #8
0
 public int getAllCount() {
   return dao.getCount();
 }
예제 #9
0
 public void updateAdmin(Admin admin) {
   dao.save(admin);
 }