โครงการเพิ่มบันทึกยุทธศาสตร์
This commit is contained in:
parent
650c6fe3e3
commit
be703f8e3b
16 changed files with 930 additions and 84 deletions
|
|
@ -185,6 +185,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
@Query("year") year?: number,
|
||||
@Query("root") root?: number,
|
||||
) {
|
||||
const type = "OFFICER";
|
||||
const [development, total] = await AppDataSource.getRepository(DevelopmentHistory)
|
||||
|
|
@ -192,14 +193,18 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
.leftJoinAndSelect("developmentHistory.development", "development")
|
||||
.leftJoinAndSelect("developmentHistory.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("developmentHistory.posType", "posType")
|
||||
.andWhere(year != 0 && year != null && year != undefined ? "development.year = :year" : "1=1", { year: year })
|
||||
.andWhere(
|
||||
year != 0 && year != null && year != undefined ? "development.year = :year" : "1=1",
|
||||
{ year: year },
|
||||
)
|
||||
.andWhere(root != null && root != undefined ? "development.root = :root" : "1=1", {
|
||||
root: root,
|
||||
})
|
||||
.andWhere("developmentHistory.type = :type", { type: type })
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
keyword != null && keyword != ""
|
||||
? "developmentHistory.prefix LIKE :keyword"
|
||||
: "1=1",
|
||||
keyword != null && keyword != "" ? "developmentHistory.prefix LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
|
|
@ -237,25 +242,19 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "development.projectName LIKE :keyword"
|
||||
: "1=1",
|
||||
keyword != null && keyword != "" ? "development.projectName LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "posType.posTypeName LIKE :keyword"
|
||||
: "1=1",
|
||||
keyword != null && keyword != "" ? "posType.posTypeName LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "posLevel.posLevelName LIKE :keyword"
|
||||
: "1=1",
|
||||
keyword != null && keyword != "" ? "posLevel.posLevelName LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
|
|
@ -266,10 +265,10 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
const formattedData = development.map(item => ({
|
||||
const formattedData = development.map((item) => ({
|
||||
id: item.id,
|
||||
citizenId: item.citizenId,
|
||||
fullName: item.prefix+item.firstName+" "+item.lastName,
|
||||
fullName: item.prefix + item.firstName + " " + item.lastName,
|
||||
position: item.position,
|
||||
posType: item.posType ? item.posType.posTypeName : null,
|
||||
posLevel: item.posLevel ? item.posLevel.posLevelName : null,
|
||||
|
|
@ -287,11 +286,11 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
*
|
||||
* @param {string} id Id โครงการ
|
||||
*/
|
||||
@Get("{id}")
|
||||
@Get("{id}")
|
||||
async GetDevelopemtHistoryById(@Path() id: string) {
|
||||
const type = "OFFICER";
|
||||
const getDevelopment = await this.developmentHistoryRepository.findOne({
|
||||
relations: ["development","posLevel","posType"],
|
||||
relations: ["development", "posLevel", "posType"],
|
||||
where: { id: id, type: type },
|
||||
});
|
||||
if (!getDevelopment) {
|
||||
|
|
@ -306,7 +305,9 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
citizenId: getDevelopment.citizenId ? getDevelopment.citizenId : null,
|
||||
position: getDevelopment.position ? getDevelopment.position : null,
|
||||
posLevelId: getDevelopment.posLevelId ? getDevelopment.posLevelId : null,
|
||||
posLevelName: getDevelopment.posLevel.posLevelName ? getDevelopment.posLevel.posLevelName : null,
|
||||
posLevelName: getDevelopment.posLevel.posLevelName
|
||||
? getDevelopment.posLevel.posLevelName
|
||||
: null,
|
||||
posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null,
|
||||
posTypeName: getDevelopment.posType.posTypeName ? getDevelopment.posType.posTypeName : null,
|
||||
posExecutive: getDevelopment.posExecutive ? getDevelopment.posExecutive : null,
|
||||
|
|
@ -314,17 +315,27 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
order: getDevelopment.order ? getDevelopment.order : null,
|
||||
dateOrder: getDevelopment.dateOrder ? getDevelopment.dateOrder : null,
|
||||
year: getDevelopment.development.year ? getDevelopment.development.year : null,
|
||||
projectName: getDevelopment.development.projectName ? getDevelopment.development.projectName : null,
|
||||
projectName: getDevelopment.development.projectName
|
||||
? getDevelopment.development.projectName
|
||||
: null,
|
||||
dateStart: getDevelopment.development.dateStart ? getDevelopment.development.dateStart : null,
|
||||
dateEnd: getDevelopment.development.dateEnd ? getDevelopment.development.dateEnd : null,
|
||||
totalDate: getDevelopment.development.totalDate ? getDevelopment.development.totalDate : null,
|
||||
addressAcademic: getDevelopment.development.addressAcademic ? getDevelopment.development.addressAcademic : null,
|
||||
topicAcademic: getDevelopment.development.topicAcademic ? getDevelopment.development.topicAcademic : null,
|
||||
dateStudyStart: getDevelopment.development.dateStudyStart ? getDevelopment.development.dateStudyStart : null,
|
||||
dateStudyEnd: getDevelopment.development.dateStudyEnd ? getDevelopment.development.dateStudyEnd : null,
|
||||
addressAcademic: getDevelopment.development.addressAcademic
|
||||
? getDevelopment.development.addressAcademic
|
||||
: null,
|
||||
topicAcademic: getDevelopment.development.topicAcademic
|
||||
? getDevelopment.development.topicAcademic
|
||||
: null,
|
||||
dateStudyStart: getDevelopment.development.dateStudyStart
|
||||
? getDevelopment.development.dateStudyStart
|
||||
: null,
|
||||
dateStudyEnd: getDevelopment.development.dateStudyEnd
|
||||
? getDevelopment.development.dateStudyEnd
|
||||
: null,
|
||||
org: null,
|
||||
};
|
||||
|
||||
|
||||
return new HttpSuccess(formattedData);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue