📄 groupbean.java
字号:
package com.sxit.wap.group;import java.sql.*;import java.util.*;import com.sxit.wap.common.*;import com.sxit.wap.exception.*;public class GroupBean extends GroupDao{ public static void deleteGroup(int[] ids) throws SysException,UpdateException,AppException { Connection conn = null; try { conn = Database.getConnection(); conn.setAutoCommit(false); for (int i=0; i<ids.length; i++) { String sql = "UPDATE WAP_USER SET USER_GROUP = 0 WHERE USER_GROUP = " + ids[i]; updateBySql(sql, conn); } delete(ids, conn); conn.commit(); } catch (Exception e) { e.printStackTrace(); try {conn.rollback();} catch (Exception ex) {} throw new SysException("SQLException while execute deleteGroup"); } finally { try {conn.setAutoCommit(false);} catch (Exception ex) {} try {conn.close();} catch (Exception ex) {} } } public static Hashtable getGroupTable() throws SysException { Hashtable value = new Hashtable(); Collection coll = queryAll(); Iterator it = coll.iterator(); while (it.hasNext()) { Hashtable element = (Hashtable)it.next(); GroupModel groupModel = GroupBean.toModel(element); value.put(""+groupModel.getId(), groupModel); } return value; } public static void changeGroupPwd(int id, String groupPwd) throws SysException { String sql = "UPDATE " + tableName + " SET GROUP_PWD = '" + groupPwd + "' WHERE ID = " + id; updateBySql(sql); } public static void changeCpPwd(int id, String groupPwd) throws SysException { String sql = "UPDATE " + tableName + " SET GROUP_PWD = '" + groupPwd + "' WHERE ID = " + id; updateBySql(sql); } public static boolean isExists(int id) throws SysException { try { findByPK(id); return true; } catch (FinderException e) { return false; } } public static boolean isExists(String groupName) throws SysException { return getRowCountBySql("SELECT COUNT(*) FROM " + tableName + " WHERE GROUP_NAME = '" + groupName +"'")>=1; } public static boolean isExists(int id, String groupName) throws SysException { return getRowCountBySql("SELECT COUNT(*) FROM " + tableName + " WHERE GROUP_NAME = '" + groupName +"'" + " AND ID <> '" + id + "'")>=1; } public static int getRowCountByGroupid(String groupid) throws SysException { String sql = "SELECT COUNT(*) FROM " + tableName + " WHERE ID LIKE '" + groupid + "%'"; return getRowCountBySql(sql); } public static Collection queryByGroupid(String groupid, int beginRow, int endRow) throws SysException { String sql = "SELECT * FROM " + tableName + " WHERE ID LIKE '" + groupid + "%'"; return queryBySql(sql, beginRow, endRow); } public static boolean hasRegister(int id) throws SysException { return getRowCountBySql("SELECT COUNT(*) FROM " + tableName + " WHERE ID = '" + id + "'")>=1; } public static Collection queryGroupOrderById(int beginRow, int endRow) throws SysException { return queryBySql("SELECT * FROM " + tableName + " ORDER BY ID", beginRow, endRow); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -