/** * */ package com.zteits.pay.dao.impl; import java.util.List; import com.alipay.api.domain.DataEnumValue; import com.zteits.clouds.api.apibase.constants.DataStatusEnum; import com.zteits.clouds.api.dto.pay.param.TdCCustInvoiceinfoRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import com.zteits.pay.dao.TdCCustInvoiceinfoDao; import com.zteits.pay.domain.TdCCustInvoiceinfo; import com.zteits.pay.domain.TdCCustInvoiceinfoExample; import com.zteits.pay.mapper.TdCCustInvoiceinfoMapper; /** * @author hxz * */ @Component public class TdCCustInvoiceinfoDaoImpl implements TdCCustInvoiceinfoDao { @Autowired private TdCCustInvoiceinfoMapper tdCCustInvoiceinfoMapper; @Override @Transactional public Long insertCustomerInvoiceInfo(TdCCustInvoiceinfo record) { if (record.getIsDefault().equals("1")) { TdCCustInvoiceinfoExample example = new TdCCustInvoiceinfoExample (); example.createCriteria().andCustIdEqualTo(record.getCustId()); TdCCustInvoiceinfo updateRecord = new TdCCustInvoiceinfo (); updateRecord.setCustId(record.getCustId()); updateRecord.setIsDefault("0"); tdCCustInvoiceinfoMapper.updateByExampleSelective(updateRecord, example); } return new Long((long)tdCCustInvoiceinfoMapper.insertSelective(record)); } @Override public Boolean deleteCustomerInvoiceInfoByID(Long id) { TdCCustInvoiceinfoExample example = new TdCCustInvoiceinfoExample(); example.createCriteria().andIdEqualTo(id); return tdCCustInvoiceinfoMapper.deleteByExample(example) > 0; } @Override @Transactional public Boolean updateByPrimaryKeySelective(TdCCustInvoiceinfo record) { if (record.getIsDefault().equals("1")) { TdCCustInvoiceinfoExample example = new TdCCustInvoiceinfoExample (); example.createCriteria().andCustIdEqualTo(record.getCustId()); TdCCustInvoiceinfo updateRecord = new TdCCustInvoiceinfo (); updateRecord.setCustId(record.getCustId()); updateRecord.setIsDefault("0"); tdCCustInvoiceinfoMapper.updateByExampleSelective(updateRecord, example); } return tdCCustInvoiceinfoMapper.updateByPrimaryKeySelective(record) > 0; } @Override public TdCCustInvoiceinfo queryCustomerInvoiceInfoById(Long id) { return tdCCustInvoiceinfoMapper.selectByPrimaryKey(id); } @Override public List queryCustInvoiceInfoList(TdCCustInvoiceinfoExample example) { return tdCCustInvoiceinfoMapper.selectByExample(example); } @Override public Long checkBindInfoNum(TdCCustInvoiceinfoRequest requestObject) { TdCCustInvoiceinfoExample example = new TdCCustInvoiceinfoExample(); example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value()) .andCustIdEqualTo(requestObject.getCustId()); return tdCCustInvoiceinfoMapper.countByExample(example); } @Override public Boolean updateByExampleSelective(TdCCustInvoiceinfo record, TdCCustInvoiceinfoExample example) { return tdCCustInvoiceinfoMapper.updateByExampleSelective(record, example) > 0; } }