|
@@ -42,33 +42,45 @@ export function get(json: IRequest, params: IMethodParams, cachedData: ICachedDa
|
|
|
let data: IData = <IData>json.data;
|
|
|
if (data.domain_id !== undefined)
|
|
|
await domainGuard(json, cachedData);
|
|
|
- let count_sql = `select count(distinct staff.id)
|
|
|
- from ${AcsUserInfo.table_name} staff, ${AcsDomain.table_name} domain, ${AcsUserDomain.table_name} user_domain `;
|
|
|
+ let count_sql = `
|
|
|
+ select count(distinct staff.id)
|
|
|
+ from ${AcsUserInfo.table_name} staff, ${AcsUserDomain.table_name} user_domain, ${AcsDomain.table_name} domain
|
|
|
+ where staff.id = user_domain.user_id and user_domain.domain_id = domain.id and domain.path <@ '1.3.1000'
|
|
|
+ `;
|
|
|
let select_sql = `
|
|
|
- select
|
|
|
- distinct staff.id, staff.name, staff.mobile, staff.email, staff.status,
|
|
|
- staff.mobile, staff.email, role.id as role_id, role.name as role_name,
|
|
|
- COALESCE(staff.ext_info->'full_range', 'false')::boolean as full_range,
|
|
|
- COALESCE(staff.ext_info->'level', '0')::integer as level,
|
|
|
- domain.id as domain_id, domain.name as domain_name,
|
|
|
- TO_CHAR(staff.reg_time, 'yyyy-MM-dd HH24' || ':' || 'MI' || ':' || 'ss') as reg_time,
|
|
|
- TO_CHAR(staff.act_time, 'yyyy-MM-dd HH24' || ':' || 'MI' || ':' || 'ss') as act_time
|
|
|
- from ${AcsUserInfo.table_name} staff, ${AcsDomain.table_name} domain, ${AcsUserDomain.table_name} user_domain,
|
|
|
- ${AcsUserRole.table_name} user_role, ${AcsRole.table_name} role
|
|
|
+ select distinct staff.id,
|
|
|
+ staff.name,
|
|
|
+ staff.mobile,
|
|
|
+ staff.email,
|
|
|
+ staff.status,
|
|
|
+ COALESCE(staff.ext_info -> 'full_range', 'false')::boolean as full_range,
|
|
|
+ COALESCE(staff.ext_info -> 'level', '0')::integer as level,
|
|
|
+ TO_CHAR(staff.reg_time, 'yyyy-MM-dd HH24' || ':' || 'MI' || ':' || 'ss') as reg_time,
|
|
|
+ TO_CHAR(staff.act_time, 'yyyy-MM-dd HH24' || ':' || 'MI' || ':' || 'ss') as act_time,
|
|
|
+ array_agg(distinct domain.id) as domain_id,
|
|
|
+ substring(array_agg(distinct domain.name)::text from 2 for char_length(array_agg(distinct domain.name)::text)-2) as domain_name,
|
|
|
+ array_agg(distinct role_id) as role_id,
|
|
|
+ substring(array_agg(distinct role.name)::text from 2 for char_length(array_agg(distinct role.name)::text)-2) as role_name
|
|
|
+ from ${AcsUserInfo.table_name} staff
|
|
|
+ left join tb_acs_user_domain user_domain on staff.id = user_domain.user_id
|
|
|
+ left join tb_acs_domain domain on user_domain.domain_id = domain.id
|
|
|
+ left join tb_acs_user_role user_role on staff.id = user_role.user_id
|
|
|
+ left join tb_acs_role role on user_role.role_id = role.id
|
|
|
+ where domain.path <@ '1.3.1000'
|
|
|
`;
|
|
|
- let conditions = ` where staff.id = user_domain.user_id and user_role.user_id = staff.id and user_role.role_id = role.id and
|
|
|
- domain.id = user_domain.domain_id and domain.path <@ '1.3.1000' `
|
|
|
- let replacements: ISQLReplacements = {
|
|
|
-
|
|
|
- };
|
|
|
- if (data.domain_id === undefined) {
|
|
|
- conditions += ` and domain.path <@ array (
|
|
|
- select path from ${AcsDomain.table_name} domain, ${AcsUserDomain.table_name} user_domain
|
|
|
- where user_domain.user_id = :manager and user_domain.domain_id = domain.id
|
|
|
- )`;
|
|
|
- replacements.manager = cachedData.user_id;
|
|
|
- } else {
|
|
|
-
|
|
|
+ let conditions = ` `;
|
|
|
+ let replacements: ISQLReplacements = {};
|
|
|
+ // if (data.domain_id === undefined) {
|
|
|
+ // conditions += ` and domain.path <@ array (
|
|
|
+ // select path from ${AcsDomain.table_name} domain, ${AcsUserDomain.table_name} user_domain
|
|
|
+ // where user_domain.user_id = :user_id and user_domain.domain_id = domain.id
|
|
|
+ // )`;
|
|
|
+ // replacements.user_id = cachedData.user_id;
|
|
|
+ // } else
|
|
|
+ if (data.domain_id !== undefined)
|
|
|
+ {
|
|
|
+ conditions += ` and domain.path <@ (select path from ${AcsDomain.table_name} domain where domain.id = :domain_id) `;
|
|
|
+ replacements.domain_id = data.domain_id;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -84,6 +96,17 @@ export function get(json: IRequest, params: IMethodParams, cachedData: ICachedDa
|
|
|
|
|
|
count_sql += conditions;
|
|
|
select_sql += conditions;
|
|
|
+ select_sql += `
|
|
|
+ group by staff.id,
|
|
|
+ staff.name,
|
|
|
+ staff.mobile,
|
|
|
+ staff.email,
|
|
|
+ staff.status,
|
|
|
+ full_range,
|
|
|
+ level,
|
|
|
+ reg_time,
|
|
|
+ act_time
|
|
|
+ `
|
|
|
select_sql += ` order by name desc `;
|
|
|
let result = await DataCURD.get_page_list({
|
|
|
sequelize: BizCustomer.sequelize!,
|