邱宇豪
2023-10-26 a12423474cd5384898fb91dba49dea23931f7b9a
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
<?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.engineering.modules.biz.car.mapper.SysCarMapper">
  <resultMap id="BaseResultMap" type="com.thhy.engineering.modules.biz.car.entity.SysCar">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon May 15 10:53:49 CST 2023.
    -->
    <id column="car_id" jdbcType="VARCHAR" property="carId" />
    <result column="car_brand" jdbcType="VARCHAR" property="carBrand" />
    <result column="car_type" jdbcType="VARCHAR" property="carType" />
    <result column="car_driver" jdbcType="VARCHAR" property="carDriver" />
    <result column="car_phone" jdbcType="VARCHAR" property="carPhone" />
    <result column="car_notes" jdbcType="VARCHAR" property="carNotes" />
    <result column="is_use" jdbcType="INTEGER" property="isUse" />
    <result column="company_id" jdbcType="VARCHAR" property="companyId" />
  </resultMap>
 
 
  <select id="carBrandByOne" parameterType="java.lang.String" resultType="java.lang.String">
    select car_id as carId from sys_car
    where  is_use=1
    and car_brand=#{carBrand}
  </select>
  <insert id="carInsert">
    insert into sys_car
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="carId != null">
        car_id,
      </if>
      <if test="carBrand != null">
        car_brand,
      </if>
      <if test="carType != null">
        car_type,
      </if>
      <if test="carDriver != null">
        car_driver,
      </if>
      <if test="carPhone != null">
        car_phone,
      </if>
      <if test="carNotes != null">
        car_notes,
      </if>
      <if test="isUse != null">
        is_use,
      </if>
      <if test="companyId != null">
        company_id,
      </if>
      <if test="createUser != null">
        create_user,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="carId != null">
        #{carId,jdbcType=VARCHAR},
      </if>
      <if test="carBrand != null">
        #{carBrand,jdbcType=VARCHAR},
      </if>
      <if test="carType != null">
        #{carType,jdbcType=VARCHAR},
      </if>
      <if test="carDriver != null">
        #{carDriver,jdbcType=VARCHAR},
      </if>
      <if test="carPhone != null">
        #{carPhone,jdbcType=VARCHAR},
      </if>
      <if test="carNotes != null">
        #{carNotes,jdbcType=VARCHAR},
      </if>
      <if test="isUse != null">
        #{isUse,jdbcType=INTEGER},
      </if>
      <if test="companyId != null">
        #{companyId,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
 
  <select id="carList" resultType="com.thhy.engineering.modules.biz.car.entity.SysCar">
        SELECT
    sc.car_id AS carId,
    sc.car_brand AS carBrand,
    sc.car_driver AS carDriver,
    sc.car_notes AS carNotes,
    sc.car_phone AS carPhone,
    sd.dict_name AS dictName
FROM
    sys_car sc
    LEFT JOIN sys_dict sd ON sc.car_type = sd.dict_id
    where sc.is_use=1
    <if test="companyId!=null and companyId!='' ">
      and sc.company_id=#{companyId}
    </if>
    <if test="carBrand!=null and carBrand!='' ">
      and sc.car_brand like concat('%',#{carBrand},'%')
    </if>
    order by sc.create_time desc
  </select>
 
  <select id="carInfo" parameterType="java.lang.String" resultType="com.thhy.engineering.modules.biz.car.entity.SysCar">
    SELECT
    sc.car_id AS carId,
    sc.car_brand AS carBrand,
    sc.car_driver AS carDriver,
    sc.car_notes AS carNotes,
    sc.car_phone AS carPhone,
    sd.dict_name AS dictName,
    sc.car_type as carType
    FROM
    sys_car sc
    LEFT JOIN sys_dict sd ON sc.car_type = sd.dict_id
    where sc.is_use=1
        and sc.car_id=#{carId}
  </select>
  <update id="carDel" parameterType="java.lang.String">
    update sys_car set
    is_use=2
    where car_id=#{carId}
  </update>
  <update id="carUpdate" >
    update sys_car
    <set>
      <if test="carBrand != null">
        car_brand = #{carBrand,jdbcType=VARCHAR},
      </if>
      <if test="carType != null">
        car_type = #{carType,jdbcType=VARCHAR},
      </if>
      <if test="carDriver != null">
        car_driver = #{carDriver,jdbcType=VARCHAR},
      </if>
      <if test="carPhone != null">
        car_phone = #{carPhone,jdbcType=VARCHAR},
      </if>
      <if test="carNotes != null">
        car_notes = #{carNotes,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 car_id = #{carId,jdbcType=VARCHAR}
  </update>
  <select id="carPull" parameterType="java.lang.String" resultType="com.thhy.engineering.modules.biz.car.entity.SysCar">
      SELECT
      sc.car_id AS carId,
      sc.car_brand AS carBrand,
      sc.car_driver AS carDriver,
      sc.car_notes AS carNotes,
      sc.car_phone AS carPhone,
      sd.dict_name AS dictName
      FROM
      sys_car sc
      LEFT JOIN sys_dict sd ON sc.car_type = sd.dict_id
      where sc.is_use=1
      <if test="companyId!=null and companyId!='' ">
        and sc.company_id=#{companyId}
      </if>
  </select>
</mapper>