package serviceimp; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; import po.Power; import po.Role; import service.PowerService; @SuppressWarnings("unchecked") public class PowerServiceImp extends BaseServiceImp implements PowerService { /** * add update,delete role * * @param id * @param name * @param oper * @return */ public String edit_role(String id, String name, String oper) { // add if ("add".equals(oper)) { if (!this.isNull(name)) { Role r = new Role(); r.setName(name.trim()); this.saveOrUpdate(r); } else { return "请输入角色名称!"; } } // edit if ("update".equals(oper)) { if (!this.isNull(name)) { Role r = (Role) this.get(Role.class, id); r.setName(name.trim()); this.saveOrUpdate(r); } else { return "请输入角色名称!"; } } // delete if ("delete".equals(oper)) { this.bulkUpdate("delete from Role as r where r.id='" + id + "'"); } return "1"; } /** * add update,delete role * * @param id * @param name * @param url * @param oper * @return */ public String edit_power(String id, String name, String url, String oper) { // add if ("add".equals(oper)) { if (this.isNull(name)) return "请输入权限名称!"; if (this.isNull(url)) return "请输入角色url!"; Power p = new Power(name.trim(), url.trim()); this.saveOrUpdate(p); } // edit if ("update".equals(oper)) { if (this.isNull(name)) return "请输入权限名称!"; if (this.isNull(url)) return "请输入角色url!"; Power p = (Power) this.get(Power.class, id); p.setName(name.trim()); p.setUrl(url.trim()); this.saveOrUpdate(p); } // delete if ("delete".equals(oper)) { this.bulkUpdate("delete from Power as p where p.id='" + id + "'"); } return "1"; } /** * 为角色分配权限 * * @param role_id * @param power_id * @return */ public String set_power_to_role(String role_id, String power_id[], String unpower_id[]) { try { @SuppressWarnings("unused") Role r = (Role) this.findAll( "from Role as r left join fetch r.powers where r.id='" + role_id + "'").get(0); Set<Power> pset = r.getPowers(); for (Iterator<Power> it = pset.iterator(); it.hasNext();) { Power p = it.next(); // if (ArrayUtils.contains(unpower_id, p.getId())) { // p.getRoles().remove(r); // it.remove(); // } for (int i = 0; i < unpower_id.length; i++) { if (p.getId().equals(unpower_id[i])) { // 删除权限 p.getRoles().remove(r); it.remove(); } } } for (int i = 0; i < power_id.length; i++) { if (power_id[i] != null && !power_id[i].trim().equals("")) { Power p = (Power) this.get(Power.class, power_id[i]); p.getRoles().add(r); pset.add(p); } } this.saveOrUpdate(r); } catch (Exception ex) { ex.printStackTrace(); return "-1"; } return "1"; } /** * 取角色权限 * * @param role_id * @return */ public List list_powers_by_role_id(String role_id) { List t = new ArrayList(); Role r = (Role) this.findAll( "from Role as r left join fetch r.powers where r.id='" + role_id + "'").get(0); Set<Power> pset = r.getPowers(); Iterator<Power> it = pset.iterator(); while (it.hasNext()) { t.add(it.next().getName()); } return t; } public List list_powers(int cur_page, int page_size) { // TODO Auto-generated method stub String hql = "select new Power(p.id,p.name,p.url) from Power as p"; return this.findAllByPage01(hql, page_size, cur_page); } public List list_roles(int cur_page, int page_size) { // TODO Auto-generated method stub String hql = "select new Role(r.id,r.name) from Role as r"; return this.findAllByPage01(hql, page_size, cur_page); } }
启动oracle数据库时,提示没有监听器 如果,你在控制面板/管理工具/服务中双击打开OracleOraHome92TNSListener的服务看到其“可执行文件的路径”一栏为空时的处理方法: 首先运行regedit.exe启动注册表编辑器,在HKEY_LOCAL_MACHINE/SYSTEM/ControlSet002/下的Services和CurrentControlSet/Services下找到OracleOraHome92TNSListener项,在右边窗口按右键,新建/字符串,取名ImagePath。 双击新见的建,在“数值数据”项输入D:\oracle\ora92\bin\TNSLSNR.EXE(根据你自己的实际情况进行修改),确定完成。 再次在服务中双击打开OracleOraHome92TNSListener的服务看到其“可执行文件的路径”一栏已经显示了其正确的值。这时你可以启动监听了。
package action; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import javax.imageio.ImageIO; import service.AdminService; import service.ManagerService; import service.UserService; import com.opensymphony.xwork2.ActionSupport; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGImageEncoder; public class BaseAction extends ActionSupport { private static final long serialVersionUID = 1L; @SuppressWarnings("unused") protected ManagerService managerService; protected AdminService adminService; protected UserService userService; public void setManagerService(ManagerService managerService) { this.managerService = managerService; } public void setAdminService(AdminService adminService) { this.adminService = adminService; } public UserService getUserService() { return userService; } public void setUserService(UserService userService) { this.userService = userService; } public boolean isNull(String str) { if (str == null || "".equals(str.trim())) { return true; } return false; } // 自己封装的一个把源文件对象复制成目标文件对象 public boolean copy(File src, File dst) { InputStream in = null; OutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(src), 1024); out = new BufferedOutputStream(new FileOutputStream(dst), 1024); byte[] buffer = new byte[1024]; int len = 0; while ((len = in.read(buffer)) > 0) { out.write(buffer, 0, len); } return true; } catch (Exception e) { e.printStackTrace(); return false; } finally { if (null != in) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } if (null != out) { try { out.close(); } catch (IOException e) { e.printStackTrace(); } } } } /** * 图像的等比缩略 * * @param fi大图文件 * @param fo将要转换出的小图文件 */ public boolean resize_image(File fi, File fo) { try { // File fi = new File("E:/3.jpg"); // 大图文件 // File fo = new File("E:/333.jpg"); // 将要转换出的小图文件 // AffineTransform transform = new AffineTransform(); BufferedImage bis = ImageIO.read(fi); int w = bis.getWidth(); // System.out.println(w); int h = bis.getHeight(); // System.out.println(h); // double scale = (double) w / h; int nw = w; int nh = h; if (w > 320) { nw = 320; nh = nw * h / w; if (nh > 320) { nh = 320; nw = nh * w / h; } } else if (h > 320) { nh = 320; nw = nh * w / h; if (nw > 320) { nw = 320; nh = nw * h / w; } } BufferedImage tag = new BufferedImage(nw, nh, BufferedImage.TYPE_INT_RGB); tag.getGraphics().drawImage(bis, 0, 0, nw, nh, null); // 绘制缩小后的图 // 转换为32*32 jpg格式 FileOutputStream newimage = new FileOutputStream(fo); // 输出到文件流 JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(newimage); encoder.encode(tag); newimage.close(); return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 图像的等比缩略 * * * width 输出图片大小 height * * @param fi大图文件 * @param fo将要转换出的小图文件 */ public boolean resize_image(File fi, File fo, int width, int height) { try { // File fi = new File("E:/3.jpg"); // 大图文件 // File fo = new File("E:/333.jpg"); // 将要转换出的小图文件 // AffineTransform transform = new AffineTransform(); BufferedImage bis = ImageIO.read(fi); int w = bis.getWidth(); // System.out.println(w); int h = bis.getHeight(); // System.out.println(h); // double scale = (double) w / h; int nw = w; int nh = h; if (w > width) { nw = width; nh = nw * h / w; if (nh > height) { nh = height; nw = nh * w / h; } } else if (h > height) { nh = height; nw = nh * w / h; if (nw > width) { nw = width; nh = nw * h / w; } } BufferedImage tag = new BufferedImage(nw, nh, BufferedImage.TYPE_INT_RGB); tag.getGraphics().drawImage(bis, 0, 0, nw, nh, null); // 绘制缩小后的图 // 转换为32*32 jpg格式 FileOutputStream newimage = new FileOutputStream(fo); // 输出到文件流 JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(newimage); encoder.encode(tag); newimage.close(); return true; } catch (Exception e) { e.printStackTrace(); return false; } } }