package com.jeesharp.business.modules.setting.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jeesharp.business.modules.setting.entity.MarketingActivityRule;
import com.jeesharp.business.modules.setting.mapper.MarketingActivityRuleMapper;
import com.jeesharp.business.modules.setting.service.MarketingActivityRuleService;
import com.jeesharp.business.modules.setting.vo.MarketingActivityRuleQueryVO;
import com.jeesharp.framework.mybatis.core.service.CrudService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true)
public class MarketingActivityRuleServiceImpl extends CrudService<MarketingActivityRuleMapper, MarketingActivityRule, MarketingActivityRuleQueryVO>
        implements MarketingActivityRuleService {

    @Override
    @Transactional(readOnly = false)
    public void createMarketingActivityRule(MarketingActivityRule entity) {
        save(entity);
    }

    @Override
    @Transactional(readOnly = false)
    public void updateMarketingActivityRule(MarketingActivityRule entity) {
        update(entity);
    }

    @Override
    public List<MarketingActivityRule> listByActivityId(String activityId) {
        LambdaQueryWrapper<MarketingActivityRule> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MarketingActivityRule::getActivityId, activityId);
        wrapper.eq(MarketingActivityRule::getDelFlag, "0");
        return list(wrapper);
    }
}
