ผูกสิท

This commit is contained in:
kittapath 2024-08-22 14:14:35 +07:00
parent 2a536dcc32
commit 204984f63e
4 changed files with 58 additions and 27 deletions

View file

@ -896,7 +896,7 @@ export class DevelopmentController extends Controller {
developmentProjectTypes: true,
developmentProjectTechniquePlanneds: true,
developmentProjectTechniqueActuals: true,
developmentAddresss: true
developmentAddresss: true,
},
});
if (!development) {
@ -907,7 +907,7 @@ export class DevelopmentController extends Controller {
developmentProjectTypes: [],
developmentProjectTechniquePlanneds: [],
developmentProjectTechniqueActuals: [],
developmentAddresss: []
developmentAddresss: [],
});
development.lastUpdateUserId = request.user.sub;
development.lastUpdateFullName = request.user.name;
@ -1184,7 +1184,7 @@ export class DevelopmentController extends Controller {
await this.developmentAddresssRepository.remove(development.developmentAddresss, {
data: request,
});
// const before = structuredClone(development);
await Promise.all(
requestBody.developmentAddresss.map(async (x) => {
@ -1211,7 +1211,7 @@ export class DevelopmentController extends Controller {
// setLogDataDiff(request, { before, after: development });
}),
);
//End
return new HttpSuccess(development.id);
}
@ -1266,7 +1266,8 @@ export class DevelopmentController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
}
console.log(">>>>>>>>>>", requestBody.results);
let results:any = requestBody.results && requestBody.results != ""?requestBody.results:null;
let results: any =
requestBody.results && requestBody.results != "" ? requestBody.results : null;
const before = structuredClone(development);
const data = Object.assign(new DevelopmentEvaluation(), requestBody);
data.results = results;
@ -1390,7 +1391,7 @@ export class DevelopmentController extends Controller {
if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
}
if (requestBody.provinceActualId != null) {
if (requestBody.provinceActualId != null) {
const checkId = await this.provinceRepository.findOne({
where: { id: requestBody.provinceActualId },
});
@ -1494,7 +1495,8 @@ export class DevelopmentController extends Controller {
* @param {string} id Id
*/
@Get("tab7/{id}")
async GetDevelopemtTab7ById(@Path() id: string) {
async GetDevelopemtTab7ById(@Request() request: RequestWithUser, @Path() id: string) {
await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentRepository.findOne({
where: { id },
});
@ -1518,7 +1520,8 @@ export class DevelopmentController extends Controller {
* @param {string} id Id
*/
@Get("tab8/{id}")
async GetDevelopemtTab8ById(@Path() id: string) {
async GetDevelopemtTab8ById(@Request() request: RequestWithUser, @Path() id: string) {
await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentRepository.findOne({
relations: ["developmentRisks"],
where: { id: id },
@ -1531,7 +1534,9 @@ export class DevelopmentController extends Controller {
getDevelopment.developmentRisks == null
? null
: getDevelopment.developmentRisks.sort((a, b) =>
(a.createdAt.toString() == null ? "" : a.createdAt.toString()).localeCompare(b.createdAt.toString() == null ? "" : b.createdAt.toString()),
(a.createdAt.toString() == null ? "" : a.createdAt.toString()).localeCompare(
b.createdAt.toString() == null ? "" : b.createdAt.toString(),
),
),
expect: getDevelopment.expect,
};
@ -1851,6 +1856,7 @@ export class DevelopmentController extends Controller {
*/
@Get()
async GetDevelopmentLists(
@Request() request: RequestWithUser,
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query("year") year: number,
@ -1859,6 +1865,7 @@ export class DevelopmentController extends Controller {
@Query("node") node?: number | null,
@Query("keyword") keyword?: string,
) {
await new permission().PermissionList(request, "SYS_DEV_SCHOLARSHIP");
const [development, total] = await AppDataSource.getRepository(Development)
.createQueryBuilder("development")
.andWhere(year > 0 ? "development.year LIKE :year" : "1=1", {
@ -1956,7 +1963,8 @@ export class DevelopmentController extends Controller {
* @param {string} id Id
*/
@Get("tab1/{id}")
async GetDevelopemtTab1ById(@Path() id: string) {
async GetDevelopemtTab1ById(@Request() request: RequestWithUser, @Path() id: string) {
await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentRepository.findOne({
where: { id: id },
});
@ -2008,7 +2016,8 @@ export class DevelopmentController extends Controller {
* @param {string} id Id
*/
@Get("tab2/{id}")
async GetDevelopemtTab2ById(@Path() id: string) {
async GetDevelopemtTab2ById(@Request() request: RequestWithUser, @Path() id: string) {
await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentRepository.findOne({
where: { id: id },
relations: [
@ -2102,7 +2111,8 @@ export class DevelopmentController extends Controller {
* @param {string} id Id
*/
@Get("tab3/{id}")
async GetDevelopemtTab3ById(@Path() id: string) {
async GetDevelopemtTab3ById(@Request() request: RequestWithUser, @Path() id: string) {
await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentRepository.findOne({
where: { id: id },
relations: [
@ -2155,9 +2165,7 @@ export class DevelopmentController extends Controller {
dateEnd: getDevelopment.dateEnd,
totalDate: getDevelopment.totalDate,
developmentAddresss:
getDevelopment.developmentAddresss == null
? null
: getDevelopment.developmentAddresss
getDevelopment.developmentAddresss == null ? null : getDevelopment.developmentAddresss,
};
return new HttpSuccess(_getDevelopment);
}
@ -2212,7 +2220,8 @@ export class DevelopmentController extends Controller {
* @param {string} id Id
*/
@Get("tab4/{id}")
async GetDevelopemtTab4ById(@Path() id: string) {
async GetDevelopemtTab4ById(@Request() request: RequestWithUser, @Path() id: string) {
await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentRepository.findOne({
where: { id: id },
relations: ["developmentEvaluations"],
@ -2244,20 +2253,23 @@ export class DevelopmentController extends Controller {
* @param {string} id Id
*/
@Get("tab5/{id}")
async GetDevelopemtTab5ById(@Path() id: string) {
async GetDevelopemtTab5ById(@Request() request: RequestWithUser, @Path() id: string) {
await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentRepository.findOne({
relations: ["developmentOthers"],
where: { id: id },
});
if (!getDevelopment) {
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
}
let _getDevelopment = {
let _getDevelopment = {
developmentOthers:
getDevelopment.developmentOthers == null
? null
: getDevelopment.developmentOthers.sort((a, b) =>
(a.createdAt.toString() == null ? "" : a.createdAt.toString()).localeCompare(b.createdAt.toString() == null ? "" : b.createdAt.toString()),
(a.createdAt.toString() == null ? "" : a.createdAt.toString()).localeCompare(
b.createdAt.toString() == null ? "" : b.createdAt.toString(),
),
),
obstacle: getDevelopment.obstacle,
suggestion: getDevelopment.suggestion,

View file

@ -27,6 +27,7 @@ import { EmployeePosType } from "../entities/EmployeePosType";
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
import { RequestWithUser } from "../middlewares/user";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
import permission from "../interfaces/permission";
@Route("api/v1/development/history/employee")
@Tags("DevelopmentEmployeeHistory")
@ -44,7 +45,8 @@ export class DevelopmentEmployeeHistoryController extends Controller {
*
*/
@Get("org/{year}")
async GetOrgDevelopemt(@Path() year: number) {
async GetOrgDevelopemt(@Request() request: RequestWithUser, @Path() year: number) {
await new permission().PermissionList(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const getOrg = await this.developmentHistoryRepository
.createQueryBuilder("developmentHistory")
@ -76,6 +78,7 @@ export class DevelopmentEmployeeHistoryController extends Controller {
@Body() requestBody: CreateDevelopmentHistory,
@Request() request: RequestWithUser,
) {
await new permission().PermissionCreate(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const chk_name = await this.developmentHistoryRepository.find({
where: {
@ -144,6 +147,7 @@ export class DevelopmentEmployeeHistoryController extends Controller {
@Body() requestBody: UpdateDevelopmentHistory,
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const development = await this.developmentHistoryRepository.findOne({
where: { id: id, type: type },
@ -209,7 +213,8 @@ export class DevelopmentEmployeeHistoryController extends Controller {
* @param {string} id Id
*/
@Delete("{id}")
async DeleteDevelopmentHistory(@Path() id: string,@Request () request: RequestWithUser) {
async DeleteDevelopmentHistory(@Path() id: string, @Request() request: RequestWithUser) {
await new permission().PermissionDelete(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const development = await this.developmentHistoryRepository.findOne({
where: { id: id, type: type },
@ -234,6 +239,7 @@ export class DevelopmentEmployeeHistoryController extends Controller {
*/
@Post("filter")
async GetDevelopmentHistoryLists(
@Request() request: RequestWithUser,
@Body()
body: {
page: number;
@ -243,6 +249,7 @@ export class DevelopmentEmployeeHistoryController extends Controller {
root: string | null;
},
) {
await new permission().PermissionList(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const [development, total] = await AppDataSource.getRepository(DevelopmentHistory)
.createQueryBuilder("developmentHistory")
@ -352,7 +359,8 @@ export class DevelopmentEmployeeHistoryController extends Controller {
* @param {string} id Id
*/
@Get("{id}")
async GetDevelopemtHistoryById(@Path() id: string) {
async GetDevelopemtHistoryById(@Request() request: RequestWithUser, @Path() id: string) {
await new permission().PermissionGet(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const getDevelopment = await this.developmentHistoryRepository.findOne({
relations: ["development", "employeePosLevel", "employeePosType"],

View file

@ -27,6 +27,7 @@ import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel";
import { RequestWithUser } from "../middlewares/user";
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
import permission from "../interfaces/permission";
@Route("api/v1/development/history/officer")
@Tags("DevelopmentOfficerHistory")
@ -44,7 +45,8 @@ export class DevelopmentOfficerHistoryController extends Controller {
*
*/
@Get("org/{year}")
async GetOrgDevelopemt(@Path() year: number) {
async GetOrgDevelopemt(@Request() request: RequestWithUser, @Path() year: number) {
await new permission().PermissionList(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const getOrg = await this.developmentHistoryRepository
.createQueryBuilder("developmentHistory")
@ -76,6 +78,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
@Body() requestBody: CreateDevelopmentHistory,
@Request() request: RequestWithUser,
) {
await new permission().PermissionCreate(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const chk_name = await this.developmentHistoryRepository.find({
where: {
@ -140,6 +143,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
@Body() requestBody: UpdateDevelopmentHistory,
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const development = await this.developmentHistoryRepository.findOne({
where: { id: id, type: type },
@ -202,6 +206,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
*/
@Delete("{id}")
async DeleteDevelopmentHistory(@Path() id: string, @Request() request: RequestWithUser) {
await new permission().PermissionDelete(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const development = await this.developmentHistoryRepository.findOne({
where: { id: id, type: type },
@ -226,6 +231,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
*/
@Post("filter")
async GetDevelopmentHistoryLists(
@Request() request: RequestWithUser,
@Body()
body: {
page: number;
@ -235,6 +241,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
root: string | null;
},
) {
await new permission().PermissionList(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const [development, total] = await AppDataSource.getRepository(DevelopmentHistory)
.createQueryBuilder("developmentHistory")
@ -330,7 +337,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
fullName: item.prefix + item.firstName + " " + item.lastName,
position: item.position,
year: item.development.year,
root: item.development.root,//test
root: item.development.root, //test
posType: item.posType ? item.posType.posTypeName : null,
posLevel: item.posLevel ? item.posLevel.posLevelName : null,
posExecutive: item.posExecutive,
@ -348,7 +355,8 @@ export class DevelopmentOfficerHistoryController extends Controller {
* @param {string} id Id
*/
@Get("{id}")
async GetDevelopemtHistoryById(@Path() id: string) {
async GetDevelopemtHistoryById(@Request() request: RequestWithUser, @Path() id: string) {
await new permission().PermissionGet(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const getDevelopment = await this.developmentHistoryRepository.findOne({
relations: ["development", "posLevel", "posType"],

View file

@ -196,12 +196,14 @@ export class DevelopmentScholarshipController extends Controller {
*/
@Get()
async GetDevelopmentScholarshipLists(
@Request() request: RequestWithUser,
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query("keyword") keyword?: string,
@Query("year") year?: number,
@Query("scholarshipType") scholarshipType?: string,
) {
await new permission().PermissionList(request, "SYS_DEV_SCHOLARSHIP");
const [development, total] = await AppDataSource.getRepository(DevelopmentScholarship)
.createQueryBuilder("developmentScholarship")
.leftJoinAndSelect("developmentScholarship.posLevel", "posLevel")
@ -292,7 +294,8 @@ export class DevelopmentScholarshipController extends Controller {
* @param {string} id Id
*/
@Get("{id}")
async GetDevelopemtScholarshipById(@Path() id: string) {
async GetDevelopemtScholarshipById(@Request() request: RequestWithUser, @Path() id: string) {
await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentScholarshipRepository.findOne({
relations: ["posLevel", "posType", "posLevelguarantor", "posTypeguarantor"],
where: { id: id },