package com.jc.taobao.gjj.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.jc.taobao.gjj.db.DBManager;
import com.jc.taobao.gjj.entity.UserInfo;
public class UserInfoDAO{
DBManager dm = new DBManager();
public int delete(Integer id) {
String sql = "delete from userinfo where userid=" + id;
return dm.updb(sql);
}
public int updateuser(Integer userid,Integer userscore)
{
String sql="update userinfo set userscore="+userscore+" where userid="+userid;
return dm.updb(sql);
}
public int merge(UserInfo user) {
String sql = "update userinfo set photoid=" + user.getPhotoid()
+ ",usercardid='" + user.getUsercardid() + "',userpwd='"
+ user.getUserpwd() + "',username='" + user.getUsername()
+ "',userquestion='" + user.getUserquestion()
+ "',useranswer='" + user.getUseranswer() + "',userunid='"
+ user.getUserunid() + "',useremail='" + user.getUseremail()
+ "',useraddress='" + user.getUseraddress() + "',usertel='"
+ user.getUsertel() + "',userscore=" + user.getUserscore()
+ ",userule=" + user.getUserule() + " where userid="
+ user.getUserid();
return dm.updb(sql);
}
public int save(UserInfo user) {
String sql = "insert into userinfo values("
+ user.getPhotoid() + ",'" + user.getUsercardid() + "','"
+ user.getUserpwd() + "','" + user.getUsername() + "','"
+ user.getUserquestion() + "','" + user.getUseranswer() + "','"
+ user.getUserunid() + "','" + user.getUseremail() + "','"
+ user.getUseraddress() + "','" + user.getUsertel() + "',"
+ user.getUserscore() + "," + user.getUserule() + ")";
return dm.updb(sql);
}
private List<UserInfo> query(String sql) {// 查询方法
List<UserInfo> list = new ArrayList<UserInfo>();
DBManager db = new DBManager();
ResultSet rs = db.getRs(sql);
try {
while (rs.next()) {
UserInfo user = new UserInfo();
user.setUserid(rs.getInt("userid"));
user.setPhotoid(rs.getInt("photoid"));
user.setUsercardid(rs.getString("usercardid"));
user.setUsername(rs.getString("username"));
user.setUserpwd(rs.getString("userpwd"));
user.setUserunid(rs.getString("userunid"));
user.setUseremail(rs.getString("useremail"));
user.setUseraddress(rs.getString("useraddress"));
user.setUsertel(rs.getString("usertel"));
user.setUserscore(rs.getInt("userscore"));
user.setUserule(rs.getInt("userule"));
list.add(user);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
/*public int updateuserstate(Integer userid,Integer stateid)
{
String sql="update orderinfo set userscore="+stateid+" where userid="+userid;
return dm.updb(sql);
}*/
public int login(UserInfo user) {// 用户登录,根据查处权限若为-1则不是用户,为0则为管理员,为1则为普通用户
ResultSet rs = null;
int userrule = -1;
String sql = "select userule from userinfo where username='"
+ user.getUsername() + "'";
try {
rs = dm.getRs(sql);
while (rs.next()) {
userrule = rs.getInt("userule");
}
return userrule;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return -1;
}
}
public int SmallLogin(String username,String pwd)
{
ResultSet rs=null;
String sql="select * from userinfo where username='"+username+"' and userpwd='"+pwd+"'";
try {
rs=dm.getRs(sql);
while(rs.next())
{
return 1;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return 0;
}
public List<UserInfo> querybyuserunid(String userunid)//根据用户昵称查
{
String sql="select * from userinfo where userunid='"+userunid+"'";
return query(sql);
}
public List<UserInfo> queryAll()// 查询所有用户信息
{
String sql = "select * from userinfo";
return query(sql);
}
public List<UserInfo> querybyuserscore(Integer score) {// 根据积分查用户信息
String sql = "select * from userinfo where userscore ="
+ score;
return query(sql);
}
public List<UserInfo> querybyuserid(Integer userid) {//根据用户id查用户信息
String sql = "select * from userinfo where userid="
+ userid;
return query(sql);
}
public List<UserInfo> querybyusername(UserInfo user)//根据用户名察看个人信息
{
String sql="select* from userinfo where username='"+user.getUsername()+"'";
return query(sql);
}
public int getUserCardID(String username)
{
int count=0;
String sql="select count(username)as isName from userinfo where username='"+username+"'";
try {
ResultSet rs=dm.getRs(sql);
while(rs.next())
{
count=rs.getInt("isName");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return count;
}
public List<UserInfo> querybyuserule(int userule)// 根据权限查信息
{
String sql = "select * from userinfo where userule="
+ userule;
return query(sql);
}
public int getCount(){//判断用户是否存在
String sql="select count(usercardid) from userinfo";
try {
ResultSet rs=dm.getRs(sql);
if(rs.next())
{
return rs.getInt(1);
}
return 0;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return 0;
}
}
public String getuserpwd(UserInfo user)// 找回密码
{
ResultSet rs = null;
try {
String sql = "select userpwd from userinfo where username='"
+ user.getUsername() + "' and question='"
+ user.getUserquestion() + "' and answer='"
+ user.getUseranswer() + "'";
rs = dm.getRs(sql);
if (rs.next()) {
return rs.getString("userpwd");
}
return null;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
public int queryUserInfoCount()
{
int userinfocount=0;
String sql="select count(*) as userinfocount from userinfo";
try {
ResultSet rs=dm.getRs(sql);
while(rs.next())
{
userinfocount=rs.getInt("userinfocount");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return userinfocount;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Jsp仿淘宝网项目源代码 (1335个子文件)
config.ascx 5KB
class_upload.asp 10KB
io.asp 6KB
commands.asp 6KB
config.asp 6KB
connector.asp 2KB
basexml.asp 2KB
upload.asp 2KB
util.asp 1KB
connector.aspx 1KB
upload.aspx 1KB
9.bmp 200KB
bb.bmp 200KB
l5.bmp 196KB
n2.bmp 196KB
l4.bmp 191KB
n1.bmp 191KB
QQ截图未命名3.bmp 157KB
QQ截图未命名3.bmp 157KB
aa.bmp 111KB
a3.bmp 68KB
a49.bmp 68KB
zhifubao.bmp 54KB
zhuce01.bmp 54KB
1.bmp 38KB
headpic.bmp 38KB
10.bmp 31KB
taoketuiguan.bmp 31KB
qiangxian72.bmp 21KB
xiaofeibaozhang.bmp 19KB
wang2.bmp 19KB
wang1.bmp 19KB
taobaodaxue.bmp 15KB
wanzhuang.bmp 11KB
jiffen.bmp 11KB
chuxiawanmei.bmp 11KB
taobao.bmp 10KB
yangjing.bmp 9KB
zixun.bmp 9KB
taobao.bmp 8KB
zhuce.bmp 8KB
2.bmp 8KB
5.bmp 6KB
11.bmp 6KB
bank2.bmp 6KB
bank6.bmp 6KB
bank10.bmp 6KB
bank3.bmp 6KB
bank8.bmp 6KB
bank4.bmp 6KB
bank12.bmp 6KB
bank7.bmp 6KB
bank9.bmp 6KB
bank11.bmp 6KB
bank5.bmp 6KB
bank1.bmp 6KB
sell4.bmp 5KB
sell2.bmp 5KB
12.bmp 5KB
sell3.bmp 4KB
sell1.bmp 4KB
buttom3.bmp 4KB
buttom1.bmp 4KB
buttom2.bmp 4KB
yuantiena.bmp 4KB
6.bmp 4KB
3.bmp 2KB
2.bmp 2KB
4.bmp 2KB
1.bmp 2KB
biao.bmp 378B
image.cfc 46KB
ImageObject.cfc 12KB
cf5_upload.cfm 10KB
cf5_connector.cfm 10KB
cf_io.cfm 10KB
cf_commands.cfm 8KB
config.cfm 8KB
spellchecker.cfm 5KB
cf_util.cfm 4KB
cf_connector.cfm 3KB
cf_basexml.cfm 3KB
cf_upload.cfm 2KB
connector.cfm 1005B
upload.cfm 993B
connector.cgi 4KB
upload.cgi 3KB
ShopInfoDAO.class 8KB
MasterNoteDAO.class 7KB
UserInfoDAO.class 7KB
OrderInfoDAO.class 5KB
FollowNoteDAO.class 5KB
UserInfoBean.class 5KB
AddShopServlet.class 4KB
UserissueShopServlet.class 4KB
CheckoutServlet.class 4KB
ShopInfoBean.class 4KB
ModeInfoDAO.class 4KB
OrderInfoBean.class 4KB
MasterNoteBean.class 4KB
共 1335 条
- 1
- 2
- 3
- 4
- 5
- 6
- 14
积跬步DEV
- 粉丝: 439
- 资源: 30
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页