fix isNull and fix Get{id}
This commit is contained in:
parent
d632d5e10b
commit
5834958081
2 changed files with 63 additions and 28 deletions
|
|
@ -342,9 +342,9 @@ export class kpiRoleController extends Controller {
|
|||
nodeId?: string | null;
|
||||
node?: number | null;
|
||||
position?: string | null;
|
||||
keyword?: string;
|
||||
isAll?: boolean;
|
||||
isNull?: boolean;
|
||||
keyword?: string | null;
|
||||
isAll?: boolean | false;
|
||||
// isNull?: boolean | false;
|
||||
},
|
||||
) {
|
||||
let condition = "";
|
||||
|
|
@ -392,11 +392,11 @@ export class kpiRoleController extends Controller {
|
|||
}
|
||||
parameters.nodeId = `%${requestBody.nodeId}%`;
|
||||
}
|
||||
if (requestBody.year && requestBody.period && requestBody.isNull === true) {
|
||||
condition += ` AND (kpiRole.year LIKE :year OR kpiRole.year IS NULL) AND (kpiRole.period LIKE :period OR kpiRole.period IS NULL)`;
|
||||
parameters.year = `%${requestBody.year}%`;
|
||||
parameters.period = `%${requestBody.period}%`;
|
||||
}
|
||||
// if (requestBody.year && requestBody.period && requestBody.isNull === true) {
|
||||
// condition += ` AND (kpiRole.year LIKE :year OR kpiRole.year IS NULL) AND (kpiRole.period LIKE :period OR kpiRole.period IS NULL)`;
|
||||
// parameters.year = `%${requestBody.year}%`;
|
||||
// parameters.period = `%${requestBody.period}%`;
|
||||
// }
|
||||
const [kpiRole, total] = await AppDataSource.getRepository(KpiRole)
|
||||
.createQueryBuilder("kpiRole")
|
||||
.leftJoinAndSelect("kpiRole.kpiPeriod", "kpiPeriod")
|
||||
|
|
@ -416,15 +416,31 @@ export class kpiRoleController extends Controller {
|
|||
nodeId: requestBody.nodeId,
|
||||
},
|
||||
)
|
||||
// .andWhere(
|
||||
// requestBody.year && requestBody.period
|
||||
// ? "kpiRole.year LIKE :year AND kpiRole.period LIKE :period"
|
||||
// : "1=1",
|
||||
// {
|
||||
// year: `%${requestBody.year}%`,
|
||||
// period: `%${requestBody.period}%`,
|
||||
// },
|
||||
// )
|
||||
.andWhere(
|
||||
requestBody.isNull === false && requestBody.year && requestBody.period
|
||||
? "kpiRole.year LIKE :year AND kpiRole.period LIKE :period"
|
||||
: "1=1",
|
||||
{
|
||||
year: `%${requestBody.year}%`,
|
||||
period: `%${requestBody.period}%`,
|
||||
},
|
||||
)
|
||||
requestBody.year
|
||||
? "kpiRole.year LIKE :year"
|
||||
: "1=1",
|
||||
{
|
||||
year: `%${requestBody.year}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
requestBody.period
|
||||
? "kpiRole.period LIKE :period"
|
||||
: "1=1",
|
||||
{
|
||||
period: `%${requestBody.period}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(requestBody.position != undefined ? "kpiRole.position LIKE :position" : "1=1", {
|
||||
position: `%${requestBody.position}%`,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue