parent
ee3975c934
commit
b7ae2e35a4
2 changed files with 64 additions and 18 deletions
|
|
@ -301,17 +301,8 @@ export class DevelopmentRequestController extends Controller {
|
|||
});
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER");
|
||||
const before = structuredClone(record);
|
||||
requestBody.status = requestBody.status.trim().toUpperCase();
|
||||
Object.assign(record, requestBody);
|
||||
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
|
||||
await this.developmentRequestRepository.save(record, { data: req });
|
||||
setLogDataDiff(req, { before, after: record });
|
||||
if (requestBody.status == "APPROVE") {
|
||||
|
||||
if (requestBody.status == "APPROVE" && record.status == "PENDING") {
|
||||
let profileDevelopment = new ProfileDevelopment();
|
||||
const meta = {
|
||||
createdUserId: req.user.sub,
|
||||
|
|
@ -368,7 +359,16 @@ export class DevelopmentRequestController extends Controller {
|
|||
);
|
||||
}
|
||||
}
|
||||
const before = structuredClone(record);
|
||||
requestBody.status = requestBody.status.trim().toUpperCase();
|
||||
Object.assign(record, requestBody);
|
||||
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
|
||||
await this.developmentRequestRepository.save(record, { data: req });
|
||||
setLogDataDiff(req, { before, after: record });
|
||||
return new HttpSuccess(record.id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import {
|
|||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Query
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
|
|
@ -25,7 +26,7 @@ import {
|
|||
} from "../entities/ProfileDevelopment";
|
||||
import permission from "../interfaces/permission";
|
||||
import { DevelopmentProject } from "../entities/DevelopmentProject";
|
||||
import { In } from "typeorm";
|
||||
import { In, Brackets } from "typeorm";
|
||||
@Route("api/v1/org/profile/development")
|
||||
@Tags("ProfileDevelopment")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -49,13 +50,58 @@ export class ProfileDevelopmentController extends Controller {
|
|||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getDevelopment(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
public async getDevelopment(
|
||||
@Path() profileId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query() searchKeyword: string = "",
|
||||
) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
const [profileDevelopment, total] = await AppDataSource.getRepository(ProfileDevelopment)
|
||||
.createQueryBuilder("profileDevelopment")
|
||||
.where({ profileId: profileId })
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
||||
? "profileDevelopment.name LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${searchKeyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
||||
? "profileDevelopment.developmentTarget LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${searchKeyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
||||
? "profileDevelopment.developmentResults LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${searchKeyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
||||
? "profileDevelopment.developmentReport LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${searchKeyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("profileDevelopment.createdAt", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
return new HttpSuccess({ data: profileDevelopment, total });
|
||||
}
|
||||
|
||||
@Get("history/{developmentId}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue