package com.sifang.modules.customer.dao;

import com.sifang.modules.customer.constant.SourceConstants;
import com.sifang.modules.customer.entity.PowerStationDevice;
import com.sifang.modules.sys.common.persistence.BaseDao;
import com.sifang.modules.sys.common.persistence.Parameter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class PowerStationDeviceDao extends BaseDao<PowerStationDevice> {

    public List<PowerStationDevice> getListByPowerStationId(String id, String userId) {
        String sql = "from PowerStationDevice a WHERE a.powerStationId =:p1 AND a.userId=:p2 and status='1' ";

        List<PowerStationDevice> list = find(sql, new Parameter(id, userId));
        return list;
    }

    public void updateStatus(String id) {
        PowerStationDevice dev = get(id);
        dev.setStatus(SourceConstants.STATUS_TWO);
        save(dev);
    }


}
