package com.hai.service.impl;

import com.hai.dao.OutRechargePriceMapper;
import com.hai.entity.*;
import com.hai.service.OutRechargePriceService;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("outRechargePriceServiceImpl")
public class OutRechargePriceServiceImpl implements OutRechargePriceService {

    @Resource
    private OutRechargePriceMapper outRechargePriceMapper;

    @Override
    public List<OutRechargePrice> getListRechargePrice(Map<String , String> map) {
        OutRechargePriceExample example = new OutRechargePriceExample();
        OutRechargePriceExample.Criteria criteria = example.createCriteria();

        if (StringUtils.isNotBlank(map.get("type"))) {
            criteria.andTypeEqualTo(Integer.valueOf(map.get("type")));
        }

        example.setOrderByClause("type asc");
        return outRechargePriceMapper.selectByExample(example);
    }
    @Override
    public List<OutRechargePrice> getListRechargePriceC(Map<String , String> map) {
        OutRechargePriceExample example = new OutRechargePriceExample();
        OutRechargePriceExample.Criteria criteria = example.createCriteria();

        criteria.andStatusEqualTo(1);

        if (StringUtils.isNotBlank(map.get("type"))) {
            criteria.andTypeEqualTo(Integer.valueOf(map.get("type")));
        }

        example.setOrderByClause("sort asc");
        return outRechargePriceMapper.selectByExample(example);
    }


    @Override
    public OutRechargePrice findById(Long id) {
        return outRechargePriceMapper.selectByPrimaryKey(id);
    }

    @Override
    public void insertRechargePrice(OutRechargePrice outRechargePrice) {
         outRechargePriceMapper.insert(outRechargePrice);
    }

    @Override
    public void updateRechargePrice(OutRechargePrice outRechargePrice) {
         outRechargePriceMapper.updateByPrimaryKey(outRechargePrice);
    }

    @Override
    public void deletePrice(Long id) {
        outRechargePriceMapper.deleteByPrimaryKey(id);
    }
}
