fix
This commit is contained in:
parent
0524653f4b
commit
4dac692284
7 changed files with 26 additions and 22 deletions
|
|
@ -68,10 +68,10 @@ export class ProfileAddressController extends Controller {
|
||||||
* @summary ประวัติแก้ไขที่อยู่
|
* @summary ประวัติแก้ไขที่อยู่
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("history/{addressId}")
|
@Get("history/{profileId}")
|
||||||
public async getProfileAddressHistory(@Path() addressId: string) {
|
public async getProfileAddressHistory(@Path() profileId: string) {
|
||||||
const record = await this.profileAddressHistoryRepo.find({
|
const record = await this.profileAddressHistoryRepo.find({
|
||||||
where: { profileId: addressId },
|
where: { profileId: profileId },
|
||||||
relations: {
|
relations: {
|
||||||
registrationProvince: true,
|
registrationProvince: true,
|
||||||
registrationDistrict: true,
|
registrationDistrict: true,
|
||||||
|
|
@ -106,13 +106,13 @@ export class ProfileAddressController extends Controller {
|
||||||
* @summary แก้ไขที่อยู่
|
* @summary แก้ไขที่อยู่
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Patch("{addressId}")
|
@Patch("{profileId}")
|
||||||
public async editProfileAddress(
|
public async editProfileAddress(
|
||||||
@Body() requestBody: UpdateProfileAddress,
|
@Body() requestBody: UpdateProfileAddress,
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Path() addressId: string,
|
@Path() profileId: string,
|
||||||
) {
|
) {
|
||||||
const record = await this.profileRepo.findOneBy({ id: addressId });
|
const record = await this.profileRepo.findOneBy({ id: profileId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
||||||
const history = new ProfileAddressHistory();
|
const history = new ProfileAddressHistory();
|
||||||
|
|
@ -120,7 +120,7 @@ export class ProfileAddressController extends Controller {
|
||||||
Object.assign(history, { ...record, id: undefined });
|
Object.assign(history, { ...record, id: undefined });
|
||||||
Object.assign(record, requestBody);
|
Object.assign(record, requestBody);
|
||||||
|
|
||||||
history.profileId = addressId;
|
history.profileId = profileId;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,10 +69,10 @@ export class ProfileAddressEmployeeController extends Controller {
|
||||||
* @summary ประวัติแก้ไขที่อยู่
|
* @summary ประวัติแก้ไขที่อยู่
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("history/{addressId}")
|
@Get("history/{profileId}")
|
||||||
public async getProfileAddressHistory(@Path() addressId: string) {
|
public async getProfileAddressHistory(@Path() profileId: string) {
|
||||||
const record = await this.profileAddressHistoryRepo.find({
|
const record = await this.profileAddressHistoryRepo.find({
|
||||||
where: { profileEmployeeId: addressId },
|
where: { profileEmployeeId: profileId },
|
||||||
relations: {
|
relations: {
|
||||||
registrationProvince: true,
|
registrationProvince: true,
|
||||||
registrationDistrict: true,
|
registrationDistrict: true,
|
||||||
|
|
@ -107,13 +107,13 @@ export class ProfileAddressEmployeeController extends Controller {
|
||||||
* @summary แก้ไขที่อยู่
|
* @summary แก้ไขที่อยู่
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Patch("{addressId}")
|
@Patch("{profileId}")
|
||||||
public async editProfileAddress(
|
public async editProfileAddress(
|
||||||
@Body() requestBody: UpdateProfileAddressEmployee,
|
@Body() requestBody: UpdateProfileAddressEmployee,
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Path() addressId: string,
|
@Path() profileId: string,
|
||||||
) {
|
) {
|
||||||
const record = await this.profileEmployeeRepo.findOneBy({ id: addressId });
|
const record = await this.profileEmployeeRepo.findOneBy({ id: profileId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
||||||
const history = new ProfileAddressHistory();
|
const history = new ProfileAddressHistory();
|
||||||
|
|
@ -121,7 +121,7 @@ export class ProfileAddressEmployeeController extends Controller {
|
||||||
Object.assign(history, { ...record, id: undefined });
|
Object.assign(history, { ...record, id: undefined });
|
||||||
Object.assign(record, requestBody);
|
Object.assign(record, requestBody);
|
||||||
|
|
||||||
history.profileEmployeeId = addressId;
|
history.profileEmployeeId = profileId;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ export class ProfileChangeNameController extends Controller {
|
||||||
|
|
||||||
const chkLastRecord = await this.changeNameRepository.findOne({
|
const chkLastRecord = await this.changeNameRepository.findOne({
|
||||||
where:{
|
where:{
|
||||||
profileEmployeeId: record.profileEmployeeId
|
profileId: record.profileId
|
||||||
},
|
},
|
||||||
order:{
|
order:{
|
||||||
createdAt: "DESC"
|
createdAt: "DESC"
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
||||||
await this.profileEmployeeRepo.save(profile);
|
await this.profileEmployeeRepo.save(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HttpSuccess([chkLastRecord.id,record.id]);
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete("{changeNameId}")
|
@Delete("{changeNameId}")
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import { OrgRevision } from "../entities/OrgRevision";
|
||||||
import { PosMaster } from "../entities/PosMaster";
|
import { PosMaster } from "../entities/PosMaster";
|
||||||
import { PosLevel } from "../entities/PosLevel";
|
import { PosLevel } from "../entities/PosLevel";
|
||||||
import { PosType } from "../entities/PosType";
|
import { PosType } from "../entities/PosType";
|
||||||
import { calculateAge, calculateRetireDate, calculateRetireYear } from "../interfaces/utils";
|
import { calculateAge, calculateRetireDate, calculateRetireLaw, calculateRetireYear } from "../interfaces/utils";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Position } from "../entities/Position";
|
import { Position } from "../entities/Position";
|
||||||
|
|
||||||
|
|
@ -242,7 +242,7 @@ export class ProfileController extends Controller {
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
profile.lastUpdateFullName = request.user.name;
|
profile.lastUpdateFullName = request.user.name;
|
||||||
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
||||||
// profile.dateRetireLaw = calculateRetireDate(profile.birthDate);
|
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
||||||
await this.profileRepo.save(profile);
|
await this.profileRepo.save(profile);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -383,7 +383,7 @@ export class ProfileController extends Controller {
|
||||||
record.lastUpdateUserId = request.user.sub;
|
record.lastUpdateUserId = request.user.sub;
|
||||||
record.lastUpdateFullName = request.user.name;
|
record.lastUpdateFullName = request.user.name;
|
||||||
record.dateRetire = calculateRetireDate(record.birthDate);
|
record.dateRetire = calculateRetireDate(record.birthDate);
|
||||||
// record.dateRetireLaw = calculateRetireDate(record.birthDate);
|
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||||
await this.profileRepo.save(record);
|
await this.profileRepo.save(record);
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { Brackets, IsNull, Like, Not } from "typeorm";
|
import { Brackets, IsNull, Like, Not } from "typeorm";
|
||||||
import { OrgRevision } from "../entities/OrgRevision";
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
import { calculateRetireDate } from "../interfaces/utils";
|
import { calculateRetireDate, calculateRetireLaw } from "../interfaces/utils";
|
||||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
import {
|
import {
|
||||||
ProfileEmployee,
|
ProfileEmployee,
|
||||||
|
|
@ -115,7 +115,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
profile.lastUpdateFullName = request.user.name;
|
profile.lastUpdateFullName = request.user.name;
|
||||||
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
||||||
// profile.dateRetireLaw = calculateRetireDate(profile.birthDate);
|
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
||||||
await this.profileRepo.save(profile);
|
await this.profileRepo.save(profile);
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
@ -205,7 +205,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
record.lastUpdateUserId = request.user.sub;
|
record.lastUpdateUserId = request.user.sub;
|
||||||
record.lastUpdateFullName = request.user.name;
|
record.lastUpdateFullName = request.user.name;
|
||||||
record.dateRetire = calculateRetireDate(record.birthDate);
|
record.dateRetire = calculateRetireDate(record.birthDate);
|
||||||
// record.dateRetireLaw = calculateRetireDate(record.birthDate);
|
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||||
|
|
||||||
await this.profileRepo.save(record);
|
await this.profileRepo.save(record);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,10 @@ export function calculateRetireDate(birthDate: Date) {
|
||||||
|
|
||||||
return new Date(`${yy + 61}-09-30T00:00:00.000+07:00`);
|
return new Date(`${yy + 61}-09-30T00:00:00.000+07:00`);
|
||||||
}
|
}
|
||||||
|
export function calculateRetireLaw(birthDate: Date) {
|
||||||
|
let yy = birthDate.getFullYear();
|
||||||
|
return new Date(`${yy + 60}-09-30T00:00:00.000+07:00`);
|
||||||
|
}
|
||||||
|
|
||||||
export function calculateRetireYear(birthDate: Date) {
|
export function calculateRetireYear(birthDate: Date) {
|
||||||
let dd = birthDate.getDate();
|
let dd = birthDate.getDate();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue