首页>代码>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日
最近浏览更多
CCCCWWWW  LV4 3月27日
15103432984  LV2 3月16日
Guiyun  LV1 3月15日
sbyhm111 3月14日
暂无贡献等级
admin_z  LV22 1月28日
qwe6002  LV9 1月12日
李林112233  LV2 1月12日
1273082356 1月12日
暂无贡献等级
夜起星河  LV8 2023年12月29日
颜伟峰  LV1 2023年12月20日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友