一个用java编写的功能强大的OA系统

源代码在线查看: privilege.java

软件大小: 32919 K
上传用户: l550253832
关键词: java OA系统 编写
下载地址: 免注册下载 普通下载 VIP

相关代码

				package com.redmoon.oa.message;																import java.sql.*;				import javax.servlet.http.HttpServletRequest;				import cn.js.fan.db.*;				import cn.js.fan.web.Global;				import org.apache.log4j.Logger;								public class Privilege {				    String connname = Global.defaultDB;								    Logger logger = Logger.getLogger(this.getClass().getName());								    public Privilege() {				    }												    public boolean canSendDraft(HttpServletRequest request, int id) {				        MessageDb md = new MessageDb();				        md = (MessageDb)md.getMessageDb(id);				        if (!md.isDraft())				            return false;				        com.redmoon.oa.pvg.Privilege pvg = new com.redmoon.oa.pvg.Privilege();				        if (md.getSender().equals(pvg.getUser(request)))				            return true;				        else				            return false;				    }								    public boolean canManage(HttpServletRequest request, String[] ids) {				        com.redmoon.oa.pvg.Privilege pvg = new com.redmoon.oa.pvg.Privilege();				        String username = pvg.getUser(request);				        				        boolean isvalid = false;				        int len = ids.length;				        String str = "";				        for (int i = 0; i < len; i++)				            if (str.equals(""))				                str += ids[i];				            else				                str += "," + ids[i];				        str = "(" + str + ")";				        String receiver = null;				        String sql = "select receiver,isDraft,sender from oa_message where id in " + str;				        Conn conn = new Conn(connname);				        try {				            ResultSet rs = conn.executeQuery(sql);				            if (rs != null) {				                while (rs.next()) {				                    receiver = rs.getString(1);				                    boolean isDraft = rs.getInt(2)==1;				                    String sender = rs.getString(3);				                    if (isDraft) {				                        if (!sender.equals(username)) {				                            isvalid = false;				                            break;				                        }				                    }				                    else {				                        if (!receiver.equals(username)) {				                            isvalid = false;				                            break;				                        }				                    }				                    isvalid = true;				                }				            }				        } catch (SQLException e) {				            logger.error("canManage:" + e.getMessage());				        } finally {				            if (conn != null) {				                conn.close();				                conn = null;				            }				        }								        return isvalid;				    }								}							

相关资源