
package com.bocloud.ims.repository.resource;

import com.bocloud.common.model.Param;
import com.bocloud.common.model.SimpleBean;
import com.bocloud.common.utils.MapTools;
import com.bocloud.database.core.intf.impl.JdbcGenericDao;
import com.bocloud.ims.entity.resource.StorageSyncedSet;
import com.bocloud.ims.entity.resource.Volume;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;

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

/**
 * xsky一致性组DAO接口实现
 *
 */
@Repository("volumeGroupDao")
public class VolumeGroupRepository extends JdbcGenericDao<StorageSyncedSet, Long> {

    public VolumeGroupRepository(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate npJdbcTemplate) {
        super(jdbcTemplate, npJdbcTemplate);
    }

    public List<Volume> list(int page, int rows, List<Param> params, Map<String, String> sorter) {
        return null;
    }

    public List<SimpleBean> list(List<Param> params, Map<String, String> sorter) {
        return null;
    }

    public List<StorageSyncedSet> listByVendorId(Long vendorId) {
        String sql = "select * from storage_synced_set a where a.vendor_id = :vendorId";
        Map<String, Object> params = MapTools.simpleMap("vendorId", vendorId);
        return this.list(StorageSyncedSet.class, sql, params);
    }

    public void remove(Long id, Long userId) {
        String sql = "update storage_synced_set set is_deleted = 1 where id = :id ";
        Map<String, Object> params = new HashMap<>(8);
        params.put("id", id);
        execute(sql, params);
    }
}
