首页>代码>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; } }
最近下载更多
Guiyun LV1
3月15日
四季镇 LV9
2023年10月11日
feibin LV1
2023年3月29日
janefilion LV3
2023年2月19日
Boss绝 LV8
2023年2月7日
快乐的程序员 LV25
2023年1月21日
Soratosiro LV6
2022年9月29日
小谢xxxxxxx LV4
2022年5月20日
loveMiku LV3
2022年5月19日
thythythythhy LV2
2022年5月12日