remove try catch more
This commit is contained in:
parent
09cc93fdf8
commit
7531a9c582
9 changed files with 477 additions and 680 deletions
|
|
@ -57,7 +57,6 @@ export class OrganizationController extends Controller {
|
|||
*/
|
||||
@Get("history")
|
||||
async GetHistory() {
|
||||
try {
|
||||
const orgRevision = await this.orgRevisionRepository.find({
|
||||
select: [
|
||||
"id",
|
||||
|
|
@ -80,9 +79,7 @@ export class OrganizationController extends Controller {
|
|||
}));
|
||||
|
||||
return new HttpSuccess(mapOrgRevisions);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -93,7 +90,6 @@ export class OrganizationController extends Controller {
|
|||
*/
|
||||
@Get("active")
|
||||
async GetActive() {
|
||||
try {
|
||||
const orgRevisionActive = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
|
|
@ -110,9 +106,7 @@ export class OrganizationController extends Controller {
|
|||
isPublic: orgRevisionDraf == null || orgRevisionDraf.orgRevisionName == null ? false : true,
|
||||
};
|
||||
return new HttpSuccess(mapData);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -126,7 +120,6 @@ export class OrganizationController extends Controller {
|
|||
@Body() requestBody: CreateOrgRevision,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
try {
|
||||
const revision = Object.assign(new OrgRevision(), requestBody) as OrgRevision;
|
||||
revision.orgRevisionIsDraft = true;
|
||||
revision.orgRevisionIsCurrent = false;
|
||||
|
|
@ -587,9 +580,7 @@ export class OrganizationController extends Controller {
|
|||
await this.orgRevisionRepository.remove(_orgRevisions);
|
||||
|
||||
return new HttpSuccess(revision);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -600,7 +591,6 @@ export class OrganizationController extends Controller {
|
|||
*/
|
||||
@Get("{id}")
|
||||
async detail(@Path() id: string) {
|
||||
try {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({ where: { id } });
|
||||
if (!orgRevision) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -1268,9 +1258,7 @@ export class OrganizationController extends Controller {
|
|||
);
|
||||
|
||||
return new HttpSuccess(formattedData);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1296,7 +1284,6 @@ export class OrganizationController extends Controller {
|
|||
if (!orgRevision) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. RevisionId");
|
||||
}
|
||||
try {
|
||||
orgRevision.lastUpdateUserId = request.user.sub;
|
||||
orgRevision.lastUpdateFullName = request.user.name;
|
||||
orgRevision.lastUpdatedAt = new Date();
|
||||
|
|
@ -1304,9 +1291,7 @@ export class OrganizationController extends Controller {
|
|||
this.orgRevisionRepository.merge(orgRevision, requestBody);
|
||||
await this.orgRevisionRepository.save(orgRevision);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1455,7 +1440,6 @@ export class OrganizationController extends Controller {
|
|||
*/
|
||||
@Post("sort")
|
||||
async Sort(@Body() requestBody: { id: string; type: number; sortId: string[] }) {
|
||||
try {
|
||||
switch (requestBody.type) {
|
||||
case 0: {
|
||||
const revisionId = await this.orgRevisionRepository.findOne({
|
||||
|
|
@ -1566,9 +1550,7 @@ export class OrganizationController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found type: " + requestBody.type);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1672,7 +1654,6 @@ export class OrganizationController extends Controller {
|
|||
*/
|
||||
@Get("struct-chart/{idNode}/{type}") //bright
|
||||
async structchart(@Path() idNode: string, type: number) {
|
||||
try {
|
||||
switch (type) {
|
||||
case 0: {
|
||||
const data = await this.orgRevisionRepository.findOne({
|
||||
|
|
@ -2758,9 +2739,7 @@ export class OrganizationController extends Controller {
|
|||
default:
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found type: ");
|
||||
}
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2771,7 +2750,6 @@ export class OrganizationController extends Controller {
|
|||
*/
|
||||
@Post("find/node")
|
||||
async findNodeAll(@Body() requestBody: { node: number; nodeId: string }) {
|
||||
try {
|
||||
switch (requestBody.node) {
|
||||
case 0: {
|
||||
const data = await this.orgRootRepository.findOne({
|
||||
|
|
@ -2827,9 +2805,7 @@ export class OrganizationController extends Controller {
|
|||
default:
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found type: " + requestBody.node);
|
||||
}
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2840,7 +2816,6 @@ export class OrganizationController extends Controller {
|
|||
*/
|
||||
@Get("active/root")
|
||||
async GetActiveRoot() {
|
||||
try {
|
||||
const orgRevisionActive = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
|
|
@ -2859,9 +2834,7 @@ export class OrganizationController extends Controller {
|
|||
],
|
||||
});
|
||||
return new HttpSuccess(data);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2872,7 +2845,6 @@ export class OrganizationController extends Controller {
|
|||
*/
|
||||
@Get("active/root/id")
|
||||
async GetActiveRootId() {
|
||||
try {
|
||||
const orgRevisionActive = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
|
|
@ -2884,9 +2856,7 @@ export class OrganizationController extends Controller {
|
|||
where: { orgRevisionId: orgRevisionActive.id },
|
||||
});
|
||||
return new HttpSuccess(data.map((x) => x.id));
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2897,7 +2867,6 @@ export class OrganizationController extends Controller {
|
|||
*/
|
||||
@Get("active/root/{revisionId}")
|
||||
async GetActiveRootByRevision(@Path() revisionId: string) {
|
||||
try {
|
||||
const data = await this.orgRootRepository.find({
|
||||
where: { orgRevisionId: revisionId },
|
||||
relations: [
|
||||
|
|
@ -2909,9 +2878,7 @@ export class OrganizationController extends Controller {
|
|||
],
|
||||
});
|
||||
return new HttpSuccess(data);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* API หา revision ล่าสุด
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ import { Not } from "typeorm";
|
|||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
|
||||
export class PosTypeController extends Controller {
|
||||
|
||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
|
||||
|
|
@ -45,12 +43,10 @@ export class PosTypeController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Post()
|
||||
@Example(
|
||||
{
|
||||
positionName: "นักบริหาร",
|
||||
posTypeRank: 1,
|
||||
},
|
||||
)
|
||||
@Example({
|
||||
positionName: "นักบริหาร",
|
||||
posTypeRank: 1,
|
||||
})
|
||||
async createType(
|
||||
@Body()
|
||||
requestBody: CreatePosType,
|
||||
|
|
@ -60,22 +56,23 @@ export class PosTypeController extends Controller {
|
|||
if (!posType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
const chkPosTypeName = await this.posTypeRepository.findOne({ where: {
|
||||
posTypeName: requestBody.posTypeName }
|
||||
})
|
||||
if(chkPosTypeName){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อประเภทตำแหน่ง: " + requestBody.posTypeName + " มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
try {
|
||||
posType.createdUserId = request.user.sub;
|
||||
posType.createdFullName = request.user.name;
|
||||
posType.lastUpdateUserId = request.user.sub;
|
||||
posType.lastUpdateFullName = request.user.name;
|
||||
await this.posTypeRepository.save(posType);
|
||||
return new HttpSuccess(posType);
|
||||
} catch (error) {
|
||||
return error;
|
||||
const chkPosTypeName = await this.posTypeRepository.findOne({
|
||||
where: {
|
||||
posTypeName: requestBody.posTypeName,
|
||||
},
|
||||
});
|
||||
if (chkPosTypeName) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ชื่อประเภทตำแหน่ง: " + requestBody.posTypeName + " มีอยู่ในระบบแล้ว",
|
||||
);
|
||||
}
|
||||
posType.createdUserId = request.user.sub;
|
||||
posType.createdFullName = request.user.name;
|
||||
posType.lastUpdateUserId = request.user.sub;
|
||||
posType.lastUpdateFullName = request.user.name;
|
||||
await this.posTypeRepository.save(posType);
|
||||
return new HttpSuccess(posType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -86,12 +83,10 @@ export class PosTypeController extends Controller {
|
|||
* @param {string} id Id ประเภทตำแหน่ง
|
||||
*/
|
||||
@Put("{id}")
|
||||
@Example(
|
||||
{
|
||||
positionName: "นักบริหาร",
|
||||
posTypeRank: 1,
|
||||
},
|
||||
)
|
||||
@Example({
|
||||
positionName: "นักบริหาร",
|
||||
posTypeRank: 1,
|
||||
})
|
||||
async editType(
|
||||
@Path() id: string,
|
||||
@Body() requestBody: UpdatePosType,
|
||||
|
|
@ -101,22 +96,23 @@ export class PosTypeController extends Controller {
|
|||
if (!posType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
const chkPosTypeName = await this.posTypeRepository.findOne({ where: {
|
||||
id: Not(id),
|
||||
posTypeName: requestBody.posTypeName }
|
||||
})
|
||||
if(chkPosTypeName){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อประเภทตำแหน่ง: " + requestBody.posTypeName + " มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
try {
|
||||
posType.lastUpdateUserId = request.user.sub;
|
||||
posType.lastUpdateFullName = request.user.name;
|
||||
this.posTypeRepository.merge(posType, requestBody);
|
||||
await this.posTypeRepository.save(posType);
|
||||
return new HttpSuccess(posType.id);
|
||||
} catch (error) {
|
||||
return error;
|
||||
const chkPosTypeName = await this.posTypeRepository.findOne({
|
||||
where: {
|
||||
id: Not(id),
|
||||
posTypeName: requestBody.posTypeName,
|
||||
},
|
||||
});
|
||||
if (chkPosTypeName) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ชื่อประเภทตำแหน่ง: " + requestBody.posTypeName + " มีอยู่ในระบบแล้ว",
|
||||
);
|
||||
}
|
||||
posType.lastUpdateUserId = request.user.sub;
|
||||
posType.lastUpdateFullName = request.user.name;
|
||||
this.posTypeRepository.merge(posType, requestBody);
|
||||
await this.posTypeRepository.save(posType);
|
||||
return new HttpSuccess(posType.id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -133,18 +129,17 @@ export class PosTypeController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
const IdExitsInLevel = await this.posLevelRepository.find({
|
||||
where: { posTypeId: id }
|
||||
})
|
||||
if(IdExitsInLevel.length > 0){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากพบข้อมูลที่ตารางระดับตำแหน่ง",);
|
||||
}
|
||||
|
||||
try {
|
||||
await this.posTypeRepository.remove(delPosType);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
where: { posTypeId: id },
|
||||
});
|
||||
if (IdExitsInLevel.length > 0) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่สามารถลบได้เนื่องจากพบข้อมูลที่ตารางระดับตำแหน่ง",
|
||||
);
|
||||
}
|
||||
|
||||
await this.posTypeRepository.remove(delPosType);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -165,38 +160,34 @@ export class PosTypeController extends Controller {
|
|||
id: "00000000-0000-0000-0000-000000000000",
|
||||
posLevelName: "นักบริหาร",
|
||||
posLevelRank: 1,
|
||||
posLevelAuthority: "HEAD"
|
||||
}
|
||||
]
|
||||
posLevelAuthority: "HEAD",
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
async GetTypeDetail(@Path() id: string) {
|
||||
try {
|
||||
const getPosType = await this.posTypeRepository.findOne({
|
||||
select: ["id", "posTypeName", "posTypeRank"],
|
||||
relations: ["posLevels"],
|
||||
where: { id: id }
|
||||
});
|
||||
if (!getPosType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
|
||||
const mapGetPosType = {
|
||||
id : getPosType.id,
|
||||
posTypeName : getPosType.posTypeName,
|
||||
posTypeRank : getPosType.posTypeRank,
|
||||
posLevels : getPosType.posLevels.map((posLevel) => ({
|
||||
id: posLevel.id,
|
||||
posLevelName: posLevel.posLevelName,
|
||||
posLevelRank: posLevel.posLevelRank,
|
||||
posLevelAuthority: posLevel.posLevelAuthority,
|
||||
})),
|
||||
}
|
||||
|
||||
return new HttpSuccess(mapGetPosType);
|
||||
} catch (error) {
|
||||
return error;
|
||||
const getPosType = await this.posTypeRepository.findOne({
|
||||
select: ["id", "posTypeName", "posTypeRank"],
|
||||
relations: ["posLevels"],
|
||||
where: { id: id },
|
||||
});
|
||||
if (!getPosType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
|
||||
const mapGetPosType = {
|
||||
id: getPosType.id,
|
||||
posTypeName: getPosType.posTypeName,
|
||||
posTypeRank: getPosType.posTypeRank,
|
||||
posLevels: getPosType.posLevels.map((posLevel) => ({
|
||||
id: posLevel.id,
|
||||
posLevelName: posLevel.posLevelName,
|
||||
posLevelRank: posLevel.posLevelRank,
|
||||
posLevelAuthority: posLevel.posLevelAuthority,
|
||||
})),
|
||||
};
|
||||
|
||||
return new HttpSuccess(mapGetPosType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -222,28 +213,24 @@ export class PosTypeController extends Controller {
|
|||
},
|
||||
])
|
||||
async GetPosType() {
|
||||
try {
|
||||
const posType = await this.posTypeRepository.find({
|
||||
select: ["id", "posTypeName", "posTypeRank"],
|
||||
relations: ["posLevels"],
|
||||
});
|
||||
if (!posType) {
|
||||
return new HttpSuccess([]);
|
||||
}
|
||||
const mapPosType = posType.map((item) => ({
|
||||
id: item.id,
|
||||
posTypeName: item.posTypeName,
|
||||
posTypeRank: item.posTypeRank,
|
||||
posLevels: item.posLevels.map((posLevel) => ({
|
||||
id: posLevel.id,
|
||||
posLevelName: posLevel.posLevelName,
|
||||
posLevelRank: posLevel.posLevelRank,
|
||||
posLevelAuthority: posLevel.posLevelAuthority,
|
||||
})),
|
||||
}));
|
||||
return new HttpSuccess(mapPosType);
|
||||
} catch (error) {
|
||||
return error;
|
||||
const posType = await this.posTypeRepository.find({
|
||||
select: ["id", "posTypeName", "posTypeRank"],
|
||||
relations: ["posLevels"],
|
||||
});
|
||||
if (!posType) {
|
||||
return new HttpSuccess([]);
|
||||
}
|
||||
const mapPosType = posType.map((item) => ({
|
||||
id: item.id,
|
||||
posTypeName: item.posTypeName,
|
||||
posTypeRank: item.posTypeRank,
|
||||
posLevels: item.posLevels.map((posLevel) => ({
|
||||
id: posLevel.id,
|
||||
posLevelName: posLevel.posLevelName,
|
||||
posLevelRank: posLevel.posLevelRank,
|
||||
posLevelAuthority: posLevel.posLevelAuthority,
|
||||
})),
|
||||
}));
|
||||
return new HttpSuccess(mapPosType);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,11 +46,7 @@ export class PrefixController extends Controller {
|
|||
if (!_prefix) {
|
||||
return new HttpSuccess([]);
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(_prefix);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(_prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -69,11 +65,7 @@ export class PrefixController extends Controller {
|
|||
if (!_prefix) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(_prefix);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(_prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -101,16 +93,12 @@ export class PrefixController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
try {
|
||||
_prefix.createdUserId = request.user.sub;
|
||||
_prefix.createdFullName = request.user.name;
|
||||
_prefix.lastUpdateUserId = request.user.sub;
|
||||
_prefix.lastUpdateFullName = request.user.name;
|
||||
await this.prefixRepository.save(_prefix);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
_prefix.createdUserId = request.user.sub;
|
||||
_prefix.createdFullName = request.user.name;
|
||||
_prefix.lastUpdateUserId = request.user.sub;
|
||||
_prefix.lastUpdateFullName = request.user.name;
|
||||
await this.prefixRepository.save(_prefix);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -138,15 +126,11 @@ export class PrefixController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
try {
|
||||
_prefix.lastUpdateUserId = request.user.sub;
|
||||
_prefix.lastUpdateFullName = request.user.name;
|
||||
this.prefixRepository.merge(_prefix, requestBody);
|
||||
await this.prefixRepository.save(_prefix);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
_prefix.lastUpdateUserId = request.user.sub;
|
||||
_prefix.lastUpdateFullName = request.user.name;
|
||||
this.prefixRepository.merge(_prefix, requestBody);
|
||||
await this.prefixRepository.save(_prefix);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -164,11 +148,7 @@ export class PrefixController extends Controller {
|
|||
if (!_delPrefix) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำนำหน้าชื่อนี้");
|
||||
}
|
||||
try {
|
||||
await this.prefixRepository.delete(_delPrefix.id);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
await this.prefixRepository.delete(_delPrefix.id);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,10 +67,7 @@ export class ProfileController extends Controller {
|
|||
where: { id: requestBody.posLevelId },
|
||||
});
|
||||
if (!checkPosLevel) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลระดับตำแหน่งนี้"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่งนี้");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,10 +79,7 @@ export class ProfileController extends Controller {
|
|||
where: { id: requestBody.posTypeId },
|
||||
});
|
||||
if (!checkPosType) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลประเภทตำแหน่งนี้"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,17 +94,13 @@ export class ProfileController extends Controller {
|
|||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const profile = Object.assign(new Profile(), requestBody);
|
||||
profile.createdUserId = request.user.sub;
|
||||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
await this.profileRepository.save(profile);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
const profile = Object.assign(new Profile(), requestBody);
|
||||
profile.createdUserId = request.user.sub;
|
||||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
await this.profileRepository.save(profile);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -147,10 +137,7 @@ export class ProfileController extends Controller {
|
|||
where: { id: requestBody.posLevelId },
|
||||
});
|
||||
if (!checkPosLevel) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลระดับตำแหน่งนี้"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่งนี้");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -162,10 +149,7 @@ export class ProfileController extends Controller {
|
|||
where: { id: requestBody.posTypeId },
|
||||
});
|
||||
if (!checkPosType) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลประเภทตำแหน่งนี้"
|
||||
);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -183,15 +167,11 @@ export class ProfileController extends Controller {
|
|||
);
|
||||
}
|
||||
|
||||
try {
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
this.profileRepository.merge(profile, requestBody);
|
||||
await this.profileRepository.save(profile);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
this.profileRepository.merge(profile, requestBody);
|
||||
await this.profileRepository.save(profile);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -209,12 +189,8 @@ export class ProfileController extends Controller {
|
|||
if (!delProfile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
}
|
||||
try {
|
||||
await this.profileRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
await this.profileRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -242,11 +218,7 @@ export class ProfileController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(profile);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(profile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -334,108 +306,104 @@ export class ProfileController extends Controller {
|
|||
keyword?: string;
|
||||
},
|
||||
) {
|
||||
try {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
where: {
|
||||
orgRevisionIsDraft: true,
|
||||
orgRevisionIsCurrent: false,
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
where: {
|
||||
orgRevisionIsDraft: true,
|
||||
orgRevisionIsCurrent: false,
|
||||
},
|
||||
relations: ["posMasters"],
|
||||
});
|
||||
if (!orgRevision) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
|
||||
}
|
||||
const [profiles, total] = await this.profileRepository
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.next_holders", "next_holders")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.where(
|
||||
requestBody.position != null && requestBody.position != ""
|
||||
? "profile.position LIKE :position"
|
||||
: "1=1",
|
||||
{
|
||||
position: `%${requestBody.position}%`,
|
||||
},
|
||||
relations: ["posMasters"],
|
||||
});
|
||||
if (!orgRevision) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
|
||||
}
|
||||
const [profiles, total] = await this.profileRepository
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.next_holders", "next_holders")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.where(
|
||||
requestBody.position != null && requestBody.position != ""
|
||||
? "profile.position LIKE :position"
|
||||
: "1=1",
|
||||
{
|
||||
position: `%${requestBody.position}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profile.prefix LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profile.prefix LIKE :keyword"
|
||||
? "profile.firstName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profile.firstName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profile.lastName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profile.citizenId LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.andWhere(
|
||||
requestBody.posTypeId != null && requestBody.posTypeId != ""
|
||||
? "profile.posTypeId LIKE :posTypeId"
|
||||
: "1=1",
|
||||
{
|
||||
posTypeId: `%${requestBody.posTypeId}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
requestBody.posLevelId != null && requestBody.posLevelId != ""
|
||||
? "profile.posLevelId LIKE :posLevelId"
|
||||
: "1=1",
|
||||
{
|
||||
posLevelId: `%${requestBody.posLevelId}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where("next_holders.id IS NULL").orWhere("next_holders.id NOT IN (:...ids)", {
|
||||
ids: orgRevision.posMasters.map((x) => x.id),
|
||||
});
|
||||
}),
|
||||
)
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profile.lastName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
requestBody.keyword != null && requestBody.keyword != ""
|
||||
? "profile.citizenId LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.andWhere(
|
||||
requestBody.posTypeId != null && requestBody.posTypeId != ""
|
||||
? "profile.posTypeId LIKE :posTypeId"
|
||||
: "1=1",
|
||||
{
|
||||
posTypeId: `%${requestBody.posTypeId}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
requestBody.posLevelId != null && requestBody.posLevelId != ""
|
||||
? "profile.posLevelId LIKE :posLevelId"
|
||||
: "1=1",
|
||||
{
|
||||
posLevelId: `%${requestBody.posLevelId}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where("next_holders.id IS NULL").orWhere("next_holders.id NOT IN (:...ids)", {
|
||||
ids: orgRevision.posMasters.map((x) => x.id),
|
||||
});
|
||||
}),
|
||||
)
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const data = profiles.map((_data) => ({
|
||||
id: _data.id,
|
||||
prefix: _data.prefix,
|
||||
firstName: _data.firstName,
|
||||
lastName: _data.lastName,
|
||||
citizenId: _data.citizenId,
|
||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||
position: _data.position,
|
||||
}));
|
||||
const data = profiles.map((_data) => ({
|
||||
id: _data.id,
|
||||
prefix: _data.prefix,
|
||||
firstName: _data.firstName,
|
||||
lastName: _data.lastName,
|
||||
citizenId: _data.citizenId,
|
||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||
position: _data.position,
|
||||
}));
|
||||
|
||||
return new HttpSuccess({ data: data, total });
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess({ data: data, total });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -547,11 +515,7 @@ export class ProfileController extends Controller {
|
|||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4
|
||||
.orgChild4Name,
|
||||
};
|
||||
try {
|
||||
return new HttpSuccess(_profile);
|
||||
} catch (error: any) {
|
||||
throw new Error(error);
|
||||
}
|
||||
return new HttpSuccess(_profile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -568,56 +532,52 @@ export class ProfileController extends Controller {
|
|||
keyword?: string;
|
||||
},
|
||||
) {
|
||||
try {
|
||||
let findProfile: any;
|
||||
switch (body.fieldName) {
|
||||
case "idcard":
|
||||
findProfile = await this.profileRepository.find({
|
||||
where: { citizenId: Like(`%${body.keyword}%`) },
|
||||
relations: ["posType", "posLevel"],
|
||||
});
|
||||
break;
|
||||
let findProfile: any;
|
||||
switch (body.fieldName) {
|
||||
case "idcard":
|
||||
findProfile = await this.profileRepository.find({
|
||||
where: { citizenId: Like(`%${body.keyword}%`) },
|
||||
relations: ["posType", "posLevel"],
|
||||
});
|
||||
break;
|
||||
|
||||
case "firstname":
|
||||
findProfile = await this.profileRepository.find({
|
||||
where: { firstName: Like(`%${body.keyword}%`) },
|
||||
relations: ["posType", "posLevel"],
|
||||
});
|
||||
break;
|
||||
case "firstname":
|
||||
findProfile = await this.profileRepository.find({
|
||||
where: { firstName: Like(`%${body.keyword}%`) },
|
||||
relations: ["posType", "posLevel"],
|
||||
});
|
||||
break;
|
||||
|
||||
case "lastname":
|
||||
findProfile = await this.profileRepository.find({
|
||||
where: { lastName: Like(`%${body.keyword}%`) },
|
||||
relations: ["posType", "posLevel"],
|
||||
});
|
||||
break;
|
||||
case "lastname":
|
||||
findProfile = await this.profileRepository.find({
|
||||
where: { lastName: Like(`%${body.keyword}%`) },
|
||||
relations: ["posType", "posLevel"],
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
findProfile = await this.profileRepository.find({
|
||||
relations: ["posType", "posLevel"],
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
const mapDataProfile = await Promise.all(
|
||||
findProfile.map(async (item: Profile) => {
|
||||
return {
|
||||
id: item.id,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
position: item.position,
|
||||
idcard: item.citizenId,
|
||||
email: item.email,
|
||||
phone: item.phone,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return new HttpSuccess(mapDataProfile);
|
||||
} catch (error: any) {
|
||||
throw new Error(error);
|
||||
default:
|
||||
findProfile = await this.profileRepository.find({
|
||||
relations: ["posType", "posLevel"],
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
const mapDataProfile = await Promise.all(
|
||||
findProfile.map(async (item: Profile) => {
|
||||
return {
|
||||
id: item.id,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
position: item.position,
|
||||
idcard: item.citizenId,
|
||||
email: item.email,
|
||||
phone: item.phone,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return new HttpSuccess(mapDataProfile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -823,11 +783,7 @@ export class ProfileController extends Controller {
|
|||
if (profile) {
|
||||
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "เลขบัตรนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -845,100 +801,96 @@ export class ProfileController extends Controller {
|
|||
keyword?: string;
|
||||
},
|
||||
) {
|
||||
try {
|
||||
const [findProfile, total] = await AppDataSource.getRepository(Profile)
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
.leftJoinAndSelect("current_holders.orgRevision", "orgRevision")
|
||||
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||
.where("profile.prefix LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("profile.firstName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("profile.lastName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orderBy("profile.citizenId", "ASC")
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
const [findProfile, total] = await AppDataSource.getRepository(Profile)
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
.leftJoinAndSelect("current_holders.orgRevision", "orgRevision")
|
||||
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||
.where("profile.prefix LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("profile.firstName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("profile.lastName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||
.orderBy("profile.citizenId", "ASC")
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const orgRevisionActive = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
const orgRevisionActive = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
|
||||
const mapDataProfile = await Promise.all(
|
||||
findProfile.map(async (item: Profile) => {
|
||||
return {
|
||||
id: item.id,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
position: item.position,
|
||||
idcard: item.citizenId,
|
||||
posLevelName: item.posLevel == null ? null : item.posLevel.posLevelName,
|
||||
isProbation: item.isProbation,
|
||||
orgRootName:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot ==
|
||||
null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot
|
||||
?.orgRootName == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgRoot?.orgRootName,
|
||||
orgChild1Name:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild1 == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1
|
||||
?.orgChild1Name == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild1?.orgChild1Name,
|
||||
orgChild2Name:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild2 == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2
|
||||
?.orgChild2Name == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild2?.orgChild2Name,
|
||||
orgChild3Name:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild3 == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3
|
||||
?.orgChild3Name == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild3?.orgChild3Name,
|
||||
orgChild4Name:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild4 == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4
|
||||
?.orgChild4Name == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild4?.orgChild4Name,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const mapDataProfile = await Promise.all(
|
||||
findProfile.map(async (item: Profile) => {
|
||||
return {
|
||||
id: item.id,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
position: item.position,
|
||||
idcard: item.citizenId,
|
||||
posLevelName: item.posLevel == null ? null : item.posLevel.posLevelName,
|
||||
isProbation: item.isProbation,
|
||||
orgRootName:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot ==
|
||||
null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot
|
||||
?.orgRootName == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot
|
||||
?.orgRootName,
|
||||
orgChild1Name:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1 ==
|
||||
null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1
|
||||
?.orgChild1Name == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild1?.orgChild1Name,
|
||||
orgChild2Name:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2 ==
|
||||
null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2
|
||||
?.orgChild2Name == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild2?.orgChild2Name,
|
||||
orgChild3Name:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3 ==
|
||||
null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3
|
||||
?.orgChild3Name == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild3?.orgChild3Name,
|
||||
orgChild4Name:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4 ==
|
||||
null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4
|
||||
?.orgChild4Name == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild4?.orgChild4Name,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return new HttpSuccess({ data: mapDataProfile, total });
|
||||
} catch (error: any) {
|
||||
throw new Error(error);
|
||||
}
|
||||
return new HttpSuccess({ data: mapDataProfile, total });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -962,7 +914,7 @@ export class ProfileController extends Controller {
|
|||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
|
||||
|
||||
const [findPosMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||
.createQueryBuilder("posMaster")
|
||||
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
||||
|
|
@ -990,55 +942,55 @@ export class ProfileController extends Controller {
|
|||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? "current_holder.firstName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? "current_holder.lastName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? "current_holder.position LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
|
||||
.orWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? "current_holder.citizenId LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? "posType.posTypeName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? "posLevel.posLevelName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? "current_holder.firstName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? "current_holder.lastName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? "current_holder.position LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
|
||||
.orWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? "current_holder.citizenId LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? "posType.posTypeName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? "posLevel.posLevelName LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
|
|
@ -1047,8 +999,7 @@ export class ProfileController extends Controller {
|
|||
if (!findPosMaster) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. PosMaster");
|
||||
}
|
||||
|
||||
|
||||
|
||||
const formattedData = findPosMaster.map((item) => {
|
||||
let orgShortName = "";
|
||||
|
||||
|
|
@ -1089,21 +1040,21 @@ export class ProfileController extends Controller {
|
|||
posMasterNoSuffix: item.posMasterNoSuffix,
|
||||
orgShortName: orgShortName,
|
||||
position: item.current_holder.position,
|
||||
posType: item.current_holder.posType.posTypeName,
|
||||
posLevel: item.current_holder.posLevel.posLevelName,
|
||||
posType: item.current_holder.posType.posTypeName,
|
||||
posLevel: item.current_holder.posLevel.posLevelName,
|
||||
posExecutive: posExecutive,
|
||||
amount: amount?amount:0,
|
||||
amount: amount ? amount : 0,
|
||||
// revisionId: item.orgRevisionId,
|
||||
rootId: item.orgRootId,
|
||||
root: item.orgRoot?.orgRootName?item.orgRoot.orgRootName:null,
|
||||
root: item.orgRoot?.orgRootName ? item.orgRoot.orgRootName : null,
|
||||
child1Id: item.orgChild1Id,
|
||||
child1: item.orgChild1?.orgChild1Name?item.orgChild1.orgChild1Name:null,
|
||||
child1: item.orgChild1?.orgChild1Name ? item.orgChild1.orgChild1Name : null,
|
||||
child2Id: item.orgChild2Id,
|
||||
child2: item.orgChild2?.orgChild2Name?item.orgChild2.orgChild2Name:null,
|
||||
child2: item.orgChild2?.orgChild2Name ? item.orgChild2.orgChild2Name : null,
|
||||
child3Id: item.orgChild3Id,
|
||||
child3: item.orgChild3?.orgChild3Name?item.orgChild3.orgChild3Name:null,
|
||||
child3: item.orgChild3?.orgChild3Name ? item.orgChild3.orgChild3Name : null,
|
||||
child4Id: item.orgChild4Id,
|
||||
child4: item.orgChild4?.orgChild4Name?item.orgChild4.orgChild4Name:null,
|
||||
child4: item.orgChild4?.orgChild4Name ? item.orgChild4.orgChild4Name : null,
|
||||
isResult: true,
|
||||
isDuration: false,
|
||||
isPunish: true,
|
||||
|
|
@ -1112,7 +1063,7 @@ export class ProfileController extends Controller {
|
|||
};
|
||||
});
|
||||
|
||||
return new HttpSuccess({data:formattedData,total:total});
|
||||
return new HttpSuccess({ data: formattedData, total: total });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1212,10 +1163,6 @@ export class ProfileController extends Controller {
|
|||
: profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4
|
||||
.orgChild4Name,
|
||||
};
|
||||
try {
|
||||
return new HttpSuccess(_profile);
|
||||
} catch (error: any) {
|
||||
throw new Error(error);
|
||||
}
|
||||
return new HttpSuccess(_profile);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import { Not } from "typeorm";
|
|||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class ProfileSalaryController extends Controller {
|
||||
|
||||
private profileSalaryRepository = AppDataSource.getRepository(ProfileSalary);
|
||||
private profileRepository = AppDataSource.getRepository(Profile);
|
||||
|
||||
|
|
@ -47,14 +46,14 @@ export class ProfileSalaryController extends Controller {
|
|||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const profileSalary = Object.assign(new ProfileSalary(), requestBody);
|
||||
if(!profileSalary){
|
||||
if (!profileSalary) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: {id : profileSalary.profileId}
|
||||
})
|
||||
if(!profile){
|
||||
where: { id: profileSalary.profileId },
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +63,6 @@ export class ProfileSalaryController extends Controller {
|
|||
profileSalary.lastUpdateFullName = request.user.name;
|
||||
await this.profileSalaryRepository.save(profileSalary);
|
||||
return new HttpSuccess();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -91,7 +89,6 @@ export class ProfileSalaryController extends Controller {
|
|||
this.profileSalaryRepository.merge(profileSalary, requestBody);
|
||||
await this.profileSalaryRepository.save(profileSalary);
|
||||
return new HttpSuccess();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,12 +106,8 @@ export class ProfileSalaryController extends Controller {
|
|||
if (!delprofileSalary) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
}
|
||||
try {
|
||||
await this.profileSalaryRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
await this.profileSalaryRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -133,11 +126,7 @@ export class ProfileSalaryController extends Controller {
|
|||
if (!profileSalary) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(profileSalary);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(profileSalary);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -156,10 +145,6 @@ export class ProfileSalaryController extends Controller {
|
|||
if (!profileSalary) {
|
||||
return new HttpSuccess([]);
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(profileSalary);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(profileSalary);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,17 +50,13 @@ export class RankController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
try {
|
||||
const rank = Object.assign(new Rank(), requestBody);
|
||||
rank.createdUserId = request.user.sub;
|
||||
rank.createdFullName = request.user.name;
|
||||
rank.lastUpdateUserId = request.user.sub;
|
||||
rank.lastUpdateFullName = request.user.name;
|
||||
await this.rankRepository.save(rank);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
const rank = Object.assign(new Rank(), requestBody);
|
||||
rank.createdUserId = request.user.sub;
|
||||
rank.createdFullName = request.user.name;
|
||||
rank.lastUpdateUserId = request.user.sub;
|
||||
rank.lastUpdateFullName = request.user.name;
|
||||
await this.rankRepository.save(rank);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -90,15 +86,11 @@ export class RankController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
try {
|
||||
rank.lastUpdateUserId = request.user.sub;
|
||||
rank.lastUpdateFullName = request.user.name;
|
||||
this.rankRepository.merge(rank, requestBody);
|
||||
await this.rankRepository.save(rank);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
rank.lastUpdateUserId = request.user.sub;
|
||||
rank.lastUpdateFullName = request.user.name;
|
||||
this.rankRepository.merge(rank, requestBody);
|
||||
await this.rankRepository.save(rank);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,12 +108,8 @@ export class RankController extends Controller {
|
|||
if (!delRank) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลยศนี้");
|
||||
}
|
||||
try {
|
||||
await this.rankRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
await this.rankRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,11 +128,7 @@ export class RankController extends Controller {
|
|||
if (!rank) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(rank);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(rank);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -163,10 +147,6 @@ export class RankController extends Controller {
|
|||
if (!rank) {
|
||||
return new HttpSuccess([]);
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(rank);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(rank);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,17 +50,13 @@ export class RelationshipController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
try {
|
||||
const relationship = Object.assign(new Relationship(), requestBody);
|
||||
relationship.createdUserId = request.user.sub;
|
||||
relationship.createdFullName = request.user.name;
|
||||
relationship.lastUpdateUserId = request.user.sub;
|
||||
relationship.lastUpdateFullName = request.user.name;
|
||||
await this.relationshipRepository.save(relationship);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
const relationship = Object.assign(new Relationship(), requestBody);
|
||||
relationship.createdUserId = request.user.sub;
|
||||
relationship.createdFullName = request.user.name;
|
||||
relationship.lastUpdateUserId = request.user.sub;
|
||||
relationship.lastUpdateFullName = request.user.name;
|
||||
await this.relationshipRepository.save(relationship);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -90,15 +86,11 @@ export class RelationshipController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
try {
|
||||
relationship.lastUpdateUserId = request.user.sub;
|
||||
relationship.lastUpdateFullName = request.user.name;
|
||||
this.relationshipRepository.merge(relationship, requestBody);
|
||||
await this.relationshipRepository.save(relationship);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
relationship.lastUpdateUserId = request.user.sub;
|
||||
relationship.lastUpdateFullName = request.user.name;
|
||||
this.relationshipRepository.merge(relationship, requestBody);
|
||||
await this.relationshipRepository.save(relationship);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,12 +108,8 @@ export class RelationshipController extends Controller {
|
|||
if (!delRelationship) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพนี้");
|
||||
}
|
||||
try {
|
||||
await this.relationshipRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
await this.relationshipRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,11 +128,7 @@ export class RelationshipController extends Controller {
|
|||
if (!relationship) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(relationship);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(relationship);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -162,10 +146,6 @@ export class RelationshipController extends Controller {
|
|||
if (!relationship) {
|
||||
return new HttpSuccess([]);
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(relationship);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(relationship);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,17 +50,13 @@ export class ReligionController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
try {
|
||||
const religion = Object.assign(new Religion(), requestBody);
|
||||
religion.createdUserId = request.user.sub;
|
||||
religion.createdFullName = request.user.name;
|
||||
religion.lastUpdateUserId = request.user.sub;
|
||||
religion.lastUpdateFullName = request.user.name;
|
||||
await this.religionRepository.save(religion);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
const religion = Object.assign(new Religion(), requestBody);
|
||||
religion.createdUserId = request.user.sub;
|
||||
religion.createdFullName = request.user.name;
|
||||
religion.lastUpdateUserId = request.user.sub;
|
||||
religion.lastUpdateFullName = request.user.name;
|
||||
await this.religionRepository.save(religion);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -90,15 +86,11 @@ export class ReligionController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
try {
|
||||
religion.lastUpdateUserId = request.user.sub;
|
||||
religion.lastUpdateFullName = request.user.name;
|
||||
this.religionRepository.merge(religion, requestBody);
|
||||
await this.religionRepository.save(religion);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
religion.lastUpdateUserId = request.user.sub;
|
||||
religion.lastUpdateFullName = request.user.name;
|
||||
this.religionRepository.merge(religion, requestBody);
|
||||
await this.religionRepository.save(religion);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,12 +108,8 @@ export class ReligionController extends Controller {
|
|||
if (!delReligion) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลศาสนานี้");
|
||||
}
|
||||
try {
|
||||
await this.religionRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
await this.religionRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,11 +128,7 @@ export class ReligionController extends Controller {
|
|||
if (!religion) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(religion);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(religion);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -163,10 +147,6 @@ export class ReligionController extends Controller {
|
|||
if (!religion) {
|
||||
return new HttpSuccess([]);
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(religion);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(religion);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ export class ReportController extends Controller {
|
|||
*/
|
||||
@Get("report1")
|
||||
async findReport1() {
|
||||
try {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsDraft: true, orgRevisionIsCurrent: false },
|
||||
relations: ["orgRoots"],
|
||||
|
|
@ -644,9 +643,7 @@ export class ReportController extends Controller {
|
|||
}
|
||||
}
|
||||
return new HttpSuccess({ template: "report1", reportName: "report1", data: { data } });
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -657,7 +654,6 @@ export class ReportController extends Controller {
|
|||
*/
|
||||
@Get("report2")
|
||||
async findReport2() {
|
||||
try {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsDraft: true, orgRevisionIsCurrent: false },
|
||||
relations: ["orgRoots"],
|
||||
|
|
@ -2313,9 +2309,7 @@ export class ReportController extends Controller {
|
|||
}
|
||||
}
|
||||
return new HttpSuccess({ template: "report2", reportName: "report2", data: { data } });
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2326,7 +2320,6 @@ export class ReportController extends Controller {
|
|||
*/
|
||||
@Get("report3")
|
||||
async findReport3() {
|
||||
try {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsDraft: true, orgRevisionIsCurrent: false },
|
||||
relations: ["orgRoots"],
|
||||
|
|
@ -3181,8 +3174,6 @@ export class ReportController extends Controller {
|
|||
}
|
||||
}
|
||||
return new HttpSuccess({ template: "report3", reportName: "report3", data: { data } });
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue