package com.hzs.activity.recommend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.activity.recommend.mapper.AcRecomUpgradeRuleConfigMapper;
import com.hzs.activity.recommend.service.IAcRecomUpgradeRuleConfigService;
import com.hzs.activity.recommend.vo.AcRecommendUpgradeVO;
import com.hzs.common.core.constant.SystemFieldConstants;
import com.hzs.common.core.enums.EDelFlag;
import com.hzs.common.domain.activity.recommend.AcRecomUpgradeRuleConfig;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 直推-推荐升级 服务实现类
 * </p>
 *
 * @author hzs
 * @since 2023-04-22
 */
@Service
public class AcRecomUpgradeRuleConfigServiceImpl extends ServiceImpl<AcRecomUpgradeRuleConfigMapper, AcRecomUpgradeRuleConfig> implements IAcRecomUpgradeRuleConfigService {

    @Override
    public List<AcRecomUpgradeRuleConfig> selectByActivityId(Long activityId) {
        QueryWrapper<AcRecomUpgradeRuleConfig> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("PK_BASE_ID", activityId);
        return baseMapper.selectList(queryWrapper);

    }


    @Override
    public List<AcRecomUpgradeRuleConfig> selectRuleConfig(AcRecommendUpgradeVO recommendUpgradeVO) {
        return baseMapper.selectRuleConfig(recommendUpgradeVO);
    }

    @Override
    public Boolean deleteUpgradeRuleConfigByBaseId(Long pkBaseId, Long pkModifyId) {
        UpdateWrapper<AcRecomUpgradeRuleConfig> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set(SystemFieldConstants.DEL_FLAG, EDelFlag.DELETE.getValue());
        updateWrapper.set(SystemFieldConstants.PK_MODIFIED, pkModifyId);
        updateWrapper.set(SystemFieldConstants.MODIFIED_TIME, new Date());
        updateWrapper.eq("PK_BASE_ID", pkBaseId);
        return update(updateWrapper);

    }


}
