📄 userbean.java
字号:
package com.sxit.wap.user;import java.sql.*;import java.util.*;import com.sxit.wap.common.*;import com.sxit.wap.exception.*;public class UserBean extends UserDao{ public static int getRowCountOfAllOrOne(String userMdn) throws SysException { String sql = "SELECT COUNT(*) FROM " + tableName + (StringUtil.isNotEmpty(userMdn)?" WHERE USER_MDN LIKE '" + userMdn + "%'":""); return getRowCountBySql(sql); } public static Collection queryAllOrOne(String userMdn, int beginRow, int endRow) throws SysException { String sql = "SELECT * FROM " + tableName + (StringUtil.isNotEmpty(userMdn)?" WHERE USER_MDN LIKE '" + userMdn + "%'":""); return queryBySql(sql, beginRow, endRow); } public static int getRowCountByGroupId(int groupId, String userMdn) throws SysException { String sql = "SELECT COUNT(*) FROM WAP_USER U, WAP_GROUP_USER GU " + " WHERE U.USER_MDN = GU.USER_MDN AND U.USER_STATUS = 1" + " AND GU.GROUP_ID = " + groupId + (StringUtil.isNotEmpty(userMdn)?" AND U.USER_MDN LIKE '" + userMdn + "%'":""); //String sql = "SELECT COUNT(*) FROM " + tableName + " WHERE USER_GROUP = " + groupId + // (StringUtil.isNotEmpty(userMdn)?" AND USER_MDN LIKE '" + userMdn + "%'":""); return getRowCountBySql(sql); } public static Collection queryByGroupId(int groupId, String userMdn, int beginRow, int endRow) throws SysException { String sql = "SELECT * FROM WAP_USER U, WAP_GROUP_USER GU " + " WHERE U.USER_MDN = GU.USER_MDN AND U.USER_STATUS = 1" + " AND GU.GROUP_ID = " + groupId + (StringUtil.isNotEmpty(userMdn)?" AND U.USER_MDN LIKE '" + userMdn + "%'":""); //String sql = "SELECT * FROM " + tableName + " WHERE USER_GROUP = " + groupId + // (StringUtil.isNotEmpty(userMdn)?" AND USER_MDN LIKE '" + userMdn + "%'":""); return queryBySql(sql, beginRow, endRow); } public static int getRowCountByUserMdn(String userMdn) throws SysException { String sql = "SELECT COUNT(*) FROM " + tableName + " WHERE USER_MDN LIKE '" + userMdn + "%'"; return getRowCountBySql(sql); } public static int getRowCountByGroupId(String groupId) throws SysException { String sql = "SELECT COUNT(*) FROM " + tableName + " WHERE USER_GROUP LIKE '" + groupId + "%'"; return getRowCountBySql(sql); } public static Collection queryByUserMdn(String userMdn, int beginRow, int endRow) throws SysException { String sql = "SELECT * FROM " + tableName + " WHERE USER_MDN LIKE '" + userMdn + "%'"; return queryBySql(sql, beginRow, endRow); } public static Collection queryByGroupId(String groupId, int beginRow, int endRow) throws SysException { String sql = "SELECT * FROM " + tableName + " WHERE USER_GROUP LIKE '" + groupId + "%'"; return queryBySql(sql, beginRow, endRow); } public static boolean isExists(String userMdn) throws SysException { return getRowCountBySql("SELECT COUNT(*) FROM " + tableName + " WHERE USER_MDN = '" + userMdn +"'")>=1; } public static UserModel insertwithDate(UserModel model) throws SysException,UpdateException,AppException { model.setUserRegdate(DateUtil.getCurrTime()); return insert(model); } public static boolean isUserExists(String mdn) throws SysException { try { UserModel userModel = findByPK(mdn); return true; } catch (FinderException e) { return false; } } public static void updateUserAgent(String mdn, String userAgent) throws SysException { String sql = "UPDATE " + tableName + " SET USER_AGENT = '" + userAgent + "' WHERE USER_MDN = '" + mdn + "'"; if (updateBySql(sql) != 1) { throw new SysException("ERROR in updateUserAgent !! resultCount != 1"); } } public static void changeUserName(String userMdn, String userName) throws SysException { String sql = "UPDATE " + tableName + " SET USER_NAME = '" + userName + "' WHERE USER_MDN = '" + userMdn + "'"; updateBySql(sql); } public static void changeUserPwd(String userMdn, String userPwd) throws SysException { String sql = "UPDATE " + tableName + " SET USER_PWD = '" + userPwd + "' WHERE USER_MDN = '" + userMdn + "'"; updateBySql(sql); } public static UserModel newUser(String mdn, String userPwd, int userPoint, String userAgent) throws SysException { try { UserModel model=new UserModel(); model.setUserMdn(mdn); model.setUserName(mdn); model.setUserPwd(userPwd); model.setUserAgent(userAgent); model.setUserArea(0); model.setUserStatus(1); model.setUserPoint(userPoint); model.setUserGroup(0); model.setUserRegdate(DateUtil.getCurrTime()); UserModel userModel = UserBean.insert(model); return userModel; } catch (UpdateException e) { throw new SysException("UpdateException while execute newUser method:\n" + e); } catch (AppException e) { throw new SysException("AppException while execute newUser method:\n" + e); } } public static void updateGroupUser(String mdn,int groupId) throws SysException{ String sql = "UPDATE WAP_USER SET USER_GROUP =" + groupId + " WHERE USER_MDN ='"+mdn+"'"; if (updateBySql(sql) != 1) { throw new SysException("ERROR in updateUserAgent !! resultCount != 1"); } } public static void insertGroupUser(String mdn,int groupId) throws SysException{ String sql = "INSERT INTO WAP_GROUP_USER VALUES(" + groupId +",'" +mdn +"')"; if (updateBySql(sql) != 1) { throw new SysException("ERROR in updateUserAgent !! resultCount != 1"); } } public static boolean isTest(String userMdn) throws SysException{ String sql = "SELECT USER_TEST FROM " + tableName + " WHERE USER_TEST = 1 AND USER_MDN ='" +userMdn +"'"; return queryBySql(sql).size()>=1; } public static Collection getUserGroupChannel(String userMdn) throws SysException{ String sql = "SELECT CH.ID,CH.CHANNEL_NAME,I.IMG_URL FROM WAP_CHANNEL CH,WAP_USER U,WAP_MENU M,WAP_MENU_IMG I WHERE CH.CHANNEL_TRADE = U.USER_GROUP AND CH.ID = M.MENU_CHANNEL AND I.ID = M.IMG_ID AND U.USER_MDN = '" + userMdn + "'"; System.out.println(sql); return queryBySql(sql); } public static boolean isGroupChannel(int channelId) throws SysException{ String sql = "SELECT COUNT(*) FROM WAP_CHANNEL WHERE CHANNEL_TRADE !=0 AND ID = " +channelId; return getRowCountBySql(sql)>0; } public static int getRowCountOfUser(String userMdn, String type) throws SysException { String sql = ""; if ("common".equals(type)) { sql = "SELECT COUNT(*) FROM WAP_USER WHERE USER_TEST <> 1 AND USER_STATUS =1 AND USER_MDN NOT IN (SELECT DISTINCT USER_MDN FROM WAP_GROUP_USER)"; } else if ("group".equals(type)) { sql = "SELECT COUNT(*) FROM WAP_USER WHERE USER_MDN IN (SELECT DISTINCT USER_MDN FROM WAP_GROUP_USER)"; } else if ("test".equals(type)) { sql = "SELECT COUNT(*) FROM WAP_USER WHERE USER_TEST = 1"; } else if ("black".equals(type)) { sql = "SELECT COUNT(*) FROM WAP_USER WHERE USER_STATUS = 0"; } else { sql = "SELECT COUNT(*) FROM WAP_USER WHERE 1=1 "; } sql += (StringUtil.isNotEmpty(userMdn)?" AND USER_MDN LIKE '" + userMdn + "%'":""); return getRowCountBySql(sql); } public static Collection queryUser(String userMdn, String type, int beginRow, int endRow) throws SysException { String sql = ""; if ("common".equals(type)) { sql = "SELECT * FROM WAP_USER WHERE USER_TEST <> 1 AND USER_STATUS =1 AND USER_MDN NOT IN (SELECT DISTINCT USER_MDN FROM WAP_GROUP_USER)"; } else if ("group".equals(type)) { sql = "SELECT * FROM WAP_USER WHERE USER_MDN IN (SELECT DISTINCT USER_MDN FROM WAP_GROUP_USER)"; } else if ("test".equals(type)) { sql = "SELECT * FROM WAP_USER WHERE USER_TEST = 1"; } else if ("black".equals(type)) { sql = "SELECT * FROM WAP_USER WHERE USER_STATUS = 0"; } else { sql = "SELECT * FROM WAP_USER WHERE 1=1 "; } sql += (StringUtil.isNotEmpty(userMdn)?" AND USER_MDN LIKE '" + userMdn + "%'":""); return queryBySql(sql, beginRow, endRow); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -