import { CoolController, BaseController } from '@cool-midway/core';
|
import { RecycleTransactionEntity } from '../../entity/transaction';
|
import { RecycleTransactionService } from '../../service/transaction';
|
import { UserInfoEntity } from '../../../user/entity/info';
|
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: RecycleTransactionEntity,
|
service: RecycleTransactionService,
|
pageQueryOp: {
|
select: ['a.*', 'b.userName as userName', 'c.name as departmentName'],
|
keyWordLikeFields: ['a.remark'],
|
fieldEq: [
|
{ column: 'a.userId', requestParam: 'userId' },
|
{ column: 'a.orderId', requestParam: 'orderId' },
|
{ column: 'a.departmentId', requestParam: 'departmentId' },
|
{ column: 'a.type', requestParam: 'type' },
|
{ column: 'a.sourceType', requestParam: 'sourceType' }
|
],
|
join: [
|
{
|
entity: UserInfoEntity,
|
alias: 'b',
|
condition: 'a.userId = b.unionid',
|
type: 'leftJoin'
|
},
|
{
|
entity: BaseSysDepartmentEntity,
|
alias: 'c',
|
condition: 'a.departmentId = c.id',
|
type: 'leftJoin'
|
}
|
],
|
where: async (ctx) => {
|
const { startTime, endTime } = ctx.request.body;
|
const conditions: any[][] = [];
|
if (startTime && endTime) {
|
conditions.push(['a.createTime BETWEEN :startTime AND :endTime', { startTime, endTime }]);
|
}
|
conditions.push(...(await WithDeptFilterWhere(ctx, { alias: 'a', field: 'departmentId' })));
|
return conditions;
|
},
|
addOrderBy: {
|
createTime: 'desc'
|
}
|
}
|
})
|
export class AdminFinanceTransactionController extends BaseController { }
|