package com.shkj.wms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shkj.common.utils.SecurityUtils;
import com.shkj.wms.domain.BasRuleDetail;
import com.shkj.wms.mapper.BasRuleDetailMapper;
import com.shkj.wms.service.IBasRuleDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 编码规则Service业务层处理
 *
 * @author j.liang
 * @date 2022-12-08
 */
@Slf4j
@Service
public class BasRuleDetailServiceImpl extends ServiceImpl<BasRuleDetailMapper, BasRuleDetail> implements IBasRuleDetailService {
    public static ThreadLocal<Boolean> threadLocal = new ThreadLocal<>();


    @Override
    public Boolean saveBatchRuleDetail(Long ruleId, List<BasRuleDetail> list) {
        this.remove(new LambdaQueryWrapper<BasRuleDetail>().eq(BasRuleDetail::getRuleId, ruleId));
        for (BasRuleDetail basRuleDetail : list) {
            basRuleDetail.setRuleId(ruleId);
            basRuleDetail.setBranchId(SecurityUtils.getCurrentBranchId());
        }
        return this.saveBatch(list);
    }
}
