ParkingLotExtendDaoImpl.java 3.8 KB
package com.zteits.park.dao.impl;

import org.apache.commons.collections4.CollectionUtils;
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.param.ParkingLotExtendQueryRequest;
import com.zteits.clouds.api.dto.park.param.ParkingLotExtendRequest;
import com.zteits.park.dao.ParkingLotExtendDao;
import com.zteits.park.domain.ParkingLotExtend;
import com.zteits.park.domain.ParkingLotExtendExample;
import com.zteits.park.mapper.ParkingLotExtendMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

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

@Component
public class ParkingLotExtendDaoImpl implements  ParkingLotExtendDao {
    @Autowired
    private ParkingLotExtendMapper parkingLotExtendMapper;
    @Override
    public int deleteParkingLotExtendByPrimaryKey(Long id, String opId, String opName) {
        ParkingLotExtend record = new ParkingLotExtend();
        record.setId(id);
        record.setDataStatus(DataStatusEnum.DATA_STATUS_NO_VALID.value());
        record.setModifyOp(opId);
        record.setModifyTime(new Date());
        return parkingLotExtendMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int saveParkingLotExtend(ParkingLotExtend parkingLotExtend) {
        if(parkingLotExtend.getCreateTime()==null){
            parkingLotExtend.setCreateTime(new Date());
        }
        return parkingLotExtendMapper.insertSelective(parkingLotExtend);
    }

    @Override
    public int updateByExampleSelective(ParkingLotExtend record, ParkingLotExtendExample example) {
        return parkingLotExtendMapper.updateByExampleSelective(record,example);
    }

    @Override
    public int updateByPrimaryKeySelective(ParkingLotExtend record) {
        return parkingLotExtendMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public List<ParkingLotExtend> selectByExample(ParkingLotExtendExample example) {
        return parkingLotExtendMapper.selectByExample(example);
    }

    @Override
    public ParkingLotExtend queryByPrimaryKey(Long id) {
        return parkingLotExtendMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<ParkingLotExtend> queryParkingLotExtend(ParkingLotExtendQueryRequest request) {
        ParkingLotExtendExample example = new ParkingLotExtendExample();
        example.createCriteria().andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
                .andPlNoIn(request.getPlNos());
        List<ParkingLotExtend> list = parkingLotExtendMapper.selectByExample(example);
        return list;
    }

    @Override
    public int batchDeleteParkingLotExtendByPrimaryKey(List<Long> ids, String opId, String opName) {
        ParkingLotExtend record = new ParkingLotExtend();
        //where条件
        ParkingLotExtendExample example = new ParkingLotExtendExample();
        example.createCriteria().andIdIn(ids);
        return parkingLotExtendMapper.updateByExampleSelective(record,example);
    }

    @Override
    public PageInfo<ParkingLotExtend> queryParkingLotExtendForPage(ParkingLotExtendQueryRequest request) {
        PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
        ParkingLotExtendExample example = new ParkingLotExtendExample();
        example.createCriteria().andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
                .andPlNoIn(request.getPlNos());
        List<ParkingLotExtend> list = parkingLotExtendMapper.selectByExample(example);
        if (CollectionUtils.isNotEmpty(list)) {
            return new PageInfo<ParkingLotExtend>(list);
        }
        return new PageInfo<ParkingLotExtend>(new ArrayList<ParkingLotExtend>());
    }
}