attrValue.js 842 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { getAll } from '../_utils/model';
  2. import { DATA_MODEL_KEY } from '../../config/model';
  3. import { cloudbaseTemplateConfig } from "../../config/index"
  4. import { ATTR_VALUE } from "../cloudbaseMock/index"
  5. const ATTR_VALUE_MODEL_KEY = DATA_MODEL_KEY.ATTR_VALUE;
  6. export async function getAllAttrValues(skuId) {
  7. if (cloudbaseTemplateConfig.useMock) {
  8. return ATTR_VALUE.filter(x => x.sku.find(x => x._id === skuId))
  9. }
  10. const res = await getAll({
  11. name: ATTR_VALUE_MODEL_KEY,
  12. filter: {
  13. relateWhere: {
  14. sku: {
  15. where: {
  16. _id: {
  17. $eq: skuId,
  18. },
  19. },
  20. },
  21. },
  22. },
  23. select: {
  24. _id: true,
  25. value: true,
  26. attr_name: {
  27. _id: true,
  28. name: true,
  29. },
  30. sku: {
  31. _id: true
  32. }
  33. },
  34. });
  35. return res;
  36. }