role
This commit is contained in:
parent
8e82201fbd
commit
1736f5043e
7 changed files with 147 additions and 30 deletions
|
|
@ -29,6 +29,8 @@ import CallAPI from "../interfaces/call-api";
|
|||
import { SalaryOrgEmployee } from "../entities/SalaryOrgEmployee";
|
||||
import { SalaryProfileEmployee } from "../entities/SalaryProfileEmployee";
|
||||
import { isNullOrUndefined } from "util";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import permission from "../interfaces/permission";
|
||||
|
||||
@Route("api/v1/salary/period")
|
||||
@Tags("Salary")
|
||||
|
|
@ -285,7 +287,8 @@ export class SalaryPeriodController extends Controller {
|
|||
* @param {string} id profile Id
|
||||
*/
|
||||
@Delete("profile/{id}")
|
||||
async deleteSalaryProfile(@Path() id: string) {
|
||||
async deleteSalaryProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_SALARY_OFFICER");
|
||||
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: { id: id },
|
||||
|
|
@ -399,7 +402,8 @@ export class SalaryPeriodController extends Controller {
|
|||
* @param {string} amount ฐานเงินเดือน
|
||||
*/
|
||||
@Post("change/amount")
|
||||
async changeAmount(@Body() body: { profileId: string; amount: number }) {
|
||||
async changeAmount(@Body() body: { profileId: string; amount: number }, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionCreate(request, "SYS_SALARY_OFFICER");
|
||||
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: { id: body.profileId },
|
||||
|
|
@ -675,7 +679,8 @@ export class SalaryPeriodController extends Controller {
|
|||
* @param {string} groupId groupId
|
||||
*/
|
||||
@Post("change/group")
|
||||
async changeGroup(@Body() body: { profileId: string; groupId: string }) {
|
||||
async changeGroup(@Body() body: { profileId: string; groupId: string } ,@Request() req: RequestWithUser) {
|
||||
await new permission().PermissionCreate(req, "SYS_SALARY_OFFICER");
|
||||
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||
// relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: { id: body.profileId },
|
||||
|
|
@ -797,7 +802,9 @@ export class SalaryPeriodController extends Controller {
|
|||
@Post("change/type")
|
||||
async changeType(
|
||||
@Body() body: { profileId: string; type: string; isReserve: boolean; remark?: string | null },
|
||||
@Request() req: RequestWithUser
|
||||
) {
|
||||
await new permission().PermissionCreate(req, "SYS_SALARY_OFFICER");
|
||||
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: { id: body.profileId },
|
||||
|
|
@ -1195,8 +1202,9 @@ export class SalaryPeriodController extends Controller {
|
|||
isAbsent: any;
|
||||
isLeave: any;
|
||||
},
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_SALARY_OFFICER");
|
||||
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||
where: {
|
||||
id: id,
|
||||
|
|
@ -1225,8 +1233,9 @@ export class SalaryPeriodController extends Controller {
|
|||
@Post("org/profile")
|
||||
async addSalaryProfile(
|
||||
@Body() requestBody: CreateSalaryProfile,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionCreate(request, "SYS_SALARY_OFFICER");
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
relations: ["salaryPeriod", "salaryProfiles"],
|
||||
where: {
|
||||
|
|
@ -1558,8 +1567,9 @@ export class SalaryPeriodController extends Controller {
|
|||
@Post()
|
||||
async create_salary_period(
|
||||
@Body() requestBody: CreateSalaryPeriod,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionCreate(request, "SYS_SALARY_ROUND");
|
||||
const salaryPeriod = Object.assign(new SalaryPeriod(), requestBody);
|
||||
|
||||
const chk_toUpper = ["SPECIAL", "APR", "OCT"];
|
||||
|
|
@ -1663,8 +1673,9 @@ export class SalaryPeriodController extends Controller {
|
|||
async update_salary_period(
|
||||
@Path() id: string,
|
||||
@Body() requestBody: UpdateSalaryPeriod,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_SALARY_ROUND");
|
||||
const chk_SalaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -1770,7 +1781,8 @@ export class SalaryPeriodController extends Controller {
|
|||
* @param {string} id Guid, *Id รอบเงินเดือน
|
||||
*/
|
||||
@Delete("{id}")
|
||||
async delete_salary_period(@Path() id: string) {
|
||||
async delete_salary_period(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request, "SYS_SALARY_ROUND");
|
||||
const SalaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -2965,7 +2977,9 @@ export class SalaryPeriodController extends Controller {
|
|||
body: {
|
||||
titleRecommend: string;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_SALARY_OFFICER");
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: { id: periodId },
|
||||
relations: ["salaryOrgs"],
|
||||
|
|
@ -2994,6 +3008,7 @@ export class SalaryPeriodController extends Controller {
|
|||
*/
|
||||
@Put("head/comment/{periodId}/{rootId}")
|
||||
async WaitHeadApprove(
|
||||
@Request() request: RequestWithUser,
|
||||
@Path() periodId: string,
|
||||
rootId: string,
|
||||
@Body()
|
||||
|
|
@ -3001,6 +3016,7 @@ export class SalaryPeriodController extends Controller {
|
|||
titleRecommend: string;
|
||||
},
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_SALARY_ROUND");
|
||||
const salaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||
where: { id: periodId },
|
||||
relations: ["salaryOrgs"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue