ParkIllegalAreaRelDaoImpl.java 3.31 KB
package com.zteits.park.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import com.zteits.clouds.api.dto.park.param.ParkIllegalAreaRelQueryReq;
import com.zteits.park.dao.ParkIllegalAreaRelDao;
import com.zteits.park.domain.ParkIllegalAreaRel;
import com.zteits.park.domain.ParkIllegalAreaRelExample;
import com.zteits.park.mapper.ParkIllegalAreaRelMapper;
import com.zteits.park.mapper.smapper.ParkIllegalAreaRelSMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Copyright: Copyright (c) 2019  zteits
 *
 * @ClassName: com.zteits.park.dao.impl
 * @Description:
 * @version: v1.0.0
 * @author: atao
 * @date: 2019-04-02   11:07
 * Modification History:
 * Date         Author          Version      Description
 * ---------------------------------------------------------*
 * 2019-04-02      atao          v1.0.0          创建
 */
@Component
public class ParkIllegalAreaRelDaoImpl implements ParkIllegalAreaRelDao {

    @Autowired
    private ParkIllegalAreaRelSMapper parkIllegalAreaRelSMapper;

    @Autowired
    private ParkIllegalAreaRelMapper parkIllegalAreaRelMapper;

    @Override
    public Map<Long, String> ParkIllegalAreaRelByIllegalBaseIds(List<Long> illegalBaseIds) {

        Map<Long, String> result = new HashMap<>();

        List<Map<String, Object>> list = parkIllegalAreaRelSMapper.ParkIllegalAreaRelByIllegalBaseIds(illegalBaseIds);

        if (list != null && !list.isEmpty()) {
            for (Map<String, Object> map1 : list) {
                Long key = null;
                String value = null;
                for (Map.Entry<String, Object> entry : map1.entrySet()) {
                    if ("id".equals(entry.getKey())) {
                        key = (Long)entry.getValue();
                    } else if ("plName".equals(entry.getKey())) {
                        value = (String)entry.getValue();
                    }
                }
                result.put(key, value);
            }
        }

        return result;
    }

    @Override
    public int saveParkIllegalAreaRel(ParkIllegalAreaRel parkIllegalAreaRel) {

        parkIllegalAreaRel.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
        return parkIllegalAreaRelMapper.insertSelective(parkIllegalAreaRel);
    }

    @Override
    public int deleteParkIllegalAreaRelByParkIllegalBaseId(Long parkIllegalBaseId) {

        ParkIllegalAreaRelExample example = new ParkIllegalAreaRelExample();
        example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
            .andParkIllegalBaseIdEqualTo(parkIllegalBaseId);

        ParkIllegalAreaRel rel = new ParkIllegalAreaRel();
        rel.setDataState(DataStatusEnum.DATA_STATUS_NO_VALID.value());
        return parkIllegalAreaRelMapper.updateByExampleSelective(rel, example);
    }

    @Override
    public List<ParkIllegalAreaRel> queryParkIllegalAreaRel(ParkIllegalAreaRelQueryReq request) {

        ParkIllegalAreaRelExample example = new ParkIllegalAreaRelExample();
        example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
            .andParkIllegalBaseIdEqualTo(request.getParkIllegalBaseId());

        return parkIllegalAreaRelMapper.selectByExample(example);
    }
}