feat: add parameter to accept shared product
This commit is contained in:
parent
1a31a29680
commit
b758067e14
1 changed files with 34 additions and 14 deletions
|
|
@ -121,6 +121,7 @@ export class ProductController extends Controller {
|
||||||
async getProduct(
|
async getProduct(
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Query() status?: Status,
|
@Query() status?: Status,
|
||||||
|
@Query() shared?: boolean,
|
||||||
@Query() productGroupId?: string,
|
@Query() productGroupId?: string,
|
||||||
@Query() query: string = "",
|
@Query() query: string = "",
|
||||||
@Query() page: number = 1,
|
@Query() page: number = 1,
|
||||||
|
|
@ -134,21 +135,40 @@ export class ProductController extends Controller {
|
||||||
]),
|
]),
|
||||||
AND: {
|
AND: {
|
||||||
...filterStatus(status),
|
...filterStatus(status),
|
||||||
productGroupId,
|
OR: [
|
||||||
OR: isSystem(req.user)
|
...(productGroupId
|
||||||
? undefined
|
? [
|
||||||
: [
|
shared
|
||||||
|
? {
|
||||||
|
OR: [
|
||||||
|
{ productGroupId },
|
||||||
{
|
{
|
||||||
productGroup: {
|
productGroup: {
|
||||||
registeredBranch: { OR: permissionCond(req.user) },
|
shared: true,
|
||||||
|
registeredBranch: { OR: permissionCondCompany(req.user) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
: { productGroupId },
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
...(isSystem(req.user)
|
||||||
|
? []
|
||||||
|
: [
|
||||||
{
|
{
|
||||||
shared: true,
|
shared: true,
|
||||||
productGroup: {
|
productGroup: {
|
||||||
registeredBranch: { OR: permissionCondCompany(req.user) },
|
registeredBranch: { OR: permissionCondCompany(req.user) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
productGroup: {
|
||||||
|
shared: true,
|
||||||
|
registeredBranch: { OR: permissionCondCompany(req.user) },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
} satisfies Prisma.ProductWhereInput;
|
} satisfies Prisma.ProductWhereInput;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue