ChargerTicketConfigDaoImpl.java 2.77 KB
package com.zteits.pay.dao.impl;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import com.zteits.pay.dao.ChargerTicketConfigDao;
import com.zteits.pay.domain.ChargerTicketBaseConfig;
import com.zteits.pay.domain.ChargerTicketBaseConfigExample;
import com.zteits.pay.domain.ChargerTicketConfig;
import com.zteits.pay.domain.ChargerTicketConfigExample;
import com.zteits.pay.mapper.ChargerTicketBaseConfigMapper;
import com.zteits.pay.mapper.ChargerTicketConfigMapper;
import com.zteits.pay.mapper.smapper.ChargerTicketConfigSMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ChargerTicketConfigDaoImpl implements ChargerTicketConfigDao {

    @Autowired
    private ChargerTicketConfigMapper chargerTicketConfigMapper;
    @Autowired
    private ChargerTicketBaseConfigMapper chargerTicketBaseConfigMapper;
    @Autowired
    private ChargerTicketConfigSMapper chargerTicketConfigSMapper;

    @Override
    public int bathSaveChargerTicketConfigs(List<ChargerTicketConfig> configs) {
        return chargerTicketConfigSMapper.bathInsertSelective(configs);
    }

    @Override
    public List<ChargerTicketConfig> queryChargerTicketConfigsByCondition(ChargerTicketConfig config) {
        ChargerTicketConfigExample example = new ChargerTicketConfigExample();
        ChargerTicketConfigExample.Criteria sql = example.createCriteria();
        sql.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
                .andOrgIdEqualTo(config.getOrgId()).andTicketTypeEqualTo(config.getTicketType())
                .andTicketCategoryEqualTo(config.getTicketCategory());
        if (!StringUtils.isBlank(config.getTicketNo())) {
            sql.andTicketNoEqualTo(config.getTicketNo());
        }
        return chargerTicketConfigMapper.selectByExample(example);
    }

    @Override
    public List<ChargerTicketBaseConfig> queryChargerTicketBaseConfigsByCondition(List<String> widgetNos,
                                                                                  Integer ticketType, Integer ticketCategory, Long orgId) {
        ChargerTicketBaseConfigExample example = new ChargerTicketBaseConfigExample();
        ChargerTicketBaseConfigExample.Criteria sql = example.createCriteria();
        sql.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
                .andOrgIdEqualTo(orgId).andTicketTypeEqualTo(ticketType)
                .andTicketCategoryEqualTo(ticketCategory);
        if (CollectionUtils.isNotEmpty(widgetNos)) {
            sql.andWidgetNoIn(widgetNos);
        }
        return chargerTicketBaseConfigMapper.selectByExample(example);
    }
}