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

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.activity.base.AcGoalMemberConfig;
import com.hzs.activity.base.mapper.AcGoalMemberConfigMapper;
import com.hzs.activity.base.service.IAcGoalMemberConfigService;
import org.springframework.stereotype.Service;

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

/**
 * 活动基本配置-目标群体配置 服务实现类
 */
@Service
public class AcGoalMemberConfigServiceImpl extends ServiceImpl<AcGoalMemberConfigMapper, AcGoalMemberConfig> implements IAcGoalMemberConfigService {

    @Override
    public List<AcGoalMemberConfig> selectMemberConfig(Long activityId) {
        LambdaQueryWrapper<AcGoalMemberConfig> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AcGoalMemberConfig::getPkBaseId, activityId);
        return this.list(queryWrapper);
    }

    @Override
    public Boolean deleteGoalMemberConfig(Long pkBaseId, Long pkModifyId) {
        LambdaUpdateWrapper<AcGoalMemberConfig> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(AcGoalMemberConfig::getDelFlag, EDelFlag.DELETE.getValue());
        updateWrapper.set(AcGoalMemberConfig::getPkModified, pkModifyId);
        updateWrapper.set(AcGoalMemberConfig::getModifiedTime, new Date());
        updateWrapper.eq(AcGoalMemberConfig::getPkBaseId, pkBaseId);
        return update(updateWrapper);
    }

}
