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(
|
||||
@Request() req: RequestWithUser,
|
||||
@Query() status?: Status,
|
||||
@Query() shared?: boolean,
|
||||
@Query() productGroupId?: string,
|
||||
@Query() query: string = "",
|
||||
@Query() page: number = 1,
|
||||
|
|
@ -134,22 +135,41 @@ export class ProductController extends Controller {
|
|||
]),
|
||||
AND: {
|
||||
...filterStatus(status),
|
||||
productGroupId,
|
||||
OR: isSystem(req.user)
|
||||
? undefined
|
||||
: [
|
||||
{
|
||||
productGroup: {
|
||||
registeredBranch: { OR: permissionCond(req.user) },
|
||||
OR: [
|
||||
...(productGroupId
|
||||
? [
|
||||
shared
|
||||
? {
|
||||
OR: [
|
||||
{ productGroupId },
|
||||
{
|
||||
productGroup: {
|
||||
shared: true,
|
||||
registeredBranch: { OR: permissionCondCompany(req.user) },
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
: { productGroupId },
|
||||
]
|
||||
: []),
|
||||
...(isSystem(req.user)
|
||||
? []
|
||||
: [
|
||||
{
|
||||
shared: true,
|
||||
productGroup: {
|
||||
registeredBranch: { OR: permissionCondCompany(req.user) },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
shared: true,
|
||||
productGroup: {
|
||||
registeredBranch: { OR: permissionCondCompany(req.user) },
|
||||
{
|
||||
productGroup: {
|
||||
shared: true,
|
||||
registeredBranch: { OR: permissionCondCompany(req.user) },
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
]),
|
||||
],
|
||||
},
|
||||
} satisfies Prisma.ProductWhereInput;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue