no message

This commit is contained in:
kittapath 2024-08-22 17:23:48 +07:00
parent 927d9563f6
commit ce8bb41bda
7 changed files with 238 additions and 43 deletions

View file

@ -25,6 +25,8 @@ import {
UpdateSalaryRankEmployee,
} from "../entities/SalaryRankEmployee";
import { SalaryEmployee } from "../entities/SalaryEmployee";
import permission from "../interfaces/permission";
import { RequestWithUser } from "../middlewares/user";
@Route("api/v1/salary/rate/employee")
@Tags("SalaryRankEmployee")
@Security("bearerAuth")
@ -44,10 +46,11 @@ export class SalaryRankEmployeeController extends Controller {
*/
@Post()
async CreateSalaryRankEmployee(
@Request() request: RequestWithUser,
@Body()
requestBody: CreateSalaryRankEmployee,
@Request() request: { user: Record<string, any> },
) {
await new permission().PermissionCreate(request, "SYS_WAGE_CHART_EMP");
try {
const checkSalary = await this.salaryEmployeeRepository.findOne({
where: { id: requestBody.salaryEmployeeId },
@ -84,11 +87,12 @@ export class SalaryRankEmployeeController extends Controller {
*/
@Put("{id}")
async updateSalaryRankEmployees(
@Request() request: RequestWithUser,
@Path() id: string,
@Body()
requestBody: UpdateSalaryRankEmployee,
@Request() request: { user: Record<string, any> },
) {
await new permission().PermissionUpdate(request, "SYS_WAGE_CHART_EMP");
const salaryRankEmployee = await this.salaryRankEmployeeRepository.findOne({
where: { id: id },
});
@ -119,7 +123,8 @@ export class SalaryRankEmployeeController extends Controller {
* @param {string} id Id
*/
@Delete("{id}")
async deleteSalaryRankEmployees(@Path() id: string) {
async deleteSalaryRankEmployees(@Request() request: RequestWithUser, @Path() id: string) {
await new permission().PermissionDelete(request, "SYS_WAGE_CHART_EMP");
const delSalaryRankEmployees = await this.salaryRankEmployeeRepository.findOne({
where: { id },
});
@ -138,11 +143,13 @@ export class SalaryRankEmployeeController extends Controller {
*/
@Get("{id}")
async listSalaryRankEmployees(
@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_WAGE_CHART_EMP");
const [salaryRankEmployee, total] = await AppDataSource.getRepository(SalaryRankEmployee)
.createQueryBuilder("salaryRankEmployee")
.andWhere(