เช็คจังหวัดออกคำสั่ง
This commit is contained in:
parent
b349dd5944
commit
3a0fc39397
1 changed files with 38 additions and 0 deletions
|
|
@ -63,6 +63,9 @@ import { CommandSign } from "../entities/CommandSign";
|
||||||
import { RoleKeycloak } from "../entities/RoleKeycloak";
|
import { RoleKeycloak } from "../entities/RoleKeycloak";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import querystring from "querystring";
|
import querystring from "querystring";
|
||||||
|
import { SubDistrict } from "../entities/SubDistrict";
|
||||||
|
import { District } from "../entities/District";
|
||||||
|
import { Province } from "../entities/Province";
|
||||||
|
|
||||||
@Route("api/v1/org/command")
|
@Route("api/v1/org/command")
|
||||||
@Tags("Command")
|
@Tags("Command")
|
||||||
|
|
@ -99,6 +102,9 @@ export class CommandController extends Controller {
|
||||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||||
private commandSignRepository = AppDataSource.getRepository(CommandSign);
|
private commandSignRepository = AppDataSource.getRepository(CommandSign);
|
||||||
private roleKeycloakRepo = AppDataSource.getRepository(RoleKeycloak);
|
private roleKeycloakRepo = AppDataSource.getRepository(RoleKeycloak);
|
||||||
|
private provinceRepo = AppDataSource.getRepository(Province);
|
||||||
|
private districtRepo = AppDataSource.getRepository(District);
|
||||||
|
private subDistrictRepo = AppDataSource.getRepository(SubDistrict);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API list รายการคำสั่ง
|
* API list รายการคำสั่ง
|
||||||
|
|
@ -3719,6 +3725,7 @@ export class CommandController extends Controller {
|
||||||
const roleKeycloak = await this.roleKeycloakRepo.findOne({
|
const roleKeycloak = await this.roleKeycloakRepo.findOne({
|
||||||
where: { name: Like("USER") },
|
where: { name: Like("USER") },
|
||||||
});
|
});
|
||||||
|
const null_: any = null;
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
body.data.map(async (item) => {
|
body.data.map(async (item) => {
|
||||||
const before = null;
|
const before = null;
|
||||||
|
|
@ -3780,6 +3787,37 @@ export class CommandController extends Controller {
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
// if (!result) throw new Error("Failed. Cannot set user's role.");
|
// if (!result) throw new Error("Failed. Cannot set user's role.");
|
||||||
|
let registrationProvinceId = await this.provinceRepo.findOneBy({
|
||||||
|
id: profile.registrationProvinceId,
|
||||||
|
});
|
||||||
|
profile.registrationProvinceId = registrationProvinceId
|
||||||
|
? registrationProvinceId.id
|
||||||
|
: null_;
|
||||||
|
let registrationDistrictId = await this.districtRepo.findOneBy({
|
||||||
|
id: profile.registrationDistrictId,
|
||||||
|
});
|
||||||
|
profile.registrationDistrictId = registrationDistrictId
|
||||||
|
? registrationDistrictId.id
|
||||||
|
: null_;
|
||||||
|
let registrationSubDistrictId = await this.subDistrictRepo.findOneBy({
|
||||||
|
id: profile.registrationSubDistrictId,
|
||||||
|
});
|
||||||
|
profile.registrationSubDistrictId = registrationSubDistrictId
|
||||||
|
? registrationSubDistrictId.id
|
||||||
|
: null_;
|
||||||
|
|
||||||
|
let currentProvinceId = await this.provinceRepo.findOneBy({
|
||||||
|
id: profile.currentProvinceId,
|
||||||
|
});
|
||||||
|
profile.currentProvinceId = currentProvinceId ? currentProvinceId.id : null_;
|
||||||
|
let currentDistrictId = await this.districtRepo.findOneBy({
|
||||||
|
id: profile.currentDistrictId,
|
||||||
|
});
|
||||||
|
profile.currentDistrictId = currentDistrictId ? currentDistrictId.id : null_;
|
||||||
|
let currentSubDistrictId = await this.subDistrictRepo.findOneBy({
|
||||||
|
id: profile.currentSubDistrictId,
|
||||||
|
});
|
||||||
|
profile.currentSubDistrictId = currentSubDistrictId ? currentSubDistrictId.id : null_;
|
||||||
profile.keycloak = typeof userKeycloakId === "string" ? userKeycloakId : "";
|
profile.keycloak = typeof userKeycloakId === "string" ? userKeycloakId : "";
|
||||||
profile.roleKeycloaks = result && roleKeycloak ? [roleKeycloak] : [];
|
profile.roleKeycloaks = result && roleKeycloak ? [roleKeycloak] : [];
|
||||||
profile.email = item.bodyProfile.email;
|
profile.email = item.bodyProfile.email;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue