package com.hzs.system.config.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.enums.EDelFlag;
import com.hzs.common.domain.system.config.BdLabel;

import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.system.config.mapper.BdLabelMapper;
import com.hzs.system.config.service.IBdLabelService;
import com.hzs.system.config.vo.BdLabelVO;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 商品标签数据 服务实现类
 */
@Service
public class BdLabelServiceImpl extends ServiceImpl<BdLabelMapper, BdLabel> implements IBdLabelService {

    @Override
    public BdLabel getByPkId(Integer labelId) {
        return baseMapper.selectById(labelId);
    }

    @Override
    public List<BdLabel> getLabelByPkCountry(BdLabelVO bdLabelVO) {
        return baseMapper.getLabelByPkCountry(bdLabelVO);
    }

    @Override
    public Boolean deleteLabelById(Integer pkId) {
        LambdaUpdateWrapper<BdLabel> queryWrapper = new LambdaUpdateWrapper<>();
        queryWrapper.eq(BdLabel::getPkId, pkId);
        queryWrapper.set(BdLabel::getPkModified, SecurityUtils.getUserId());
        queryWrapper.set(BdLabel::getModifiedTime, new Date());
        queryWrapper.set(BdLabel::getDelFlag, EDelFlag.DELETE.getValue());
        return this.update(queryWrapper);
    }

    @Override
    public Boolean updateLabelById(BdLabel bdLabel) {
        return updateById(bdLabel);
    }
}
