제품 커밋

This commit is contained in:
chpark 2025-01-06 10:21:29 +09:00
parent d9731d03b1
commit d834359577
3 changed files with 8 additions and 0 deletions

View File

@ -68,6 +68,8 @@ class Company extends Model {
this.hasMany(models.MaintenanceLog, { foreignKey: "companyId" });
this.hasMany(models.ApiKey, { foreignKey: "companyId" });
this.hasMany(models.OemMng, { foreignKey: "companyId" });
this.hasMany(models.ProductGroup, { foreignKey: "companyId" });
this.hasMany(models.Product, { foreignKey: "companyId" });
}
}

View File

@ -55,6 +55,7 @@ class ProductGroup extends Model {
static associate(models) {
// OemMng이 Company에 속함
this.belongsTo(models.Company, { foreignKey: "companyId" });
this.hasMany(models.Product, { foreignKey: "product_group_id" });
}
}

View File

@ -1,5 +1,6 @@
const {
Product,
ProductGroup,
Company,
Role,
} = require("../models");
@ -31,6 +32,10 @@ class productService {
model: Company,
attributes: ["id", "name"],
},
{
model: ProductGroup,
attributes: ["id", "product_group_name"], // 필요한 속성들을 추가하세요
},
],
order: [["createdAt", "DESC"]],
offset,