orderBy
This commit is contained in:
parent
67c54e3273
commit
c9c14f052b
8 changed files with 18 additions and 6 deletions
|
|
@ -142,7 +142,7 @@ export class BloodGroupController extends Controller {
|
|||
async listBloodGroup() {
|
||||
const bloodGroup = await this.bloodGroupRepository.find({
|
||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
|
||||
order: { createdAt: "ASC" },
|
||||
order: { name: "ASC" },
|
||||
});
|
||||
|
||||
// if (!bloodGroup) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export class GenderController extends Controller {
|
|||
async GetResult() {
|
||||
const _gender = await this.genderRepository.find({
|
||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
|
||||
order: { createdAt: "ASC" },
|
||||
order: { name: "ASC" },
|
||||
});
|
||||
// if (!_gender) {
|
||||
// return new HttpSuccess([]);
|
||||
|
|
|
|||
|
|
@ -199,6 +199,7 @@ export class PosExecutiveController extends Controller {
|
|||
async GetPosExecutive() {
|
||||
const posExecutive = await this.posExecutiveRepository.find({
|
||||
select: ["id", "posExecutiveName", "posExecutivePriority"],
|
||||
order: { posExecutivePriority: "ASC" },
|
||||
});
|
||||
// if (!posExecutive) {
|
||||
// return new HttpSuccess([]);
|
||||
|
|
|
|||
|
|
@ -352,6 +352,7 @@ export class PositionController extends Controller {
|
|||
findPosDict = await this.posDictRepository.find({
|
||||
where: { posDictName: Like(`%${keyword}%`) },
|
||||
relations: ["posType", "posLevel", "posExecutive"],
|
||||
order: { posDictName: "ASC" },
|
||||
});
|
||||
// if (!findPosDict) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||
|
|
@ -362,6 +363,7 @@ export class PositionController extends Controller {
|
|||
findPosDict = await this.posDictRepository.find({
|
||||
where: { posDictField: Like(`%${keyword}%`) },
|
||||
relations: ["posType", "posLevel", "posExecutive"],
|
||||
order: { posDictField: "ASC" },
|
||||
});
|
||||
// if (!findPosDict) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||
|
|
@ -371,33 +373,39 @@ export class PositionController extends Controller {
|
|||
case "positionType":
|
||||
const findTypes: PosType[] = await this.posTypeRepository.find({
|
||||
where: { posTypeName: Like(`%${keyword}%`) },
|
||||
order: { posTypeName: "ASC" },
|
||||
select: ["id"],
|
||||
});
|
||||
findPosDict = await this.posDictRepository.find({
|
||||
where: { posTypeId: In(findTypes.map((x) => x.id)) },
|
||||
relations: ["posType", "posLevel", "posExecutive"],
|
||||
order: { posDictName: "ASC" },
|
||||
});
|
||||
break;
|
||||
|
||||
case "positionLevel":
|
||||
const findLevel: PosLevel[] = await this.posLevelRepository.find({
|
||||
where: { posLevelName: Like(`%${keyword}%`) },
|
||||
order: { posLevelName: "ASC" },
|
||||
select: ["id"],
|
||||
});
|
||||
findPosDict = await this.posDictRepository.find({
|
||||
where: { posLevelId: In(findLevel.map((x) => x.id)) },
|
||||
relations: ["posType", "posLevel", "posExecutive"],
|
||||
order: { posDictName: "ASC" },
|
||||
});
|
||||
break;
|
||||
|
||||
case "positionExecutive":
|
||||
const findExecutive: PosExecutive[] = await this.posExecutiveRepository.find({
|
||||
where: { posExecutiveName: Like(`%${keyword}%`) },
|
||||
order: { posExecutiveName: "ASC" },
|
||||
select: ["id"],
|
||||
});
|
||||
findPosDict = await this.posDictRepository.find({
|
||||
where: { posExecutiveId: In(findExecutive.map((x) => x.id)) },
|
||||
relations: ["posType", "posLevel", "posExecutive"],
|
||||
order: { posDictName: "ASC" },
|
||||
});
|
||||
break;
|
||||
|
||||
|
|
@ -405,6 +413,7 @@ export class PositionController extends Controller {
|
|||
findPosDict = await this.posDictRepository.find({
|
||||
where: { posDictExecutiveField: Like(`%${keyword}%`) },
|
||||
relations: ["posType", "posLevel", "posExecutive"],
|
||||
order: { posDictName: "ASC" },
|
||||
});
|
||||
// if (!findPosDict) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||
|
|
@ -415,6 +424,7 @@ export class PositionController extends Controller {
|
|||
findPosDict = await this.posDictRepository.find({
|
||||
where: { posDictArea: Like(`%${keyword}%`) },
|
||||
relations: ["posType", "posLevel", "posExecutive"],
|
||||
order: { posDictName: "ASC" },
|
||||
});
|
||||
// if (!findPosDict) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||
|
|
@ -424,6 +434,7 @@ export class PositionController extends Controller {
|
|||
default:
|
||||
findPosDict = await this.posDictRepository.find({
|
||||
relations: ["posType", "posLevel", "posExecutive"],
|
||||
order: { posDictName: "ASC" },
|
||||
});
|
||||
// if (!findPosDict) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export class PrefixController extends Controller {
|
|||
async Get() {
|
||||
const _prefix = await this.prefixRepository.find({
|
||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
|
||||
order: { createdAt: "ASC" },
|
||||
order: { name: "ASC" },
|
||||
});
|
||||
// if (!_prefix) {
|
||||
// return new HttpSuccess([]);
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ export class RankController extends Controller {
|
|||
async listRank() {
|
||||
const rank = await this.rankRepository.find({
|
||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
|
||||
order: { createdAt: "ASC" },
|
||||
order: { name: "ASC" },
|
||||
});
|
||||
|
||||
// if (!rank) {
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ export class RelationshipController extends Controller {
|
|||
async listRelationship() {
|
||||
const relationship = await this.relationshipRepository.find({
|
||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
|
||||
order: { createdAt: "ASC" },
|
||||
order: { name: "ASC" },
|
||||
});
|
||||
// if (!relationship) {
|
||||
// return new HttpSuccess([]);
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ export class ReligionController extends Controller {
|
|||
async listReligion() {
|
||||
const religion = await this.religionRepository.find({
|
||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"],
|
||||
order: { createdAt: "ASC" },
|
||||
order: { name: "ASC" },
|
||||
});
|
||||
|
||||
// if (!religion) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue