整理代码

This commit is contained in:
ap 2021-03-12 23:46:56 +08:00
parent a66d67cf64
commit 591fc20e6f
6 changed files with 112 additions and 110 deletions

View File

@ -30,27 +30,29 @@ import { DemoAppGoodsEntity } from '../../entity/goods';
// 指定返回字段
select: ['a.*', 'b.name'],
// 关联表用户表
leftJoin: [{
leftJoin: [
{
// 管理的表
entity: BaseSysUserEntity,
// 别名
alias: 'b',
// 关联条件
condition: 'a.userId = b.id'
}],
condition: 'a.userId = b.id',
},
],
// 增加其他条件
where: async (ctx: Context) => {
return [
// 价格大于90
['a.price > :price', { price: 90.00 }]
]
['a.price > :price', { price: 90.0 }],
];
},
// 添加排序
addOrderBy: {
// 排序字段及排序方式
price: 'desc'
}
}
price: 'desc',
},
},
})
export class DemoAdminGoodsController extends BaseController {
/**

View File

@ -20,5 +20,5 @@ export class DemoAppGoodsEntity extends BaseEntity {
price: number;
@Column({ comment: '分类', type: 'tinyint' })
type: number
type: number;
}