1 2 3 24 package com.geinuke.dao; 25 26 import java.util.ArrayList ; 27 import java.util.List ; 28 29 import com.geinuke.vo.BlogAuthorVO; 30 import com.geinuke.vo.RoleVO; 31 import com.geinuke.vo.UserVO; 32 33 public class UserDAO extends GeiDAO{ 34 35 36 public UserDAO() throws Exception { 37 super(); 38 39 } 40 41 public List getUsersByForumID(int fid)throws Exception { 42 List list=null; 43 try{ 44 this.sqlMap().startTransaction(); 45 list=this.sqlMap().queryForList("getUsersByForumID",new Integer (fid)); 46 this.sqlMap().commitTransaction(); 47 }finally{ 48 this.sqlMap().endTransaction(); 49 } 50 return list; 51 52 } 53 54 public UserVO getUserByID(UserVO u) throws Exception { 55 UserVO user=null; 56 try{ 57 this.sqlMap().startTransaction(); 58 user=(UserVO)this.sqlMap().queryForObject("getUserByID",u); 59 this.sqlMap().commitTransaction(); 60 }finally{ 61 this.sqlMap().endTransaction(); 62 } 63 return user; 64 } 65 66 public UserVO getUserFromByPID(int pid) throws Exception { 67 UserVO user=null; 68 try{ 69 this.sqlMap().startTransaction(); 70 user=(UserVO)this.sqlMap().queryForObject("getUserFromByPID", 71 new Integer (pid)); 72 this.sqlMap().commitTransaction(); 73 }finally{ 74 this.sqlMap().endTransaction(); 75 } 76 return user; 77 } 78 79 public UserVO getUserToByPID(int pid) throws Exception { 80 UserVO user=null; 81 try{ 82 this.sqlMap().startTransaction(); 83 user=(UserVO)this.sqlMap().queryForObject("getUserToByPID", 84 new Integer (pid)); 85 this.sqlMap().commitTransaction(); 86 }finally{ 87 this.sqlMap().endTransaction(); 88 } 89 return user; 90 } 91 92 public UserVO getUserByID(int id) throws Exception { 93 UserVO user=null; 94 user=new UserVO(); 95 user.setId(id); 96 97 return getUserByID(user); 98 } 99 100 public BlogAuthorVO getBlogAuthorByBID(int bid) throws Exception { 101 BlogAuthorVO user=null; 102 try{ 103 this.sqlMap().startTransaction(); 104 user=(BlogAuthorVO)this.sqlMap().queryForObject("getBlogAuthorByBID",new Integer (bid)); 105 this.sqlMap().commitTransaction(); 106 }finally{ 107 this.sqlMap().endTransaction(); 108 } 109 return user; 110 } 111 112 113 public ArrayList getAllRoles()throws Exception { 114 ArrayList list=null; 115 List llist=null; 116 try{ 117 sqlMap().startTransaction(); 118 llist=sqlMap().queryForList("getAllRoles",new String ("")); 119 this.sqlMap().commitTransaction(); 120 }finally{ 121 sqlMap().endTransaction(); 122 } 123 list=new ArrayList (llist); 124 125 return list; 126 } 127 128 public ArrayList getBlogAuthors()throws Exception { 129 ArrayList list=null; 130 List llist=null; 131 try{ 132 sqlMap().startTransaction(); 133 llist=sqlMap().queryForList("getBlogAuthors",new String ("")); 134 this.sqlMap().commitTransaction(); 135 }finally{ 136 sqlMap().endTransaction(); 137 } 138 list=new ArrayList (llist); 139 140 return list; 141 } 142 143 public ArrayList getAllUsers()throws Exception { 144 ArrayList list=null; 145 List llist=null; 146 try{ 147 sqlMap().startTransaction(); 148 llist=sqlMap().queryForList("getAllUsers",new String ("")); 149 this.sqlMap().commitTransaction(); 150 }finally{ 151 sqlMap().endTransaction(); 152 } 153 list=new ArrayList (llist); 154 155 return list; 156 } 157 158 public void insertUser(UserVO u) throws Exception { 159 160 try{ 161 this.sqlMap().startTransaction(); 162 this.sqlMap().insert("insUser",u); 163 this.sqlMap().commitTransaction(); 164 }finally{ 165 this.sqlMap().endTransaction(); 166 } 167 168 } 169 170 public void insertRole(RoleVO u) throws Exception { 171 172 try{ 173 this.sqlMap().startTransaction(); 174 this.sqlMap().insert("insRole",u); 175 this.sqlMap().commitTransaction(); 176 }finally{ 177 this.sqlMap().endTransaction(); 178 } 179 180 } 181 182 public void updateUser(UserVO u) throws Exception { 183 184 try{ 185 this.sqlMap().startTransaction(); 186 this.sqlMap().update("updateUser",u); 187 this.sqlMap().commitTransaction(); 188 }finally{ 189 this.sqlMap().endTransaction(); 190 } 191 193 } 194 195 public void updateAllDefStyle(String style) throws Exception { 196 197 try{ 198 this.sqlMap().startTransaction(); 199 this.sqlMap().update("updateAllDefStyle",style); 200 this.sqlMap().commitTransaction(); 201 }finally{ 202 this.sqlMap().endTransaction(); 203 } 204 206 } 207 208 public void updateUserRole(UserVO u) throws Exception { 209 210 try{ 211 this.sqlMap().startTransaction(); 212 this.sqlMap().update("updateUserRole",u); 213 this.sqlMap().commitTransaction(); 214 }finally{ 215 this.sqlMap().endTransaction(); 216 } 217 218 } 219 220 public UserVO getUserByAuth(UserVO u) throws Exception { 221 UserVO user=null; 222 try{ 223 this.sqlMap().startTransaction(); 224 user=(UserVO)this.sqlMap().queryForObject("getUserByAuth",u); 225 this.sqlMap().commitTransaction(); 226 }finally{ 227 this.sqlMap().endTransaction(); 228 } 229 return user; 230 } 231 232 public UserVO getUserByUName(UserVO u) throws Exception { 233 UserVO user=null; 234 try{ 235 this.sqlMap().startTransaction(); 236 user=(UserVO)this.sqlMap().queryForObject("getUserByUName",u); 237 this.sqlMap().commitTransaction(); 238 }finally{ 239 this.sqlMap().endTransaction(); 240 } 241 return user; 242 } 243 244 245 } 246 | Popular Tags |