Merge branch 'develop' into adiDev
This commit is contained in:
commit
eb1e797354
10 changed files with 964 additions and 8 deletions
|
|
@ -14,6 +14,7 @@ import { In } from "typeorm";
|
|||
import permission from "../interfaces/permission";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
const REDIS_HOST = process.env.REDIS_HOST;
|
||||
const REDIS_PORT = process.env.REDIS_PORT;
|
||||
|
||||
|
|
@ -28,6 +29,7 @@ export class PermissionController extends Controller {
|
|||
private authRoleRepo = AppDataSource.getRepository(AuthRole);
|
||||
private authRoleAttrRepo = AppDataSource.getRepository(AuthRoleAttr);
|
||||
private authSysRepo = AppDataSource.getRepository(AuthSys);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
private redis = require("redis");
|
||||
|
||||
@Get("")
|
||||
|
|
@ -118,6 +120,13 @@ export class PermissionController extends Controller {
|
|||
|
||||
@Get("menu")
|
||||
public async listAuthSys(@Request() request: { user: Record<string, any> }) {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
});
|
||||
const redisClient = await this.redis.createClient({
|
||||
host: REDIS_HOST,
|
||||
port: REDIS_PORT,
|
||||
|
|
@ -148,10 +157,11 @@ export class PermissionController extends Controller {
|
|||
select: ["authRoleId"],
|
||||
where: {
|
||||
current_holderId: profile.id,
|
||||
orgRevision: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
// orgRevision: {
|
||||
// orgRevisionIsDraft: false,
|
||||
// orgRevisionIsCurrent: true,
|
||||
// },
|
||||
orgRevisionId: orgRevision?.id
|
||||
},
|
||||
});
|
||||
if (!posMaster) {
|
||||
|
|
@ -159,10 +169,11 @@ export class PermissionController extends Controller {
|
|||
select: ["authRoleId"],
|
||||
where: {
|
||||
current_holderId: profile.id,
|
||||
orgRevision: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
// orgRevision: {
|
||||
// orgRevisionIsDraft: false,
|
||||
// orgRevisionIsCurrent: true,
|
||||
// },
|
||||
orgRevisionId: orgRevision?.id
|
||||
},
|
||||
});
|
||||
if (!posMaster) {
|
||||
|
|
|
|||
231
src/controllers/ProfileDevelopmentController.ts
Normal file
231
src/controllers/ProfileDevelopmentController.ts
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
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 { ProfileDevelopmentHistory } from "../entities/ProfileDevelopmentHistory";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { CreateProfileDevelopment, ProfileDevelopment, UpdateProfileDevelopment } from "../entities/ProfileDevelopment";
|
||||
import permission from "../interfaces/permission";
|
||||
import { DevelopmentProject } from "../entities/developmentProject";
|
||||
@Route("api/v1/org/profile/development")
|
||||
@Tags("ProfileDevelopment")
|
||||
@Security("bearerAuth")
|
||||
export class ProfileDevelopmentController extends Controller {
|
||||
private profileRepository = AppDataSource.getRepository(Profile);
|
||||
private developmentRepository = AppDataSource.getRepository(ProfileDevelopment);
|
||||
private developmentHistoryRepository = AppDataSource.getRepository(ProfileDevelopmentHistory);
|
||||
private developmentProjectRepository = AppDataSource.getRepository(DevelopmentProject);
|
||||
|
||||
@Get("user")
|
||||
public async getDevelopmentUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepository.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
result: [
|
||||
{
|
||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
||||
isActive: true,
|
||||
date: "2024-03-12T10:09:47.000Z",
|
||||
reference: "string",
|
||||
detail: "string",
|
||||
refCommandNo: "string",
|
||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
||||
},
|
||||
],
|
||||
})
|
||||
public async getDevelopment(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileId: profileId },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("history/{developmentId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
result: [
|
||||
{
|
||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
||||
isActive: true,
|
||||
date: "2024-03-12T10:09:47.000Z",
|
||||
detail: "string",
|
||||
},
|
||||
{
|
||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
||||
isActive: true,
|
||||
date: "2024-03-12T10:09:47.000Z",
|
||||
detail: "string",
|
||||
},
|
||||
],
|
||||
})
|
||||
public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.developmentRepository.findOneBy({ id: developmentId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const record = await this.developmentHistoryRepository.find({
|
||||
where: { profileDevelopmentId: developmentId },
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Post()
|
||||
public async newDevelopment(@Request() req: RequestWithUser, @Body() body: CreateProfileDevelopment) {
|
||||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
const profile = await this.profileRepository.findOneBy({ id: body.profileId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
|
||||
const data = new ProfileDevelopment();
|
||||
|
||||
const meta = {
|
||||
createdUserId: req.user.sub,
|
||||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
const history = new ProfileDevelopmentHistory();
|
||||
Object.assign(history, { ...data, id: undefined });
|
||||
|
||||
await this.developmentRepository.save(data);
|
||||
history.profileDevelopmentId = data.id;
|
||||
await this.developmentHistoryRepository.save(history);
|
||||
|
||||
if (body.developmentProjects != null) {
|
||||
await Promise.all(
|
||||
body.developmentProjects.map(async (x) => {
|
||||
let data1 = new DevelopmentProject();
|
||||
data1.name = x;
|
||||
data1.createdUserId = req.user.sub;
|
||||
data1.createdFullName = req.user.name;
|
||||
data1.lastUpdateUserId = req.user.sub;
|
||||
data1.lastUpdateFullName = req.user.name;
|
||||
data1.profileDevelopmentId = data.id;
|
||||
await this.developmentProjectRepository.save(data1);
|
||||
let data2 = new DevelopmentProject();
|
||||
data2.name = x;
|
||||
data2.createdUserId = req.user.sub;
|
||||
data2.createdFullName = req.user.name;
|
||||
data2.lastUpdateUserId = req.user.sub;
|
||||
data2.lastUpdateFullName = req.user.name;
|
||||
data2.profileDevelopmentId = data.id;
|
||||
await this.developmentProjectRepository.save(data2);
|
||||
}),
|
||||
);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Patch("{developmentId}")
|
||||
public async editDevelopment(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body() body: UpdateProfileDevelopment,
|
||||
@Path() developmentId: string,
|
||||
) {
|
||||
const record = await this.developmentRepository.findOne({ where:{id: developmentId},
|
||||
relations: ["developmentProjects"], });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
|
||||
const history = new ProfileDevelopmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
|
||||
history.profileDevelopmentId = developmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
|
||||
await Promise.all([
|
||||
this.developmentRepository.save(record),
|
||||
this.developmentHistoryRepository.save(history),
|
||||
]);
|
||||
await this.developmentProjectRepository.remove(record.developmentProjects);
|
||||
|
||||
if (body.developmentProjects != null) {
|
||||
await Promise.all(
|
||||
body.developmentProjects.map(async (x) => {
|
||||
let data1 = new DevelopmentProject();
|
||||
data1.name = x;
|
||||
data1.createdUserId = req.user.sub;
|
||||
data1.createdFullName = req.user.name;
|
||||
data1.lastUpdateUserId = req.user.sub;
|
||||
data1.lastUpdateFullName = req.user.name;
|
||||
data1.profileDevelopmentId = record.id;
|
||||
await this.developmentProjectRepository.save(data1);
|
||||
let data2 = new DevelopmentProject();
|
||||
data2.name = x;
|
||||
data2.createdUserId = req.user.sub;
|
||||
data2.createdFullName = req.user.name;
|
||||
data2.lastUpdateUserId = req.user.sub;
|
||||
data2.lastUpdateFullName = req.user.name;
|
||||
data2.profileDevelopmentId = history.id;
|
||||
await this.developmentProjectRepository.save(data2);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{developmentId}")
|
||||
public async deleteDevelopment(@Path() developmentId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.developmentRepository.findOneBy({ id: developmentId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
await this.developmentProjectRepository.delete({profileDevelopmentId:developmentId});
|
||||
await this.developmentProjectRepository.delete({profileDevelopmentHistory:{profileDevelopmentId:developmentId}});
|
||||
await this.developmentHistoryRepository.delete({
|
||||
profileDevelopmentId: developmentId,
|
||||
});
|
||||
|
||||
const result = await this.developmentRepository.delete({ id: developmentId });
|
||||
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
153
src/controllers/ProfileDevelopmentEmployeeController.ts
Normal file
153
src/controllers/ProfileDevelopmentEmployeeController.ts
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
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 { ProfileDevelopmentHistory } from "../entities/ProfileDevelopmentHistory";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import {
|
||||
CreateProfileEmployeeDevelopment,
|
||||
ProfileDevelopment,
|
||||
UpdateProfileDevelopment,
|
||||
} from "../entities/ProfileDevelopment";
|
||||
import permission from "../interfaces/permission";
|
||||
@Route("api/v1/org/profile-employee/development")
|
||||
@Tags("ProfileDevelopment")
|
||||
@Security("bearerAuth")
|
||||
export class ProfileDevelopmentEmployeeController extends Controller {
|
||||
private profileRepository = AppDataSource.getRepository(ProfileEmployee);
|
||||
private developmentRepository = AppDataSource.getRepository(ProfileDevelopment);
|
||||
private developmentHistoryRepository = AppDataSource.getRepository(ProfileDevelopmentHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getDevelopmentUser(@Request() request: RequestWithUser) {
|
||||
const profile = await this.profileRepository.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getDevelopment(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileId);
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("history/{developmentId}")
|
||||
public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.developmentRepository.findOneBy({ id: developmentId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
||||
}
|
||||
const record = await this.developmentHistoryRepository.find({
|
||||
where: { profileDevelopmentId: developmentId },
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Post()
|
||||
public async newDevelopment(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeDevelopment) {
|
||||
if (!body.profileEmployeeId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
const profile = await this.profileRepository.findOneBy({ id: body.profileEmployeeId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id);
|
||||
|
||||
const data = new ProfileDevelopment();
|
||||
|
||||
const meta = {
|
||||
createdUserId: req.user.sub,
|
||||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
const history = new ProfileDevelopmentHistory();
|
||||
Object.assign(history, { ...data, id: undefined });
|
||||
|
||||
await this.developmentRepository.save(data);
|
||||
history.profileDevelopmentId = data.id;
|
||||
await this.developmentHistoryRepository.save(history);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Patch("{developmentId}")
|
||||
public async editDevelopment(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body() body: UpdateProfileDevelopment,
|
||||
@Path() developmentId: string,
|
||||
) {
|
||||
|
||||
const record = await this.developmentRepository.findOneBy({ id: developmentId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
||||
|
||||
const history = new ProfileDevelopmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
|
||||
history.profileDevelopmentId = developmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
|
||||
await Promise.all([
|
||||
this.developmentRepository.save(record),
|
||||
this.developmentHistoryRepository.save(history),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{developmentId}")
|
||||
public async deleteDevelopment(@Path() developmentId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.developmentRepository.findOneBy({ id: developmentId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
||||
}
|
||||
|
||||
await this.developmentHistoryRepository.delete({
|
||||
profileDevelopmentId: developmentId,
|
||||
});
|
||||
|
||||
const result = await this.developmentRepository.delete({ id: developmentId });
|
||||
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
147
src/controllers/ProfileDevelopmentEmployeeTempController.ts
Normal file
147
src/controllers/ProfileDevelopmentEmployeeTempController.ts
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
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 { ProfileDevelopmentHistory } from "../entities/ProfileDevelopmentHistory";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import {
|
||||
CreateProfileEmployeeDevelopment,
|
||||
ProfileDevelopment,
|
||||
UpdateProfileDevelopment,
|
||||
} from "../entities/ProfileDevelopment";
|
||||
import permission from "../interfaces/permission";
|
||||
@Route("api/v1/org/profile-temp/development")
|
||||
@Tags("ProfileDevelopment")
|
||||
@Security("bearerAuth")
|
||||
export class ProfileDevelopmentEmployeeTempController extends Controller {
|
||||
private profileRepository = AppDataSource.getRepository(ProfileEmployee);
|
||||
private developmentRepository = AppDataSource.getRepository(ProfileDevelopment);
|
||||
private developmentHistoryRepository = AppDataSource.getRepository(ProfileDevelopmentHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getDevelopmentUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepository.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getDevelopment(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("history/{developmentId}")
|
||||
public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.developmentHistoryRepository.find({
|
||||
where: { profileDevelopmentId: developmentId },
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Post()
|
||||
public async newDevelopment(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeDevelopment) {
|
||||
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP");
|
||||
if (!body.profileEmployeeId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
const profile = await this.profileRepository.findOneBy({ id: body.profileEmployeeId });
|
||||
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
const data = new ProfileDevelopment();
|
||||
|
||||
const meta = {
|
||||
createdUserId: req.user.sub,
|
||||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
const history = new ProfileDevelopmentHistory();
|
||||
Object.assign(history, { ...data, id: undefined });
|
||||
|
||||
await this.developmentRepository.save(data);
|
||||
history.profileDevelopmentId = data.id;
|
||||
await this.developmentHistoryRepository.save(history);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Patch("{developmentId}")
|
||||
public async editDevelopment(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body() body: UpdateProfileDevelopment,
|
||||
@Path() developmentId: string,
|
||||
) {
|
||||
await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.developmentRepository.findOneBy({ id: developmentId });
|
||||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const history = new ProfileDevelopmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
|
||||
history.profileDevelopmentId = developmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
|
||||
await Promise.all([
|
||||
this.developmentRepository.save(record),
|
||||
this.developmentHistoryRepository.save(history),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{developmentId}")
|
||||
public async deleteDevelopment(@Path() developmentId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
await this.developmentHistoryRepository.delete({
|
||||
profileDevelopmentId: developmentId,
|
||||
});
|
||||
|
||||
const result = await this.developmentRepository.delete({ id: developmentId });
|
||||
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@ import { ProfileChildren } from "./ProfileChildren";
|
|||
import { ProfileDiscipline } from "./ProfileDiscipline";
|
||||
import { ProfileEmployee } from "./ProfileEmployee";
|
||||
import { ProfileEdit } from "./ProfileEdit";
|
||||
import { ProfileDevelopment } from "./ProfileDevelopment";
|
||||
|
||||
@Entity("profile")
|
||||
export class Profile extends EntityBase {
|
||||
|
|
@ -338,6 +339,9 @@ export class Profile extends EntityBase {
|
|||
@OneToMany(() => ProfileOther, (profileOther) => profileOther.profile)
|
||||
profileOthers: ProfileOther[];
|
||||
|
||||
@OneToMany(() => ProfileDevelopment, (profileDevelopment) => profileDevelopment.profile)
|
||||
profileDevelopments: ProfileDevelopment[];
|
||||
|
||||
@OneToMany(() => ProfileAvatar, (profileAvatar) => profileAvatar.profile)
|
||||
profileAvatars: ProfileAvatar[];
|
||||
|
||||
|
|
|
|||
184
src/entities/ProfileDevelopment.ts
Normal file
184
src/entities/ProfileDevelopment.ts
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { Profile } from "./Profile";
|
||||
import { ProfileEmployee } from "./ProfileEmployee";
|
||||
import { ProfileDevelopmentHistory } from "./ProfileDevelopmentHistory";
|
||||
import { DevelopmentProject } from "./developmentProject";
|
||||
|
||||
@Entity("profileDevelopment")
|
||||
export class ProfileDevelopment extends EntityBase {
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง Profile",
|
||||
default: null,
|
||||
})
|
||||
profileId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง ProfileEmployee",
|
||||
default: null,
|
||||
})
|
||||
profileEmployeeId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อเรื่อง",
|
||||
default: null,
|
||||
})
|
||||
name: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "เป้าหมาย",
|
||||
default: null,
|
||||
})
|
||||
target: string;
|
||||
|
||||
@Column({
|
||||
type: "double",
|
||||
nullable: true,
|
||||
default: null,
|
||||
comment: "ผลการประเมิน",
|
||||
})
|
||||
summary: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ระดับคะแนน",
|
||||
default: null,
|
||||
})
|
||||
point: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "เกณฑ์การประเมิน 10",
|
||||
default: null,
|
||||
})
|
||||
achievement10: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "เกณฑ์การประเมิน 5",
|
||||
default: null,
|
||||
})
|
||||
achievement5: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "เกณฑ์การประเมิน 0",
|
||||
default: null,
|
||||
})
|
||||
achievement0: string;
|
||||
|
||||
@Column({
|
||||
comment: "วิธีพัฒนา70",
|
||||
default: false,
|
||||
})
|
||||
isDevelopment70: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "วิธีพัฒนา20",
|
||||
default: false,
|
||||
})
|
||||
isDevelopment20: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "วิธีพัฒนา10",
|
||||
default: false,
|
||||
})
|
||||
isDevelopment10: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "รายละเอียดอื่นๆ 70 แผน",
|
||||
default: null,
|
||||
})
|
||||
reasonDevelopment70: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "รายละเอียดอื่นๆ 20 แผน",
|
||||
default: null,
|
||||
})
|
||||
reasonDevelopment20: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "รายละเอียดอื่นๆ 10 แผน",
|
||||
default: null,
|
||||
})
|
||||
reasonDevelopment10: string;
|
||||
|
||||
@OneToMany(
|
||||
() => DevelopmentProject,
|
||||
(developmentProject: DevelopmentProject) => developmentProject.profileDevelopment,
|
||||
)
|
||||
developmentProjects: DevelopmentProject[];
|
||||
|
||||
@OneToMany(() => ProfileDevelopmentHistory, (profileDevelopmentHistory) => profileDevelopmentHistory.histories)
|
||||
profileDevelopmentHistories: ProfileDevelopmentHistory[];
|
||||
|
||||
@ManyToOne(() => Profile, (profile) => profile.profileDevelopments)
|
||||
@JoinColumn({ name: "profileId" })
|
||||
profile: Profile;
|
||||
|
||||
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileDevelopments)
|
||||
@JoinColumn({ name: "profileEmployeeId" })
|
||||
profileEmployee: ProfileEmployee;
|
||||
}
|
||||
|
||||
export class CreateProfileDevelopment {
|
||||
profileId: string | null;
|
||||
name: string;
|
||||
target: string | null;
|
||||
achievement10?: string | null;
|
||||
achievement5?: string | null;
|
||||
achievement0?: string | null;
|
||||
developmentProjects?: string[];
|
||||
reasonDevelopment70?: string;
|
||||
reasonDevelopment20?: string;
|
||||
reasonDevelopment10?: string;
|
||||
isDevelopment70: boolean;
|
||||
isDevelopment20: boolean;
|
||||
isDevelopment10: boolean;
|
||||
summary?: number;
|
||||
point?: number;
|
||||
}
|
||||
|
||||
export class CreateProfileEmployeeDevelopment {
|
||||
profileEmployeeId: string | null;
|
||||
name: string;
|
||||
target: string | null;
|
||||
achievement10?: string | null;
|
||||
achievement5?: string | null;
|
||||
achievement0?: string | null;
|
||||
developmentProjects?: string[];
|
||||
reasonDevelopment70?: string;
|
||||
reasonDevelopment20?: string;
|
||||
reasonDevelopment10?: string;
|
||||
isDevelopment70: boolean;
|
||||
isDevelopment20: boolean;
|
||||
isDevelopment10: boolean;
|
||||
summary?: number;
|
||||
point?: number;
|
||||
}
|
||||
|
||||
export type UpdateProfileDevelopment = {
|
||||
name: string;
|
||||
target: string | null;
|
||||
achievement10?: string | null;
|
||||
achievement5?: string | null;
|
||||
achievement0?: string | null;
|
||||
developmentProjects?: string[];
|
||||
reasonDevelopment70?: string;
|
||||
reasonDevelopment20?: string;
|
||||
reasonDevelopment10?: string;
|
||||
isDevelopment70: boolean;
|
||||
isDevelopment20: boolean;
|
||||
isDevelopment10: boolean;
|
||||
summary?: number;
|
||||
point?: number;
|
||||
};
|
||||
114
src/entities/ProfileDevelopmentHistory.ts
Normal file
114
src/entities/ProfileDevelopmentHistory.ts
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { ProfileDevelopment } from "./ProfileDevelopment";
|
||||
import { DevelopmentProject } from "./developmentProject";
|
||||
|
||||
@Entity("profileDevelopmentHistory")
|
||||
export class ProfileDevelopmentHistory extends EntityBase {
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อเรื่อง",
|
||||
default: null,
|
||||
})
|
||||
name: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "เป้าหมาย",
|
||||
default: null,
|
||||
})
|
||||
target: string;
|
||||
|
||||
@Column({
|
||||
type: "double",
|
||||
nullable: true,
|
||||
default: null,
|
||||
comment: "ผลการประเมิน",
|
||||
})
|
||||
summary: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ระดับคะแนน",
|
||||
default: null,
|
||||
})
|
||||
point: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "เกณฑ์การประเมิน 10",
|
||||
default: null,
|
||||
})
|
||||
achievement10: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "เกณฑ์การประเมิน 5",
|
||||
default: null,
|
||||
})
|
||||
achievement5: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "เกณฑ์การประเมิน 0",
|
||||
default: null,
|
||||
})
|
||||
achievement0: string;
|
||||
|
||||
@Column({
|
||||
comment: "วิธีพัฒนา70",
|
||||
default: false,
|
||||
})
|
||||
isDevelopment70: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "วิธีพัฒนา20",
|
||||
default: false,
|
||||
})
|
||||
isDevelopment20: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "วิธีพัฒนา10",
|
||||
default: false,
|
||||
})
|
||||
isDevelopment10: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "รายละเอียดอื่นๆ 70 แผน",
|
||||
default: null,
|
||||
})
|
||||
reasonDevelopment70: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "รายละเอียดอื่นๆ 20 แผน",
|
||||
default: null,
|
||||
})
|
||||
reasonDevelopment20: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "รายละเอียดอื่นๆ 10 แผน",
|
||||
default: null,
|
||||
})
|
||||
reasonDevelopment10: string;
|
||||
|
||||
@OneToMany(
|
||||
() => DevelopmentProject,
|
||||
(developmentHistoryProject: DevelopmentProject) => developmentHistoryProject.profileDevelopmentHistory,
|
||||
)
|
||||
developmentHistoryProjects: DevelopmentProject[];
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง Profile",
|
||||
default: null,
|
||||
})
|
||||
profileDevelopmentId: string;
|
||||
|
||||
@ManyToOne(() => ProfileDevelopment, (profileDevelopment) => profileDevelopment.profileDevelopmentHistories)
|
||||
@JoinColumn({ name: "profileDevelopmentId" })
|
||||
histories: ProfileDevelopment;
|
||||
}
|
||||
|
|
@ -31,6 +31,7 @@ import { SubDistrict } from "./SubDistrict";
|
|||
import { ProfileEmployeeInformationHistory } from "./ProfileEmployeeInformationHistory";
|
||||
import { ProfileEmployeeEmployment } from "./ProfileEmployeeEmployment";
|
||||
import { ProfileEdit } from "./ProfileEdit";
|
||||
import { ProfileDevelopment } from "./ProfileDevelopment";
|
||||
|
||||
@Entity("profileEmployee")
|
||||
export class ProfileEmployee extends EntityBase {
|
||||
|
|
@ -626,6 +627,9 @@ export class ProfileEmployee extends EntityBase {
|
|||
@OneToMany(() => ProfileOther, (v) => v.profileEmployee)
|
||||
profileOthers: ProfileOther[];
|
||||
|
||||
@OneToMany(() => ProfileDevelopment, (v) => v.profileEmployee)
|
||||
profileDevelopments: ProfileDevelopment[];
|
||||
|
||||
@OneToMany(() => ProfileAvatar, (v) => v.profileEmployee)
|
||||
profileAvatars: ProfileAvatar[];
|
||||
|
||||
|
|
|
|||
56
src/entities/developmentProject.ts
Normal file
56
src/entities/developmentProject.ts
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { ProfileDevelopment } from "./ProfileDevelopment";
|
||||
import { ProfileDevelopmentHistory } from "./ProfileDevelopmentHistory";
|
||||
|
||||
@Entity("developmentProject")
|
||||
export class DevelopmentProject extends EntityBase {
|
||||
@Column({
|
||||
// TRAINING = การอบรม
|
||||
// MEETING = การประชุม
|
||||
// SEMINAR = การสัมมนา
|
||||
// STUDY_TOUR = การศึกษาดูงาน
|
||||
// ACADEMIC_SEMINAR = การสัมมนาทางวิชาการ
|
||||
// WORKSHOP = การสัมมนาเชิงปฏิบัติการ
|
||||
// SPECIAL_LECTURE = การบรรยายพิเศษ
|
||||
// LECTURE = การบรรยาย
|
||||
// STUDY_TRAINING = การฝึกศึกษา
|
||||
// OTHER = อื่น
|
||||
nullable: true,
|
||||
comment: "เทคนิควิธีการที่ใช้ในการพัฒนา",
|
||||
default: null,
|
||||
})
|
||||
name: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "โครงการ/หลักสูตรการฝึกอบรม",
|
||||
default: null,
|
||||
})
|
||||
profileDevelopmentId: string;
|
||||
|
||||
@ManyToOne(
|
||||
() => ProfileDevelopment,
|
||||
(profileDevelopment: ProfileDevelopment) => profileDevelopment.developmentProjects,
|
||||
)
|
||||
@JoinColumn({ name: "profileDevelopmentId" })
|
||||
profileDevelopment: ProfileDevelopment;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "โครงการ/หลักสูตรการฝึกอบรม",
|
||||
default: null,
|
||||
})
|
||||
profileDevelopmentHistoryId: string;
|
||||
|
||||
@ManyToOne(
|
||||
() => ProfileDevelopmentHistory,
|
||||
(profileDevelopmentHistory: ProfileDevelopmentHistory) => profileDevelopmentHistory.developmentHistoryProjects,
|
||||
)
|
||||
@JoinColumn({ name: "profileDevelopmentHistoryId" })
|
||||
profileDevelopmentHistory: ProfileDevelopmentHistory;
|
||||
}
|
||||
export class CreateDevelopmentProject {
|
||||
@Column()
|
||||
name: string;
|
||||
}
|
||||
52
src/migration/1724689893914-add_profiledevelopment.ts
Normal file
52
src/migration/1724689893914-add_profiledevelopment.ts
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddProfiledevelopment1724689893914 implements MigrationInterface {
|
||||
name = 'AddProfiledevelopment1724689893914'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
// await queryRunner.query(`CREATE TABLE \`subDistrictImport\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`PROVINCE_CODE\` varchar(255) NULL, \`AMPHUR_CODE\` varchar(255) NULL, \`DISTRICT_CODE\` varchar(255) NULL, \`DISTRICT_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
// await queryRunner.query(`CREATE TABLE \`provinceImport\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`PROVINCE_CODE\` varchar(255) NULL, \`PROVINCE_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`developmentProject\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`name\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา', \`profileDevelopmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', \`profileDevelopmentHistoryId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`profileDevelopmentHistory\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`name\` varchar(255) NULL COMMENT 'ชื่อเรื่อง', \`target\` varchar(255) NULL COMMENT 'เป้าหมาย', \`summary\` double NULL COMMENT 'ผลการประเมิน', \`point\` int NULL COMMENT 'ระดับคะแนน', \`achievement10\` varchar(255) NULL COMMENT 'เกณฑ์การประเมิน 10', \`achievement5\` varchar(255) NULL COMMENT 'เกณฑ์การประเมิน 5', \`achievement0\` varchar(255) NULL COMMENT 'เกณฑ์การประเมิน 0', \`isDevelopment70\` tinyint NOT NULL COMMENT 'วิธีพัฒนา70' DEFAULT 0, \`isDevelopment20\` tinyint NOT NULL COMMENT 'วิธีพัฒนา20' DEFAULT 0, \`isDevelopment10\` tinyint NOT NULL COMMENT 'วิธีพัฒนา10' DEFAULT 0, \`reasonDevelopment70\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 70 แผน', \`reasonDevelopment20\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 20 แผน', \`reasonDevelopment10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน', \`profileDevelopmentId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง Profile', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`profileDevelopment\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง Profile', \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee', \`name\` varchar(255) NULL COMMENT 'ชื่อเรื่อง', \`target\` varchar(255) NULL COMMENT 'เป้าหมาย', \`summary\` double NULL COMMENT 'ผลการประเมิน', \`point\` int NULL COMMENT 'ระดับคะแนน', \`achievement10\` varchar(255) NULL COMMENT 'เกณฑ์การประเมิน 10', \`achievement5\` varchar(255) NULL COMMENT 'เกณฑ์การประเมิน 5', \`achievement0\` varchar(255) NULL COMMENT 'เกณฑ์การประเมิน 0', \`isDevelopment70\` tinyint NOT NULL COMMENT 'วิธีพัฒนา70' DEFAULT 0, \`isDevelopment20\` tinyint NOT NULL COMMENT 'วิธีพัฒนา20' DEFAULT 0, \`isDevelopment10\` tinyint NOT NULL COMMENT 'วิธีพัฒนา10' DEFAULT 0, \`reasonDevelopment70\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 70 แผน', \`reasonDevelopment20\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 20 แผน', \`reasonDevelopment10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
// await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_OFFICER_FAMILY\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`FATHER_RANK_NAME\` text NULL, \`FATHER_FNAME\` text NULL, \`FATHER_LNAME\` text NULL, \`MOTHER_RANK_NAME\` text NULL, \`MOTHER_FNAME\` text NULL, \`MOTHER_LNAME\` text NULL, \`SPOUSE_RANK_NAME\` text NULL, \`SPOUSE_FNAME\` text NULL, \`SPOUSE_LNAME\` text NULL, \`SPOUSE_ID\` text NULL, \`MARRIAGE_STATE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
// await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_OFFICER_ADDRESS\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`PROVINCE_CODE\` text NULL, \`AMPHUR_CODE\` text NULL, \`DISTRICT_CODE\` text NULL, \`CONTACT_PROVINCE_CODE\` text NULL, \`CONTACT_AMPHUR_CODE\` text NULL, \`CONTACT_DISTRICT_CODE\` text NULL, \`H_NUMBER\` text NULL, \`ZIPCODE\` text NULL, \`CONTACT_H_NUMBER\` text NULL, \`CONTACT_ZIPCODE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
// await queryRunner.query(`CREATE TABLE \`HR_POSITION_OFFICER\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`MP_POS_DATE\` text NULL, \`SALARY\` text NULL, \`MP_COMMAND_NUM\` text NULL, \`POS_NUM_NAME\` text NULL, \`POS_NUM_CODE\` text NULL, \`FLAG_TO_NAME\` text NULL, \`WORK_LINE_NAME\` text NULL, \`SPECIALIST_NAME\` text NULL, \`ADMIN_NAME\` text NULL, \`REMARK\` text NULL, \`ORDER_MOVE_POSITION\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
// await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_EMP_FAMILY\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`FATHER_RANK_NAME\` text NULL, \`FATHER_FNAME\` text NULL, \`FATHER_LNAME\` text NULL, \`MOTHER_RANK_NAME\` text NULL, \`MOTHER_FNAME\` text NULL, \`MOTHER_LNAME\` text NULL, \`SPOUSE_RANK_NAME\` text NULL, \`SPOUSE_FNAME\` text NULL, \`SPOUSE_LNAME\` text NULL, \`SPOUSE_ID\` text NULL, \`MARRIAGE_STATE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
// await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_EMP_ADDRESS\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`PROVINCE_CODE\` text NULL, \`AMPHUR_CODE\` text NULL, \`DISTRICT_CODE\` text NULL, \`CONTACT_PROVINCE_CODE\` text NULL, \`CONTACT_AMPHUR_CODE\` text NULL, \`CONTACT_DISTRICT_CODE\` text NULL, \`H_NUMBER\` text NULL, \`ZIPCODE\` text NULL, \`CONTACT_H_NUMBER\` text NULL, \`CONTACT_ZIPCODE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
// await queryRunner.query(`CREATE TABLE \`HR_EDUCATION_EMP\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`EDUCATION_CODE\` text NULL, \`START_EDUCATION_YEAR\` text NULL, \`EDUCATION_YEAR\` text NULL, \`INSTITUE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
// await queryRunner.query(`CREATE TABLE \`HR_EDUCATION\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`EDUCATION_CODE\` text NULL, \`START_EDUCATION_YEAR\` text NULL, \`EDUCATION_YEAR\` text NULL, \`INSTITUE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
// await queryRunner.query(`CREATE TABLE \`educationMis\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`EDUCATION_CODE\` varchar(255) NULL, \`EDUCATION_NAME\` varchar(255) NULL, \`EDUCATION_ABB_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
// await queryRunner.query(`CREATE TABLE \`amphurImport\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`PROVINCE_CODE\` varchar(255) NULL, \`AMPHUR_CODE\` varchar(255) NULL, \`AMPHUR_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`ALTER TABLE \`authRoleAttr\` CHANGE \`attrPrivilege\` \`attrPrivilege\` varchar(255) NULL COMMENT 'สิทธิ์การเข้าถึง(Privilege)'`);
|
||||
await queryRunner.query(`ALTER TABLE \`developmentProject\` ADD CONSTRAINT \`FK_4913ef1466f9f35c1429e213d4b\` FOREIGN KEY (\`profileDevelopmentId\`) REFERENCES \`profileDevelopment\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`developmentProject\` ADD CONSTRAINT \`FK_8e3f2e86427befeff4283ae80f0\` FOREIGN KEY (\`profileDevelopmentHistoryId\`) REFERENCES \`profileDevelopmentHistory\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileDevelopmentHistory\` ADD CONSTRAINT \`FK_9fbaa3ecee59ad3234dc54d1ffc\` FOREIGN KEY (\`profileDevelopmentId\`) REFERENCES \`profileDevelopment\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileDevelopment\` ADD CONSTRAINT \`FK_072762f69ecb89f5c888d29187e\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileDevelopment\` ADD CONSTRAINT \`FK_25fcdd2e5cd0b8d2a7c27c015d0\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`profileDevelopment\` DROP FOREIGN KEY \`FK_25fcdd2e5cd0b8d2a7c27c015d0\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileDevelopment\` DROP FOREIGN KEY \`FK_072762f69ecb89f5c888d29187e\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileDevelopmentHistory\` DROP FOREIGN KEY \`FK_9fbaa3ecee59ad3234dc54d1ffc\``);
|
||||
await queryRunner.query(`ALTER TABLE \`developmentProject\` DROP FOREIGN KEY \`FK_8e3f2e86427befeff4283ae80f0\``);
|
||||
await queryRunner.query(`ALTER TABLE \`developmentProject\` DROP FOREIGN KEY \`FK_4913ef1466f9f35c1429e213d4b\``);
|
||||
await queryRunner.query(`ALTER TABLE \`authRoleAttr\` CHANGE \`attrPrivilege\` \`attrPrivilege\` varchar(255) NULL COMMENT 'สิทธิการเข้าถึง(Privilege)'`);
|
||||
// await queryRunner.query(`DROP TABLE \`amphurImport\``);
|
||||
// await queryRunner.query(`DROP TABLE \`educationMis\``);
|
||||
// await queryRunner.query(`DROP TABLE \`HR_EDUCATION\``);
|
||||
// await queryRunner.query(`DROP TABLE \`HR_EDUCATION_EMP\``);
|
||||
// await queryRunner.query(`DROP TABLE \`HR_PERSONAL_EMP_ADDRESS\``);
|
||||
// await queryRunner.query(`DROP TABLE \`HR_PERSONAL_EMP_FAMILY\``);
|
||||
// await queryRunner.query(`DROP TABLE \`HR_POSITION_OFFICER\``);
|
||||
// await queryRunner.query(`DROP TABLE \`HR_PERSONAL_OFFICER_ADDRESS\``);
|
||||
// await queryRunner.query(`DROP TABLE \`HR_PERSONAL_OFFICER_FAMILY\``);
|
||||
await queryRunner.query(`DROP TABLE \`profileDevelopment\``);
|
||||
await queryRunner.query(`DROP TABLE \`profileDevelopmentHistory\``);
|
||||
await queryRunner.query(`DROP TABLE \`developmentProject\``);
|
||||
// await queryRunner.query(`DROP TABLE \`provinceImport\``);
|
||||
// await queryRunner.query(`DROP TABLE \`subDistrictImport\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue