package com.yiqi.activity.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yiqi.common.utils.DateUtils;
import com.yiqi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yiqi.activity.mapper.ActivityApplyOrgMapper;
import com.yiqi.activity.domain.ActivityApplyOrg;
import com.yiqi.activity.service.IActivityApplyOrgService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 活动适用组织Service业务层处理
 *
 * @author ruoyi
 * @date 2023-09-10
 */
@Service
public class ActivityApplyOrgServiceImpl extends ServiceImpl<ActivityApplyOrgMapper,ActivityApplyOrg> implements IActivityApplyOrgService {

    /**
     * 查询活动适用组织
     *
     * @param id 活动适用组织主键
     * @return 活动适用组织
     */
    @Override
    public ActivityApplyOrg selectActivityApplyOrgById(Long id) {
        return baseMapper.selectActivityApplyOrgById(id);
    }

    @Override
    public Long getActivityApplyOrgNumByActivityId(Long activityId) {
        QueryWrapper<ActivityApplyOrg> wrapper = new QueryWrapper<>();
        wrapper.eq("activity_id",activityId);
        return count(wrapper);
    }


    /**
     * 查询活动适用组织列表
     *
     * @param activityApplyOrg 活动适用组织
     * @return 活动适用组织
     */
    @Override
    public List<ActivityApplyOrg> selectActivityApplyOrgList(ActivityApplyOrg activityApplyOrg) {
        return baseMapper.selectActivityApplyOrgList(activityApplyOrg);
    }

    /**
     * 新增活动适用组织
     *
     * @param activityApplyOrg 活动适用组织
     * @return 结果
     */
    @Override
    public int insertActivityApplyOrg(ActivityApplyOrg activityApplyOrg) {
        activityApplyOrg.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insertActivityApplyOrg(activityApplyOrg);
    }

    /**
     * 修改活动适用组织
     *
     * @param activityApplyOrg 活动适用组织
     * @return 结果
     */
    @Override
    public int updateActivityApplyOrg(ActivityApplyOrg activityApplyOrg) {
        activityApplyOrg.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateActivityApplyOrg(activityApplyOrg);
    }

    /**
     * 批量删除活动适用组织
     *
     * @param ids 需要删除的活动适用组织主键
     * @return 结果
     */
    @Override
    public int deleteActivityApplyOrgByIds(Long[] ids) {
        return baseMapper.deleteActivityApplyOrgByIds(ids);
    }

    /**
     * 删除活动适用组织信息
     *
     * @param id 活动适用组织主键
     * @return 结果
     */
    @Override
    public int deleteActivityApplyOrgById(Long id) {
        return baseMapper.deleteActivityApplyOrgById(id);
    }



}
