Merge branch 'develop' into adiDev
This commit is contained in:
commit
e6539edaec
1 changed files with 30 additions and 4 deletions
|
|
@ -27,7 +27,9 @@ import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
export class AuthRoleController extends Controller {
|
export class AuthRoleController extends Controller {
|
||||||
private authRoleRepo = AppDataSource.getRepository(AuthRole);
|
private authRoleRepo = AppDataSource.getRepository(AuthRole);
|
||||||
private authRoleAttrRepo = AppDataSource.getRepository(AuthRoleAttr);
|
private authRoleAttrRepo = AppDataSource.getRepository(AuthRoleAttr);
|
||||||
|
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||||
|
private employeePosMasterRepository = AppDataSource.getRepository(EmployeePosMaster)
|
||||||
|
|
||||||
@Get("list")
|
@Get("list")
|
||||||
public async listAuthRole() {
|
public async listAuthRole() {
|
||||||
|
|
@ -74,9 +76,33 @@ export class AuthRoleController extends Controller {
|
||||||
return new HttpSuccess(data.id);
|
return new HttpSuccess(data.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post("assign")
|
@Post("govoment")
|
||||||
public async AddAuthRole(@Request() req: RequestWithUser, @Body() body: CreateAddAuthRole) {
|
public async AddAuthRoleGovoment(@Request() req: RequestWithUser, @Body() body: CreateAddAuthRole) {
|
||||||
// console pasMater = await this
|
const getDetail = await this.authRoleRepo.findOneBy({ id: body.authRoleId });
|
||||||
|
if (!getDetail) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์");
|
||||||
|
|
||||||
|
const posMaster = await this.posMasterRepository.findOneBy({ id : body.posMasterId })
|
||||||
|
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||||
|
|
||||||
|
posMaster.lastUpdateUserId = req.user.sub;
|
||||||
|
posMaster.lastUpdateFullName = req.user.name;
|
||||||
|
posMaster.authRoleId = body.authRoleId
|
||||||
|
await this.posMasterRepository.save(posMaster);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("employee")
|
||||||
|
public async AddAuthRoleEmployee(@Request() req: RequestWithUser, @Body() body: CreateAddAuthRole) {
|
||||||
|
const getDetail = await this.authRoleRepo.findOneBy({ id: body.authRoleId });
|
||||||
|
if (!getDetail) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์");
|
||||||
|
|
||||||
|
const posMaster = await this.employeePosMasterRepository.findOneBy({ id : body.posMasterId })
|
||||||
|
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||||
|
|
||||||
|
posMaster.lastUpdateUserId = req.user.sub;
|
||||||
|
posMaster.lastUpdateFullName = req.user.name;
|
||||||
|
posMaster.authRoleId = body.authRoleId
|
||||||
|
await this.employeePosMasterRepository.save(posMaster);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue