// Path: server/src/main/java/com/cloudwise/sap/niping/common/entity/Monitor.java
// @Data
// @Builder
// @EqualsAndHashCode(callSuper = true)
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Monitor extends AbstractEntity {
// 
//     private static final long serialVersionUID = 6732242760258530600L;
//     private String monitorId;
//     private String version;
//     private String name;
//     private String country;
//     private String province;
//     private String city;
//     private String isp;
//     private String area;
//     private String ip;
//     private String nipingT;
//     private int status;
//     private List<String> runningTaskIds;
// 
//     @JsonIgnore
//     private boolean isUsable;
// 
//     public enum Status {
//         active(1), inactive(0);
// 
//         @Getter
//         private int status;
// 
//         Status(int status) {this.status = status;}
//     }
// }
// 
// Path: server/src/main/java/com/cloudwise/sap/niping/dao/mapper/MonitorMapper.java
// public class MonitorMapper implements ResultSetMapper<Monitor> {
// 
//     @Override
//     public Monitor map(int index, ResultSet r, StatementContext ctx) throws SQLException {
// 
//         int status = r.getInt("STATUS");
//         boolean isUsable = true;
//         if (status == 0) {
//             isUsable = false;
//         }
// 
//         Monitor monitor = Monitor.builder()
//                 .monitorId(r.getString("MONITOR_ID"))
//                 .version(r.getString("VERSION"))
//                 .name(r.getString("NAME"))
//                 .country(r.getString("COUNTRY"))
//                 .province(r.getString("PROVINCE"))
//                 .city(r.getString("CITY"))
//                 .isp(r.getString("ISP"))
//                 .area(r.getString("AREA"))
//                 .ip(r.getString("IP"))
//                 .nipingT(r.getString("NIPING_T"))
//                 .status(status)
//                 .isUsable(isUsable).build();
// 
//         monitor.set(r.getString("ACCOUNT_ID"), r.getDate("CREATION_TIME"), r.getDate("MODIFIED_TIME"));
//         return monitor;
//     }
// }


import com.cloudwise.sap.niping.common.entity.Monitor;
import com.cloudwise.sap.niping.dao.mapper.MonitorMapper;
import org.jvnet.hk2.annotations.Service;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.BindBean;
import org.skife.jdbi.v2.sqlobject.SqlQuery;
import org.skife.jdbi.v2.sqlobject.SqlUpdate;
import org.skife.jdbi.v2.sqlobject.customizers.Define;
import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
import org.skife.jdbi.v2.sqlobject.stringtemplate.UseStringTemplate3StatementLocator;
import org.skife.jdbi.v2.unstable.BindIn;
import java.util.Date;
import java.util.List;
package com.cloudwise.sap.niping.dao;



@Service
@UseStringTemplate3StatementLocator
public interface MonitorDao {
    @SqlQuery("SELECT COUNT(1) FROM SNM_MONITOR WHERE MONITOR_ID = :monitorId")
    int countMonitor(@Bind("monitorId") String monitorId);

    @SqlUpdate("INSERT INTO SNM_MONITOR (MONITOR_ID, VERSION, ACCOUNT_ID, NAME, COUNTRY, PROVINCE, CITY, ISP, AREA, IP, NIPING_T, STATUS, CREATION_TIME, MODIFIED_TIME) " +
            " VALUES (:monitorId, :version, :accountId, :name, :country, :province, :city, :isp, :area, :ip, :nipingT, :status, :creationTime, :modifiedTime)")
    void insertMonitor(@BindBean Monitor monitor);

    @SqlUpdate("UPDATE SNM_MONITOR SET STATUS = :status, MODIFIED_TIME = :modifiedTime")
    void updateAllMonitorsStatus(@Bind("status") int status, @Bind("modifiedTime") Date modifiedTime);

    @SqlUpdate("UPDATE SNM_MONITOR SET STATUS = :status, MODIFIED_TIME = :modifiedTime WHERE MONITOR_ID IN (<monitorIds>)")
// Path: server/src/main/java/com/cloudwise/sap/niping/common/entity/Monitor.java
// @Data
// @Builder
// @EqualsAndHashCode(callSuper = true)
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Monitor extends AbstractEntity {
// 
//     private static final long serialVersionUID = 6732242760258530600L;
//     private String monitorId;
//     private String version;
//     private String name;
//     private String country;
//     private String province;
//     private String city;
//     private String isp;
//     private String area;
//     private String ip;
//     private String nipingT;
//     private int status;
//     private List<String> runningTaskIds;
// 
//     @JsonIgnore
//     private boolean isUsable;
// 
//     public enum Status {
//         active(1), inactive(0);
// 
//         @Getter
//         private int status;
// 
//         Status(int status) {this.status = status;}
//     }
// }
// 
// Path: server/src/main/java/com/cloudwise/sap/niping/dao/mapper/MonitorMapper.java
// public class MonitorMapper implements ResultSetMapper<Monitor> {
// 
//     @Override
//     public Monitor map(int index, ResultSet r, StatementContext ctx) throws SQLException {
// 
//         int status = r.getInt("STATUS");
//         boolean isUsable = true;
//         if (status == 0) {
//             isUsable = false;
//         }
// 
//         Monitor monitor = Monitor.builder()
//                 .monitorId(r.getString("MONITOR_ID"))
//                 .version(r.getString("VERSION"))
//                 .name(r.getString("NAME"))
//                 .country(r.getString("COUNTRY"))
//                 .province(r.getString("PROVINCE"))
//                 .city(r.getString("CITY"))
//                 .isp(r.getString("ISP"))
//                 .area(r.getString("AREA"))
//                 .ip(r.getString("IP"))
//                 .nipingT(r.getString("NIPING_T"))
//                 .status(status)
//                 .isUsable(isUsable).build();
// 
//         monitor.set(r.getString("ACCOUNT_ID"), r.getDate("CREATION_TIME"), r.getDate("MODIFIED_TIME"));
//         return monitor;
//     }
// }


// Path: server/src/main/java/com/cloudwise/sap/niping/dao/MonitorDao.java
import com.cloudwise.sap.niping.common.entity.Monitor;
import com.cloudwise.sap.niping.dao.mapper.MonitorMapper;
import org.jvnet.hk2.annotations.Service;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.BindBean;
import org.skife.jdbi.v2.sqlobject.SqlQuery;
import org.skife.jdbi.v2.sqlobject.SqlUpdate;
import org.skife.jdbi.v2.sqlobject.customizers.Define;
import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
import org.skife.jdbi.v2.sqlobject.stringtemplate.UseStringTemplate3StatementLocator;
import org.skife.jdbi.v2.unstable.BindIn;
import java.util.Date;
import java.util.List;

package com.cloudwise.sap.niping.dao;



@Service
@UseStringTemplate3StatementLocator
public interface MonitorDao {
    @SqlQuery("SELECT COUNT(1) FROM SNM_MONITOR WHERE MONITOR_ID = :monitorId")
    int countMonitor(@Bind("monitorId") String monitorId);

    @SqlUpdate("INSERT INTO SNM_MONITOR (MONITOR_ID, VERSION, ACCOUNT_ID, NAME, COUNTRY, PROVINCE, CITY, ISP, AREA, IP, NIPING_T, STATUS, CREATION_TIME, MODIFIED_TIME) " +
            " VALUES (:monitorId, :version, :accountId, :name, :country, :province, :city, :isp, :area, :ip, :nipingT, :status, :creationTime, :modifiedTime)")
    void insertMonitor(@BindBean Monitor monitor);

    @SqlUpdate("UPDATE SNM_MONITOR SET STATUS = :status, MODIFIED_TIME = :modifiedTime")
    void updateAllMonitorsStatus(@Bind("status") int status, @Bind("modifiedTime") Date modifiedTime);

    @SqlUpdate("UPDATE SNM_MONITOR SET STATUS = :status, MODIFIED_TIME = :modifiedTime WHERE MONITOR_ID IN (<monitorIds>)")
    void updateMonitorsStatus(@BindIn("monitorIds") List<String> monitorIds, @Bind("status") int status, @Bind("modifiedTime") Date modifiedTime);