You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
3.1 KiB
103 lines
3.1 KiB
<?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">
|
|
<!-- 配置Mabatis映射文件 -->
|
|
<mapper namespace="com.dao.AdminDAO">
|
|
<resultMap type="admin" id="adminMap">
|
|
<id property="adminid" column="adminid" />
|
|
<result property="username" column="username" />
|
|
<result property="password" column="password" />
|
|
<result property="realname" column="realname" />
|
|
<result property="contact" column="contact" />
|
|
<result property="addtime" column="addtime" />
|
|
</resultMap>
|
|
<!-- 插入语句 DAO通过id调用此配置 -->
|
|
<insert id="insertAdmin" parameterType="admin">
|
|
insert into admin(adminid , username , password , realname , contact , addtime ) values(#{adminid} , #{username} , #{password} , #{realname} , #{contact} , #{addtime} )
|
|
</insert>
|
|
<!-- 更新语句 DAO通过id调用此配置 -->
|
|
<update id="updateAdmin" parameterType="admin">
|
|
update admin set username=#{username} , password=#{password} , realname=#{realname} , contact=#{contact} , addtime=#{addtime} where adminid=#{adminid}
|
|
</update>
|
|
<!-- 按主键删除 DAO通过id调用此配置 -->
|
|
<delete id="deleteAdmin" parameterType="String">
|
|
delete from admin where adminid = #{adminid}
|
|
</delete>
|
|
<!-- 查询全部信息 DAO通过id调用此配置 -->
|
|
<select id="getAllAdmin" resultMap="adminMap">
|
|
select a.* from admin a where 1=1 order by adminid desc
|
|
</select>
|
|
|
|
<!-- 按主键查询 DAO通过id调用此配置 -->
|
|
<select id="getAdminById" parameterType="String" resultMap="adminMap">
|
|
select a.* from admin a where 1=1 and adminid=#{adminid} order by adminid desc
|
|
</select>
|
|
<!-- 按条件精确查询 DAO通过id调用此配置 -->
|
|
<select id="getAdminByCond" parameterType="admin" resultMap="adminMap">
|
|
select a.* from admin a where 1=1
|
|
<if test="username != null and '' != username">
|
|
and a.username = #{username}
|
|
</if>
|
|
<if test="password != null and '' != password">
|
|
and a.password = #{password}
|
|
</if>
|
|
<if test="realname != null and '' != realname">
|
|
and a.realname = #{realname}
|
|
</if>
|
|
<if test="contact != null and '' != contact">
|
|
and a.contact = #{contact}
|
|
</if>
|
|
<if test="addtime != null and '' != addtime">
|
|
and a.addtime = #{addtime}
|
|
</if>
|
|
</select>
|
|
<!-- 按条件模糊查询 DAO通过id调用此配置 -->
|
|
<select id="getAdminByLike" parameterType="admin" resultMap="adminMap">
|
|
select a.* from admin a where 1=1
|
|
<if test="username != null and '' != username">
|
|
and a.username like CONCAT('%', CONCAT(#{username}, '%'))
|
|
</if>
|
|
<if test="password != null and '' != password">
|
|
and a.password like CONCAT('%', CONCAT(#{password}, '%'))
|
|
</if>
|
|
<if test="realname != null and '' != realname">
|
|
and a.realname like CONCAT('%', CONCAT(#{realname}, '%'))
|
|
</if>
|
|
<if test="contact != null and '' != contact">
|
|
and a.contact like CONCAT('%', CONCAT(#{contact}, '%'))
|
|
</if>
|
|
<if test="addtime != null and '' != addtime">
|
|
and a.addtime like CONCAT('%', CONCAT(#{addtime}, '%'))
|
|
</if>
|
|
</select>
|
|
</mapper>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|