Migrate table portfolio add field position&posLevel
This commit is contained in:
parent
b57a64fe0e
commit
d74a8e14d8
3 changed files with 55 additions and 8 deletions
|
|
@ -23,7 +23,7 @@ import { CreatePortfolio, Portfolio } from "../entities/Portfolio";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
import { setLogDataDiff } from "../interfaces/utils";
|
||||||
import { Brackets } from "typeorm";
|
import { Brackets } from "typeorm";
|
||||||
|
import CallAPI from "../interfaces/call-api";
|
||||||
@Route("api/v1/development/portfolio")
|
@Route("api/v1/development/portfolio")
|
||||||
@Tags("Portfolio")
|
@Tags("Portfolio")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -104,19 +104,21 @@ export class PortfolioController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API รายละเอียดรายการผลงาน ใช้แสดงในรายงาน ก.พ.7/ก.ก.1
|
* API รายละเอียดรายการผลงาน ใช้แสดงในรายงาน ทปอ. สามัญ
|
||||||
*
|
*
|
||||||
* @summary รายละเอียดรายการผลงาน ใช้แสดงในรายงาน ก.พ.7/ก.ก.1
|
* @summary รายละเอียดรายการผลงาน ใช้แสดงในรายงาน ทปอ. สามัญ
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("kk1/{keycloak}")
|
@Get("kk1/{keycloak}")
|
||||||
async GetPortfolio(@Path() keycloak: string, @Request() request: RequestWithUser) {
|
async GetPortfolio(@Path() keycloak: string, @Request() request: RequestWithUser) {
|
||||||
const _portfolio = await this.portfolioRepository.find({
|
const _portfolio = await this.portfolioRepository.find({
|
||||||
where: { createdUserId: keycloak },
|
where: { createdUserId: keycloak },
|
||||||
select: [
|
select: {
|
||||||
"name",
|
name: true,
|
||||||
"createdAt"
|
createdAt: true,
|
||||||
],
|
position: true,
|
||||||
|
posLevel: true
|
||||||
|
},
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
const result =
|
const result =
|
||||||
|
|
@ -124,7 +126,8 @@ export class PortfolioController extends Controller {
|
||||||
name: x.name,
|
name: x.name,
|
||||||
year: x.createdAt.getFullYear() > 2500
|
year: x.createdAt.getFullYear() > 2500
|
||||||
? x.createdAt.getFullYear()
|
? x.createdAt.getFullYear()
|
||||||
: x.createdAt.getFullYear()+543
|
: x.createdAt.getFullYear()+543,
|
||||||
|
position: `${x.position ?? ""}${x.posLevel ?? ""}`.trim()
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(result);
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +156,20 @@ export class PortfolioController extends Controller {
|
||||||
if (checkName) {
|
if (checkName) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _position:string=""
|
||||||
|
let _posLevel:string=""
|
||||||
|
await new CallAPI()
|
||||||
|
.GetData(request, `/org/dotnet/by-keycloak/${request.user.sub}`)
|
||||||
|
.then((x) => {
|
||||||
|
_position = x.position;
|
||||||
|
_posLevel = x.posLevel;
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
|
||||||
const before = null;
|
const before = null;
|
||||||
|
_portfolio.position = _position;
|
||||||
|
_portfolio.posLevel = _posLevel;
|
||||||
_portfolio.createdUserId = request.user.sub;
|
_portfolio.createdUserId = request.user.sub;
|
||||||
_portfolio.createdFullName = request.user.name;
|
_portfolio.createdFullName = request.user.name;
|
||||||
_portfolio.lastUpdateUserId = request.user.sub;
|
_portfolio.lastUpdateUserId = request.user.sub;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,21 @@ export class Portfolio extends EntityBase {
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
detail: string;
|
detail: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ตำแหน่ง",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
position: string;
|
||||||
|
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ระดับตำแหน่ง",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
posLevel: string;
|
||||||
}
|
}
|
||||||
export class CreatePortfolio {
|
export class CreatePortfolio {
|
||||||
@Column()
|
@Column()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTablePortfolioAddFieldPosition_1773974268282 implements MigrationInterface {
|
||||||
|
name = 'UpdateTablePortfolioAddFieldPosition_1773974268282'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`portfolio\` ADD \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`portfolio\` ADD \`posLevel\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`portfolio\` DROP COLUMN \`posLevel\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`portfolio\` DROP COLUMN \`position\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue