mybatis语句

<?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 namespace="cn.dw.hy.mapper.UserMapper">

<resultMap type="cn.dw.hy.model.User" id="baseMap">
<id column="id" property="id"></id>
<result column="name" property="name"/>
<result column="dartpartment" property="dartpartment"/>
<result column="sex" property="sex"/>
<result column="tel" property="tel"/>
<result column="login_id" property="login_id"/>
<result column="password" property="password"/>
</resultMap>

<insert id="addUser" parameterType="cn.dw.hy.model.User">
insert into user(name,dartpartment,sex,tel,login_id,password) values(#{name},#{dartpartment},#{sex},#{tel},#{login_id},#{password})
</insert>

<update id="updateUser" parameterType="cn.dw.hy.model.User">
update user
<set>
<if test="name!=null">name=#{name},</if>
<if test="dartpartment!=null">dartpartment=#{dartpartment},</if>
<if test="sex!=null">sex=#{sex},</if>
<if test="tel!=null">tel=#{tel},</if>
<if test="login_id!=null">login_id=#{login_id},</if>
<if test="password!=null">password=#{password},</if>
</set>
where id=#{id}
</update>

<select id="getById" parameterType="int" resultType="cn.dw.hy.model.User">
select * from user where id=#{id}
</select>

<select id="queryUsers" resultType="cn.dw.hy.model.User">
select * from user where type=2
</select>

<select id="queryUser" resultType="cn.dw.hy.model.User">
select * from user where login_id=#{login_id} and password=#{password}
</select>

<select id="queryUsersBySql" parameterType="map" resultType="cn.dw.hy.model.User">
select * from user limit #{currIndex} , #{pageSize}
</select>

<insert id="counts" parameterType="cn.dw.hy.model.MethodsValues">
insert into log (methodName) values (#{methodName})
</insert>

</mapper>

posted @ 2018-08-29 15:53  鱼丸1993  阅读(143)  评论(0编辑  收藏  举报