Merge branch 'develop' into adiDev
This commit is contained in:
commit
4ed6a08557
6 changed files with 92 additions and 4 deletions
|
|
@ -128,4 +128,56 @@ export class ApiKeyController extends Controller {
|
|||
});
|
||||
return new HttpSuccess(apiName);
|
||||
}
|
||||
|
||||
/**
|
||||
* API สร้าง Api Key
|
||||
*
|
||||
* @summary สร้าง Api Key (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post("history")
|
||||
async getHistory(
|
||||
@Body()
|
||||
requestBody: {
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
apiNameId: string | null;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
if (requestBody.apiNameId) {
|
||||
const apiName = await this.apiNameRepository.findOne({
|
||||
where: { id: requestBody.apiNameId },
|
||||
});
|
||||
if (apiName)
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไท้พบรายการ Web Service นี้ในระบบ");
|
||||
}
|
||||
const apiHistory = await AppDataSource.getRepository(ApiHistory)
|
||||
.createQueryBuilder("apiHistory")
|
||||
.leftJoinAndSelect("apiHistory.apiKey", "apiKey")
|
||||
.leftJoinAndSelect("apiHistory.apiName", "apiName")
|
||||
.andWhere(requestBody.apiNameId ? `apiHistory.apiNameId = :apiNameId` : "1=1", {
|
||||
apiNameId: requestBody.apiNameId,
|
||||
})
|
||||
.andWhere(
|
||||
`apiHistory.createdAt >= DATE(:startDate) AND apiHistory.createdAt <= DATE(:endDate)`,
|
||||
{
|
||||
startDate: new Date(requestBody.startDate),
|
||||
endDate: new Date(
|
||||
requestBody.endDate.setDate(new Date(requestBody.endDate).getDate() + 1),
|
||||
),
|
||||
},
|
||||
)
|
||||
.orderBy("apiHistory.createdAt", "DESC")
|
||||
.getMany();
|
||||
const result = apiHistory.map((x) => ({
|
||||
id: x.id,
|
||||
apiName: x.apiName.name,
|
||||
apiKey: x.apiKey.name,
|
||||
createdAt: x.createdAt,
|
||||
ipApi: x.ipApi,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2240,8 +2240,8 @@ export class CommandController extends Controller {
|
|||
firstName: profile.firstName,
|
||||
lastName: profile.lastName,
|
||||
});
|
||||
// กรณี Keycloak ไม่ถูกลบ ให้ลบซ้ำอีกรอบแล้วสร้างใหม่
|
||||
if (profile.keycloak != null && userKeycloakId && userKeycloakId.error === "User exists with same username") {
|
||||
// กรณี Keycloak ไม่ถูกลบ ให้ลบซ้ำอีกรอบแล้วสร้างใหม่ และหากยังไม่สามารถลบได้ให้แสดง Error
|
||||
if (profile.keycloak != null && userKeycloakId && userKeycloakId.errorMessage === "User exists with same username") {
|
||||
const delUserKeycloak = await deleteUser(profile.keycloak);
|
||||
if(delUserKeycloak) {
|
||||
userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
|
||||
|
|
@ -2249,6 +2249,9 @@ export class CommandController extends Controller {
|
|||
lastName: profile.lastName,
|
||||
});
|
||||
}
|
||||
else {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "พบข้อผิดพลาด ไม่สามารถจัดการผู้ใช้งานได้");
|
||||
}
|
||||
}
|
||||
const list = await getRoles();
|
||||
let result = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue