TpPEqpGatewayDaoImpl.java 3.83 KB
package com.zteits.park.dao.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import com.zteits.clouds.api.dto.park.dto.StaticEqpConutForGatewayDTO;
import com.zteits.clouds.api.dto.park.param.TpPEqpGatewayRequest;
import com.zteits.park.dao.TpPEqpGatewayDao;
import com.zteits.park.domain.TpPEqpGateway;
import com.zteits.park.domain.TpPEqpGatewayExample;
import com.zteits.park.mapper.TpPEqpGatewayMapper;
import com.zteits.park.mapper.smapper.TpPEqpGatewaySMapper;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TpPEqpGatewayDaoImpl implements TpPEqpGatewayDao {

    @Autowired
    private TpPEqpGatewayMapper tpPEqpGatewayMapper;

    @Autowired
    private TpPEqpGatewaySMapper tpPEqpGatewaySMapper;

    @Override
    public int deleteTpPEqpGatewayByPrimaryKey(Long id, Long opId, String opName) {
        TpPEqpGateway record = new TpPEqpGateway();
        record.setId(id);
        record.setModifyOp(opId);
        record.setModifyOpName(opName);
        record.setModifyTime(new Date());
        record.setDataState(DataStatusEnum.DATA_STATUS_NO_VALID.value());
        return tpPEqpGatewayMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int saveTpPEqpGateway(TpPEqpGateway tpPEqpGateway) {
        if (tpPEqpGateway.getCreateTime() == null) {
            tpPEqpGateway.setCreateTime(new Date());
        }
        if (tpPEqpGateway.getModifyTime() == null) {
            tpPEqpGateway.setModifyTime(new Date());
        }
        return tpPEqpGatewayMapper.insertSelective(tpPEqpGateway);
    }

    @Override
    public int updateByExampleSelective(TpPEqpGateway record, TpPEqpGatewayExample example) {
        return tpPEqpGatewayMapper.updateByExampleSelective(record, example);
    }

    @Override
    public int updateByPrimaryKeySelective(TpPEqpGateway record) {
        return tpPEqpGatewayMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public List<TpPEqpGateway> selectByExample(TpPEqpGatewayExample example) {
        return tpPEqpGatewayMapper.selectByExample(example);
    }

    @Override
    public TpPEqpGateway queryByPrimaryKey(Long id) {
        return tpPEqpGatewayMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<TpPEqpGateway> queryTpPEqpGateway(TpPEqpGatewayRequest request) {
        return tpPEqpGatewaySMapper.queryTpPEqpGateway(request);
    }

    @Override
    public int batchDeleteTpPEqpGatewayByPrimaryKey(List<Long> ids, Long opId, String opName) {
        TpPEqpGateway record = new TpPEqpGateway();
        record.setModifyOp(opId);
        record.setModifyOpName(opName);
        record.setModifyTime(new Date());
        //where条件
        TpPEqpGatewayExample example = new TpPEqpGatewayExample();
        example.createCriteria().andIdIn(ids);
        return tpPEqpGatewayMapper.updateByExampleSelective(record, example);
    }

    @Override
    public PageInfo<TpPEqpGateway> queryTpPEqpGatewayForPage(TpPEqpGatewayRequest request) {
        PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
        List<TpPEqpGateway> list = tpPEqpGatewaySMapper.queryTpPEqpGateway(request);
        if (CollectionUtils.isNotEmpty(list)) {
            return new PageInfo<>(list);
        }
        return new PageInfo<>(new ArrayList<>());
    }

    @Override
    public StaticEqpConutForGatewayDTO statisticEqpCountByCondition(TpPEqpGatewayRequest request) {

        StaticEqpConutForGatewayDTO dto = tpPEqpGatewaySMapper.statisticEqpCountByCondition(request);
        return dto == null ? new StaticEqpConutForGatewayDTO() : dto;
    }
}