邱宇豪
2023-11-08 ce1798b6f6ef2d4e82a156a22e9646b57a2a3649
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
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
<?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.thhy.secure.modules.biz.material.mapper.TMaterialMapper">
  <resultMap id="BaseResultMap" type="com.thhy.secure.modules.biz.material.entity.TMaterial">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon Jun 05 12:47:02 CST 2023.
    -->
    <id column="material_id" jdbcType="VARCHAR" property="materialId" />
    <result column="material_name" jdbcType="VARCHAR" property="materialName" />
    <result column="material_type" jdbcType="VARCHAR" property="materialType" />
    <result column="material_number" jdbcType="VARCHAR" property="materialNumber" />
    <result column="material_version" jdbcType="VARCHAR" property="materialVersion" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_user" jdbcType="VARCHAR" property="createUser" />
    <result column="is_use" jdbcType="INTEGER" property="isUse" />
    <result column="company_id" jdbcType="VARCHAR" property="companyId" />
  </resultMap>
 
 
  <insert id="materialInsert">
    insert into t_material
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="materialId != null">
        material_id,
      </if>
      <if test="materialName != null">
        material_name,
      </if>
      <if test="materialType != null">
        material_type,
      </if>
      <if test="materialNumber != null">
        material_number,
      </if>
      <if test="materialVersion != null">
        material_version,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createUser != null">
        create_user,
      </if>
      <if test="isUse != null">
        is_use,
      </if>
      <if test="companyId != null">
        company_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="materialId != null">
        #{materialId,jdbcType=VARCHAR},
      </if>
      <if test="materialName != null">
        #{materialName,jdbcType=VARCHAR},
      </if>
      <if test="materialType != null">
        #{materialType,jdbcType=VARCHAR},
      </if>
      <if test="materialNumber != null">
        #{materialNumber,jdbcType=VARCHAR},
      </if>
      <if test="materialVersion != null">
        #{materialVersion,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="isUse != null">
        #{isUse,jdbcType=INTEGER},
      </if>
      <if test="companyId != null">
        #{companyId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
 
  <insert id="materialPathInsert">
    insert into t_material_path
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="materialPathId != null">
        material_path_id,
      </if>
      <if test="materialPath != null">
        material_path,
      </if>
      <if test="materialId != null">
        material_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="materialPathId != null">
        #{materialPathId,jdbcType=VARCHAR},
      </if>
      <if test="materialPath != null">
        #{materialPath,jdbcType=VARCHAR},
      </if>
      <if test="materialId != null">
        #{materialId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
 
  <select id="materialList" resultType="com.thhy.secure.modules.biz.material.entity.TMaterial">
        SELECT
    tm.material_id as materialId,
    tm.material_name as materialName,
    tm.material_type as materialType,
    tm.material_number as materialNumber,
    tm.material_version as materialVersion,
    sd.dict_name as dictName
FROM
    t_material tm
    LEFT JOIN sys_dict sd ON tm.material_type = sd.dict_id
    where  tm.is_use=1
    <if test="companyId!=null and companyId!='' ">
      and tm.company_id=#{companyId}
    </if>
    <if test="materialName!=null and materialName!='' ">
      and  tm.material_name like concat('%',#{materialName},'%')
    </if>
    <if test="materialType!=null and materialType!='' ">
      and tm.material_type=#{materialType}
    </if>
    order by  tm.create_time desc
  </select>
  <select id="materialInfo" resultType="com.thhy.secure.modules.biz.material.entity.TMaterial">
    SELECT
    tm.material_id as materialId,
    tm.material_name as materialName,
    tm.material_type as materialType,
    tm.material_number as materialNumber,
    tm.material_version as materialVersion,
    sd.dict_name as dictName
    FROM
    t_material tm
    LEFT JOIN sys_dict sd ON tm.material_type = sd.dict_id
    where  tm.is_use=1 and tm.material_id=#{materialId}
  </select>
  <select id="materialPathList" parameterType="java.lang.String" resultType="com.thhy.secure.modules.biz.material.entity.TMaterialPath">
    select
        material_path_id as materialPathId,
        material_path as materialPath,
        material_id as materialId
     from  t_material_path where
    material_id=#{materialId}
  </select>
 
  <update id="materialUpdate">
    update t_material
    <set>
      <if test="materialName != null">
        material_name = #{materialName,jdbcType=VARCHAR},
      </if>
      <if test="materialType != null">
        material_type = #{materialType,jdbcType=VARCHAR},
      </if>
      <if test="materialNumber != null">
        material_number = #{materialNumber,jdbcType=VARCHAR},
      </if>
      <if test="materialVersion != null">
        material_version = #{materialVersion,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        create_user = #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="isUse != null">
        is_use = #{isUse,jdbcType=INTEGER},
      </if>
      <if test="companyId != null">
        company_id = #{companyId,jdbcType=VARCHAR},
      </if>
    </set>
    where material_id = #{materialId,jdbcType=VARCHAR}
  </update>
 
  <delete id="materialPathDel" parameterType="java.lang.String">
        delete  from t_material_path
        where  material_id=#{materialId}
  </delete>
 
</mapper>