EmployeeMapper.xml 6.49 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<?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.iocoder.yudao.module.delivery.mapper.EmployeeMapper">

    <select id="pageCC" resultType="cn.iocoder.yudao.module.delivery.entity.Employee">
        select *
        from employee ${ew.customSqlSegment}
    </select>

    <resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.delivery.entity.Employee">
        <result column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="emp_gender" property="empGender"/>
        <result column="age" property="age"/>
        <result column="email" property="email"/>
    </resultMap>


lanbaoming's avatar
lanbaoming committed
19
    <!-- 通用查询结果列 2024-04-22-->
lanbaoming's avatar
lanbaoming committed
20 21
    <sql id="Base_Column_List">
        id, name, emp_gender, age, email    </sql>
lanbaoming's avatar
lanbaoming committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

    <!-- 目的:为dao接口方法提供sql语句配置 -->
    <insert id="addUser">
        <!-- 具体的sql -->
        insert into user(user_name,user_password,phone_number,day)
        value (#{userName},#{userPassword},#{phoneNumber},#{day})
    </insert>

    <select id="queryUserByname" resultType="cn.iocoder.yudao.module.delivery.entity.Employee">
        select *
        from user
        where user_name = #{userName}
    </select>

    <select id="queryUser" resultType="cn.iocoder.yudao.module.delivery.entity.Employee">
        select *
        from user
    </select>

    <update id="updateUserDay">
        UPDATE user
        SET day=#{day}
        WHERE user_name = #{userName}
    </update>

    <update id="addUserOverdue">
        UPDATE user
        SET Overdue=Overdue + 1
        WHERE user_name = #{userName}
    </update>
lanbaoming's avatar
lanbaoming committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197


    <resultMap type="cn.iocoder.yudao.module.delivery.entity.Employee" id="SysTestMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="testName" column="test_name" jdbcType="VARCHAR"/>
        <result property="orderNum" column="order_num" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
    </resultMap>

    <!--查询所有-->
    <select id="queryAll" resultMap="SysTestMap">
        select id,
               test_name,
               order_num,
               create_time,
               del_flag,
               remark
        from sys_test
    </select>

    <!--查询单个-->
    <select id="queryById" resultMap="SysTestMap">
        select id,
               test_name,
               order_num,
               create_time,
               del_flag,
               remark
        from sys_test
        where id = #{id}
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="SysTestMap">
        select
        id, test_name, order_num, create_time, del_flag, remark
        from sys_test
        <where>
            <if test="id != null">
                and id = #{id}
            </if>
            <if test="testName != null and testName != ''">
                and test_name = #{testName}
            </if>
            <if test="orderNum != null">
                and order_num = #{orderNum}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="delFlag != null">
                and del_flag = #{delFlag}
            </if>
            <if test="remark != null and remark != ''">
                and remark = #{remark}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from sys_test
        <where>
            <if test="id != null">
                and id = #{id}
            </if>
            <if test="testName != null and testName != ''">
                and test_name = #{testName}
            </if>
            <if test="orderNum != null">
                and order_num = #{orderNum}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="delFlag != null">
                and del_flag = #{delFlag}
            </if>
            <if test="remark != null and remark != ''">
                and remark = #{remark}
            </if>
        </where>
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
        insert into sys_test(test_name, order_num, create_time, del_flag, remark)
        values (#{testName}, #{orderNum}, #{createTime}, #{delFlag}, #{remark})
    </insert>

    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into sys_test(test_name, order_num, create_time, del_flag, remark)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.testName}, #{entity.orderNum}, #{entity.createTime}, #{entity.delFlag}, #{entity.remark})
        </foreach>
    </insert>

    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into sys_test(test_name, order_num, create_time, del_flag, remark)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.testName}, #{entity.orderNum}, #{entity.createTime}, #{entity.delFlag}, #{entity.remark})
        </foreach>
        on duplicate key update
        test_name = values(test_name),
        order_num = values(order_num),
        create_time = values(create_time),
        del_flag = values(del_flag),
        remark = values(remark)
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        update sys_test
        <set>
            <if test="testName != null and testName != ''">
                test_name = #{testName},
            </if>
            <if test="orderNum != null">
                order_num = #{orderNum},
            </if>
            <if test="createTime != null">
                create_time = #{createTime},
            </if>
            <if test="delFlag != null">
                del_flag = #{delFlag},
            </if>
            <if test="remark != null and remark != ''">
                remark = #{remark},
            </if>
        </set>
        where id = #{id}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete
        from sys_test
        where id = #{id}
    </delete>

lanbaoming's avatar
lanbaoming committed
198 199 200
</mapper>