check workflow

This commit is contained in:
kittapath 2024-10-22 08:20:45 +07:00
parent 4c2188a363
commit 32b0aa325d
74 changed files with 529 additions and 285 deletions

View file

@ -10,7 +10,7 @@ import {
Route,
Security,
Tags,
Query
Query,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
@ -51,13 +51,15 @@ export class ProfileDevelopmentController extends Controller {
@Get("{profileId}")
public async getDevelopment(
@Path() profileId: string,
@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);
let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER");
if (_workflow == false)
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const [profileDevelopment, total] = await AppDataSource.getRepository(ProfileDevelopment)
.createQueryBuilder("profileDevelopment")
.where({ profileId: profileId })
@ -67,10 +69,10 @@ export class ProfileDevelopmentController extends Controller {
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
? "profileDevelopment.name LIKE :keyword"
: "1=1",
{
keyword: `%${searchKeyword}%`,
},
)
{
keyword: `%${searchKeyword}%`,
},
)
.orWhere(
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
? "profileDevelopment.developmentTarget LIKE :keyword"
@ -108,7 +110,9 @@ export class ProfileDevelopmentController extends Controller {
public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) {
const _record = await this.developmentRepository.findOneBy({ id: developmentId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
let _workflow = await new permission().Workflow(req, developmentId, "SYS_REGISTRY_OFFICER");
if (_workflow == false)
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
const record = await this.developmentHistoryRepository.find({
where: { profileDevelopmentId: developmentId },