Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop

This commit is contained in:
Kittapath 2024-05-15 16:09:42 +07:00
commit 1a017dcd76
14 changed files with 1226 additions and 6 deletions

View file

@ -142,7 +142,7 @@ export class BloodGroupController extends Controller {
async listBloodGroup() {
const bloodGroup = await this.bloodGroupRepository.find({
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
order: { createdAt: "ASC" },
order: { name: "ASC" },
});
// if (!bloodGroup) {

View file

@ -41,7 +41,7 @@ export class GenderController extends Controller {
async GetResult() {
const _gender = await this.genderRepository.find({
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
order: { createdAt: "ASC" },
order: { name: "ASC" },
});
// if (!_gender) {
// return new HttpSuccess([]);

View file

@ -199,6 +199,7 @@ export class PosExecutiveController extends Controller {
async GetPosExecutive() {
const posExecutive = await this.posExecutiveRepository.find({
select: ["id", "posExecutiveName", "posExecutivePriority"],
order: { posExecutivePriority: "ASC" },
});
// if (!posExecutive) {
// return new HttpSuccess([]);

View file

@ -352,6 +352,7 @@ export class PositionController extends Controller {
findPosDict = await this.posDictRepository.find({
where: { posDictName: Like(`%${keyword}%`) },
relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" },
});
// if (!findPosDict) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
@ -362,6 +363,7 @@ export class PositionController extends Controller {
findPosDict = await this.posDictRepository.find({
where: { posDictField: Like(`%${keyword}%`) },
relations: ["posType", "posLevel", "posExecutive"],
order: { posDictField: "ASC" },
});
// if (!findPosDict) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
@ -371,33 +373,39 @@ export class PositionController extends Controller {
case "positionType":
const findTypes: PosType[] = await this.posTypeRepository.find({
where: { posTypeName: Like(`%${keyword}%`) },
order: { posTypeName: "ASC" },
select: ["id"],
});
findPosDict = await this.posDictRepository.find({
where: { posTypeId: In(findTypes.map((x) => x.id)) },
relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" },
});
break;
case "positionLevel":
const findLevel: PosLevel[] = await this.posLevelRepository.find({
where: { posLevelName: Like(`%${keyword}%`) },
order: { posLevelName: "ASC" },
select: ["id"],
});
findPosDict = await this.posDictRepository.find({
where: { posLevelId: In(findLevel.map((x) => x.id)) },
relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" },
});
break;
case "positionExecutive":
const findExecutive: PosExecutive[] = await this.posExecutiveRepository.find({
where: { posExecutiveName: Like(`%${keyword}%`) },
order: { posExecutiveName: "ASC" },
select: ["id"],
});
findPosDict = await this.posDictRepository.find({
where: { posExecutiveId: In(findExecutive.map((x) => x.id)) },
relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" },
});
break;
@ -405,6 +413,7 @@ export class PositionController extends Controller {
findPosDict = await this.posDictRepository.find({
where: { posDictExecutiveField: Like(`%${keyword}%`) },
relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" },
});
// if (!findPosDict) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
@ -415,6 +424,7 @@ export class PositionController extends Controller {
findPosDict = await this.posDictRepository.find({
where: { posDictArea: Like(`%${keyword}%`) },
relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" },
});
// if (!findPosDict) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
@ -424,6 +434,7 @@ export class PositionController extends Controller {
default:
findPosDict = await this.posDictRepository.find({
relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" },
});
// if (!findPosDict) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -41,7 +41,7 @@ export class PrefixController extends Controller {
async Get() {
const _prefix = await this.prefixRepository.find({
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
order: { createdAt: "ASC" },
order: { name: "ASC" },
});
// if (!_prefix) {
// return new HttpSuccess([]);

View file

@ -0,0 +1,207 @@
import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { ProfileFamilyCouple, CreateProfileFamilyCouple, UpdateProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
@Route("api/v1/org/profile/family/couple")
@Tags("ProfileFamilyCouple")
@Security("bearerAuth")
export class ProfileFamilyCoupleController extends Controller {
private profileRepo = AppDataSource.getRepository(Profile);
private ProfileFamilyCouple = AppDataSource.getRepository(ProfileFamilyCouple);
private ProfileFamilyCoupleHistory = AppDataSource.getRepository(ProfileFamilyCoupleHistory);
@Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
couple: true,
couplePrefix: "string",
coupleFirstName: "string",
coupleLastName: "string",
coupleLastNameOld: "string",
coupleCareer: "string",
coupleCitizenId: "string",
coupleLive: true,
relationship: "string",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyCouple(@Path() profileId: string) {
const profile = await this.profileRepo.findOne({
where: { id: profileId }
})
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyCouple = await this.ProfileFamilyCouple.findOne({
select: [
"id", "couple", "couplePrefix", "coupleFirstName", "coupleLastName", "coupleLastNameOld",
"coupleCareer", "coupleCitizenId", "coupleLive", "relationship", "profileId",
],
where: { profileId },
});
return new HttpSuccess(familyCouple);
}
@Get("history/{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
couple: true,
couplePrefix: "string",
coupleFirstName: "string",
coupleLastName: "string",
coupleLastNameOld: "string",
coupleCareer: "string",
coupleCitizenId: "string",
coupleLive: true,
relationship: "string",
profileFamilyCoupleId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
}
],
})
public async familyCoupleHistory(@Path() profileId: string) {
const profile = await this.profileRepo.findOne({
where: { id: profileId }
})
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyCouple = await this.ProfileFamilyCouple.find({
relations: ["histories"],
order: { lastUpdatedAt: "DESC" },
where: { profileId: profileId},
});
const mapData = familyCouple.flatMap((x) => x.histories).map((y) => ({
id: y.id,
createdAt: y.createdAt,
createdUserId: y.createdUserId,
lastUpdatedAt: y.lastUpdatedAt,
lastUpdateUserId: y.lastUpdateUserId,
createdFullName: y.createdFullName,
lastUpdateFullName: y.lastUpdateFullName,
couple: y.couple,
couplePrefix: y.couplePrefix,
coupleFirstName: y.coupleFirstName,
coupleLastName: y.coupleLastName,
coupleLastNameOld: y.coupleLastNameOld,
coupleCareer: y.coupleCareer,
coupleLive: y.coupleLive,
relationship: y.relationship,
profileFamilyCoupleId: y.profileFamilyCoupleId,
profileId: profileId,
}));
return new HttpSuccess(mapData);
}
@Post()
public async FamilyCouple(
@Request() req: RequestWithUser,
@Body() body: CreateProfileFamilyCouple,
) {
const familyCouple = Object.assign(new ProfileFamilyCouple(), body);
if (!familyCouple) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
familyCouple.createdUserId = req.user.sub;
familyCouple.createdFullName = req.user.name;
familyCouple.lastUpdateUserId = req.user.sub;
familyCouple.lastUpdateFullName = req.user.name;
await this.ProfileFamilyCouple.save(familyCouple);
if (familyCouple) {
const history: ProfileFamilyCoupleHistory = Object.assign(new ProfileFamilyCoupleHistory(), {
profileFamilyCoupleId: familyCouple.id,
couple: familyCouple.couple,
couplePrefix: familyCouple.couplePrefix,
coupleFirstName: familyCouple.coupleFirstName,
coupleLastName: familyCouple.coupleLastName,
coupleLastNameOld: familyCouple.coupleLastNameOld,
coupleCareer: familyCouple.coupleCareer,
coupleLive: familyCouple.coupleLive,
relationship: familyCouple.relationship,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
});
await this.ProfileFamilyCoupleHistory.save(history);
}
return new HttpSuccess(familyCouple.id);
}
@Patch("{profileId}")
public async editFamilyCouple(
@Request() req: RequestWithUser,
@Body() body: UpdateProfileFamilyCouple,
@Path() profileId: string,
) {
const familyCouple = await this.ProfileFamilyCouple.findOneBy({ profileId: profileId });
if (!familyCouple) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileFamilyCoupleHistory();
Object.assign(history, { ...familyCouple, id: undefined });
Object.assign(familyCouple, body);
familyCouple.lastUpdateUserId = req.user.sub,
familyCouple.lastUpdateFullName = req.user.name;
history.profileFamilyCoupleId = familyCouple.id;
history.couple = familyCouple.couple,
history.couplePrefix = familyCouple.couplePrefix,
history.coupleFirstName = familyCouple.coupleFirstName,
history.coupleLastName = familyCouple.coupleLastName,
history.coupleLastNameOld = familyCouple.coupleLastNameOld,
history.coupleCareer = familyCouple.coupleCareer,
history.coupleLive = familyCouple.coupleLive,
history.relationship = familyCouple.relationship,
history.lastUpdateUserId = req.user.sub,
history.lastUpdateFullName = req.user.name;
await Promise.all([
this.ProfileFamilyCouple.save(familyCouple),
this.ProfileFamilyCoupleHistory.save(history),
]);
return new HttpSuccess();
}
}

View file

@ -0,0 +1,207 @@
import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import { ProfileFamilyCouple, CreateProfileEmployeeFamilyCouple, UpdateProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
@Route("api/v1/org/profile-employee/family/couple")
@Tags("ProfileEmployeeFamilyCouple")
@Security("bearerAuth")
export class ProfileFamilyCoupleEmployeeController extends Controller {
private profileRepo = AppDataSource.getRepository(ProfileEmployee);
private ProfileFamilyCouple = AppDataSource.getRepository(ProfileFamilyCouple);
private ProfileFamilyCoupleHistory = AppDataSource.getRepository(ProfileFamilyCoupleHistory);
@Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
couple: true,
couplePrefix: "string",
coupleFirstName: "string",
coupleLastName: "string",
coupleLastNameOld: "string",
coupleCareer: "string",
coupleCitizenId: "string",
coupleLive: true,
relationship: "string",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyCouple(@Path() profileEmployeeId: string) {
const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }
})
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyCouple = await this.ProfileFamilyCouple.findOne({
select: [
"id", "couple", "couplePrefix", "coupleFirstName", "coupleLastName", "coupleLastNameOld",
"coupleCareer", "coupleCitizenId", "coupleLive", "relationship", "profileEmployeeId",
],
where: { profileEmployeeId },
});
return new HttpSuccess(familyCouple);
}
@Get("history/{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
couple: true,
couplePrefix: "string",
coupleFirstName: "string",
coupleLastName: "string",
coupleLastNameOld: "string",
coupleCareer: "string",
coupleCitizenId: "string",
coupleLive: true,
relationship: "string",
profileFamilyCoupleId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
}
],
})
public async familyCoupleHistory(@Path() profileEmployeeId: string) {
const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }
})
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyCouple = await this.ProfileFamilyCouple.find({
relations: ["histories"],
order: { lastUpdatedAt: "DESC" },
where: { profileEmployeeId: profileEmployeeId},
});
const mapData = familyCouple.flatMap((x) => x.histories).map((y) => ({
id: y.id,
createdAt: y.createdAt,
createdUserId: y.createdUserId,
lastUpdatedAt: y.lastUpdatedAt,
lastUpdateUserId: y.lastUpdateUserId,
createdFullName: y.createdFullName,
lastUpdateFullName: y.lastUpdateFullName,
couple: y.couple,
couplePrefix: y.couplePrefix,
coupleFirstName: y.coupleFirstName,
coupleLastName: y.coupleLastName,
coupleLastNameOld: y.coupleLastNameOld,
coupleCareer: y.coupleCareer,
coupleLive: y.coupleLive,
relationship: y.relationship,
profileFamilyCoupleId: y.profileFamilyCoupleId,
profileEmployeeId: profileEmployeeId,
}));
return new HttpSuccess(mapData);
}
@Post()
public async FamilyCouple(
@Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeFamilyCouple,
) {
const familyCouple = Object.assign(new ProfileFamilyCouple(), body);
if (!familyCouple) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
const profile = await this.profileRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
familyCouple.createdUserId = req.user.sub;
familyCouple.createdFullName = req.user.name;
familyCouple.lastUpdateUserId = req.user.sub;
familyCouple.lastUpdateFullName = req.user.name;
await this.ProfileFamilyCouple.save(familyCouple);
if (familyCouple) {
const history: ProfileFamilyCoupleHistory = Object.assign(new ProfileFamilyCoupleHistory(), {
profileFamilyCoupleId: familyCouple.id,
couple: familyCouple.couple,
couplePrefix: familyCouple.couplePrefix,
coupleFirstName: familyCouple.coupleFirstName,
coupleLastName: familyCouple.coupleLastName,
coupleLastNameOld: familyCouple.coupleLastNameOld,
coupleCareer: familyCouple.coupleCareer,
coupleLive: familyCouple.coupleLive,
relationship: familyCouple.relationship,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
});
await this.ProfileFamilyCoupleHistory.save(history);
}
return new HttpSuccess(familyCouple.id);
}
@Patch("{profileEmployeeId}")
public async editFamilyCouple(
@Request() req: RequestWithUser,
@Body() body: UpdateProfileFamilyCouple,
@Path() profileEmployeeId: string,
) {
const familyCouple = await this.ProfileFamilyCouple.findOneBy({ profileEmployeeId: profileEmployeeId });
if (!familyCouple) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileFamilyCoupleHistory();
Object.assign(history, { ...familyCouple, id: undefined });
Object.assign(familyCouple, body);
familyCouple.lastUpdateUserId = req.user.sub,
familyCouple.lastUpdateFullName = req.user.name;
history.profileFamilyCoupleId = familyCouple.id;
history.couple = familyCouple.couple,
history.couplePrefix = familyCouple.couplePrefix,
history.coupleFirstName = familyCouple.coupleFirstName,
history.coupleLastName = familyCouple.coupleLastName,
history.coupleLastNameOld = familyCouple.coupleLastNameOld,
history.coupleCareer = familyCouple.coupleCareer,
history.coupleLive = familyCouple.coupleLive,
history.relationship = familyCouple.relationship,
history.lastUpdateUserId = req.user.sub,
history.lastUpdateFullName = req.user.name;
await Promise.all([
this.ProfileFamilyCouple.save(familyCouple),
this.ProfileFamilyCoupleHistory.save(history),
]);
return new HttpSuccess();
}
}

View file

@ -0,0 +1,206 @@
import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { ProfileFamilyFather, CreateProfileFamilyFather, UpdateProfileFamilyFather } from "../entities/ProfileFamilyFather";
import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory";
@Route("api/v1/org/profile/family/father")
@Tags("ProfileFamilyFather")
@Security("bearerAuth")
export class ProfileFamilyFatherController extends Controller {
private profileRepo = AppDataSource.getRepository(Profile);
private ProfileFamilyFather = AppDataSource.getRepository(ProfileFamilyFather);
private ProfileFamilyFatherHistory = AppDataSource.getRepository(ProfileFamilyFatherHistory);
@Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
fatherPrefix: "string",
fatherFirstName: "string",
fatherLastName: "string",
fatherCareer: "string",
fatherCitizenId: "string",
fatherLive: true,
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyFather(@Path() profileId: string) {
const profile = await this.profileRepo.findOne({
where: { id: profileId }
})
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyFather = await this.ProfileFamilyFather.findOne({
select: [
"id", "fatherPrefix", "fatherFirstName", "fatherLastName",
"fatherCareer", "fatherCitizenId", "fatherLive", "profileId",
],
where: { profileId },
});
return new HttpSuccess(familyFather);
}
@Get("history/{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
fatherPrefix: "string",
fatherFirstName: "string",
fatherLastName: "string",
fatherCareer: "string",
fatherCitizenId: "string",
fatherLive: true,
profileFamilyFatherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
}
],
})
public async familyFatherHistory(@Path() profileId: string) {
const profile = await this.profileRepo.findOne({
where: { id: profileId }
})
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyFather = await this.ProfileFamilyFather.find({
relations: ["histories"],
order: { lastUpdatedAt: "DESC" },
where: { profileId: profileId},
});
const mapData = familyFather.flatMap((x) => x.histories).map((y) => ({
id: y.id,
createdAt: y.createdAt,
createdUserId: y.createdUserId,
lastUpdatedAt: y.lastUpdatedAt,
lastUpdateUserId: y.lastUpdateUserId,
createdFullName: y.createdFullName,
lastUpdateFullName: y.lastUpdateFullName,
fatherPrefix: y.fatherPrefix,
fatherFirstName: y.fatherFirstName,
fatherLastName: y.fatherLastName,
fatherCareer: y.fatherCareer,
fatherCitizenId: y.fatherCitizenId,
fatherLive: y.fatherLive,
profileFamilyFatherId: y.profileFamilyFatherId,
profileId: profileId,
}));
return new HttpSuccess(mapData);
}
@Post()
public async FamilyFather(
@Request() req: RequestWithUser,
@Body() body: CreateProfileFamilyFather,
) {
const familyFather = Object.assign(new ProfileFamilyFather(), body);
if (!familyFather) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
familyFather.createdUserId = req.user.sub;
familyFather.createdFullName = req.user.name;
familyFather.lastUpdateUserId = req.user.sub;
familyFather.lastUpdateFullName = req.user.name;
await this.ProfileFamilyFather.save(familyFather);
if (familyFather) {
const history: ProfileFamilyFatherHistory = Object.assign(new ProfileFamilyFatherHistory(), {
profileFamilyFatherId: familyFather.id,
fatherPrefix: familyFather.fatherPrefix,
fatherFirstName: familyFather.fatherFirstName,
fatherLastName: familyFather.fatherLastName,
fatherCareer: familyFather.fatherCareer,
fatherCitizenId: familyFather.fatherCitizenId,
fatherLive: familyFather.fatherLive,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
});
await this.ProfileFamilyFatherHistory.save(history);
}
return new HttpSuccess(familyFather.id);
}
@Patch("{profileId}")
public async editFamilyFather(
@Request() req: RequestWithUser,
@Body() body: UpdateProfileFamilyFather,
@Path() profileId: string,
) {
const familyFather = await this.ProfileFamilyFather.findOneBy({ profileId: profileId });
if (!familyFather) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileFamilyFatherHistory();
Object.assign(history, { ...familyFather, id: undefined });
Object.assign(familyFather, body);
familyFather.lastUpdateUserId = req.user.sub,
familyFather.lastUpdateFullName = req.user.name;
history.profileFamilyFatherId = familyFather.id; //profileFamilyFatherId
history.fatherPrefix = familyFather.fatherPrefix,
history.fatherFirstName = familyFather.fatherFirstName,
history.fatherLastName = familyFather.fatherLastName,
history.fatherCareer = familyFather.fatherCareer,
history.fatherCitizenId = familyFather.fatherCitizenId,
history.fatherLive = familyFather.fatherLive,
history.lastUpdateUserId = req.user.sub,
history.lastUpdateFullName = req.user.name;
await Promise.all([
this.ProfileFamilyFather.save(familyFather),
this.ProfileFamilyFatherHistory.save(history),
]);
return new HttpSuccess();
}
// @Delete("{profileId}")
// public async deleteFamilyFather(@Path() profileId: string) {
// const result = await this.ProfileFamilyFather.delete({ profileId: profileId });
// if (result.affected == undefined || result.affected <= 0) {
// throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
// }
// return new HttpSuccess();
// }
}

View file

@ -0,0 +1,196 @@
import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import { ProfileFamilyFather, CreateProfileEmployeeFamilyFather, UpdateProfileFamilyFather } from "../entities/ProfileFamilyFather";
import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory";
@Route("api/v1/org/profile-employee/family/father")
@Tags("ProfileEmployeeFamilyFather")
@Security("bearerAuth")
export class ProfileFamilyFatherEmployeeController extends Controller {
private profileRepo = AppDataSource.getRepository(ProfileEmployee);
private ProfileFamilyFather = AppDataSource.getRepository(ProfileFamilyFather);
private ProfileFamilyFatherHistory = AppDataSource.getRepository(ProfileFamilyFatherHistory);
@Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
fatherPrefix: "string",
fatherFirstName: "string",
fatherLastName: "string",
fatherCareer: "string",
fatherCitizenId: "string",
fatherLive: true,
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyFather(@Path() profileEmployeeId: string) {
const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }
})
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyFather = await this.ProfileFamilyFather.findOne({
select: [
"id", "fatherPrefix", "fatherFirstName", "fatherLastName",
"fatherCareer", "fatherCitizenId", "fatherLive", "profileEmployeeId",
],
where: { profileEmployeeId },
});
return new HttpSuccess(familyFather);
}
@Get("history/{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
fatherPrefix: "string",
fatherFirstName: "string",
fatherLastName: "string",
fatherCareer: "string",
fatherCitizenId: "string",
fatherLive: true,
profileFamilyFatherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
}
],
})
public async familyFatherHistory(@Path() profileEmployeeId: string) {
const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }
})
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyFather = await this.ProfileFamilyFather.find({
relations: ["histories"],
order: { lastUpdatedAt: "DESC" },
where: { profileEmployeeId: profileEmployeeId},
});
const mapData = familyFather.flatMap((x) => x.histories).map((y) => ({
id: y.id,
createdAt: y.createdAt,
createdUserId: y.createdUserId,
lastUpdatedAt: y.lastUpdatedAt,
lastUpdateUserId: y.lastUpdateUserId,
createdFullName: y.createdFullName,
lastUpdateFullName: y.lastUpdateFullName,
fatherPrefix: y.fatherPrefix,
fatherFirstName: y.fatherFirstName,
fatherLastName: y.fatherLastName,
fatherCareer: y.fatherCareer,
fatherCitizenId: y.fatherCitizenId,
fatherLive: y.fatherLive,
profileFamilyFatherId: y.profileFamilyFatherId,
profileEmployeeId: profileEmployeeId,
}));
return new HttpSuccess(mapData);
}
@Post()
public async FamilyFather(
@Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeFamilyFather,
) {
const familyFather = Object.assign(new ProfileFamilyFather(), body);
if (!familyFather) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
const profile = await this.profileRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
familyFather.createdUserId = req.user.sub;
familyFather.createdFullName = req.user.name;
familyFather.lastUpdateUserId = req.user.sub;
familyFather.lastUpdateFullName = req.user.name;
await this.ProfileFamilyFather.save(familyFather);
if (familyFather) {
const history: ProfileFamilyFatherHistory = Object.assign(new ProfileFamilyFatherHistory(), {
profileFamilyFatherId: familyFather.id,
fatherPrefix: familyFather.fatherPrefix,
fatherFirstName: familyFather.fatherFirstName,
fatherLastName: familyFather.fatherLastName,
fatherCareer: familyFather.fatherCareer,
fatherCitizenId: familyFather.fatherCitizenId,
fatherLive: familyFather.fatherLive,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
});
await this.ProfileFamilyFatherHistory.save(history);
}
return new HttpSuccess(familyFather.id);
}
@Patch("{profileEmployeeId}")
public async editFamilyFather(
@Request() req: RequestWithUser,
@Body() body: UpdateProfileFamilyFather,
@Path() profileEmployeeId: string,
) {
const familyFather = await this.ProfileFamilyFather.findOneBy({ profileEmployeeId: profileEmployeeId });
if (!familyFather) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileFamilyFatherHistory();
Object.assign(history, { ...familyFather, id: undefined });
Object.assign(familyFather, body);
familyFather.lastUpdateUserId = req.user.sub,
familyFather.lastUpdateFullName = req.user.name;
history.profileFamilyFatherId = familyFather.id;
history.fatherPrefix = familyFather.fatherPrefix,
history.fatherFirstName = familyFather.fatherFirstName,
history.fatherLastName = familyFather.fatherLastName,
history.fatherCareer = familyFather.fatherCareer,
history.fatherCitizenId = familyFather.fatherCitizenId,
history.fatherLive = familyFather.fatherLive,
history.lastUpdateUserId = req.user.sub,
history.lastUpdateFullName = req.user.name;
await Promise.all([
this.ProfileFamilyFather.save(familyFather),
this.ProfileFamilyFatherHistory.save(history),
]);
return new HttpSuccess();
}
}

View file

@ -0,0 +1,196 @@
import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { ProfileFamilyMother, CreateProfileFamilyMother, UpdateProfileFamilyMother } from "../entities/ProfileFamilyMother";
import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory";
@Route("api/v1/org/profile/family/mother")
@Tags("ProfileFamilyMother")
@Security("bearerAuth")
export class ProfileFamilyMotherController extends Controller {
private profileRepo = AppDataSource.getRepository(Profile);
private ProfileFamilyMother = AppDataSource.getRepository(ProfileFamilyMother);
private ProfileFamilyMotherHistory = AppDataSource.getRepository(ProfileFamilyMotherHistory);
@Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
motherPrefix: "string",
motherFirstName: "string",
motherLastName: "string",
motherCareer: "string",
motherCitizenId: "string",
motherLive: true,
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyMother(@Path() profileId: string) {
const profile = await this.profileRepo.findOne({
where: { id: profileId }
})
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyMother = await this.ProfileFamilyMother.findOne({
select: [
"id", "motherPrefix", "motherFirstName", "motherLastName",
"motherCareer", "motherCitizenId", "motherLive", "profileId",
],
where: { profileId },
});
return new HttpSuccess(familyMother);
}
@Get("history/{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
motherPrefix: "string",
motherFirstName: "string",
motherLastName: "string",
motherCareer: "string",
motherCitizenId: "string",
motherLive: true,
profileFamilyMotherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
}
],
})
public async familyMotherHistory(@Path() profileId: string) {
const profile = await this.profileRepo.findOne({
where: { id: profileId }
})
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyMother = await this.ProfileFamilyMother.find({
relations: ["histories"],
order: { lastUpdatedAt: "DESC" },
where: { profileId: profileId},
});
const mapData = familyMother.flatMap((x) => x.histories).map((y) => ({
id: y.id,
createdAt: y.createdAt,
createdUserId: y.createdUserId,
lastUpdatedAt: y.lastUpdatedAt,
lastUpdateUserId: y.lastUpdateUserId,
createdFullName: y.createdFullName,
lastUpdateFullName: y.lastUpdateFullName,
motherPrefix: y.motherPrefix,
motherFirstName: y.motherFirstName,
motherLastName: y.motherLastName,
motherCareer: y.motherCareer,
motherCitizenId: y.motherCitizenId,
motherLive: y.motherLive,
profileFamilyMotherId: y.profileFamilyMotherId,
profileId: profileId,
}));
return new HttpSuccess(mapData);
}
@Post()
public async FamilyMother(
@Request() req: RequestWithUser,
@Body() body: CreateProfileFamilyMother,
) {
const familyMother = Object.assign(new ProfileFamilyMother(), body);
if (!familyMother) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
familyMother.createdUserId = req.user.sub;
familyMother.createdFullName = req.user.name;
familyMother.lastUpdateUserId = req.user.sub;
familyMother.lastUpdateFullName = req.user.name;
await this.ProfileFamilyMother.save(familyMother);
if (familyMother) {
const history: ProfileFamilyMotherHistory = Object.assign(new ProfileFamilyMotherHistory(), {
profileFamilyMotherId: familyMother.id,
motherPrefix: familyMother.motherPrefix,
motherFirstName: familyMother.motherFirstName,
motherLastName: familyMother.motherLastName,
motherCareer: familyMother.motherCareer,
motherCitizenId: familyMother.motherCitizenId,
motherLive: familyMother.motherLive,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
});
await this.ProfileFamilyMotherHistory.save(history);
}
return new HttpSuccess(familyMother.id);
}
@Patch("{profileId}")
public async editFamilyMother(
@Request() req: RequestWithUser,
@Body() body: UpdateProfileFamilyMother,
@Path() profileId: string,
) {
const familyMother = await this.ProfileFamilyMother.findOneBy({ profileId: profileId });
if (!familyMother) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileFamilyMotherHistory();
Object.assign(history, { ...familyMother, id: undefined });
Object.assign(familyMother, body);
familyMother.lastUpdateUserId = req.user.sub,
familyMother.lastUpdateFullName = req.user.name;
history.profileFamilyMotherId = familyMother.id;
history.motherPrefix = familyMother.motherPrefix,
history.motherFirstName = familyMother.motherFirstName,
history.motherLastName = familyMother.motherLastName,
history.motherCareer = familyMother.motherCareer,
history.motherCitizenId = familyMother.motherCitizenId,
history.motherLive = familyMother.motherLive,
history.lastUpdateUserId = req.user.sub,
history.lastUpdateFullName = req.user.name;
await Promise.all([
this.ProfileFamilyMother.save(familyMother),
this.ProfileFamilyMotherHistory.save(history),
]);
return new HttpSuccess();
}
}

View file

@ -0,0 +1,196 @@
import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import { ProfileFamilyMother, CreateProfileEmployeeFamilyMother, UpdateProfileFamilyMother } from "../entities/ProfileFamilyMother";
import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory";
@Route("api/v1/org/profile-employee/family/mother")
@Tags("ProfileEmployeeFamilyMother")
@Security("bearerAuth")
export class ProfileFamilyMotherEmployeeController extends Controller {
private profileRepo = AppDataSource.getRepository(ProfileEmployee);
private ProfileFamilyMother = AppDataSource.getRepository(ProfileFamilyMother);
private ProfileFamilyMotherHistory = AppDataSource.getRepository(ProfileFamilyMotherHistory);
@Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
motherPrefix: "string",
motherFirstName: "string",
motherLastName: "string",
motherCareer: "string",
motherCitizenId: "string",
motherLive: true,
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyMother(@Path() profileEmployeeId: string) {
const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }
})
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyMother = await this.ProfileFamilyMother.findOne({
select: [
"id", "motherPrefix", "motherFirstName", "motherLastName",
"motherCareer", "motherCitizenId", "motherLive", "profileEmployeeId",
],
where: { profileEmployeeId },
});
return new HttpSuccess(familyMother);
}
@Get("history/{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
motherPrefix: "string",
motherFirstName: "string",
motherLastName: "string",
motherCareer: "string",
motherCitizenId: "string",
motherLive: true,
profileFamilyMotherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
}
],
})
public async familyMotherHistory(@Path() profileEmployeeId: string) {
const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }
})
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyMother = await this.ProfileFamilyMother.find({
relations: ["histories"],
order: { lastUpdatedAt: "DESC" },
where: { profileEmployeeId: profileEmployeeId},
});
const mapData = familyMother.flatMap((x) => x.histories).map((y) => ({
id: y.id,
createdAt: y.createdAt,
createdUserId: y.createdUserId,
lastUpdatedAt: y.lastUpdatedAt,
lastUpdateUserId: y.lastUpdateUserId,
createdFullName: y.createdFullName,
lastUpdateFullName: y.lastUpdateFullName,
motherPrefix: y.motherPrefix,
motherFirstName: y.motherFirstName,
motherLastName: y.motherLastName,
motherCareer: y.motherCareer,
motherCitizenId: y.motherCitizenId,
motherLive: y.motherLive,
profileFamilyMotherId: y.profileFamilyMotherId,
profileEmployeeId: profileEmployeeId,
}));
return new HttpSuccess(mapData);
}
@Post()
public async FamilyMother(
@Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeFamilyMother,
) {
const familyMother = Object.assign(new ProfileFamilyMother(), body);
if (!familyMother) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
const profile = await this.profileRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
familyMother.createdUserId = req.user.sub;
familyMother.createdFullName = req.user.name;
familyMother.lastUpdateUserId = req.user.sub;
familyMother.lastUpdateFullName = req.user.name;
await this.ProfileFamilyMother.save(familyMother);
if (familyMother) {
const history: ProfileFamilyMotherHistory = Object.assign(new ProfileFamilyMotherHistory(), {
profileFamilyMotherId: familyMother.id,
motherPrefix: familyMother.motherPrefix,
motherFirstName: familyMother.motherFirstName,
motherLastName: familyMother.motherLastName,
motherCareer: familyMother.motherCareer,
motherCitizenId: familyMother.motherCitizenId,
motherLive: familyMother.motherLive,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
});
await this.ProfileFamilyMotherHistory.save(history);
}
return new HttpSuccess(familyMother.id);
}
@Patch("{profileEmployeeId}")
public async editFamilyMother(
@Request() req: RequestWithUser,
@Body() body: UpdateProfileFamilyMother,
@Path() profileEmployeeId: string,
) {
const familyMother = await this.ProfileFamilyMother.findOneBy({ profileEmployeeId: profileEmployeeId });
if (!familyMother) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileFamilyMotherHistory();
Object.assign(history, { ...familyMother, id: undefined });
Object.assign(familyMother, body);
familyMother.lastUpdateUserId = req.user.sub,
familyMother.lastUpdateFullName = req.user.name;
history.profileFamilyMotherId = familyMother.id;
history.motherPrefix = familyMother.motherPrefix,
history.motherFirstName = familyMother.motherFirstName,
history.motherLastName = familyMother.motherLastName,
history.motherCareer = familyMother.motherCareer,
history.motherCitizenId = familyMother.motherCitizenId,
history.motherLive = familyMother.motherLive,
history.lastUpdateUserId = req.user.sub,
history.lastUpdateFullName = req.user.name;
await Promise.all([
this.ProfileFamilyMother.save(familyMother),
this.ProfileFamilyMotherHistory.save(history),
]);
return new HttpSuccess();
}
}

View file

@ -141,7 +141,7 @@ export class RankController extends Controller {
async listRank() {
const rank = await this.rankRepository.find({
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
order: { createdAt: "ASC" },
order: { name: "ASC" },
});
// if (!rank) {

View file

@ -141,7 +141,7 @@ export class RelationshipController extends Controller {
async listRelationship() {
const relationship = await this.relationshipRepository.find({
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
order: { createdAt: "ASC" },
order: { name: "ASC" },
});
// if (!relationship) {
// return new HttpSuccess([]);

View file

@ -141,7 +141,7 @@ export class ReligionController extends Controller {
async listReligion() {
const religion = await this.religionRepository.find({
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
order: { createdAt: "ASC" },
order: { name: "ASC" },
});
// if (!religion) {