1.数据库表名:manage
3.实体类(略)
2.接口:ManageMapper
这里ManageMapper 继承了BaseDao(我的理解是BaseDao是一个公共的接口)
//管理员登录
public interface ManageMapper extends BaseDao<Manage> {
}
他这边给BaseDao<>简括里面赋了值(Manage)
3.公共接口:BasaDao
/**
* 基础dao封装一些简单的方法
* @author
*
*/
public interface BaseDao<T>{
/**
* 查询所有实体,根据实体属性值为判断条件查询所有实体,
* @param entity
* @return
*/
List<T> listAllByEntity(T entity);
}
4.接口的实现类:ManageMapper .xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "<http://mybatis.org/dtd/mybatis-3-mapper.dtd>">
<!--命名空间:实现哪一个Mapper的方法-->
<mapper namespace="com.javapandeng.mapper.ManageMapper">
<!--实体类与数据库映射字段部分-->
<resultMap id="ResultMapManage" type="com.javapandeng.po.Manage">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="userName" column="userName" jdbcType="VARCHAR"/>
<result property="passWord" column="passWord" jdbcType="VARCHAR"/>
<result property="realName" column="realName" jdbcType="VARCHAR"/>
</resultMap>
<!-- 声明数据库字段:以后需要新增或者修改字段,所有的sql都会跟着变 -->
<sql id="Manage_field">
id,userName,passWord,realName
</sql>
<!-- 实体类属性-->
<sql id="Manage_insert">
#{id},#{userName},#{passWord},#{realName}
</sql>
<!-- 更新结果 -->
<sql id="Manage_update">
<if test="userName != null">
userName = #{userName},
</if>
<if test="passWord != null">
passWord = #{passWord},
</if>
<if test="realName != null">
realName = #{realName}
</if>
</sql>
<!-- 查询时条件 -->
<sql id="Manage_where">
<if test="id != null">
and id = #{id}
</if>
<if test="userName != null">
and userName = #{userName}
</if>
<if test="passWord != null">
and passWord = #{passWord}
</if>
<if test="realName != null">
and realName = #{realName}
</if>
</sql>
<!-- 查询所有实体,根据实体属性值为判断条件查询所有实体-->
<select id="listAllByEntity" resultMap="ResultMapManage" parameterType="com.javapandeng.po.Manage">
select <include refid="Manage_field"/>
from manage where 1=1
<include refid="Manage_where"/>
</select>
5.疑惑点
标签:userName,realName,公共,接口,BaseDao,Sql,passWord,id From: https://www.cnblogs.com/itxiaofei/p/16906743.html