首页>代码>ssm(spring+spring mvc+mybatis+maven)高仿bilibili视频网站项目实例>/bilibili/src/main/java/com/sf/dao/impl/RegisterImpl.java
package com.sf.dao.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.sf.dao.RegisterDao;
import com.sf.db.Data_jdbcTemplate;
import com.sf.entity.userEntity;
@Component
public class RegisterImpl implements RegisterDao {
@Autowired
Data_jdbcTemplate jdbcTemplate;
public int Register(userEntity user) {
//默认为0
int register=0;
//SELECT count(*) FROM user WHERE userName="admin" and `passWord`="123321aaa";
//先根据用户名查询
String sql = "SELECT count(*) FROM user WHERE userName = ?";
int num=jdbcTemplate.getJdbcTemplate().queryForObject(sql, new Object[] {user.getUserName()},Integer.class);
if(num>0){
System.out.println("此用户被注册");
}else{
//开始注册
String chaxunSql="insert into user(userID,userName,passWord,userPhone,userState,userEmial,userHand,userPaypassword) values(?,?,?,?,?,?,?,?)";
register=jdbcTemplate.getJdbcTemplate().update(chaxunSql,new Object[]{user.getUserID(),user.getUserName(),user.getPassWord(),user.getUserPhone(),user.getUserState(),user.getUserEmial(),user.getUserHand(),user.getUserPaypassword()});
}
return register;
}
}
最近下载更多
微信网友_7044194812350464 LV8
2024年9月13日
Guiyun LV2
2024年3月15日
四季镇 LV9
2023年10月11日
feibin LV1
2023年3月29日
janefilion LV3
2023年2月19日
Boss绝 LV10
2023年2月7日
快乐的程序员 LV25
2023年1月21日
Soratosiro LV6
2022年9月29日
小谢xxxxxxx LV4
2022年5月20日
loveMiku LV3
2022年5月19日
最近浏览更多
vincemokea LV9
9月14日
背上书包上学校 LV7
6月23日
2022102154 LV1
3月27日
三秋桂子 LV1
2024年12月22日
sjwc88 LV4
2024年12月4日
JokerTang LV1
2024年12月3日
s4dmcc LV1
2024年9月17日
微信网友_7044194812350464 LV8
2024年9月13日
CCCCWWWW LV4
2024年3月27日
15103432984 LV2
2024年3月16日

