jinlin
2025-03-01 86f02fee03614fef275c6e0c355d73318ca3025e
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
<?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.example.server.major.dao.SysMajorDao">
 
 
    <select id="page" resultType="com.example.server.major.model.SysMajor">
        select
        a.id,
        a.product_id,
        p.name AS modelName
        from DJ_SYS_MAJOR a
        left join  view_zt_boat_tree p ON   p.product_id=concat(a.product_id)
        where a.is_delete = 0
        GROUP BY modelName
        order by p.sort, a.sort asc
<!--        select a.id,-->
<!--               a.product_id,-->
<!--               a.name,-->
<!--               a.short_name,-->
<!--               a.comment,-->
<!--               a.sort,-->
<!--               p.name AS modelName-->
<!--        from DJ_SYS_MAJOR a-->
<!--                 left join  view_zt_boat_tree p ON   p.product_id=concat(a.product_id)-->
<!--        where a.is_delete = 0-->
<!--        order by p.sort, a.sort asc-->
    </select>
    <select id="selectMaxSort" resultType="java.lang.Integer">
        select CASE WHEN max(sort) IS NULL THEN 0 ELSE max(sort) end AS aa
        from DJ_SYS_MAJOR
        where is_delete = 0
    </select>
    <select id="exitsSameMajorByProductId" resultType="java.lang.Integer">
        SELECT count(1)
        FROM DJ_SYS_MAJOR a
        WHERE #{name} IN (
            SELECT b.name
            FROM DJ_SYS_MAJOR b
            WHERE b.product_id = #{productId}
            <if test=" id != null">
                and  b.id != #{id}
            </if>
            )
          AND a.product_id = #{productId}  and a.is_delete=0
    </select>
    <select id="getList" resultType="com.example.server.major.model.SysMajor">
        select a.id,
        a.product_id,
        a.name,
        a.comment,
        a.sort
        from dj_sys_major a
        where a.is_delete = 0
        <if test=" modelId != null and modelId != '' ">
            and  a.product_id = #{modelId}
        </if>
        <if test=" shipId != null and shipId != ''">
            and  a.product_id in (select CONNECT_ID from zt_boat_tree where INFO_ID = #{shipId})
        </if>
        <if test=" projectId != null and projectId != ''">
            and  a.product_id in (select CONNECT_ID from zt_boat_tree where INFO_ID in (select product_id from dj_wx_project where id=#{projectId})
            or INFO_ID in (select product_id from dj_bz_project where id=#{projectId}))
        </if>
        order by a.product_id,a.sort asc
    </select>
 
    <select id="sysMajorChildren" resultType="com.example.server.major.model.SysMajor">
        select a.id,
               a.name,
               a.short_name,
               a.comment,
               a.sort
        from DJ_SYS_MAJOR a
        where a.is_delete = 0
        <if test="productId != null">
            and a.product_id = #{productId}
        </if>
            order by a.sort asc
    </select>
 
    <select id="getIdByMajorName" resultType="java.lang.Long">
          select
          a.id
        from DJ_SYS_MAJOR a
        where a.is_delete = 0
        and code is not null
        and name = #{majorName}
        limit 1
    </select>
 
    <select id="isMajorNameExistsSysh" resultType="java.lang.Integer">
        SELECT count(1)
        FROM DJ_SYS_MAJOR a
        WHERE a.product_id=10000 and a.is_delete=0
        AND a.name=#{name}
    </select>
 
    <select id="getMajorByNameSysh" resultType="com.example.server.major.model.SysMajor">
        select a.*
        from dj_sys_major a
        where a.product_id=10000 and a.is_delete=0
        AND a.name=#{name}
        limit 1
    </select>
 
    <select id="getSyshMajorSelect" resultType="com.example.server.major.model.SysMajor">
        select a.id,a.name
        from dj_sys_major a
        where a.product_id=10000 and a.is_delete=0
    </select>
</mapper>