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

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jeesharp.business.modules.setting.entity.MarketingActivityScope;
import com.jeesharp.business.modules.setting.mapper.MarketingActivityScopeMapper;
import com.jeesharp.business.modules.setting.service.MarketingActivityScopeService;
import com.jeesharp.business.modules.setting.vo.MarketingActivityScopeQueryVO;
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 MarketingActivityScopeServiceImpl extends CrudService<MarketingActivityScopeMapper, MarketingActivityScope, MarketingActivityScopeQueryVO>
        implements MarketingActivityScopeService {

    @Override
    @Transactional(readOnly = false)
    public void createMarketingActivityScope(MarketingActivityScope entity) {
        save(entity);
    }

    @Override
    @Transactional(readOnly = false)
    public void updateMarketingActivityScope(MarketingActivityScope entity) {
        update(entity);
    }

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