liujie
2023-10-15 871efa21e6c95520e9825ae1f2338c9a919fdd5d
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
<?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.stylefeng.guns.modular.system.dao.TPortMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TPort">
        <id column="id" property="id" />
        <result column="name" property="name" />
        <result column="country" property="country" />
        <result column="state" property="state" />
        <result column="city" property="city" />
        <result column="zip_code" property="zipCode" />
        <result column="address" property="address" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="remove" property="remove" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, name, country, state, city, zip_code, address, create_time, update_time, remove
    </sql>
    <select id="getList" resultType="com.stylefeng.guns.modular.system.model.TPortVo">
      select t1.*,t2.name countryName,t2.id countryId,t3.name as stateName,t3.id stateId ,t4.name as cityName,t4.id cityId from t_port t1 left join t_country t2 on(t2.id=t1.country and t2.type =1) left join t_country t3 on (t3.id=t1.state and t3.type =2)
            left join t_country t4 on (t4.id=t1.city and t4.type =3)  where t1.remove=0
        <if test="name!=null and name !=''">
            and t1.name like concat("%",#{name},"%")
        </if>
        <if test="countryName !=null and countryName !=''">
            and (t2.name like concat("%",#{countryName},"%") or t3.name like concat("%",#{countryName},"%") or t4.name like concat("%",#{countryName},"%"))
        </if>
        <if test="zipCode !=null and zipCode !=''">
            and t1.zipCode like concat("%",#{zipCode},"%")
        </if>
    </select>
 
</mapper>