no message
This commit is contained in:
parent
927d9563f6
commit
ce8bb41bda
7 changed files with 238 additions and 43 deletions
|
|
@ -21,6 +21,8 @@ import HttpStatusCode from "../interfaces/http-status";
|
|||
import HttpError from "../interfaces/http-error";
|
||||
import { CreateSalaryRank, SalaryRanks, UpdateSalaryRank } from "../entities/SalaryRanks";
|
||||
import { Salarys } from "../entities/Salarys";
|
||||
import permission from "../interfaces/permission";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
@Route("api/v1/salary/rate")
|
||||
@Tags("SalaryRank")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -41,10 +43,11 @@ export class SalaryRanksController extends Controller {
|
|||
*/
|
||||
@Post()
|
||||
async CreateSalaryRank(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body()
|
||||
requestBody: CreateSalaryRank,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
await new permission().PermissionCreate(request, "SYS_SALARY_CHART_OFFICER");
|
||||
try {
|
||||
const checkSalary = await this.salaryRepository.findOne({
|
||||
where: { id: requestBody.salaryId },
|
||||
|
|
@ -73,11 +76,12 @@ export class SalaryRanksController extends Controller {
|
|||
*/
|
||||
@Put("{id}")
|
||||
async updateSalaryRanks(
|
||||
@Request() request: RequestWithUser,
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: UpdateSalaryRank,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_SALARY_CHART_OFFICER");
|
||||
const salaryRank = await this.salaryRankRepository.findOne({ where: { id: id } });
|
||||
if (!salaryRank) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับผังเงินเดือนนี้");
|
||||
|
|
@ -97,7 +101,8 @@ export class SalaryRanksController extends Controller {
|
|||
* @param {string} id Id อัตราเงินเดือน
|
||||
*/
|
||||
@Delete("{id}")
|
||||
async deleteSalaryRanks(@Path() id: string) {
|
||||
async deleteSalaryRanks(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
await new permission().PermissionDelete(request, "SYS_SALARY_CHART_OFFICER");
|
||||
const delSalaryRanks = await this.salaryRankRepository.findOne({
|
||||
where: { id },
|
||||
});
|
||||
|
|
@ -117,11 +122,13 @@ export class SalaryRanksController extends Controller {
|
|||
*/
|
||||
@Get("{id}")
|
||||
async listSalaryRanks(
|
||||
@Request() request: RequestWithUser,
|
||||
@Path() id: string,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
await new permission().PermissionGet(request, "SYS_SALARY_CHART_OFFICER");
|
||||
const [salaryRank, total] = await AppDataSource.getRepository(SalaryRanks)
|
||||
.createQueryBuilder("salaryRank")
|
||||
.andWhere(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue