find isCommission

This commit is contained in:
kittapath 2025-02-18 10:34:31 +07:00
parent e1e400a24a
commit 54c847cdd6

View file

@ -8024,4 +8024,50 @@ export class OrganizationController extends Controller {
}
return data;
}
/**
* API 1
*
* @summary - 1 (ADMIN)
*
*/
@Get("find/head/officer")
async findIsHeadOfficer(@Request() request: RequestWithUser) {
const posMaster = await this.posMasterRepository.find({
where: {
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
orgRoot: { isCommission: true },
},
order: { posMasterOrder: "ASC", posMasterActChilds: { posMasterOrder: "ASC" } },
relations: [
"current_holder",
"posMasterActChilds",
"posMasterActChilds.posMasterChild",
"posMasterActChilds.posMasterChild.current_holder",
],
});
if (posMaster.length <= 0) {
return new HttpSuccess({ name: "", position: "" });
}
if (posMaster[0].current_holder == null) {
if (
posMaster[0].posMasterActChilds.length <= 0 ||
posMaster[0].posMasterActChilds[0].posMasterChild == null ||
posMaster[0].posMasterActChilds[0].posMasterChild.current_holder == null
) {
return new HttpSuccess({
name: "",
position: "",
});
}
return new HttpSuccess({
name: `${posMaster[0].posMasterActChilds[0].posMasterChild.current_holder.prefix}${posMaster[0].posMasterActChilds[0].posMasterChild.current_holder.firstName} ${posMaster[0].posMasterActChilds[0].posMasterChild.current_holder.lastName}`,
position: posMaster[0].posMasterActChilds[0].posMasterChild.current_holder.position,
});
} else {
return new HttpSuccess({
name: `${posMaster[0].current_holder.prefix}${posMaster[0].current_holder.firstName} ${posMaster[0].current_holder.lastName}`,
position: posMaster[0].current_holder.position,
});
}
}
}