44323
2024-04-23 16b704d18a875d1fb63827aaa507790ba2bef5be
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
<?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.FindMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.Find">
        <id column="id" property="id" />
        <result column="userId" property="userId" />
        <result column="insertTime" property="insertTime" />
        <result column="likeCount" property="likeCount" />
        <result column="title" property="title" />
        <result column="content" property="content" />
        <result column="img" property="img" />
        <result column="video" property="video" />
        <result column="isTop" property="isTop" />
        <result column="isDelete" property="isDelete" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, userId, insertTime, likeCount, title, content, img, video, isTop, isDelete
    </sql>
    <select id="findList" resultType="com.stylefeng.guns.modular.system.vo.FindVO">
        select t1.*,t2.name,t2.headImg,t2.clockIn
        from t_find t1
        left join t_user t2 on t1.userId = t2.id
        <where>
            <if test="item != null and item != ''">
                AND (t1.title LIKE concat('%',#{item},'%') or
                t2.name LIKE concat('%',#{item},'%'))
            </if>
            and t1.isDelete = 0
        </where>
        order by t1.isTop desc,t1.insertTime desc
    </select>
    <select id="selectFind" resultType="com.stylefeng.guns.modular.system.vo.FindVO">
        SELECT t1.*, t2.name AS userName, t2.phone AS phone
        FROM t_find t1
        LEFT JOIN t_user t2 ON t1.userId = t2.id
        <where>
            t1.isDelete = 0
            <if test="req.userName != null and req.userName != ''">
                AND t2.name LIKE CONCAT('%', #{req.userName}, '%')
            </if>
            <if test="req.phone != null and req.phone != ''">
                AND t2.phone LIKE CONCAT('%', #{req.phone}, '%')
            </if>
            <if test="req.title != null and req.title != ''">
                AND t1.title LIKE CONCAT('%', #{req.title}, '%')
            </if>
            <if test="req.state != null">
                AND t1.state = #{req.state}
            </if>
            <if test="req.isTop != null">
                AND t1.isTop = #{req.isTop}
            </if>
        </where>
        ORDER BY t1.isTop DESC, t1.insertTime DESC
    </select>
</mapper>