栏目分类:
子分类:
返回
文库吧用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
文库吧 > IT > 前沿技术 > 大数据 > 大数据系统

MyBatis 数据库操作

MyBatis 数据库操作

一、po(src/main/java文件下)
package demo.boot.po;

public class User {
	private int id;
	private String uname;
	private String pwd;
	private String nikname;
	private String phone;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getUname() {
		return uname;
	}

	public void setUname(String uname) {
		this.uname = uname;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	@Override
	public String toString() {
		return "User [id=" + id + ", uname=" + uname + ", pwd=" + pwd + ", nikname=" + nikname + ", phone=" + phone
				+ "]";
	}

	public User() {
		super();
	}

	public User(int id, String uname, String pwd, String nikname, String phone) {
		super();
		this.id = id;
		this.uname = uname;
		this.pwd = pwd;
		this.nikname = nikname;
		this.phone = phone;
	}

	public String getNikname() {
		return nikname;
	}

	public void setNikname(String nikname) {
		this.nikname = nikname;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

}

二、mapper(src/main/java文件下)
package demo.boot.mapper;

import java.util.List;
import java.util.Map;

import demo.boot.po.User;

public interface UserMapper {

	public List selectAll();
	
	public User selectByAuth(Map params); //String name, String pwd

	public int insertUser(User user);
	
	public int deleteUserById(int id);
	
	public int updateUser(User user);
}

三、mappers(src/main/resources文件下)



	
		select * from t_user where name=#{name} and password=#{pwd}
	
	
	
		insert into t_user values(default, #{name}, #{password})
	
	
	
		delete from t_user where id = #{id}
	
	
	
		update t_user set name=#{name}, password=#{password} where id=#{id}
	

转载请注明:文章转载自 www.wk8.com.cn
本文地址:https://www.wk8.com.cn/it/280021.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 wk8.com.cn

ICP备案号:晋ICP备2021003244-6号