
package com.tmerclub.cloud.order.service.impl;

import com.tmerclub.cloud.common.constant.Constant;
import com.tmerclub.cloud.common.i18n.LanguageEnum;
import com.tmerclub.cloud.order.mapper.PurchaseOrderLangMapper;
import com.tmerclub.cloud.order.model.PurchaseOrderLang;
import com.tmerclub.cloud.order.service.PurchaseOrderLangService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 采购订单-国际化
 *
 * @author lhd
 * @date 2022-07-12 13:57:20
 */
@Service
public class PurchaseOrderLangServiceImpl implements PurchaseOrderLangService {

    @Autowired
    private PurchaseOrderLangMapper purchaseOrderLangMapper;

    @Override
    public void saveBatch(StringBuilder orderSpuNameCn, StringBuilder orderSpuNameEn, Long purchaseOrderId) {
        List<PurchaseOrderLang> purchaseOrderLangList = new ArrayList<>(Constant.INITIAL_CAPACITY);
        PurchaseOrderLang purchaseOrderLang = new PurchaseOrderLang();
        purchaseOrderLang.setLang(LanguageEnum.LANGUAGE_ZH_CN.getLang());
        purchaseOrderLang.setSpuName(orderSpuNameCn.toString());
        purchaseOrderLang.setPurchaseOrderId(purchaseOrderId);
        purchaseOrderLangList.add(purchaseOrderLang);
        // sharing 需要单独字段做主键，暂只保存中文数据，避免插入key重复
//        PurchaseOrderLang purchaseOrderLangEn = new PurchaseOrderLang();
//        purchaseOrderLangEn.setLang(LanguageEnum.LANGUAGE_EN.getLang());
//        purchaseOrderLangEn.setSpuName(orderSpuNameEn.toString());
//        purchaseOrderLangEn.setPurchaseOrderId(purchaseOrderId);
//        purchaseOrderLangList.add(purchaseOrderLangEn);
        purchaseOrderLangMapper.saveBatch(purchaseOrderLangList);
    }
}
