package com.ruoyi.frequency.platformrules.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.code.PublicCommon;
import com.ruoyi.frequency.platformrules.mapper.PlatformRulesMapper;
import com.ruoyi.frequency.platformrules.entity.PlatformRules;
import com.ruoyi.frequency.platformrules.service.PlatformRulesService;

/**
 * 平台规则Service业务层处理
 *
 * @author liwenlong
 * @date 2024-01-24
 */
@Service
public class PlatformRulesServiceImpl extends ServiceImpl<PlatformRulesMapper, PlatformRules>  implements PlatformRulesService
{
    @Autowired
    private PlatformRulesMapper platformRulesMapper;

    /**
     * 查询平台规则
     *
     * @param id 平台规则主键
     * @return 平台规则
     */
    @Override
    public PlatformRules selectPlatformRulesById(Long id)
    {
        return platformRulesMapper.selectPlatformRulesById(id);
    }

    /**
     * 查询平台规则列表
     *
     * @param platformRules 平台规则
     * @return 平台规则
     */
    @Override
    public List<PlatformRules> selectPlatformRulesList(PlatformRules platformRules)
    {
        return platformRulesMapper.selectPlatformRulesList(platformRules);
    }

    /**
     * 新增平台规则
     *
     * @param platformRules 平台规则
     * @return 结果
     */
    @Override
    public int insertPlatformRules(PlatformRules platformRules)
    {
        platformRules.setCreateData();
        platformRules.setUpdateData();
        return platformRulesMapper.insert(platformRules);
    }

    /**
     * 修改平台规则
     *
     * @param platformRules 平台规则
     * @return 结果
     */
    @Override
    public int updatePlatformRules(PlatformRules platformRules)
    {
        platformRules.setUpdateData();
        return platformRulesMapper.updatePlatformRules(platformRules);
    }

    /**
     * 批量删除平台规则
     *
     * @param ids 需要删除的平台规则主键
     * @return 结果
     */
    @Override
    public int deletePlatformRulesByIds(Long[] ids,Integer delFlag)
    {
        this.lambdaUpdate().set(PlatformRules::getDelFlag,delFlag).in(PlatformRules::getId,ids).update();
        return ids.length;
    }

}
