编程随笔 编程随笔
  • 前端
  • 后端
  • 星球项目
  • 开源项目
  • 海康AGV
  • 四向车
  • 工具类
  • 项目仓库

    • 部署仓库 (opens new window)
    • 代码仓库 (opens new window)
  • vuepress插件

    • 自动生成导航栏与侧边栏 (opens new window)
    • 评论系统 (opens new window)
    • 全文搜索 (opens new window)
    • 选项卡 (opens new window)
    • 自动生成sitemap (opens new window)
  • 自主开发插件

    • 批量操作frontmatter (opens new window)
    • 链接美化 (opens new window)
    • 折叠代码块 (opens new window)
    • 复制代码块 (opens new window)

liyao52033

走运时,要想到倒霉,不要得意得过了头;倒霉时,要想到走运,不必垂头丧气。心态始终保持平衡,情绪始终保持稳定,此亦长寿之道
  • 前端
  • 后端
  • 星球项目
  • 开源项目
  • 海康AGV
  • 四向车
  • 工具类
  • 项目仓库

    • 部署仓库 (opens new window)
    • 代码仓库 (opens new window)
  • vuepress插件

    • 自动生成导航栏与侧边栏 (opens new window)
    • 评论系统 (opens new window)
    • 全文搜索 (opens new window)
    • 选项卡 (opens new window)
    • 自动生成sitemap (opens new window)
  • 自主开发插件

    • 批量操作frontmatter (opens new window)
    • 链接美化 (opens new window)
    • 折叠代码块 (opens new window)
    • 复制代码块 (opens new window)
  • 知识点

  • 代码调试

  • vue2

  • vue3

    • 注意事项
    • swagger自动生成接口
    • 动态路由
    • 整合 Element Plus
    • wangeditor使用
    • monacoEditor使用
    • 自定义404页面
    • 验证码封装
    • 联表查询SQL
    • element-plus多文件手动上传
  • react

  • typescript

  • 前端
  • vue3
华总
2023-08-24
0
0

联表查询SQL原创

<!-- 用户分页列表 -->
    <select id="getUserPage" resultType="com.youlai.system.model.bo.UserBO">
        SELECT
            u.id,
            u.username,
            u.nickname,
            u.mobile,
            u.gender,
            u.avatar,
            u.STATUS,
            d.NAME AS dept_name,
            GROUP_CONCAT( r.NAME ) AS roleNames,
            u.create_time
        FROM
            sys_user u
                LEFT JOIN sys_dept d ON u.dept_id = d.id
                LEFT JOIN sys_user_role sur ON u.id = sur.user_id
                LEFT JOIN sys_role r ON sur.role_id = r.id
        <where>
            u.deleted = 0 AND u.username != 'root'
            <if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
                AND (
                    u.username LIKE CONCAT('%',#{queryParams.keywords},'%')
                    OR u.nickname LIKE CONCAT('%',#{queryParams.keywords},'%')
                    OR u.mobile LIKE CONCAT('%',#{queryParams.keywords},'%')
                    )
            </if>
            <if test='queryParams.status!=null'>
                AND u.status = #{queryParams.status}
            </if>
            <if test='queryParams.deptId!=null'>
                AND concat(',',concat(d.tree_path,',',d.id),',') like concat('%,',#{queryParams.deptId},',%')
            </if>
        </where>
        GROUP BY u.id
    </select>
                                                                             
                                                                             
 <!-- 获取路由列表 -->
    <select id="listRoutes" resultMap="RouteMap">
        SELECT
           t1.id,
           t1.name,
           t1.parentId,
           t1.path,
           t1.component,
           t1.icon,
           t1.sort,
           t1.visible,
           t1.redirect,
           t1.type,
           t3.code
        FROM
            sys_menu t1
                 LEFT JOIN sys_role_menu t2 ON t1.id = t2.menuId
                 LEFT JOIN sys_role t3 ON t2.roleId = t3.id
        WHERE
            t1.type != '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'
        ORDER BY t1.sort asc
    </select>

    <!-- 获取角色拥有的权限集合 -->
    <select id="listRolePerms" resultType="java.lang.String">
        SELECT
            DISTINCT t1.perm
        FROM
            sys_menu t1
                INNER JOIN sys_role_menu t2 ON t1.id = t2.menuId
                INNER JOIN sys_role t3 ON t3.id = t2.roleId
        WHERE
            t1.type = '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'
          AND t1.perm IS NOT NULL
          <choose>
            <when test="roles!=null and roles.size()>0">
                AND t3.CODE IN
                <foreach collection="roles" item="role" separator="," open="(" close=")">
                    #{role}
                </foreach>
            </when>
            <otherwise>
                AND t1.id = -1
            </otherwise>
          </choose>
    </select>
                                                                             
<!-- 获取角色拥有的菜单ID集合 -->
    <select id="listMenuIdsByRoleId" resultType="java.lang.Long">
        SELECT
            rm.menuId
        FROM
            sys_role_menu rm
                INNER JOIN sys_menu m ON rm.menuId = m.id
        WHERE
            rm.roleId = #{roleId}
    </select>
                                                                             
    <!-- 获取用户导出列表 -->
    <select id="listExportUsers" resultType="com.youlai.system.model.vo.UserExportVO">
        SELECT
            u.username,
            u.nickname,
            u.mobile,
            CASE u.gender
                WHEN 1 THEN '男'
                WHEN 2 THEN '女'
                ELSE '未知'
            END gender,
            d.NAME AS dept_name,
            u.createTime
        FROM
            sys_user u
                LEFT JOIN sys_dept d ON u.deptId = d.id
        <where>
            u.isDelete = 0 AND u.username != 'root'
            <if test='keywords!=null and keywords.trim() neq ""'>
                AND (u.username LIKE CONCAT('%',#{keywords},'%')
                OR u.nickname LIKE CONCAT('%',#{keywords},'%')
                OR u.mobile LIKE CONCAT('%',#{keywords},'%'))
            </if>
            <if test='status!=null'>
                AND u.status = #{status}
            </if>
            <if test='deptId!=null'>
                AND concat(',',concat(d.tree_path,',',d.id),',') like concat('%,',#{deptId},',%')
            </if>
        </where>
        GROUP BY u.id
    </select>

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
#前端
上次更新: 2024/01/14 16:27:31
验证码封装
element-plus多文件手动上传

← 验证码封装 element-plus多文件手动上传→

最近更新
01
element-plus多文件手动上传 原创
11-03
02
TrueLicense 创建及安装证书 原创
10-25
03
手动修改迅捷配置 原创
09-03
04
安装 acme.sh 原创
08-29
05
zabbix部署 原创
08-20
更多文章>
Copyright © 2023-2024 liyao52033
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式