从零开始搭建物联网云平台01-产品管理设计

数据库设计

产品是对某一类设备的统一描述,所以要管理硬件设备,首先要先设计描绘好产品。

首先,产品除了基本信息之外,还有产品的数据点,所谓数据点即是设备需要传回到服务器的数据,例如设备采集到的温度、湿度等信息。所以就有了产品的第一张子表 iot_product_data

其次,要实现对设备的远程控制,需要有一个遥控器,为了动态渲染这个遥控器,我们需要将这个遥控器的布局信息维护在数据库里面。 所以就需要表 iot_product_controller,当然一张controller表是无法描绘出一个遥控器的,我们还需要一张controller组件表,以及组件表的属性表。这里不深入讨论。

有了这两个基础,就暂且可以设计出产品表的基本形态

产品设计
产品设计

接口设计

产品的操作主要是给developer操作,所以提供一个服务使其能够对产品操作即可。接口定义如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
@HttpOpenApi(group = "product.dev", description = "为Developer提供的产品服务")
public interface ProductDevService {

@HttpMethod(description = "创建")
public String create(
@NotNull @HttpParam(name = "product", type = HttpParamType.COMMON, description = "产品创建参数") ProductDevDTO product,
@NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

@HttpMethod(description = "列表")
public Page<ProductDevDTO> list(
@HttpParam(name = "pageNo", type = HttpParamType.COMMON, description = "页码", valueDef = "1") Integer pageNo,
@HttpParam(name = "pageSize", type = HttpParamType.COMMON, description = "页码长度", valueDef = "20") Integer pageSize,
@HttpParam(name = "title", type = HttpParamType.COMMON, description = "搜索标题") String title,
@NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

@HttpMethod(description = "删除")
public String delete(
@NotNull @HttpParam(name = "productId", type = HttpParamType.COMMON, description = "产品Id") Long productId,
@NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

@HttpMethod(description = "编辑")
public String edit(
@NotNull @HttpParam(name = "product", type = HttpParamType.COMMON, description = "产品创建参数") ProductDevDTO product,
@NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

@HttpMethod(description = "详情")
public ProductDevDTO detail(
@NotNull @HttpParam(name = "productId", type = HttpParamType.COMMON, description = "产品Id") Long productId,
@NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;
}

页面设计

产品页面1
产品页面1
产品页面2
产品页面2
产品页面3
产品页面3