package com.hai.service.impl; import com.hai.dao.BsRechargeCodeMapper; import com.hai.entity.BsRechargeCode; import com.hai.entity.BsRechargeCodeExample; import com.hai.service.BsRechargeCodeService; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; import java.util.Map; @Service("bsRechargeCodeService") public class BsRechargeCodeServiceImpl implements BsRechargeCodeService { @Resource private BsRechargeCodeMapper rechargeCodeMapper; @Override public void insertRechargeCode(BsRechargeCode rechargeCode) { rechargeCodeMapper.insert(rechargeCode); } @Override public void updateRechargeCode(BsRechargeCode rechargeCode) { rechargeCodeMapper.updateByPrimaryKeySelective(rechargeCode); } @Override public List getListRechargeCode(Map map) { BsRechargeCodeExample example = new BsRechargeCodeExample(); BsRechargeCodeExample.Criteria criteria = example.createCriteria(); if (MapUtils.getInteger(map, "type") != null) { criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); } if (MapUtils.getString(map, "sourceId") != null) { criteria.andSourceIdEqualTo(MapUtils.getString(map, "sourceId")); } if (MapUtils.getInteger(map, "rechargePlatform") != null) { criteria.andRechargePlatformEqualTo(MapUtils.getInteger(map, "rechargePlatform")); } return rechargeCodeMapper.selectByExample(example); } @Override public BsRechargeCode findByMap(Map map) { BsRechargeCodeExample example = new BsRechargeCodeExample(); BsRechargeCodeExample.Criteria criteria = example.createCriteria(); if (MapUtils.getInteger(map, "type") != null) { criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); } if (MapUtils.getString(map, "sourceId") != null) { criteria.andSourceIdEqualTo(MapUtils.getString(map, "sourceId")); } if (MapUtils.getInteger(map, "rechargePlatform") != null) { criteria.andRechargePlatformEqualTo(MapUtils.getInteger(map, "rechargePlatform")); } List list = rechargeCodeMapper.selectByExample(example); if (list.size() > 0) { return list.get(0); } return null; } @Override public BsRechargeCode findById(Long id) { return rechargeCodeMapper.selectByPrimaryKey(id); } }