-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d95a9b8
commit f1b0507
Showing
63 changed files
with
2,360 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright © 2023-2030 The ruanrongman Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package top.rslly.iot.dao; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import top.rslly.iot.models.EventDataEntity; | ||
|
||
import javax.transaction.Transactional; | ||
import java.util.List; | ||
|
||
public interface EventDataRepository extends JpaRepository<EventDataEntity, Long> { | ||
List<EventDataEntity> findAllByModelId(int modelId); | ||
|
||
List<EventDataEntity> findAllByModelIdAndJsonKey(int modelId, String jsonKey); | ||
|
||
@Transactional | ||
List<EventDataEntity> deleteById(int id); | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/top/rslly/iot/dao/EventStorageRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright © 2023-2030 The ruanrongman Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package top.rslly.iot.dao; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.QueryByExampleExecutor; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import top.rslly.iot.models.EventStorageEntity; | ||
|
||
import java.util.List; | ||
|
||
public interface EventStorageRepository extends JpaRepository<EventStorageEntity, Long>, | ||
JpaSpecificationExecutor<EventStorageEntity>, QueryByExampleExecutor<EventStorageEntity> { | ||
List<EventStorageEntity> findAllByTimeBetweenAndDeviceIdAndJsonKey(long time, long time2, | ||
int deviceId, | ||
String jsonKey); | ||
|
||
List<EventStorageEntity> findAllByTimeBetweenAndDeviceId(long time, long time2, int deviceId); | ||
|
||
@Query( | ||
value = "SELECT * FROM event_storage WHERE device_id =?1 And json_key=?2 ORDER BY time DESC LIMIT 1", | ||
nativeQuery = true) | ||
List<EventStorageEntity> findAllBySort(int deviceId, String jsonKey); | ||
|
||
@Transactional | ||
List<EventStorageEntity> deleteAllByTimeBeforeAndDeviceIdAndJsonKey(long time, int deviceId, | ||
String jsonKey); | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/top/rslly/iot/dao/EventStorageTimeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* Copyright © 2023-2030 The ruanrongman Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package top.rslly.iot.dao; | ||
|
||
import top.rslly.iot.models.EventStorageEntity; | ||
import top.rslly.iot.utility.influxdb.InfluxDBBaseMapper; | ||
import top.rslly.iot.utility.influxdb.ano.Delete; | ||
import top.rslly.iot.utility.influxdb.ano.Param; | ||
import top.rslly.iot.utility.influxdb.ano.Select; | ||
|
||
import java.util.List; | ||
|
||
public interface EventStorageTimeRepository extends InfluxDBBaseMapper<EventStorageEntity> { | ||
@Select( | ||
value = "SELECT * FROM \"event_storage\" where time >=#{time}ms and time <=#{time2}ms and deviceId='#{deviceId}'", | ||
resultType = EventStorageEntity.class) | ||
List<EventStorageEntity> findAllByTimeBetweenAndDeviceId(@Param("time") long time, | ||
@Param("time2") long time2, @Param("deviceId") int deviceId); | ||
|
||
@Select( | ||
value = "SELECT * FROM \"event_storage\" where time >=#{time}ms and time <=#{time2}ms and deviceId='#{deviceId}' and jsonKey=#{jsonKey}", | ||
resultType = EventStorageEntity.class) | ||
List<EventStorageEntity> findAllByTimeBetweenAndDeviceIdAndJsonKey(@Param("time") long time, | ||
@Param("time2") long time2, @Param("deviceId") int deviceId, | ||
@Param("jsonKey") String jsonKey); | ||
|
||
@Select( | ||
value = "SELECT * FROM \"event_storage\" WHERE deviceId='#{deviceId}' and jsonKey=#{jsonKey} ORDER BY time DESC LIMIT 1", | ||
resultType = EventStorageEntity.class) | ||
List<EventStorageEntity> findAllBySort(int deviceId, String jsonKey); | ||
|
||
@Delete( | ||
value = "DELETE FROM \"event_storage\" where time <=#{time}ms and deviceId='#{deviceId}' and jsonKey=#{jsonKey}") | ||
void deleteAllByTimeBeforeAndDeviceIdAndJsonKey(@Param("time") long time, | ||
@Param("deviceId") int deviceId, @Param("jsonKey") String jsonKey); | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/top/rslly/iot/dao/ProductEventRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright © 2023-2030 The ruanrongman Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package top.rslly.iot.dao; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import top.rslly.iot.models.ProductEventEntity; | ||
import top.rslly.iot.models.ProductModelEntity; | ||
|
||
import javax.transaction.Transactional; | ||
import java.util.List; | ||
|
||
public interface ProductEventRepository extends JpaRepository<ProductEventEntity, Long> { | ||
|
||
List<ProductEventEntity> findAllByModelIdAndName(int modelId, String name); | ||
|
||
List<ProductEventEntity> findAllByName(String name); | ||
|
||
|
||
List<ProductEventEntity> findAllById(int id); | ||
|
||
@Transactional | ||
List<ProductEventEntity> deleteById(int id); | ||
} |
Oops, something went wrong.