liurunyu
2024-07-05 b83f639362ae959de55900d14d132585cd72a90d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
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
<?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="com.dy.pipIrrGlobal.daoIr.IrCropMapper">
    <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoIr.IrCrop">
        <!--@mbg.generated-->
        <!--@Table ir_crop-->
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="crop_name" jdbcType="VARCHAR" property="cropName" />
        <result column="remarks" jdbcType="VARCHAR" property="remarks" />
        <result column="deleted" jdbcType="TINYINT" property="deleted" />
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, crop_name, remarks, deleted
    </sql>
    <!--添加-->
    <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrCrop">
        insert into ir_crop
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="cropName != null">
                crop_name,
            </if>
            <if test="remarks != null">
                remarks,
            </if>
            <if test="deleted != null">
                deleted,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="cropName != null">
                #{cropName,jdbcType=VARCHAR},
            </if>
            <if test="remarks != null">
                #{remarks,jdbcType=VARCHAR},
            </if>
            <if test="deleted != null">
                #{deleted,jdbcType=TINYINT},
            </if>
        </trim>
    </insert>
    <!--逻辑删除-->
    <delete id="deleteLogicById" parameterType="java.lang.Long">
        <!--@mbg.generated-->
        update ir_crop
        set deleted = 1
        where id = #{id,jdbcType=BIGINT}
    </delete>
 
    <!--修改信息-->
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrCrop">
        update ir_crop
        <set>
            <if test="cropName != null">
                crop_name = #{cropName,jdbcType=VARCHAR},
            </if>
            <if test="remarks != null">
                remarks = #{remarks,jdbcType=VARCHAR},
            </if>
            <if test="deleted != null">
                deleted = #{deleted,jdbcType=TINYINT},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
 
    <select id="getRecordCount" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        FROM ir_crop cro
        <where>
            cro.deleted = 0
            <if test="cropName != null and cropName != ''">
                AND cro.crop_name LIKE CONCAT('%', #{cropName}, '%')
            </if>
        </where>
    </select>
 
    <select id="getCrops" resultType="com.dy.pipIrrGlobal.voIr.VoCrop">
        SELECT
        CAST(cro.id AS char)AS id,
        cro.crop_name  AS  cropName,
        cro.remarks
        FROM ir_crop cro
        <where>
            cro.deleted = 0
            <if test="cropName != null and cropName != ''">
                AND cro.crop_name LIKE CONCAT('%', #{cropName}, '%')
            </if>
        </where>
        <if test="pageCurr != null and pageSize != null">
            LIMIT ${(pageCurr-1)*pageSize}, ${pageSize}
        </if>
    </select>
 
    <select id="selectById" resultType="com.dy.pipIrrGlobal.voIr.VoCropOne">
        select
        CAST(cro.id AS char)AS id,
        cro.crop_name  AS  cropName,
        cro.remarks
        from ir_crop cro
        where cro.id = #{id,jdbcType=BIGINT} and cro.deleted = 0
 
    </select>
</mapper>