|
|
<?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">
|
|
|
<!-- 配置关于网站用户表的 MyBatis映射文件 -->
|
|
|
<!-- namespace:必须与对应的接口全类名一致 id:必须与对应接口的某个对应的方法名一致 -->
|
|
|
<mapper namespace="com.dao.UsersDAO">
|
|
|
<resultMap type="users" id="usersMap">
|
|
|
<id property="usersid" column="usersid" />
|
|
|
<result property="username" column="username" />
|
|
|
<result property="password" column="password" />
|
|
|
<result property="realname" column="realname" />
|
|
|
<result property="sex" column="sex" />
|
|
|
<result property="birthday" column="birthday" />
|
|
|
<result property="contact" column="contact" />
|
|
|
<result property="regdate" column="regdate" />
|
|
|
<result property="asksid" column="asksid" />
|
|
|
<result property="answer" column="answer" />
|
|
|
<!-- 通过外键关联查询 返回封装Asks对象 -->
|
|
|
<association property="asks" column="asksid" select="com.dao.AsksDAO.getAsksById" javaType="com.entity.Asks" />
|
|
|
</resultMap>
|
|
|
|
|
|
<!-- 网站用户表 插入SQL语句 UsersDAO通过ID(insertUsers)调用此配置 -->
|
|
|
<insert id="insertUsers" parameterType="users">
|
|
|
insert into users(usersid , username , password , realname , sex , birthday , contact , regdate , asksid , answer
|
|
|
) values(#{usersid} , #{username} , #{password} , #{realname} ,
|
|
|
#{sex} , #{birthday} , #{contact} , #{regdate}, #{asksid} , #{answer} )
|
|
|
</insert>
|
|
|
|
|
|
<!-- 网站用户表 更新SQL语句 UsersDAO通过ID(updateUsers)调用此配置 -->
|
|
|
<update id="updateUsers" parameterType="users">
|
|
|
update users set username=#{username} , password=#{password} , realname=#{realname} , sex=#{sex} ,
|
|
|
birthday=#{birthday} , contact=#{contact} , regdate=#{regdate} where usersid=#{usersid}
|
|
|
</update>
|
|
|
|
|
|
<!-- 网站用户表 按主键删除SQL语句 UsersDAO通过ID(deleteUsers)调用此配置 -->
|
|
|
<delete id="deleteUsers" parameterType="String">
|
|
|
delete from users where usersid = #{usersid}
|
|
|
</delete>
|
|
|
|
|
|
<!-- 网站用户表 查询全部网站用户信息SQL语句 UsersDAO通过ID(getAllUsers)调用此配置 -->
|
|
|
<select id="getAllUsers" resultMap="usersMap">
|
|
|
select a.* , d.question from users a , asks d where 1=1 and a.asksid = d.asksid order by usersid desc
|
|
|
</select>
|
|
|
|
|
|
<!-- 网站用户表 按主键(usersid)查询SQL语句 UsersDAO通过ID(getUsersById)调用此配置 -->
|
|
|
<select id="getUsersById" parameterType="String" resultMap="usersMap">
|
|
|
select a.* , d.question from users a , asks d where 1=1 and a.asksid = d.asksid and
|
|
|
usersid=#{usersid} order by usersid desc
|
|
|
</select>
|
|
|
|
|
|
<!-- 网站用户表 按条件精确查询SQL语句 UsersDAO通过ID(getUsersByCond)调用此配置 -->
|
|
|
<select id="getUsersByCond" parameterType="users" resultMap="usersMap">
|
|
|
select a.* , d.question from users a , asks d where 1=1 and a.asksid = d.asksid
|
|
|
<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="sex != null and '' != sex">
|
|
|
and a.sex = #{sex}
|
|
|
</if>
|
|
|
<if test="birthday != null and '' != birthday">
|
|
|
and a.birthday = #{birthday}
|
|
|
</if>
|
|
|
<if test="contact != null and '' != contact">
|
|
|
and a.contact = #{contact}
|
|
|
</if>
|
|
|
<if test="regdate != null and '' != regdate">
|
|
|
and a.regdate = #{regdate}
|
|
|
</if>
|
|
|
<if test="asksid != null and '' != asksid">
|
|
|
and a.asksid = #{asksid}
|
|
|
</if>
|
|
|
<if test="answer != null and '' != answer">
|
|
|
and a.answer = #{answer}
|
|
|
</if>
|
|
|
</select>
|
|
|
|
|
|
<!-- 网站用户表 按条件模糊查询SQL语句 UsersDAO通过ID(getUsersByLike)调用此配置 -->
|
|
|
<select id="getUsersByLike" parameterType="users" resultMap="usersMap">
|
|
|
select a.* , d.question from users a , asks d where 1=1 and a.asksid = d.asksid
|
|
|
<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="sex != null and '' != sex">
|
|
|
and a.sex like CONCAT('%', CONCAT(#{sex}, '%'))
|
|
|
</if>
|
|
|
<if test="birthday != null and '' != birthday">
|
|
|
and a.birthday like CONCAT('%', CONCAT(#{birthday}, '%'))
|
|
|
</if>
|
|
|
<if test="contact != null and '' != contact">
|
|
|
and a.contact like CONCAT('%', CONCAT(#{contact}, '%'))
|
|
|
</if>
|
|
|
<if test="regdate != null and '' != regdate">
|
|
|
and a.regdate like CONCAT('%', CONCAT(#{regdate}, '%'))
|
|
|
</if>
|
|
|
</select>
|
|
|
</mapper>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|