import { default as BaseController } from "../../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { BaseCity } from "../../../entity/basicInfo/base/baseCity";
|
|
export default class CityController extends BaseController {
|
//#region 根据货主ID获取货主信息
|
/**
|
* 根据货主ID获取货主信息
|
*/
|
@Post()
|
public async getById() {
|
let { ctx } = this;
|
let body = ctx.body;
|
if (!body.id) {
|
this.info.result = false;
|
this.info.msg = "ID不存在";
|
ctx.body = this.info;
|
return;
|
}
|
|
try {
|
let dataList = await this.dbRead.find(BaseCity, {
|
select: ["city_Id", "cityName", "parentId"],
|
where: {
|
city_Id: body.city_Id
|
}
|
});
|
|
this.info.result = true;
|
this.info.data = dataList;
|
} catch (error) {
|
this.info.result = false;
|
this.info.data = error.message;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 获得所有城市列表
|
/**
|
* 获得所有城市列表
|
*/
|
@Post()
|
public async getAll() {
|
let { ctx } = this;
|
|
try {
|
let dataList = await this.dbRead.find(BaseCity, {
|
select: ["city_Id", "cityName", "parentId"]
|
});
|
|
this.info.result = true;
|
this.info.data = dataList;
|
} catch (error) {
|
this.info.result = false;
|
this.info.data = error.message;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
}
|