• 权限关系设置


    1,数据库脚本

    View Code
    -- 删除表
    DROP TABLE admin_admingroup ;
    DROP TABLE admingroup_privilege ;
    DROP TABLE admin ;
    DROP TABLE admingroup ;
    DROP TABLE privilege ;
    -- 删除序列
    DROP SEQUENCE groseq ;
    DROP SEQUENCE priseq ;
    -- 创建序列
    CREATE SEQUENCE groseq ;
    CREATE SEQUENCE priseq ;
    -- 清空回收站
    PURGE RECYCLEBIN ;
    -- 创建表
    CREATE TABLE admin(
    adminid VARCHAR2(50) PRIMARY KEY ,
    password VARCHAR2(32) NOT NULL ,
    note VARCHAR2(200) NOT NULL ,
    adminflag NUMBER DEFAULT 1
    ) ;
    CREATE TABLE admingroup(
    groupid NUMBER PRIMARY KEY ,
    name VARCHAR2(50) NOT NULL ,
    note VARCHAR2(200)
    ) ;
    CREATE TABLE privilege(
    pid NUMBER PRIMARY KEY ,
    name VARCHAR2(50) NOT NULL ,
    note VARCHAR2(200)
    ) ;
    CREATE TABLE admin_admingroup(
    adminid VARCHAR2(50) REFERENCES admin(adminid) ON DELETE CASCADE ,
    groupid NUMBER REFERENCES admingroup(groupid) ON DELETE CASCADE
    ) ;
    CREATE TABLE admingroup_privilege(
    pid NUMBER REFERENCES privilege(pid) ON DELETE CASCADE ,
    groupid NUMBER REFERENCES admingroup(groupid) ON DELETE CASCADE
    ) ;
    -- 插入测试数据 —— 管理员
    INSERT INTO admin(adminid,password,note,adminflag) VALUES ('admin','admin','超级管理员',0) ;
    INSERT INTO admin(adminid,password,note,adminflag) VALUES ('guest','guest','普通管理员',1) ;
    -- 插入测试数据 —— 管理权限
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'增加管理员','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'更新管理员','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'删除管理员','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'查看管理员','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'添加商品','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'查看商品','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'修改商品','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'更新商品','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'添加新闻','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'更新新闻','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'查看新闻','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'删除新闻','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'增加部门','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'删除部门','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'查看部门','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'修改部门','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'增加雇员','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'查看雇员','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'删除雇员','-') ;
    INSERT INTO privilege(pid,name,note) VALUES (priseq.nextval,'修改雇员','-') ;
    -- 插入测试数据 —— 管理员组
    INSERT INTO admingroup(groupid,name,note) VALUES (groseq.nextval,'系统管理员组','-') ;
    INSERT INTO admingroup(groupid,name,note) VALUES (groseq.nextval,'信息管理员组','-') ;
    -- 插入测试数据 —— 管理员-管理员组
    INSERT INTO admin_admingroup(adminid,groupid) VALUES ('mldnadmin',1) ;
    INSERT INTO admin_admingroup(adminid,groupid) VALUES ('mldnadmin',2) ;
    INSERT INTO admin_admingroup(adminid,groupid) VALUES ('admin',2) ;
    -- 插入测试数据 —— 管理员-权限
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (1,1) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (2,1) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (3,1) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (4,1) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (5,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (6,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (7,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (8,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (9,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (10,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (11,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (12,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (13,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (14,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (15,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (16,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (17,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (18,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (19,2) ;
    INSERT INTO admingroup_privilege(pid,groupid) VALUES (20,2) ;
    -- 事务提交
    COMMIT ;

    2,VO

      Privilege.java

      

    View Code
    package org.xiong.demo.vo;

    import java.io.Serializable;

    public class Privilege implements Serializable
    {
    private int pid;
    private String name;
    private String note;

    public int getPid()
    {
    return pid;
    }

    public void setPid(int pid)
    {
    this.pid = pid;
    }

    public String getName()
    {
    return name;
    }

    public void setName(String name)
    {
    this.name = name;
    }

    public String getNote()
    {
    return note;
    }

    public void setNote(String note)
    {
    this.note = note;
    }

    @Override
    public int hashCode()
    {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((name == null) ? 0 : name.hashCode());
    result = prime * result + ((note == null) ? 0 : note.hashCode());
    result = prime * result + pid;
    return result;
    }

    @Override
    public boolean equals(Object obj)
    {
    if (this == obj) return true;
    if (obj == null) return false;
    if (getClass() != obj.getClass()) return false;
    Privilege other = (Privilege) obj;
    if (name == null)
    {
    if (other.name != null) return false;
    }
    else if (!name.equals(other.name)) return false;
    if (note == null)
    {
    if (other.note != null) return false;
    }
    else if (!note.equals(other.note)) return false;
    if (pid != other.pid) return false;
    return true;
    }

    }

      Admingroup.java

    View Code
     1 package org.xiong.demo.vo;
    2
    3 import java.io.Serializable;
    4 import java.util.List;
    5
    6 public class AdminGroup implements Serializable
    7 {
    8 private int groupid;
    9 private String name;
    10 private String note;
    11 private List<Privilege> allPr;
    12
    13 public List<Privilege> getAllPr()
    14 {
    15 return allPr;
    16 }
    17
    18 public void setAllPr(List<Privilege> allPr)
    19 {
    20 this.allPr = allPr;
    21 }
    22
    23 public int getGroupid()
    24 {
    25 return groupid;
    26 }
    27
    28 public void setGroupid(int groupid)
    29 {
    30 this.groupid = groupid;
    31 }
    32
    33 public String getName()
    34 {
    35 return name;
    36 }
    37
    38 public void setName(String name)
    39 {
    40 this.name = name;
    41 }
    42
    43 public String getNote()
    44 {
    45 return note;
    46 }
    47
    48 public void setNote(String note)
    49 {
    50 this.note = note;
    51 }
    52
    53 }

    3,DAO

      PrivilegeDaoImpl.java

    View Code
      1 package org.xiong.demo.impl;
    2
    3 import java.sql.Connection;
    4 import java.sql.PreparedStatement;
    5 import java.sql.ResultSet;
    6 import java.util.ArrayList;
    7 import java.util.List;
    8
    9 import org.xiong.demo.dao.IAdminGroupDao;
    10 import org.xiong.demo.vo.AdminGroup;
    11
    12 public class AdminGroupDaoImpl implements IAdminGroupDao
    13 {
    14 private Connection conn;
    15 private PreparedStatement psmt;
    16
    17 public AdminGroupDaoImpl(Connection conn)
    18 {
    19 this.conn = conn;
    20 }
    21
    22 public boolean doInsert(AdminGroup vo) throws Exception
    23 {
    24 // TODO Auto-generated method stub
    25 boolean flag = false;
    26 String sql = "insert into admingroup(groupid,name,note) values(groseq.nextval,?,?)";
    27 this.psmt = this.conn.prepareStatement(sql);
    28 this.psmt.setString(1, vo.getName());
    29 this.psmt.setString(2, vo.getNote());
    30 int n = this.psmt.executeUpdate();
    31 if (n > 0)
    32 {
    33 flag = true;
    34 }
    35 return flag;
    36 }
    37
    38 public boolean doUpdate(AdminGroup vo) throws Exception
    39 {
    40 // TODO Auto-generated method stub
    41 boolean flag = false;
    42 String sql = "update admingroup set name=?,note=? where groupid=?";
    43 this.psmt = this.conn.prepareStatement(sql);
    44 this.psmt.setString(1, vo.getName());
    45 this.psmt.setString(2, vo.getNote());
    46 this.psmt.setInt(3, vo.getGroupid());
    47 int n = this.psmt.executeUpdate();
    48 if (n > 0)
    49 {
    50 flag = true;
    51 }
    52 return flag;
    53 }
    54
    55 public boolean doDelete(Integer id) throws Exception
    56 {
    57 // TODO Auto-generated method stub
    58 boolean flag = false;
    59 String sql = "delete from admingroup where groupid=?";
    60 this.psmt = this.conn.prepareStatement(sql);
    61 this.psmt.setInt(1, id);
    62 int n = this.psmt.executeUpdate();
    63 if (n > 0)
    64 {
    65 flag = true;
    66 }
    67 return flag;
    68 }
    69
    70 public AdminGroup findById(Integer id) throws Exception
    71 {
    72 // TODO Auto-generated method stub
    73 AdminGroup per = null;
    74 String sql = "select groupid,name,note from admingroup where groupid=?";
    75 this.psmt = this.conn.prepareStatement(sql);
    76 this.psmt.setInt(1, id);
    77 ResultSet rst = this.psmt.executeQuery();
    78 if (rst.next())
    79 {
    80 per = new AdminGroup();
    81 int groupid = rst.getInt(1);
    82 String name = rst.getString(2);
    83 String note = rst.getString(3);
    84 per.setGroupid(groupid);
    85 per.setName(name);
    86 per.setNote(note);
    87 }
    88 return per;
    89 }
    90
    91 public List<AdminGroup> findAll(String keyword) throws Exception
    92 {
    93 // TODO Auto-generated method stub
    94 List<AdminGroup> allPer = new ArrayList<AdminGroup>();
    95 String sql = "select groupid,name,note from admingroup where groupid like ? or name like ? or note like ?";
    96 this.psmt = this.conn.prepareStatement(sql);
    97 this.psmt.setString(1, "%" + keyword + "%");
    98 this.psmt.setString(2, "%" + keyword + "%");
    99 this.psmt.setString(3, "%" + keyword + "%");
    100 ResultSet rst = this.psmt.executeQuery();
    101 while (rst.next())
    102 {
    103 AdminGroup per = new AdminGroup();
    104 per.setGroupid(rst.getInt(1));
    105 per.setName(rst.getString(2));
    106 per.setNote(rst.getString(3));
    107 allPer.add(per);
    108 }
    109 return allPer;
    110 }
    111
    112 public List<AdminGroup> findAll(String keyword, int currentPage,
    113 int lineSize) throws Exception
    114 {
    115 // TODO Auto-generated method stub
    116 List<AdminGroup> allPer = new ArrayList<AdminGroup>();
    117 String sql = "select groupid,name,note from (SELECT groupid,name,note, ROWNUM rn FROM admingroup WHERE (groupid like ? or name like ? or note like ?) and ROWNUM<=? ORDER BY groupid) temp where temp.rn>?";
    118 this.psmt = conn.prepareStatement(sql);
    119 this.psmt.setString(1, "%" + keyword + "%");
    120 this.psmt.setString(2, "%" + keyword + "%");
    121 this.psmt.setString(3, "%" + keyword + "%");
    122 this.psmt.setInt(4, currentPage * lineSize);
    123 this.psmt.setInt(5, (currentPage - 1) * lineSize);
    124 ResultSet rst = this.psmt.executeQuery();
    125 while (rst.next())
    126 {
    127 AdminGroup per = new AdminGroup();
    128 per.setGroupid(rst.getInt(1));
    129 per.setName(rst.getString(2));
    130 per.setNote(rst.getString(3));
    131 allPer.add(per);
    132 }
    133 return allPer;
    134 }
    135
    136 public long getAllCount(String keyword) throws Exception
    137 {
    138 // TODO Auto-generated method stub
    139 long allCount = 0;
    140 String sql = "select count(groupid) from admingroup where groupid like ? or name like ? or note like ?";
    141 psmt = conn.prepareStatement(sql);
    142 psmt.setString(1, "%" + keyword + "%");
    143 psmt.setString(2, "%" + keyword + "%");
    144 psmt.setString(3, "%" + keyword + "%");
    145 ResultSet rst = psmt.executeQuery();
    146 if (rst.next())
    147 {
    148 allCount = rst.getInt(1);
    149 }
    150 return allCount;
    151 }
    152
    153 public int findLastGroupid() throws Exception
    154 {
    155 // TODO Auto-generated method stub
    156 int groupid = 0;
    157 String sql = "select groseq.currval from dual";
    158 this.psmt = this.conn.prepareStatement(sql);
    159 ResultSet rst = this.psmt.executeQuery();
    160 if (rst.next())
    161 {
    162 groupid = rst.getInt(1);
    163 }
    164 return groupid;
    165 }
    166
    167 }

      AdminGroupDaoImpl.java

    View Code
    package org.xiong.demo.impl;

    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.ArrayList;
    import java.util.List;

    import org.xiong.demo.dao.IPrivilegeDao;
    import org.xiong.demo.vo.Privilege;

    public class PrivilegeDaoImpl implements IPrivilegeDao
    {
    private Connection conn;
    private PreparedStatement psmt;

    public PrivilegeDaoImpl(Connection conn)
    {
    this.conn = conn;
    }

    public boolean doInsert(Privilege vo) throws Exception
    {
    // TODO Auto-generated method stub
    boolean flag = false;
    String sql = "insert into privilege(pid,name,note) values(priseq.nextval,?,?)";
    this.psmt = this.conn.prepareStatement(sql);
    this.psmt.setString(1, vo.getName());
    this.psmt.setString(2, vo.getNote());
    int n = this.psmt.executeUpdate();
    if (n > 0)
    {
    flag = true;
    }
    return flag;
    }

    public boolean doUpdate(Privilege vo) throws Exception
    {
    // TODO Auto-generated method stub
    boolean flag = false;
    String sql = "update privilege set name=?,note=? where pid=?";
    this.psmt = this.conn.prepareStatement(sql);
    this.psmt.setString(1, vo.getName());
    this.psmt.setString(2, vo.getNote());
    this.psmt.setInt(3, vo.getPid());
    int n = this.psmt.executeUpdate();
    if (n > 0)
    {
    flag = true;
    }
    return flag;
    }

    public boolean doDelete(Integer id) throws Exception
    {
    // TODO Auto-generated method stub
    boolean flag = false;
    String sql = "delete from privilege where pid=?";
    this.psmt = this.conn.prepareStatement(sql);
    this.psmt.setInt(1, id);
    int n = this.psmt.executeUpdate();
    if (n > 0)
    {
    flag = true;
    }
    return flag;
    }

    public Privilege findById(Integer id) throws Exception
    {
    // TODO Auto-generated method stub
    Privilege per = null;
    String sql = "select pid,name,note from privilege where pid=?";
    this.psmt = this.conn.prepareStatement(sql);
    this.psmt.setInt(1, id);
    ResultSet rst = this.psmt.executeQuery();
    if (rst.next())
    {
    per = new Privilege();
    int pid = rst.getInt(1);
    String name = rst.getString(2);
    String note = rst.getString(3);
    per.setPid(pid);
    per.setName(name);
    per.setNote(note);
    }
    return per;
    }

    public List<Privilege> findAll(String keyword) throws Exception
    {
    // TODO Auto-generated method stub
    List<Privilege> allPer = new ArrayList<Privilege>();
    String sql = "select pid ,name,note from privilege where pid like ? or name like ? or note like ?";
    this.psmt = this.conn.prepareStatement(sql);
    this.psmt.setString(1, "%" + keyword + "%");
    this.psmt.setString(2, "%" + keyword + "%");
    this.psmt.setString(3, "%" + keyword + "%");
    ResultSet rst = this.psmt.executeQuery();
    while (rst.next())
    {
    Privilege per = new Privilege();
    per.setPid(rst.getInt(1));
    per.setName(rst.getString(2));
    per.setNote(rst.getString(3));
    allPer.add(per);
    }
    return allPer;
    }

    public List<Privilege> findAll(String keyword, int currentPage, int lineSize)
    throws Exception
    {
    // TODO Auto-generated method stub
    List<Privilege> allPer = new ArrayList<Privilege>();
    String sql = "select pid,name,note from (SELECT pid,name,note, ROWNUM rn FROM privilege WHERE (pid like ? or name like ? or note like ?) and ROWNUM<=? ORDER BY pid) temp where temp.rn>?";
    this.psmt = conn.prepareStatement(sql);
    this.psmt.setString(1, "%" + keyword + "%");
    this.psmt.setString(2, "%" + keyword + "%");
    this.psmt.setString(3, "%" + keyword + "%");
    this.psmt.setInt(4, currentPage * lineSize);
    this.psmt.setInt(5, (currentPage - 1) * lineSize);
    ResultSet rst = this.psmt.executeQuery();
    while (rst.next())
    {
    Privilege per = new Privilege();
    per.setPid(rst.getInt(1));
    per.setName(rst.getString(2));
    per.setNote(rst.getString(3));
    allPer.add(per);
    }
    return allPer;
    }

    public long getAllCount(String keyword) throws Exception
    {
    // TODO Auto-generated method stub
    long allCount = 0;
    String sql = "select count(pid) from privilege where pid like ? or name like ? or note like ?";
    psmt = conn.prepareStatement(sql);
    psmt.setString(1, "%" + keyword + "%");
    psmt.setString(2, "%" + keyword + "%");
    psmt.setString(3, "%" + keyword + "%");
    ResultSet rst = psmt.executeQuery();
    if (rst.next())
    {
    allCount = rst.getInt(1);
    }
    return allCount;
    }

    public List<Privilege> findByGroupId(Integer groupid) throws Exception
    {
    // TODO Auto-generated method stub
    List<Privilege> allPri = new ArrayList<Privilege>();
    String sql = "select p.pid,p.name,p.note from admingroup_privilege ap,privilege p where ap.pid=p.pid and ap.groupid=?";
    this.psmt = this.conn.prepareStatement(sql);
    this.psmt.setInt(1, groupid);
    ResultSet rst = this.psmt.executeQuery();
    while (rst.next())
    {
    Privilege per = new Privilege();
    per.setPid(rst.getInt(1));
    per.setName(rst.getString(2));
    per.setNote(rst.getString(3));
    allPri.add(per);
    }
    return allPri;
    }

    }

      AdminGroupPrivilegeDaoImpl.java

    View Code
     1 package org.xiong.demo.impl;
    2
    3 import java.sql.Connection;
    4 import java.sql.PreparedStatement;
    5 import java.util.Iterator;
    6 import java.util.List;
    7
    8 import org.xiong.demo.dao.IAdminGroupPrivilegeDao;
    9 import org.xiong.demo.vo.AdminGroup;
    10 import org.xiong.demo.vo.Privilege;
    11
    12 public class AdminGroupPrivilegeDaoImpl implements IAdminGroupPrivilegeDao
    13 {
    14 private Connection conn;
    15 private PreparedStatement psmt;
    16
    17 public AdminGroupPrivilegeDaoImpl(Connection conn)
    18 {
    19 this.conn = conn;
    20 }
    21
    22 public boolean doInsertAdminGroupPrivilege(List<Privilege> selectPri,
    23 Integer groupid) throws Exception
    24 {
    25 boolean flag = false;
    26 String sql = "insert into admingroup_privilege(pid,groupid) values (?,?)";
    27 this.psmt = this.conn.prepareStatement(sql);
    28 Iterator<Privilege> sIter = selectPri.iterator();
    29 while (sIter.hasNext())
    30 {
    31 Privilege pri = sIter.next();
    32 this.psmt.setInt(1, pri.getPid());
    33 this.psmt.setInt(2, groupid);
    34 this.psmt.addBatch();
    35 }
    36 if (this.psmt.executeBatch().length > 0)
    37 {
    38 flag = true;
    39 }
    40 return flag;
    41 }
    42
    43 public boolean doDeleteAdminGroupPrivilege(Integer groupid)
    44 throws Exception
    45 {
    46 boolean flag = false;
    47 String sql = "delete from admingroup_privilege where groupid=?";
    48 this.psmt = this.conn.prepareStatement(sql);
    49 this.psmt.setInt(1, groupid);
    50
    51 if (this.psmt.executeUpdate() > 0)
    52 {
    53 flag = true;
    54 }
    55 return flag;
    56 }
    57
    58 }

    4,增加服务层

      DaoServiceImpl.java

    View Code
      1 package org.xiong.demo.service.impl;
    2
    3 import java.util.HashMap;
    4 import java.util.List;
    5 import java.util.Map;
    6 import java.util.Set;
    7
    8 import org.xiong.demo.dao.IAdminGroupDao;
    9 import org.xiong.demo.dao.IAdminGroupPrivilegeDao;
    10 import org.xiong.demo.dao.IDeptDao;
    11 import org.xiong.demo.dao.IEmpDao;
    12 import org.xiong.demo.dao.IPrivilegeDao;
    13 import org.xiong.demo.dao.IProductDao;
    14 import org.xiong.demo.dao.IUserDao;
    15 import org.xiong.demo.database.DatabaseConnection;
    16 import org.xiong.demo.impl.AdminGroupDaoImpl;
    17 import org.xiong.demo.impl.AdminGroupPrivilegeDaoImpl;
    18 import org.xiong.demo.impl.DeptDaoImpl;
    19 import org.xiong.demo.impl.EmpDaoImpl;
    20 import org.xiong.demo.impl.PrivilegeDaoImpl;
    21 import org.xiong.demo.impl.ProductDaoImpl;
    22 import org.xiong.demo.impl.UserDaoImpl;
    23 import org.xiong.demo.service.IDaoService;
    24 import org.xiong.demo.vo.AdminGroup;
    25 import org.xiong.demo.vo.Privilege;
    26 import org.xiong.demo.vo.Product;
    27
    28 public class DaoServiceImpl implements IDaoService
    29 {
    30 private DatabaseConnection dc;
    31
    32 public DaoServiceImpl()
    33 {
    34 this.dc = new DatabaseConnection();
    35 }
    36
    37 public Map<String, Object> doInsertPre() throws Exception
    38 {
    39 // TODO Auto-generated method stub
    40 Map<String, Object> mp = new HashMap<String, Object>();
    41 try
    42 {
    43 this.dc.getConn().setAutoCommit(false);
    44 IEmpDao empdao = new EmpDaoImpl(this.dc.getConn());
    45 IDeptDao deptdao = new DeptDaoImpl(this.dc.getConn());
    46 mp.put("allemp", empdao.findAll(""));
    47 mp.put("alldept", deptdao.findAll(""));
    48 this.dc.getConn().commit();
    49 }
    50 catch (Exception ex)
    51 {
    52 this.dc.getConn().rollback();
    53 throw ex;
    54 }
    55 finally
    56 {
    57 this.dc.close();
    58 }
    59
    60 return mp;
    61 }
    62
    63 public Map<String, Object> doUpdatePre(Integer empno) throws Exception
    64 {
    65 // TODO Auto-generated method stub
    66 Map<String, Object> mp = new HashMap<String, Object>();
    67 try
    68 {
    69 IEmpDao empdao = new EmpDaoImpl(this.dc.getConn());
    70 IDeptDao deptdao = new DeptDaoImpl(this.dc.getConn());
    71 mp.put("allemp", empdao.findAll(""));
    72 mp.put("alldept", deptdao.findAll(""));
    73 mp.put("emp", empdao.findById(empno));
    74 }
    75 catch (Exception ex)
    76 {
    77 throw ex;
    78 }
    79 finally
    80 {
    81 this.dc.close();
    82 }
    83
    84 return mp;
    85 }
    86
    87 public Map<String, Object> doFindPre(Integer id, Set<Integer> key)
    88 throws Exception
    89 {
    90 // TODO Auto-generated method stub
    91 Map<String, Object> mp = new HashMap<String, Object>();
    92
    93 try
    94 {
    95 IUserDao user = new UserDaoImpl(this.dc.getConn());
    96 IProductDao product = new ProductDaoImpl(this.dc.getConn());
    97 mp.put("user", user.findById(id));
    98 mp.put("allProduct", product.findShoppingCar(key));
    99 }
    100 catch (Exception ex)
    101 {
    102 throw ex;
    103 }
    104 finally
    105 {
    106 this.dc.close();
    107 }
    108
    109 return mp;
    110 }
    111
    112 public Product findProductInfo(Integer id, boolean flag) throws Exception
    113 {
    114 // TODO Auto-generated method stub
    115 Product pro = null;
    116 try
    117 {
    118 IProductDao product = new ProductDaoImpl(this.dc.getConn());
    119 pro = product.findById(id);
    120 if (flag)
    121 {
    122 product.doCount(id);
    123 }
    124
    125 }
    126 catch (Exception ex)
    127 {
    128 throw ex;
    129 }
    130 finally
    131 {
    132 this.dc.close();
    133 }
    134 return pro;
    135 }
    136
    137 public boolean doInsertAdminGroup(List<Privilege> allSelected,
    138 AdminGroup group) throws Exception
    139 {
    140 // TODO Auto-generated method stub
    141 boolean flag = false;
    142 try
    143 {
    144 this.dc.getConn().setAutoCommit(false);
    145 IAdminGroupDao groupdao = new AdminGroupDaoImpl(this.dc.getConn());
    146 IAdminGroupPrivilegeDao admingroupdao = new AdminGroupPrivilegeDaoImpl(
    147 this.dc.getConn());
    148 flag = groupdao.doInsert(group);
    149 flag = admingroupdao.doInsertAdminGroupPrivilege(allSelected,
    150 groupdao.findLastGroupid());
    151 this.dc.getConn().commit();
    152 }
    153 catch (Exception ex)
    154 {
    155 this.dc.getConn().rollback();
    156 throw ex;
    157 }
    158 finally
    159 {
    160 this.dc.close();
    161 }
    162 return flag;
    163 }
    164
    165 public Map<String, Object> doFindAdminGroupPrivilege(Integer groupid)
    166 throws Exception
    167 {
    168 // TODO Auto-generated method stub
    169 Map<String, Object> mp = new HashMap<String, Object>();
    170
    171 try
    172 {
    173 IAdminGroupDao admingroup = new AdminGroupDaoImpl(this.dc.getConn());
    174 IPrivilegeDao privilege = new PrivilegeDaoImpl(this.dc.getConn());
    175 mp.put("group", admingroup.findById(groupid));
    176 mp.put("selectPr", privilege.findByGroupId(groupid));
    177 mp.put("allPri", privilege.findAll(""));
    178 }
    179 catch (Exception ex)
    180 {
    181 throw ex;
    182 }
    183 finally
    184 {
    185 this.dc.close();
    186 }
    187
    188 return mp;
    189 }
    190
    191 public boolean doUpdateAdminGroup(List<Privilege> allSelected,
    192 AdminGroup group) throws Exception
    193 {
    194 // TODO Auto-generated method stub
    195 boolean flag = false;
    196 try
    197 {
    198 this.dc.getConn().setAutoCommit(false);
    199 IAdminGroupDao groupdao = new AdminGroupDaoImpl(this.dc.getConn());
    200 IAdminGroupPrivilegeDao admingroupdao = new AdminGroupPrivilegeDaoImpl(
    201 this.dc.getConn());
    202 flag=admingroupdao.doDeleteAdminGroupPrivilege(group.getGroupid());
    203 flag = groupdao.doUpdate(group);
    204 flag = admingroupdao.doInsertAdminGroupPrivilege(allSelected,
    205 group.getGroupid());
    206 this.dc.getConn().commit();
    207 }
    208 catch (Exception ex)
    209 {
    210 this.dc.getConn().rollback();
    211 throw ex;
    212 }
    213 finally
    214 {
    215 this.dc.close();
    216 }
    217 return flag;
    218 }
    219
    220 }

    5,Servlet

      AdminGroupServlet.java

    View Code
      1 package org.xiong.demo.servlet;
    2
    3 import java.io.IOException;
    4 import java.util.ArrayList;
    5 import java.util.List;
    6 import java.util.Map;
    7
    8 import javax.servlet.ServletException;
    9 import javax.servlet.http.HttpServlet;
    10 import javax.servlet.http.HttpServletRequest;
    11 import javax.servlet.http.HttpServletResponse;
    12
    13 import org.xiong.demo.factory.DaoFactory;
    14 import org.xiong.demo.util.MessageUtil;
    15 import org.xiong.demo.vo.AdminGroup;
    16 import org.xiong.demo.vo.Privilege;
    17
    18 public class AdminGroupServlet extends HttpServlet
    19 {
    20
    21 public void doGet(HttpServletRequest request, HttpServletResponse response)
    22 throws ServletException, IOException
    23 {
    24 this.doPost(request, response);
    25 }
    26
    27 public void doPost(HttpServletRequest request, HttpServletResponse response)
    28 throws ServletException, IOException
    29 {
    30 request.setCharacterEncoding("GBK");
    31 String path = "error.jsp";
    32 String status = request.getParameter("status");
    33 if (!("".equals(status) || null == status))
    34 {
    35 if ("list".equals(status))
    36 {
    37 this.list(request, response);
    38 }
    39 if ("add".equals(status))
    40 {
    41 this.add(request, response);
    42 }
    43 if ("updatepre".equals(status))
    44 {
    45 this.updatepre(request, response);
    46 }
    47 if ("update".equals(status))
    48 {
    49 this.update(request, response);
    50 }
    51 if ("info".equals(status))
    52 {
    53 this.info(request, response);
    54 }
    55 if ("delete".equals(status))
    56 {
    57 this.delete(request, response);
    58 }
    59
    60 }
    61 else
    62 {
    63 request.getRequestDispatcher(path).forward(request, response);
    64 }
    65 }
    66
    67 public void list(HttpServletRequest request, HttpServletResponse response)
    68 throws ServletException, IOException
    69 {
    70 String path = "error.jsp";
    71 String keyword = null;
    72 try
    73 {
    74 keyword = request.getParameter("kw");
    75 }
    76 catch (Exception ex)
    77 {
    78 }
    79 if (keyword == null)
    80 {
    81 keyword = "";
    82 }
    83 try
    84 {
    85 List<AdminGroup> allAdminGroup = DaoFactory
    86 .getAdminGroupDaoInstance().findAll(keyword);
    87 if (allAdminGroup != null)
    88 {
    89 request.setAttribute("allAdminGroup", allAdminGroup);
    90 request.setAttribute("kw", keyword);
    91 path = "AdminGroup_source.jsp";
    92 }
    93 }
    94 catch (Exception ex)
    95 {
    96 ex.printStackTrace();
    97 }
    98
    99 request.getRequestDispatcher(path).forward(request, response);
    100
    101 }
    102
    103 public void add(HttpServletRequest request, HttpServletResponse response)
    104 throws ServletException, IOException
    105 {
    106 String path = "error.jsp";
    107 String name = request.getParameter("name");
    108 String note = request.getParameter("note");
    109 AdminGroup admingroup = new AdminGroup();
    110 admingroup.setName(name);
    111 admingroup.setNote(note);
    112 String[] allSelectPri = request.getParameterValues("pid");
    113 List<Privilege> allPriv = new ArrayList<Privilege>();
    114 boolean flag = false;
    115 try
    116 {
    117 for (int i = 0; i < allSelectPri.length; i++)
    118 {
    119 Privilege per = new Privilege();
    120 per.setPid(Integer.parseInt(allSelectPri[i]));
    121 allPriv.add(per);
    122 }
    123 flag = DaoFactory.getDaoServiceInstance().doInsertAdminGroup(
    124 allPriv, admingroup);
    125
    126 }
    127 catch (Exception e)
    128 {
    129 e.printStackTrace();
    130 }
    131 if (flag)
    132 {
    133 path = "admingroup_operation.jsp";
    134 request.setAttribute("msg",
    135 MessageUtil.getMessage("admingroup.add.true"));
    136 }
    137 else
    138 {
    139 request.setAttribute("msg",
    140 MessageUtil.getMessage("admingroup.add.false"));
    141 }
    142 request.getRequestDispatcher(path).forward(request, response);
    143
    144 }
    145
    146 public void updatepre(HttpServletRequest request,
    147 HttpServletResponse response) throws ServletException, IOException
    148 {
    149 String path = "error.jsp";
    150 int groupid = Integer.parseInt(request.getParameter("pid"));
    151 try
    152 {
    153 Map<String, Object> mp = DaoFactory.getDaoServiceInstance()
    154 .doFindAdminGroupPrivilege(groupid);
    155 if (mp != null)
    156 {
    157 request.setAttribute("group", mp.get("group"));
    158 request.setAttribute("selectPr", mp.get("selectPr"));
    159 request.setAttribute("allPri", mp.get("allPri"));
    160 path = "admingroup_update.jsp";
    161 }
    162 }
    163 catch (Exception ex)
    164 {
    165 ex.printStackTrace();
    166 }
    167
    168 request.getRequestDispatcher(path).forward(request, response);
    169 }
    170
    171 public void update(HttpServletRequest request, HttpServletResponse response)
    172 throws ServletException, IOException
    173 {
    174 String path = "error.jsp";
    175 int pid = Integer.parseInt(request.getParameter("pid"));
    176 String name = request.getParameter("name");
    177 String note = request.getParameter("note");
    178 AdminGroup per = new AdminGroup();
    179 per.setGroupid(pid);
    180 per.setName(name);
    181 per.setNote(note);
    182 String[] allSelectPri = request.getParameterValues("pid");
    183 List<Privilege> allPriv = new ArrayList<Privilege>();
    184 for (int i = 0; i < allSelectPri.length; i++)
    185 {
    186 Privilege pri = new Privilege();
    187 pri.setPid(Integer.parseInt(allSelectPri[i]));
    188 allPriv.add(pri);
    189 }
    190 try
    191 {
    192 if (DaoFactory.getDaoServiceInstance().doUpdateAdminGroup(allPriv,
    193 per))
    194 {
    195 request.setAttribute("msg",
    196 MessageUtil.getMessage("admingroup.update.true"));
    197 path = "admingroup_operation.jsp";
    198 }
    199 else
    200 {
    201 request.setAttribute("msg",
    202 MessageUtil.getMessage("admingroup.update.false"));
    203 }
    204 }
    205 catch (Exception ex)
    206 {
    207 ex.printStackTrace();
    208 }
    209 request.getRequestDispatcher(path).forward(request, response);
    210
    211 }
    212
    213 public void info(HttpServletRequest request, HttpServletResponse response)
    214 throws ServletException, IOException
    215 {
    216 String path = "error.jsp";
    217 int groupid = Integer.parseInt(request.getParameter("pid"));
    218 try
    219 {
    220 Map<String, Object> mp = DaoFactory.getDaoServiceInstance()
    221 .doFindAdminGroupPrivilege(groupid);
    222 if (mp != null)
    223 {
    224 request.setAttribute("group", mp.get("group"));
    225 request.setAttribute("selectPr", mp.get("selectPr"));
    226 request.setAttribute("allPri", mp.get("allPri"));
    227 path = "admingroup_info.jsp";
    228 }
    229 }
    230 catch (Exception ex)
    231 {
    232 ex.printStackTrace();
    233 }
    234
    235 request.getRequestDispatcher(path).forward(request, response);
    236 }
    237
    238 public void delete(HttpServletRequest request, HttpServletResponse response)
    239 throws ServletException, IOException
    240 {
    241 String path = "error.jsp";
    242 int pid = Integer.parseInt(request.getParameter("pid"));
    243 try
    244 {
    245 if (DaoFactory.getAdminGroupDaoInstance().doDelete(pid))
    246 {
    247 request.setAttribute("msg",
    248 MessageUtil.getMessage("admingroup.delete.true"));
    249 path = "admingroup_operation.jsp";
    250 }
    251 else
    252 {
    253 request.setAttribute("msg",
    254 MessageUtil.getMessage("admingroup.delete.false"));
    255 }
    256 }
    257 catch (Exception ex)
    258 {
    259 ex.printStackTrace();
    260 }
    261 request.getRequestDispatcher(path).forward(request, response);
    262
    263 }
    264 }

    6,前台页面

    View Code
      1 <--AdminGroup_source.jsp-->
    2 <%@ page contentType="text/html" pageEncoding="GBK"%>
    3 <%@ page import="org.xiong.demo.vo.*,java.util.*"%>
    4
    5 <%
    6 request.setCharacterEncoding("GBK");
    7 String keyword=null;
    8 %>
    9
    10 <center>
    11 <form action="AdminGroupServlet">
    12 <h1>管理员组信息</h1>
    13 <a href="admingroup_add.jsp">添加管理员组</a>
    14 请输入查询关键字:<input type="text" name="kw" value="<%=(String)request.getAttribute("kw")==null?"":(String)request.getAttribute("kw")%>"/>
    15 <input type="hidden" name="status" value="list"/>
    16 <input type="submit" value="查询"/><br/><br/>
    17 </form>
    18 </center>
    19
    20
    21 <table border="1" width="100%">
    22 <tr>
    23 <th>管理员组编号</th>
    24 <th>名称</th>
    25 <th>简介</th>
    26 <th colspan="2">操作</th>
    27 </tr>
    28
    29 <%
    30 int count =0;
    31 List<AdminGroup> allAdminGroup=(List<AdminGroup>)request.getAttribute("allAdminGroup");
    32 if(allAdminGroup!=null)
    33 {
    34 Iterator<AdminGroup> proIter=allAdminGroup.iterator();
    35 while(proIter.hasNext())
    36 {
    37 count++;
    38 AdminGroup pr=proIter.next();
    39 int pid=pr.getGroupid();
    40 String name=pr.getName();
    41 String note=pr.getNote();
    42 %>
    43 <tr>
    44 <th><%=pid%></th>
    45 <th><a href="AdminGroupServlet?status=info&pid=<%=pid%>"><%=name%></a></th>
    46 <th><%=note%></th>
    47 <th><a href="AdminGroupServlet?status=updatepre&pid=<%=pid%>">修改</a></th>
    48 <th><a href="AdminGroupServlet?status=delete&pid=<%=pid%>">删除</a></th>
    49 </tr>
    50 <%
    51 }
    52 }
    53 %>
    54 <%
    55 if(allAdminGroup.size()==0)
    56 {
    57 %>
    58 <tr>
    59 <th colspan="8" >没有符合条件的数据!</th>
    60 </tr>
    61 <%
    62 }
    63 %>
    64 </table>
    65
    66 <--admingroup_update.jsp-->
    67 <%@ page contentType="text/html" pageEncoding="GBK"%>
    68 <%@ page import="org.xiong.demo.vo.*,org.xiong.demo.factory.*,java.util.*"%>
    69 <script language="javascript">
    70 function validateName(name)
    71 {
    72 if(name=="")
    73 {
    74 document.getElementById("name_picMsg").innerHTML="<img src=\"<%=request.getContextPath()%>/images/wrong.gif\">"+"<font color=\"red\">管理员组名称不能为空!</font>"
    75 return false;
    76 }
    77 else
    78 {
    79 document.getElementById("name_picMsg").innerHTML="<img src=\"<%=request.getContextPath()%>/images/right.gif\">"+"<font color=\"green\">管理员组名称输入正确!</font>"
    80 return true;
    81 }
    82 }
    83 function validateNote(note)
    84 {
    85 if(note=="")
    86 {
    87 document.getElementById("note_picMsg").innerHTML="<img src=\"<%=request.getContextPath()%>/images/wrong.gif\">"+"<font color=\"red\">管理员组简介不能为空!</font>"
    88 return false;
    89 }
    90 else
    91 {
    92 document.getElementById("note_picMsg").innerHTML="<img src=\"<%=request.getContextPath()%>/images/right.gif\">"+"<font color=\"green\">管理员组简介输入正确!</font>"
    93 return true;
    94 }
    95 }
    96 function validate(numValue)
    97 {
    98 return validateName(numValue.name.value)&&validateNote(numValue.note.value);
    99 }
    100 </script>
    101 <%
    102 request.setCharacterEncoding("GBK");
    103 %>
    104 <%
    105 int pid = 0;
    106 try
    107 {
    108 pid = Integer.parseInt(request.getParameter("pid"));
    109 }
    110 catch (Exception ex)
    111 {
    112 }
    113 AdminGroup pr=DaoFactory.getAdminGroupDaoInstance().findById(pid);
    114 if(pr!=null)
    115 {
    116 int proid=pr.getGroupid();
    117 String name=pr.getName();
    118 String note=pr.getNote();
    119
    120 %>
    121 <h1>修改权限信息</h1>
    122 <form action="AdminGroupServlet" method="post" onSubmit="return validate(this.value)">
    123 <table border="1" ,width="100%">
    124 <tr>
    125 <td>管理员组编号:</td>
    126 <td><input type="text" name="pid" value="<%=proid%>" readonly="true" /></td>
    127
    128 </tr>
    129 <tr>
    130 <td>管理员组名称:</td>
    131 <td><input type="text" name="name" value="<%=name%>" onBlur="validateName(this.value)"/></td>
    132 <td><span id="name_picMsg"><font color="red">*</font></span></td>
    133 </tr>
    134 <tr>
    135 <td>管理员组简介:</td>
    136 <td><input type="text" name="note" value="<%=note%>" onBlur="validateNote(this.value)"/></td>
    137 <td><span id="note_picMsg"><font color="red">*</font></span></td>
    138 </tr>
    139 <tr>
    140 <td colspan="3">权限:
    141 <table border="0" width="100%">
    142 <tr>
    143 <%
    144 int ct=0;
    145 List<Privilege> selectedPri=(List<Privilege>)request.getAttribute("selectPr");
    146 List<Privilege> allPri=(List<Privilege>)request.getAttribute("allPri");
    147 if(allPri!=null)
    148 {
    149 Iterator<Privilege> iter=allPri.iterator();
    150 while(iter.hasNext())
    151 {
    152 Privilege pri=iter.next();
    153 ct++;
    154 %>
    155 <td>
    156 &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="pid" value="<%=pri.getPid()%>" <%=selectedPri.contains(pri)?"checked":""%>><%=pri.getName()%>
    157 </td>
    158 <%
    159
    160 if(ct%6==0)
    161 {
    162 %>
    163 </tr>
    164 <tr>
    165 <%
    166 }
    167 else if(ct==allPri.size())
    168 {
    169 %>
    170 </tr>
    171 <%
    172 }
    173 }
    174 }
    175
    176 %>
    177 </table>
    178 </td>
    179 </tr>
    180 <tr conspan="3">
    181 <input type="hidden" name="status" value="update" />
    182 <th>&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="修改"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重置"/></th>
    183 </tr>
    184 </table>
    185 </form>
    186 <%
    187 }
    188 %>
    View Code
      1 <--admingroup_add.jsp-->
    2 <%@ page contentType="text/html" pageEncoding="GBK"%>
    3 <%@ page import="org.xiong.demo.vo.*,org.xiong.demo.factory.*,java.util.*" %>
    4 <script language="javascript">
    5 function validateName(name)
    6 {
    7 if(name=="")
    8 {
    9 document.getElementById("name_picMsg").innerHTML="<img src=\"<%=request.getContextPath()%>/images/wrong.gif\">"+"<font color=\"red\">管理员组名称不能为空!</font>"
    10 return false;
    11 }
    12 else
    13 {
    14 document.getElementById("name_picMsg").innerHTML="<img src=\"<%=request.getContextPath()%>/images/right.gif\">"+"<font color=\"green\">管理员组名称输入正确!</font>"
    15 return true;
    16 }
    17 }
    18 function validateNote(note)
    19 {
    20 if(note=="")
    21 {
    22 document.getElementById("note_picMsg").innerHTML="<img src=\"<%=request.getContextPath()%>/images/wrong.gif\">"+"<font color=\"red\">管理员组简介不能为空!</font>"
    23 return false;
    24 }
    25 else
    26 {
    27 document.getElementById("note_picMsg").innerHTML="<img src=\"<%=request.getContextPath()%>/images/right.gif\">"+"<font color=\"green\">管理员组简介输入正确!</font>"
    28 return true;
    29 }
    30 }
    31 function validate(numValue)
    32 {
    33 return validateName(numValue.name.value)&&validateNote(numValue.note.value);
    34 }
    35 </script>
    36
    37 <%
    38 Map<String,Object> mp=DaoFactory.getDaoServiceInstance().doInsertPre();
    39 %>
    40 <h1>添加管理员组</h1>
    41 <form action="AdminGroupServlet" method="post" onSubmit="return validate(this.value)">
    42 <table border="2" width="100%">
    43 <tr>
    44 <td>管理员组名称:</td>
    45 <td><input type="text" name="name" onBlur="validateName(this.value)"/></td>
    46 <td><span id="name_picMsg"><font color="red">*</font></span></td>
    47 </tr>
    48 <tr>
    49 <td>管理员组简介:</td>
    50 <td><input type="text" name="note" onBlur="validateNote(this.value)"/></td>
    51 <td><span id="note_picMsg"><font color="red">*</font></span></td>
    52 </tr>
    53 <tr>
    54 <td colspan="3">权限:
    55 <table border="0" width="100%">
    56 <tr>
    57 <%
    58 int ct=0;
    59 List<Privilege> allPri=DaoFactory.getPrivilegeDaoInstance().findAll("");
    60 if(allPri!=null)
    61 {
    62 Iterator<Privilege> iter=allPri.iterator();
    63 while(iter.hasNext())
    64 {
    65 Privilege pr=iter.next();
    66 ct++;
    67 %>
    68 <td>
    69 &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="pid" value="<%=pr.getPid()%>"><a href="<%=request.getContextPath()%>/RightsManagement/PrivilegeServlet?status=list&pid=<%=pr.getPid()%>"><%=pr.getName()%></a>
    70 </td>
    71 <%
    72
    73 if(ct%6==0)
    74 {
    75 %>
    76 </tr>
    77 <tr>
    78 <%
    79 }
    80 else if(ct==allPri.size())
    81 {
    82 %>
    83 </tr>
    84 <%
    85 }
    86 }
    87 }
    88
    89 %>
    90 </table>
    91 </td>
    92 </tr>
    93 <tr>
    94 <input type="hidden" name="status" value="add" />
    95 <th colspan="3">&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="添加"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重置"/></th>
    96 </tr>
    97 </table>
    98 </form>
    99
    100 <--admingroup_info.jsp-->
    101 <%@ page contentType="text/html" pageEncoding="GBK"%>
    102 <%@ page import="org.xiong.demo.vo.*,org.xiong.demo.factory.*,java.util.*"%>
    103
    104 <%
    105 request.setCharacterEncoding("GBK");
    106 %>
    107 <%
    108 int pid = 0;
    109 try
    110 {
    111 pid = Integer.parseInt(request.getParameter("pid"));
    112 }
    113 catch (Exception ex)
    114 {
    115 }
    116 AdminGroup pr=DaoFactory.getAdminGroupDaoInstance().findById(pid);
    117 if(pr!=null)
    118 {
    119 int proid=pr.getGroupid();
    120 String name=pr.getName();
    121 String note=pr.getNote();
    122
    123 %>
    124 <h1>管理员组信息</h1>
    125 <form action="AdminGroupServlet" method="post" onSubmit="return validate(this.value)">
    126 <table border="1" ,width="100%">
    127 <tr>
    128 <td>管理员组编号:</td>
    129 <td><input type="text" name="pid" value="<%=proid%>" readonly="true" /></td>
    130
    131 </tr>
    132 <tr>
    133 <td>管理员组名称:</td>
    134 <td><input type="text" name="name" value="<%=name%>" onBlur="validateName(this.value)"/></td>
    135
    136 </tr>
    137 <tr>
    138 <td>管理员组简介:</td>
    139 <td><input type="text" name="note" value="<%=note%>" onBlur="validateNote(this.value)"/></td>
    140
    141 </tr>
    142 <tr>
    143 <td colspan="3">权限:
    144 <table border="0" width="100%">
    145 <tr>
    146 <%
    147 int ct=0;
    148 List<Privilege> selectedPri=(List<Privilege>)request.getAttribute("selectPr");
    149 List<Privilege> allPri=(List<Privilege>)request.getAttribute("allPri");
    150 if(allPri!=null)
    151 {
    152 Iterator<Privilege> iter=allPri.iterator();
    153 while(iter.hasNext())
    154 {
    155 Privilege pri=iter.next();
    156 ct++;
    157 if(selectedPri.contains(pri))
    158 {
    159 %>
    160 <td>
    161 &nbsp;&nbsp;&nbsp;&nbsp;<a href="<%=request.getContextPath()%>/RightsManagement/PrivilegeServlet?status=list&pid=<%=pri.getPid()%>"><%=selectedPri.contains(pri)?pri.getName():""%></a>
    162 </td>
    163 <%
    164
    165 if(ct%6==0)
    166 {
    167 %>
    168 </tr>
    169 <tr>
    170 <%
    171 }
    172 else if(ct==allPri.size())
    173 {
    174 %>
    175 </tr>
    176 <%
    177 }
    178 }
    179 }
    180 }
    181
    182 %>
    183 </table>
    184 </td>
    185 </tr>
    186 <tr >
    187 <input type="hidden" name="status" value="update" />
    188 <th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="修改"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重置"/></th>
    189 </tr>
    190 </table>
    191 </form>
    192 <%
    193 }
    194 %>
    195 <--admingroup_operation.jsp-->
    196 <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
    197
    198 <script language="javascript">
    199 alert("<%=request.getAttribute("msg")%>");
    200 window.location="AdminGroupServlet?status=list";
    201 </script>
    202 </script>
    203 <html>
    204 <head>
    205 <title>My JSP 'admingroup_operation.jsp' starting page</title>
    206 </head>
    207 <body>
    208 </body>
    209 </html>










  • 相关阅读:
    图像识别试验
    uCos-III移植到STM32F10x
    我为什么要学习C++反汇编
    网络爬虫基本原理(一)
    JavaScript对象模型-执行模型
    gdb core调试
    进程、轻量级进程(LWP)、线程
    谁动了我的cpu——oprofile使用札记
    Linux IO多路复用之epoll网络编程(含源码)
    黑客常用WinAPI函数整理
  • 原文地址:https://www.cnblogs.com/xiongyu/p/2402836.html
Copyright © 2020-2023  润新知