zhangback
2025-11-18 f656483a233cb1213c85f32c6b4f81d71bd4db4c
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?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.ruoyi.tms.mapper.TmsProjectMapper">
 
    <resultMap type="com.ruoyi.tms.domain.TmsProject" id="TmsProjectResult">
        <result property="id"    column="id"    />
        <result property="projectName"    column="project_name"    />
        <result property="projectCode"    column="project_code"    />
        <result property="relatedContractId"    column="related_contract_id"    />
        <result property="relatedContractName"    column="related_contract_name"    />
        <result property="relatedCustomerId"    column="related_customer_id"    />
        <result property="status"    column="status"    />
        <result property="relatedCustomerName"    column="related_customer_name"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
    </resultMap>
 
    <sql id="selectTmsProjectVo">
        select thisTab.id, thisTab.project_name, thisTab.project_code, thisTab.related_contract_id, thisTab.related_contract_name, thisTab.related_customer_id, thisTab.status, thisTab.related_customer_name, thisTab.create_time, thisTab.update_by, thisTab.update_time, thisTab.remark, thisTab.create_by from tms_project AS thisTab
    </sql>
    <sql id="selectTmsProjectVoCount">
        select count(0) from tms_project as thisTab
    </sql>
 
    <sql id="whereCondition">
        <if test="projectName != null  and projectName != ''"> and  thisTab.project_name like concat('%', #{projectName}, '%')</if>
        <if test="projectCode != null  and projectCode != ''"> and thisTab.project_code = #{projectCode}</if>
        <if test="relatedContractId != null "> and thisTab.related_contract_id = #{relatedContractId}</if>
        <if test="relatedContractName != null  and relatedContractName != ''"> and  thisTab.related_contract_name like concat('%', #{relatedContractName}, '%')</if>
        <if test="relatedCustomerId != null "> and thisTab.related_customer_id = #{relatedCustomerId}</if>
        <if test="status != null "> and thisTab.status = #{status}</if>
        <if test="relatedCustomerName != null  and relatedCustomerName != ''"> and  thisTab.related_customer_name like concat('%', #{relatedCustomerName}, '%')</if>
    </sql>
 
    <!--查询-->
    <select id="selectTmsProjectById" parameterType="Integer" resultMap="TmsProjectResult">
        <include refid="selectTmsProjectVo"/>
        where id = #{id}
    </select>
 
    <select id="selectTmsProjectCount" parameterType="com.ruoyi.tms.domain.TmsProject" resultType="int">
        <include refid="selectTmsProjectVoCount"/>
        <where>
            <include refid="whereCondition"/>
        </where>
    </select>
 
    <select id="selectTmsProjectList" parameterType="com.ruoyi.tms.domain.TmsProject" resultMap="TmsProjectResult">
        <include refid="selectTmsProjectVo"/>
        <where>
            <include refid="whereCondition"/>
        </where>
        order by thisTab.id desc
    </select>
 
    <!-- 新增 -->
    <insert id="insertTmsProject" parameterType="com.ruoyi.tms.domain.TmsProject"  useGeneratedKeys="true" keyProperty="id">
        insert into tms_project
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectName != null and projectName != ''">project_name,</if>
            <if test="projectCode != null and projectCode != ''">project_code,</if>
            <if test="relatedContractId != null">related_contract_id,</if>
            <if test="relatedContractName != null">related_contract_name,</if>
            <if test="relatedCustomerId != null">related_customer_id,</if>
            <if test="status != null">status,</if>
            <if test="relatedCustomerName != null">related_customer_name,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectName != null and projectName != ''">#{projectName},</if>
            <if test="projectCode != null and projectCode != ''">#{projectCode},</if>
            <if test="relatedContractId != null">#{relatedContractId},</if>
            <if test="relatedContractName != null">#{relatedContractName},</if>
            <if test="relatedCustomerId != null">#{relatedCustomerId},</if>
            <if test="status != null">#{status},</if>
            <if test="relatedCustomerName != null">#{relatedCustomerName},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
        </trim>
    </insert>
 
    <insert id="insertTmsProjectBatch" parameterType="java.util.List"  useGeneratedKeys="true" keyProperty="id">
        insert into tms_project
        <trim prefix="(" suffix=") values" suffixOverrides=",">
            id,project_name,project_code,related_contract_id,related_contract_name,related_customer_id,status,related_customer_name,create_time,update_by,update_time,remark,create_by,
        </trim>
        <foreach item="item" index="index" collection="list" separator=",">
            <trim prefix="(" suffix=") " suffixOverrides=",">
                #{item.id},#{item.projectName},#{item.projectCode},#{item.relatedContractId},#{item.relatedContractName},#{item.relatedCustomerId},#{item.status},#{item.relatedCustomerName},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.remark},#{item.createBy},
            </trim>
        </foreach>
    </insert>
 
    <!-- 修改 -->
    <update id="updateTmsProject" parameterType="com.ruoyi.tms.domain.TmsProject">
        update tms_project
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectName != null and projectName != ''">project_name = #{projectName},</if>
            <if test="projectCode != null and projectCode != ''">project_code = #{projectCode},</if>
            <if test="relatedContractId != null">related_contract_id = #{relatedContractId},</if>
            <if test="relatedContractName != null">related_contract_name = #{relatedContractName},</if>
            <if test="relatedCustomerId != null">related_customer_id = #{relatedCustomerId},</if>
            <if test="status != null">status = #{status},</if>
            <if test="relatedCustomerName != null">related_customer_name = #{relatedCustomerName},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
        </trim>
        where id = #{id}
    </update>
    <!-- 修改 -->
    <update id="updateTmsProjectBatch" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" separator=";">
            update tms_project
            <trim prefix="SET" suffixOverrides=",">
                <if test="item.projectName != null and item.projectName != ''">project_name = #{item.projectName},</if>
                <if test="item.projectCode != null and item.projectCode != ''">project_code = #{item.projectCode},</if>
                <if test="item.relatedContractId != null">related_contract_id = #{item.relatedContractId},</if>
                <if test="item.relatedContractName != null">related_contract_name = #{item.relatedContractName},</if>
                <if test="item.relatedCustomerId != null">related_customer_id = #{item.relatedCustomerId},</if>
                <if test="item.status != null">status = #{item.status},</if>
                <if test="item.relatedCustomerName != null">related_customer_name = #{item.relatedCustomerName},</if>
                <if test="item.createTime != null">create_time = #{item.createTime},</if>
                <if test="item.updateBy != null">update_by = #{item.updateBy},</if>
                <if test="item.updateTime != null">update_time = #{item.updateTime},</if>
                <if test="item.remark != null">remark = #{item.remark},</if>
                <if test="item.createBy != null">create_by = #{item.createBy},</if>
            </trim>
            where id = #{item.id}
        </foreach>
    </update>
 
    <!--删除-->
    <delete id="deleteTmsProjectById" parameterType="Integer">
        delete from tms_project where id = #{id}
    </delete>
    <delete id="deleteTmsProjectByIds" parameterType="Integer">
        delete from tms_project where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
</mapper>