郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
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
<?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.gkhy.safePlatform.specialWork.repository.MaterialAllocationBaseInfoRepository">
 
    <resultMap type="com.gkhy.safePlatform.specialWork.entity.MaterialAllocationBaseInfo" id="MaterialAllocationBaseMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="workType" column="work_type" jdbcType="INTEGER"/>
        <result property="workLevel" column="work_level" jdbcType="INTEGER"/>
        <result property="status" column="status" jdbcType="INTEGER"/>
        <result property="info" column="info" jdbcType="VARCHAR"/>
        <result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
        <result property="createUid" column="create_uid" jdbcType="INTEGER"/>
        <result property="createUname" column="create_uname" jdbcType="VARCHAR"/>
        <result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
        <result property="modifiedUid" column="modified_uid" jdbcType="INTEGER"/>
        <result property="modifiedUname" column="modified_uname" jdbcType="VARCHAR"/>
    </resultMap>
 
    <!--查询单个-->
    <select id="queryById" resultMap="MaterialAllocationBaseMap">
        select
          id, name, work_type, work_level,info
        from material_allocation_base
        where id = #{id} and status = #{status}
    </select>
 
    <!--查询指定行数据-->
    <select id="listByCondition" resultMap="MaterialAllocationBaseMap">
        select
          id, name, work_type, work_level, status,info, gmt_create, create_uid, create_uname, gmt_modified, modified_uid, modified_uname
        from material_allocation_base
        <where>
            <if test="query.name != null and query.name != ''">
                and name like concat("%",#{query.name},"%")
            </if>
            <if test="query.workType != null">
                and work_type = #{query.workType}
            </if>
            <if test="query.workLevel != null">
                and work_level = #{query.workLevel}
            </if>
            <if test="query.status != null">
                and status = #{query.status}
            </if>
 
        </where>
        ORDER BY gmt_create desc
    </select>
 
    <!--新增所有列-->
    <insert id="saveOne" >
        insert into material_allocation_base(id,name, work_type, work_level, status, info, gmt_create, create_uid, create_uname, gmt_modified, modified_uid, modified_uname)
        values (#{id},#{name}, #{workType}, #{workLevel}, #{status}, #{info}, #{gmtCreate}, #{createUid}, #{createUname}, #{gmtModified}, #{modifiedUid}, #{modifiedUname})
    </insert>
 
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into material_allocation_base(id,name, work_type, work_level, status, info, gmt_create, create_uid, create_uname, gmt_modified, modified_uid, modified_uname)
        values
        <foreach collection="entities" item="entity" separator=",">
        (#{entity.id},#{entity.name}, #{entity.workType}, #{entity.workLevel}, #{entity.status}, #{entity.info}, #{entity.gmtCreate}, #{entity.createUid}, #{entity.createUname}, #{entity.gmtModified}, #{entity.modifiedUid}, #{entity.modifiedUname})
        </foreach>
    </insert>
 
    <!--通过主键修改数据-->
    <update id="updateOne">
        update material_allocation_base
        <set>
            <if test="name != null and name != ''">
                name = #{name},
            </if>
            <if test="workType != null">
                work_type = #{workType},
            </if>
            <if test="workLevel != null">
                work_level = #{workLevel},
            </if>
            <if test="status != null">
                status = #{status},
            </if>
            <if test="info != null and info != ''">
                info = #{info},
            </if>
            <if test="gmtCreate != null">
                gmt_create = #{gmtCreate},
            </if>
            <if test="createUid != null">
                create_uid = #{createUid},
            </if>
            <if test="createUname != null and createUname != ''">
                create_uname = #{createUname},
            </if>
            <if test="gmtModified != null">
                gmt_modified = #{gmtModified},
            </if>
            <if test="modifiedUid != null">
                modified_uid = #{modifiedUid},
            </if>
            <if test="modifiedUname != null and modifiedUname != ''">
                modified_uname = #{modifiedUname},
            </if>
        </set>
        where id = #{id}
    </update>
 
    <!--逻辑删除-->
    <update id="updateStatus">
        update material_allocation_base set status = #{status} where id = #{id}
    </update>
 
    <!--批量删除-->
    <update id="batchUpdateStatus">
        update material_allocation_base set status = #{status}
        where id in
        <foreach collection="ids" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
    </update>
    <select id="getCountByWorkTypeOrLevel" resultType="java.lang.Integer">
        select
        count(1)
        from material_allocation_base
        <where>
            <if test="query.id != null">
                and id != #{query.id}
            </if>
            <if test="query.workType != null">
                and work_type = #{query.workType}
            </if>
            <if test="query.workLevel != null">
                and work_level = #{query.workLevel}
            </if>
            <if test="query.status != null">
                and status = #{query.status}
            </if>
 
        </where>
    </select>
</mapper>