Skip to content

Commit

Permalink
'增加设备相关表'
Browse files Browse the repository at this point in the history
  • Loading branch information
jingdor committed Jun 8, 2020
1 parent 6554478 commit e9377d6
Show file tree
Hide file tree
Showing 16 changed files with 160 additions and 63 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

import javax.persistence.*;

/**
* 产品清单
*/
@Data
@SQLDelete(sql = "update `device_checklist` SET deleted_at = unix_timestamp(now()) WHERE id = ?")
@Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

import javax.persistence.*;

/**
* 设备表
*/
@Data
@SQLDelete(sql = "update `device` SET deleted_at = unix_timestamp(now()) WHERE id = ?")
@Entity
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.iotpack.api.entity.device;

import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.*;

@Data
@SQLDelete(sql = "update `device_log` SET deleted_at = unix_timestamp(now()) WHERE id = ?")
@Entity
@Table(name = "device_log")
@Where(clause = "deleted_at is null")
@DynamicUpdate
@Cacheable
public class DeviceLogEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;
/**
* 设备id
*/
Long deviceId;
/**
* 设备原始日志
*/
String raw;
/**
* 创建时间
*/
Long createdAt;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.iotpack.api.entity.device;

import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.*;

/**
* 设备表
*/
@Data
@SQLDelete(sql = "update `device_meta` SET deleted_at = unix_timestamp(now()) WHERE id = ?")
@Entity
@Table(name = "device_meta")
@Where(clause = "deleted_at is null")
@DynamicUpdate
@Cacheable
public class DeviceMetaEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;

String name;
/**
* 设备的非检索配置信息
*/
@Column(columnDefinition = "json" )
String meta;
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
package com.iotpack.api.entity.product;
package com.iotpack.api.entity.device;


import com.iotpack.api.entity.base.BaseUserEntity;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.*;


@Data
@SQLDelete(sql = "update `product` SET deleted_at = unix_timestamp(now()) WHERE id = ?")
@SQLDelete(sql = "update `device_type` SET deleted_at = unix_timestamp(now()) WHERE id = ?")
@Entity
@Table(name = "product")
@Table(name = "device_type")
@Where(clause = "deleted_at is null")
@DynamicUpdate
@Cacheable
public class ProductRepository extends BaseUserEntity {
public class DeviceTypeEntity {

/**
* 设备类型id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;

/**
* 产品名称
* 设备id
*/
String name;

/**
* 应用使用的协议
*/
String applicationProtocol;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.iotpack.api.entity.device;
package com.iotpack.api.entity.device.repo;

import com.iotpack.api.entity.device.DeviceCheckListEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.iotpack.api.entity.device.repo;

import com.iotpack.api.entity.device.DeviceEntity;
import com.iotpack.api.entity.device.DeviceLogEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface DeviceLogRepository extends CrudRepository<DeviceLogEntity, Long>,
JpaSpecificationExecutor<DeviceLogEntity>,
JpaRepository<DeviceLogEntity, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.iotpack.api.entity.device.repo;

import com.iotpack.api.entity.device.DeviceEntity;
import com.iotpack.api.entity.device.DeviceMetaEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface DeviceMetaRepository extends CrudRepository<DeviceMetaEntity, Long>, JpaSpecificationExecutor<DeviceMetaEntity>, JpaRepository<DeviceMetaEntity, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.iotpack.api.entity.device.repo;

import com.iotpack.api.entity.device.DeviceEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface DeviceRepository extends CrudRepository<DeviceEntity, Long>, JpaSpecificationExecutor<DeviceEntity>, JpaRepository<DeviceEntity, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.iotpack.api.entity.device.repo;

import com.iotpack.api.entity.device.DeviceEntity;
import com.iotpack.api.entity.device.DeviceTypeEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface DeviceTypeRepository extends CrudRepository<DeviceTypeEntity, Long>, JpaSpecificationExecutor<DeviceTypeEntity>, JpaRepository<DeviceTypeEntity, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.iotpack.api.entity.product.repo;

import com.iotpack.api.entity.device.DeviceEntity;
import com.iotpack.api.entity.device.DeviceLogEntity;
import com.iotpack.api.entity.product.ProductEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface ProductRepository extends CrudRepository<ProductEntity, Long>,
JpaSpecificationExecutor<ProductEntity>,
JpaRepository<ProductEntity, Long> {
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.iotpack.api.service.impl;

import com.iotpack.api.entity.device.DeviceCheckListEntity;
import com.iotpack.api.entity.device.DeviceCheckListRepository;
import com.iotpack.api.entity.device.repo.DeviceCheckListRepository;
import com.iotpack.api.entity.device.DeviceEntity;
import com.iotpack.api.exception.BusinessException;
import com.iotpack.api.gateway.onenet.service.OneNetServiceImpl;
Expand Down
18 changes: 9 additions & 9 deletions gateway_udp/src/main/java/com/iotpack/gateway/udp/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ public class Main {
public static void main(String[] argv) throws Exception {
EventLoopGroup group = new NioEventLoopGroup();
try {
Bootstrap b = new Bootstrap();
b.group(group)
.channel(NioDatagramChannel.class)
.option(ChannelOption.SO_BROADCAST, true)
.handler(new PongServerHandler());
Bootstrap b = new Bootstrap();
b.group(group)
.channel(NioDatagramChannel.class)
.option(ChannelOption.SO_BROADCAST, true)
.handler(new PongServerHandler());

b.bind(7686).sync().channel().closeFuture().await();
} finally {
group.shutdownGracefully();
}
b.bind(7686).sync().channel().closeFuture().await();
} finally {
group.shutdownGracefully();
}
}
}
7 changes: 3 additions & 4 deletions iotpack/lib/api/rep.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ class Resp<T> {
Resp.fromJson(Map<String, dynamic> json) {
code = json['code'];
msg = json['msg'];

// if (T is LoginDto) {
data = LoginDto.fromJson(json['data']) as T;
// }
if (T is LoginDto) {
data = LoginDto.fromJson(json['data']) as T;
}
}
}
1 change: 1 addition & 0 deletions iotpack/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies:
cupertino_icons: ^0.1.2
json_annotation: any
mqtt_client: any
charts_flutter: ^0.9.0
# flutter_barcode_scanner: ^1.0.1
dev_dependencies:
# flutter_test:
Expand Down

0 comments on commit e9377d6

Please sign in to comment.