import { CoolController, BaseController } from '@cool-midway/core';
|
import { Inject } from '@midwayjs/core';
|
import { RecycleItemEntity } from '../../entity/recycleitem';
|
import { RecycleItemService } from '../../service/recycleitem';
|
import { BaseSysDepartmentEntity } from "../../../base/entity/sys/department";
|
import { WithDeptFilterWhere } from '../../../base/middleware/with-dept-filter-where'
|
|
/**
|
* 回收物品
|
*/
|
@CoolController({
|
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
|
entity: RecycleItemEntity,
|
service: RecycleItemService,
|
pageQueryOp: {
|
keyWordLikeFields: ['a.name'],
|
fieldEq: ['a.itemId', 'a.category', 'a.status'],
|
select: [
|
"a.*",
|
"b.name AS departmentName"
|
],
|
join: [
|
{
|
entity: BaseSysDepartmentEntity,
|
alias: "b",
|
condition: "a.departmentId = b.id",
|
type: "leftJoin"
|
}
|
|
],
|
where: async (ctx) => {
|
const conditions: any[][] = [];
|
conditions.push(...(await WithDeptFilterWhere(ctx, { alias: 'a', field: 'departmentId' })));
|
return conditions;
|
}
|
},
|
})
|
export class RecycleItemController extends BaseController {
|
@Inject()
|
recycleItemService: RecycleItemService;
|
}
|