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); } }
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); } }
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; }
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; }
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; }
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; }
public void delete(Integer id) { Admin admin = dao.findOne(id); admin.setStatus(-1); dao.save(admin); }
public int getAllCount() { return dao.getCount(); }
public void updateAdmin(Admin admin) { dao.save(admin); }