?? roleinfo.java
字號:
package com.saas.biz.roleMgr;
import java.util.ArrayList;
import java.util.HashMap;
import com.saas.biz.commen.commMethodMgr;
import com.saas.biz.dao.roleDAO.RoleDAO;
import com.saas.biz.dao.roleDAO.RoleExt;
import com.saas.biz.dao.userDAO.UserExt;
import com.saas.sys.buffer.Buffers;
import com.saas.sys.dbm.Dbtable;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.sys.log.Logger;
public class RoleInfo {
Dbtable tradeQuery;
commMethodMgr comm;
Logger log;
Buffers inBuffer;
Buffers outBuffer;
ArrayList queryResult = new ArrayList();
public RoleInfo() {
log = new Logger(this);
tradeQuery = new Dbtable();
comm = new commMethodMgr();
}
public void setTradeQuery(Dbtable tradeQuery) {
this.tradeQuery = tradeQuery;
}
public Dbtable getTradeQuery() {
return this.tradeQuery;
}
public void setOutBuffer(Buffers outBuffer) {
this.outBuffer = outBuffer;
}
public Buffers getOutBuffer() {
return this.outBuffer;
}
public ArrayList getQueryResult() {
return this.queryResult;
}
public void setQueryResult(ArrayList queryResult) {
this.queryResult = queryResult;
}
// 新增角色
public void addRoleInfo(Buffers inbuffer) {
log.LOG_INFO("進入addRoleInfo方法...");
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
int iResult = -1;
String cust_id = inbuffer.getString("SESSION_CUST_ID");
String role_name = inbuffer.getString("ROLE_NAME");
String role_code = inbuffer.getString("ROLE_CODE");
String role_type = inbuffer.getString("ROLE_TYPE");
String enable_tag = inbuffer.getString("ENABLE_TAG");
String remark = inbuffer.getString("REMARK");
RoleDAO roleDao = new RoleDAO();
roleDao.setCust_id(cust_id);
roleDao.setRole_name(role_name);
roleDao.setEnable_tag(enable_tag);
roleDao.setRole_type(role_type);
roleDao.setRole_code(role_code);
roleDao.setRemark(remark);
try {
iResult = addRoleInfo(roleDao);
}
catch (Exception e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "業務處理失??!");
}
else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "業務處理成功!");
}
log.LOG_INFO("退出addRoleInfo方法...");
}
public int addRoleInfo(RoleDAO roleDao) throws SaasApplicationException {
RoleExt roleExt = new RoleExt();
roleExt.setParam(":VCUST_ID", roleDao.getCust_id());
roleExt.setParam(":VROLE_NAME", roleDao.getRole_name());
roleExt.setParam(":VENABLE_TAG", roleDao.getEnable_tag());
roleExt.setParam(":VROLE_TYPE", roleDao.getRole_type());
roleExt.setParam(":VROLE_CODE", roleDao.getRole_code());
roleExt.setParam(":VREMARK", roleDao.getRemark());
tradeQuery.executeBy(roleExt.insBy("INS_BY_ALL"));
return 0;
}
// 修改角色
public void updateRoleInfo(Buffers inbuffer) {
log.LOG_INFO("進入updateRoleInfo方法...");
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
int iResult = -1;
String cust_id = inbuffer.getString("SESSION_CUST_ID");
String role_name = inbuffer.getString("ROLE_NAME");
String role_code = inbuffer.getString("ROLE_CODE");
String role_type = inbuffer.getString("ROLE_TYPE");
String enable_tag = inbuffer.getString("ENABLE_TAG");
String remark = inbuffer.getString("REMARK");
RoleDAO roleDao = new RoleDAO();
roleDao.setCust_id(cust_id);
roleDao.setRole_name(role_name);
roleDao.setEnable_tag(enable_tag);
roleDao.setRole_type(role_type);
roleDao.setRole_code(role_code);
roleDao.setRemark(remark);
try {
iResult = updateRoleInfo(roleDao);
}
catch (Exception e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "業務處理失?。?quot;);
}
else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "業務處理成功!");
}
log.LOG_INFO("退出addRoleInfo方法...");
}
public int updateRoleInfo(RoleDAO roleDao) throws SaasApplicationException {
RoleExt roleExt = new RoleExt();
roleExt.setParam(":VCUST_ID", roleDao.getCust_id());
roleExt.setParam(":VROLE_NAME", roleDao.getRole_name());
roleExt.setParam(":VENABLE_TAG", roleDao.getEnable_tag());
roleExt.setParam(":VROLE_TYPE", roleDao.getRole_type());
roleExt.setParam(":VROLE_CODE", roleDao.getRole_code());
roleExt.setParam(":VREMARK", roleDao.getRemark());
tradeQuery.executeBy(roleExt.insBy("UPDATE_BY_ALL"));
return 0;
}
// 刪除角色
public void delRoleInfo(Buffers inbuffer) {
log.LOG_INFO("進入delRoleInfo方法...");
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
int iResult = -1;
String cust_id = inbuffer.getString("SESSION_CUST_ID");
String role_code = inbuffer.getString("ROLE_CODE");
try {
iResult = delRoleInfo(cust_id, role_code);
}
catch (Exception e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "業務處理失敗!");
}
else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "業務處理成功!");
}
log.LOG_INFO("退出delRoleInfo方法...");
}
public int delRoleInfo(String cust_id, String role_code) {
RoleExt roleExt = new RoleExt();
roleExt.setParam(":VCUST_ID", cust_id);
roleExt.setParam(":VENABLE_TAG", "1");
roleExt.setParam(":VROLE_CODE", role_code);
tradeQuery.executeBy(roleExt.insBy("DEL_BY_CUST"));
return 0;
}
// 取出角色列表
public ArrayList getRoleInfoByCust_id(int iStart, String cust_id) throws SaasApplicationException {
ArrayList list = new ArrayList();
if (iStart > 1) {
iStart = (iStart - 1) * 20;
}
else {
iStart = 0;
}
RoleExt roleExt = new RoleExt();
roleExt.setParam(":VCUST_ID", cust_id);
roleExt.setParam(":VENABLE_TAG", "0");
list = roleExt.selByList("SEL_BY_CUST", iStart, 20);
return list;
}
public int getRoleCount(String cust_id, String enable) throws SaasApplicationException {
int size = 0;
ArrayList list = new ArrayList();
RoleExt roleExt = new RoleExt();
roleExt.setParam(":VCUST_ID", cust_id);
roleExt.setParam(":VENABLE_TAG", enable);
list = roleExt.selByList("SEL_BY_CT");
if (list != null && list.size() > 0) {
HashMap map = (HashMap) list.get(0);
size = Integer.parseInt(map.get("ct").toString());
}
return size;
}
// 取出角色
public ArrayList getRoleInfoByCode(String cust_id, String role_code) throws SaasApplicationException {
ArrayList list = new ArrayList();
RoleExt roleExt = new RoleExt();
roleExt.setParam(":VCUST_ID", cust_id);
roleExt.setParam(":VROLE_CODE", role_code);
list = roleExt.selByList("SEL_BY_CODE");
return list;
}
public ArrayList getRoleInfoByCustId(String cust_id) throws SaasApplicationException {
ArrayList list = new ArrayList();
RoleExt roleExt = new RoleExt();
roleExt.setParam(":VCUST_ID", cust_id);
roleExt.setParam(":VENABLE_TAG", "0");
list = roleExt.selByList("SEL_BY_CUST");
return list;
}
// 取出角色
public ArrayList getRoleInfoByType(String cust_id, String role_type) throws SaasApplicationException {
ArrayList list = new ArrayList();
RoleExt roleExt = new RoleExt();
roleExt.setParam(":VCUST_ID", cust_id);
roleExt.setParam(":VROLE_TYPE", role_type);
list = roleExt.selByList("SEL_BY_TYPE");
log.LOG_INFO("cust_id==" + cust_id + "==role_type==" + role_type);
return list;
}
public String getRoleNameById(String cust_id, String role_code) throws SaasApplicationException {
String role_name = "";
ArrayList roleList = getRoleInfoByCode(cust_id, role_code);
if (roleList != null && roleList.size() > 0) {
HashMap map = (HashMap) roleList.get(0);
role_name = map.get("role_name").toString();
}
log.LOG_INFO("cust_id="+cust_id+"==role_code="+role_code);
return role_name;
}
/**
* @param cust_id
* @param role_type
* @return 取出角色
* @throws SaasApplicationException
*/
public String getRoleSelectByType(String cust_id, String role_type) throws SaasApplicationException {
String role = "<option value=n>未設置角色</option>";
ArrayList list = getRoleInfoByType(cust_id, role_type);
if (list != null && list.size() > 0) {
role = "";
for (int i = 0; i < list.size(); i++) {
HashMap map = (HashMap) list.get(i);
String role_name = map.get("role_name").toString();
String role_code = map.get("role_code").toString();
role = role + "<option value=" + role_code + ">" + role_name + "</option>";
}
}
return role;
}
/**
* @param cust_id
* @param user_id
* @return 找出用戶的角色名稱
* @throws SaasApplicationException
*/
public String getRoleNameByUser_id(String cust_id, String user_id) throws SaasApplicationException {
String roleName = "未分配任何角色";
UserExt roleExt = new UserExt();
roleExt.setParam(":VUSER_ID", user_id);
ArrayList list = roleExt.selByList("SEL_BY_ONE");
if (list != null && list.size() > 0) {
HashMap userMap = (HashMap) list.get(0);
String role_code = "";
if (userMap.get("rsrv_str3") != null) {
role_code = userMap.get("rsrv_str3").toString();
}
roleName = getRoleNameById(cust_id, role_code);
}
return roleName;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -