fix
This commit is contained in:
parent
aa3bbac5a5
commit
a5b57f287d
1 changed files with 37 additions and 24 deletions
|
|
@ -42,30 +42,43 @@ export class PortfolioController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async GetResult(@Request() request: RequestWithUser, @Query("keyword") keyword?: string) {
|
async GetResult(@Request() request: RequestWithUser) {
|
||||||
const _portfolio = await this.portfolioRepository
|
const _portfolio = await this.portfolioRepository.find({
|
||||||
.createQueryBuilder("portfolio")
|
where: { createdUserId: request.user.sub },
|
||||||
.select([
|
select: [
|
||||||
"portfolio.id",
|
"id",
|
||||||
"portfolio.name",
|
"name",
|
||||||
"portfolio.detail",
|
"detail",
|
||||||
"portfolio.createdAt",
|
"createdAt",
|
||||||
"portfolio.lastUpdatedAt",
|
"lastUpdatedAt",
|
||||||
"portfolio.createdFullName",
|
"createdFullName",
|
||||||
"portfolio.lastUpdateFullName",
|
"lastUpdateFullName",
|
||||||
])
|
],
|
||||||
.where("portfolio.createdUserId = :userId", { userId: request.user.sub })
|
order: { name: "ASC" },
|
||||||
.andWhere(
|
});
|
||||||
new Brackets((qb) => {
|
|
||||||
qb.where(keyword != null && keyword != "" ? "portfolio.name LIKE :keyword" : "1=1", {
|
|
||||||
keyword: `%${keyword}%`,
|
|
||||||
}).orWhere(keyword != null && keyword != "" ? "portfolio.detail LIKE :keyword" : "1=1", {
|
|
||||||
keyword: `%${keyword}%`,
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.getMany();
|
|
||||||
|
|
||||||
|
// const _portfolio = await this.portfolioRepository
|
||||||
|
// .createQueryBuilder("portfolio")
|
||||||
|
// .select([
|
||||||
|
// "portfolio.id",
|
||||||
|
// "portfolio.name",
|
||||||
|
// "portfolio.detail",
|
||||||
|
// "portfolio.createdAt",
|
||||||
|
// "portfolio.lastUpdatedAt",
|
||||||
|
// "portfolio.createdFullName",
|
||||||
|
// "portfolio.lastUpdateFullName",
|
||||||
|
// ])
|
||||||
|
// .where("portfolio.createdUserId = :userId", { userId: request.user.sub })
|
||||||
|
// .andWhere(
|
||||||
|
// new Brackets((qb) => {
|
||||||
|
// qb.where(keyword != null && keyword != "" ? "portfolio.name LIKE :keyword" : "1=1", {
|
||||||
|
// keyword: `%${keyword}%`,
|
||||||
|
// }).orWhere(keyword != null && keyword != "" ? "portfolio.detail LIKE :keyword" : "1=1", {
|
||||||
|
// keyword: `%${keyword}%`,
|
||||||
|
// });
|
||||||
|
// }),
|
||||||
|
// )
|
||||||
|
// .getMany();
|
||||||
|
|
||||||
return new HttpSuccess(_portfolio);
|
return new HttpSuccess(_portfolio);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue