no message
This commit is contained in:
parent
ade79873ed
commit
0b4e597a81
3 changed files with 61 additions and 36 deletions
|
|
@ -24,6 +24,7 @@ import { Profile } from "../entities/Profile";
|
|||
import HttpStatus from "../interfaces/http-status";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { Brackets } from "typeorm";
|
||||
|
||||
@Route("api/v1/org/permission-org")
|
||||
@Tags("PermissionOrg")
|
||||
|
|
@ -77,6 +78,10 @@ export class PermissionOrgController extends Controller {
|
|||
})
|
||||
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||
.getMany();
|
||||
data.map((x) => ({
|
||||
...x,
|
||||
labelName: `${x.orgRootName} ${x.orgRootCode} ${x.orgRootShortName}`,
|
||||
}));
|
||||
return new HttpSuccess(data);
|
||||
}
|
||||
|
||||
|
|
@ -118,6 +123,14 @@ export class PermissionOrgController extends Controller {
|
|||
IFNULL(current_holders.posMasterNo , '')
|
||||
) LIKE :keyword`;
|
||||
}
|
||||
const findRevision = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
// console.log(findRevision.id);
|
||||
|
||||
const [record, total] = await this.profileRepository
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
|
|
@ -131,24 +144,24 @@ export class PermissionOrgController extends Controller {
|
|||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||
.andWhere(
|
||||
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
||||
? queryLike
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${searchKeyword}%`,
|
||||
},
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(`current_holders.orgRevisionId = :orgRevisionId`, {
|
||||
orgRevisionId: findRevision.id,
|
||||
}).andWhere(
|
||||
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
||||
? queryLike
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${searchKeyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("current_holders.posMasterNo", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const findRevision = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const shortName =
|
||||
|
|
@ -299,6 +312,12 @@ export class PermissionOrgController extends Controller {
|
|||
IFNULL(current_holders.posMasterNo , '')
|
||||
) LIKE :keyword`;
|
||||
}
|
||||
const findRevision = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const [record, total] = await this.permissionOrgRepository
|
||||
.createQueryBuilder("permissionOrg")
|
||||
.leftJoinAndSelect("permissionOrg.orgRootTree", "orgRootTree")
|
||||
|
|
@ -325,17 +344,14 @@ export class PermissionOrgController extends Controller {
|
|||
keyword: `%${requestBody.searchKeyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(`current_holders.orgRevisionId LIKE :orgRevisionId`, {
|
||||
orgRevisionId: findRevision.id,
|
||||
})
|
||||
.orderBy("current_holders.posMasterNo", "ASC")
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const findRevision = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const shortName =
|
||||
|
|
|
|||
|
|
@ -3760,6 +3760,12 @@ export class ProfileController extends Controller {
|
|||
nodeCondition = "current_holders.orgChild4Id = :nodeId";
|
||||
}
|
||||
nodeCondition = nodeCondition + nodeAll;
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const [record, total] = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
|
|
@ -3811,17 +3817,14 @@ export class ProfileController extends Controller {
|
|||
.andWhere(nodeCondition, {
|
||||
nodeId: nodeId,
|
||||
})
|
||||
.andWhere(`current_holders.orgRevisionId LIKE :orgRevisionId`, {
|
||||
orgRevisionId: findRevision.id,
|
||||
})
|
||||
.orderBy("current_holders.posMasterNo", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const posExecutive =
|
||||
|
|
@ -4114,6 +4117,12 @@ export class ProfileController extends Controller {
|
|||
nodeCondition = "current_holders.orgChild4Id = :nodeId";
|
||||
}
|
||||
nodeCondition = nodeCondition + nodeAll;
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const [record, total] = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
|
|
@ -4215,17 +4224,14 @@ export class ProfileController extends Controller {
|
|||
.andWhere(nodeCondition, {
|
||||
nodeId: nodeId,
|
||||
})
|
||||
.andWhere(`current_holders.orgRevisionId LIKE :orgRevisionId`, {
|
||||
orgRevisionId: findRevision.id,
|
||||
})
|
||||
.orderBy("current_holders.posMasterNo", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const posExecutive =
|
||||
|
|
|
|||
|
|
@ -1420,6 +1420,12 @@ export class ProfileEmployeeController extends Controller {
|
|||
nodeCondition = "current_holders.orgChild4Id = :nodeId";
|
||||
}
|
||||
nodeCondition = nodeCondition + nodeAll;
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const [record, total] = await this.profileRepo
|
||||
.createQueryBuilder("profileEmployee")
|
||||
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
||||
|
|
@ -1524,16 +1530,13 @@ export class ProfileEmployeeController extends Controller {
|
|||
.andWhere(nodeCondition, {
|
||||
nodeId: nodeId,
|
||||
})
|
||||
.andWhere(`current_holders.orgRevisionId LIKE :orgRevisionId`, {
|
||||
orgRevisionId: findRevision.id,
|
||||
})
|
||||
.orderBy("current_holders.posMasterNo", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const shortName =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue