select app.APPListID, app.APPName, app.xorder, app.ReportToAPPListID, appb.APPName as…
- User
select app.APPListID, app.APPName, app.xorder, app.ReportToAPPListID, appb.APPName as ReportToAPPListName, app.APIaddress, app.TokenType, app.define1, app.define2, app.isRoleManage, app.isdisabled, app.IconName, app.BadgeOrAD, case when app.IsNoTitleNav =0 then 'false' else 'true' end as IsNoTitleNav, app.IsNoAppLog, case when EXISTS(SELECT 0 FROM ZM_AppFolderUser a where a.UserBadge=N'614802' and a.AppListId=app.AppListId ) then 'icon-jianhaob' else 'icon-jiahao2' end as IsNoUserlike from zm_APPFolder app(nolock) left join zm_APPFolder appb on app.ReportToAPPListID=appb.APPListID left join ZM_Language la(nolock) on la.System='Mobile' and la.Module='ZM_AppList' and la.[Page]=N'AppName' and la.Field = app.AppName left join ZM_Language ls(nolock) on ls.System='Mobile' and ls.Module='ZM_AppList' and ls.[Page]=N'System' and ls.Field = appb.AppName where isnull(app.isdisabled,0)=0 and isnull(appb.isdisabled,0)=0
and app.ListGrade=N'二级' and ( isnull(app.isRoleManage,'no') ='no' ---是否该目录有权限管控,=NO 指的全员开放 or ( isnull(app.isRoleManage,'no') ='yes' ---识别有权限的目录,然后结合三种管控方式进行识别是否具备权限 and exists ( Select 1 from ZM_APPFolderRole(nolock) where RoleType=N'User' and RoleValue=N'614802' and isnull(isdisabled,0)=0 and app.ApplistID=ZM_APPFolderRole.ApplistID union Select 1 from ZM_APPFolderRole(nolock) where RoleType=N'Group' and ( exists (Select GroupID from zm_APPRoleGroup(nolock) where GroupID in ( Select GroupID from zm_APPUserGroup_Member(nolock) where badge=N'614802' and isnull(isdisabled,0)=0 ) and isnull(isdisabled,0)=0 and zm_APPRoleGroup.GroupID=ZM_APPFolderRole.RoleValue ) or exists (Select GroupID from zm_APPRoleGroup(nolock) where GroupID in ( Select GroupID from zm_APPUserGroup_Member(nolock) where badge in ( select JobID from eEmployee (nolock) where badge=N'''+@Badge+''' union select JobID from etPartOrg_All (nolock) where badge=N'''+@Badge+''' ) and isnull(isdisabled,0)=0 ) and isnull(isdisabled,0)=0 and zm_APPRoleGroup.GroupID=ZM_APPFolderRole.RoleValue ) ) and isnull(isdisabled,0)=0 and app.ApplistID=ZM_APPFolderRole.ApplistID union Select 1 from ZM_APPFolderRole X(nolock),eemployee Y (nolock) where X.RoleType=N'Org' and (X.RoleValue = Y.COMPID OR X.RoleValue=Y.DEPID2 OR X.RoleValue=Y.DEPID3 OR X.RoleValue=Y.DEPID4) AND Y.BADGE = N'614802' and Y.STATUS <> N'离职' and isnull(isdisabled,0)=0 and app.ApplistID=X.ApplistIDcode) ) ) order by appb.xorder,app.xorder - Assistant
This query retrieves data from the zm_APPFolder table and joins it with the zm_APPFolder table again (aliased as appb) and the ZM_Language table twice (aliased as la and ls). It returns the following columns:
- app.APPListID
- app.APPName
- app.xorder
- app.ReportToAPPListID
- appb.APPName as ReportToAPPListName
- app.APIaddress
- app.TokenType
- app.define1
- app.define2
- app.isRoleManage
- app.isdisabled
- app.IconName
- app.BadgeOrAD
- IsNoTitleNav: This column is generated based on the value of app.IsNoTitleNav. If it is 0, the value is 'false'. Otherwise, it is 'true'.
- app.IsNoAppLog
- IsNoUserlike: This column is generated with a case statement. If a row exists in the ZM_AppFolderUser table where UserBadge = '614802' and AppListId = app.AppListId, the value is 'icon-jianhaob'. Otherwise, it is 'icon-jiahao2'.
The query also includes several conditions in the WHERE clause to filter the results based on certain criteria.
The results are then ordered by appb.xorder and app.xorder.
- User
中文
- Assistant
该查询从zm_APPFolder表中检索数据,并将其与zm_APPFolder表(别名为appb)和ZM_Language表(两次别名为la和ls)进行关联。它返回以下列:
- app.APPListID:应用列表ID
- app.APPName:应用名称
- app.xorder:排序顺序
- app.ReportToAPPListID:上级应用列表ID
- appb.APPName as ReportToAPPListName:上级应用名称
- app.APIaddress:API地址
- app.TokenType:令牌类型
- app.define1:自定义1
- app.define2:自定义2
- app.isRoleManage:是否有角色管理权限
- app.isdisabled:是否禁用
- app.IconName:图标名称
- app.BadgeOrAD:Badge或AD
- IsNoTitleNav:该列根据app.IsNoTitleNav的值生成。如果值为0,则为'false'。否则为'true'。
- app.IsNoAppLog:是否无应用日志
- IsNoUserlike:该列使用case语句生成。如果在ZM_AppFolderUser表中存在满足条件UserBadge = '614802'和AppListId = app.AppListId的记录,则值为'icon-jianhaob'。否则为'icon-jiahao2'。
查询中还包含一些条件,以便根据特定条件过滤结果。
最后,根据appb.xorder和app.xorder对结果进行排序。
- User
优化一下这个sql
- Assistant