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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.code.PublicCommon;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.frequency.pfwithdrawalway.entity.PfWithdrawalWay;
import com.ruoyi.frequency.pfwithdrawalway.mapper.PfWithdrawalWayMapper;
import com.ruoyi.frequency.pfwithdrawalway.service.PfWithdrawalWayService;
import com.ruoyi.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 后台提现方式Service业务层处理
 *
 * @author liwenlong
 * @date 2023-07-20
 */
@Service
public class PfWithdrawalWayServiceImpl extends ServiceImpl<PfWithdrawalWayMapper, PfWithdrawalWay>  implements PfWithdrawalWayService
{
    @Autowired
    private PfWithdrawalWayMapper pfWithdrawalWayMapper;

    /**
     * 查询后台提现方式
     *
     * @param id 后台提现方式主键
     * @return 后台提现方式
     */
    @Override
    public PfWithdrawalWay selectPfWithdrawalWayById(Long id)
    {
        return pfWithdrawalWayMapper.selectPfWithdrawalWayById(id);
    }

    /**
     * 查询后台提现方式列表
     *
     * @param pfWithdrawalWay 后台提现方式
     * @return 后台提现方式
     */
    @Override
    public List<PfWithdrawalWay> selectPfWithdrawalWayList(PfWithdrawalWay pfWithdrawalWay)
    {
        return pfWithdrawalWayMapper.selectPfWithdrawalWayList(pfWithdrawalWay);
    }

    /**
     * 新增后台提现方式
     *
     * @param pfWithdrawalWay 后台提现方式
     * @return 结果
     */
    @Override
    public int insertPfWithdrawalWay(PfWithdrawalWay pfWithdrawalWay)
    {
        pfWithdrawalWay.setCreateTime(DateUtils.getNowDate());
        return pfWithdrawalWayMapper.insertPfWithdrawalWay(pfWithdrawalWay);
    }

    /**
     * 修改后台提现方式
     *
     * @param pfWithdrawalWay 后台提现方式
     * @return 结果
     */
    @Override
    public int updatePfWithdrawalWay(PfWithdrawalWay pfWithdrawalWay)
    {
        pfWithdrawalWay.setUpdateTime(DateUtils.getNowDate());
        return pfWithdrawalWayMapper.updatePfWithdrawalWay(pfWithdrawalWay);
    }

    /**
     * 批量删除后台提现方式
     *
     * @param ids 需要删除的后台提现方式主键
     * @return 结果
     */
    @Override
    public int deletePfWithdrawalWayByIds(Long[] ids)
    {
        return pfWithdrawalWayMapper.deletePfWithdrawalWayByIds(ids);
    }

    /**
     * 删除后台提现方式信息
     *
     * @param id 后台提现方式主键
     * @return 结果
     */
    @Override
    public int deletePfWithdrawalWayById(Long id)
    {
        return pfWithdrawalWayMapper.deletePfWithdrawalWayById(id);
    }


    @Override
    public ResponseData pfList() {
        List<PfWithdrawalWay> pfWithdrawalWays = this.list(new QueryWrapper<PfWithdrawalWay>().lambda().
                eq(PfWithdrawalWay::getDelFlag, PublicCommon.启用)
                .orderByAsc(PfWithdrawalWay::getSort));

        return ResponseData.success(pfWithdrawalWays);
    }
}
