Skip to content

Commit b9304f0

Browse files
committed
refactor: improve SQL queries to include user nicknames and enhance readability
1 parent 13c5833 commit b9304f0

File tree

4 files changed

+71
-65
lines changed

4 files changed

+71
-65
lines changed
Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
select *
2-
from (select "id"::text,
3-
"name",
4-
"desc",
5-
"is_publish",
6-
"type",
2+
from (select application."id"::text,
3+
application."name",
4+
application. "desc",
5+
application. "is_publish",
6+
application."type",
77
'application' as "resource_type",
8-
"workspace_id",
9-
"folder_id",
10-
"user_id",
11-
"create_time",
12-
"update_time"
13-
from application
8+
application."workspace_id",
9+
application. "folder_id",
10+
application."user_id",
11+
"user"."nick_name" as "nick_name",
12+
application."create_time",
13+
application."update_time"
14+
from application left join "user" on user_id = "user".id
1415
${application_custom_sql}
1516
UNION
16-
select "id",
17-
"name",
18-
"desc",
19-
true as "is_publish",
17+
select application_folder."id",
18+
application_folder."name",
19+
application_folder."desc",
20+
true as "is_publish",
2021
'folder' as "type",
2122
'folder' as "resource_type",
22-
"workspace_id",
23-
"parent_id" as "folder_id",
24-
"user_id",
25-
"create_time",
26-
"update_time"
27-
from application_folder ${folder_query_set}) temp
23+
application_folder."workspace_id",
24+
application_folder."parent_id" as "folder_id",
25+
application_folder."user_id",
26+
"user"."nick_name" as "nick_name",
27+
application_folder."create_time",
28+
application_folder."update_time"
29+
from application_folder left join "user" on user_id = "user".id ${folder_query_set}) temp
2830
${application_query_set}
Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
select *
2-
from (select "id"::text,
3-
"name",
4-
"desc",
5-
"is_publish",
6-
"type",
2+
from (select application."id"::text,
3+
application."name",
4+
application. "desc",
5+
application. "is_publish",
6+
application."type",
77
'application' as "resource_type",
8-
"workspace_id",
9-
"folder_id",
10-
"user_id",
11-
"create_time",
12-
"update_time"
13-
from application
8+
application."workspace_id",
9+
application. "folder_id",
10+
application."user_id",
11+
"user"."nick_name" as "nick_name",
12+
application."create_time",
13+
application."update_time"
14+
from application left join "user" on user_id = "user".id
1415
where id in (select target
1516
from workspace_user_resource_permission
1617
where auth_target_type = 'APPLICATION'
1718
and 'VIEW' = any (permission_list))
1819
UNION
19-
select "id",
20-
"name",
21-
"desc",
22-
true as "is_publish",
20+
select application_folder."id",
21+
application_folder."name",
22+
application_folder."desc",
23+
true as "is_publish",
2324
'folder' as "type",
2425
'folder' as "resource_type",
25-
"workspace_id",
26-
"parent_id" as "folder_id",
27-
"user_id",
28-
"create_time",
29-
"update_time"
30-
from application_folder ${folder_query_set}) temp
26+
application_folder."workspace_id",
27+
application_folder."parent_id" as "folder_id",
28+
application_folder."user_id",
29+
"user"."nick_name" as "nick_name",
30+
application_folder."create_time",
31+
application_folder."update_time"
32+
from application_folder left join "user" on user_id = "user".id ${folder_query_set}) temp
3133
${application_query_set}
Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
select *
2-
from (select "id"::text,
3-
"name",
4-
"desc",
5-
"is_publish",
6-
"type",
2+
from (select application."id"::text,
3+
application."name",
4+
application. "desc",
5+
application. "is_publish",
6+
application."type",
77
'application' as "resource_type",
8-
"workspace_id",
9-
"folder_id",
10-
"user_id",
11-
"create_time",
12-
"update_time"
13-
from application
8+
application."workspace_id",
9+
application. "folder_id",
10+
application."user_id",
11+
"user"."nick_name" as "nick_name",
12+
application."create_time",
13+
application."update_time"
14+
from application left join "user" on user_id = "user".id
1415
where id in (select target
1516
from workspace_user_resource_permission
1617
where auth_target_type = 'APPLICATION'
@@ -24,16 +25,17 @@ from (select "id"::text,
2425
'VIEW' = any (permission_list)
2526
end)
2627
UNION
27-
select "id",
28-
"name",
29-
"desc",
30-
true as "is_publish",
28+
select application_folder."id",
29+
application_folder."name",
30+
application_folder."desc",
31+
true as "is_publish",
3132
'folder' as "type",
3233
'folder' as "resource_type",
33-
"workspace_id",
34-
"parent_id" as "folder_id",
35-
"user_id",
36-
"create_time",
37-
"update_time"
38-
from application_folder ${folder_query_set}) temp
34+
application_folder."workspace_id",
35+
application_folder."parent_id" as "folder_id",
36+
application_folder."user_id",
37+
"user"."nick_name" as "nick_name",
38+
application_folder."create_time",
39+
application_folder."update_time"
40+
from application_folder left join "user" on user_id = "user".id ${folder_query_set}) temp
3941
${application_query_set}

ui/src/views/application/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
</template>
154154
<template #subTitle>
155155
<el-text class="color-secondary lighter" size="small">
156-
{{ $t('common.creator') }}: {{ item.username }}
156+
{{ $t('common.creator') }}: {{ item.nick_name }}
157157
</el-text>
158158
</template>
159159
</CardBox>
@@ -171,7 +171,7 @@
171171
<template #subTitle>
172172
<el-text class="color-secondary" size="small">
173173
<auto-tooltip :content="item.username">
174-
{{ $t('common.creator') }}: {{ item.username }}
174+
{{ $t('common.creator') }}: {{ item.nick_name }}
175175
</auto-tooltip>
176176
</el-text>
177177
</template>

0 commit comments

Comments
 (0)