package com.hzs.activity.base.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.common.core.constant.SystemFieldConstants;
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;

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


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


    @Override
    public Boolean deleteGoalMemberConfig(Long pkBaseId, Long pkModifyId) {
        UpdateWrapper<AcGoalMemberConfig> 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);

    }
}
