schangxiang@126.com
2025-09-09 3d8966ba2c81e7e0365c8b123e861d18ee4f94f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { default as BaseController } from "../../baseController";
import { Post } from "egg-shell-decorators";
import { BaseDestination } from "../../../entity/basicInfo/workshop/baseDestination";
 
// import { BaseBrand } from "../../../entity/basicInfo/base/baseBrand";
 
export default class ProductInfoController extends BaseController {
  //#region getList 获得目的地列表
  /**
   * 获得目的地列表
   */
  @Post()
  public async getList() {
    let { ctx } = this;
    try {
      let whereStr = "1=1"; // 不筛选空器具
      var where: any = {};
 
      // 关键词查询条件
      if (this.body.name) {
        let name = this.ctx.helper.sqlSecurity(this.body.name);
        whereStr += ` AND (destinationName LIKE '%' + :name + '%' OR destinationCode LIKE '%' + :name + '%')`;
        where.name = name;
      }
 
      let builder = this.dbRead.createQueryBuilder(BaseDestination, "t").where(whereStr, where);
 
      builder.take(500);
      let dataList = [];
      dataList = await builder.getMany();
      this.info.result = true;
      this.info.data = dataList;
 
      ctx.body = this.info;
    } catch (ex) {
      let msg = "异常错误信息:" + ex.message;
      this.info.result = false;
      this.info.msg = msg;
      ctx.body = this.info;
    }
  }
  //#endregion
}