mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-05-05 11:31:27 +08:00
iot init
This commit is contained in:
113
apps/device/router/device.go
Normal file
113
apps/device/router/device.go
Normal file
@@ -0,0 +1,113 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
)
|
||||
|
||||
func InitDeviceRouter(container *restful.Container) {
|
||||
s := &api.DeviceApi{
|
||||
DeviceApp: services.DeviceModelDao,
|
||||
ProductApp: services.ProductModelDao,
|
||||
ProductTemplateApp: services.ProductTemplateModelDao,
|
||||
}
|
||||
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/device").Produces(restful.MIME_JSON)
|
||||
tags := []string{"device"}
|
||||
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Device分页列表").Handle(s.GetDeviceList)
|
||||
}).
|
||||
Doc("获取Device分页列表").
|
||||
Param(ws.QueryParameter("pageNum", "页数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("pageSize", "每页条数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("status", "状态").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("name", "名称").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("pid", "产品ID").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("gid", "分组Id").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("deviceType", "设备类型").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("parentId", "父ID").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("linkStatus", "连接状态").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(model.ResultPage{}).
|
||||
Returns(200, "OK", model.ResultPage{}))
|
||||
|
||||
ws.Route(ws.GET("/list/all").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Device列表").Handle(s.GetDeviceListAll)
|
||||
}).
|
||||
Doc("获取Device列表").
|
||||
Param(ws.QueryParameter("status", "状态").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("name", "名称").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("pid", "产品ID").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("deviceType", "设备类型").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.Device{}))
|
||||
|
||||
ws.Route(ws.GET("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Device信息").Handle(s.GetDevice)
|
||||
}).
|
||||
Doc("获取Device信息").
|
||||
Param(ws.PathParameter("id", "Id").DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.Device{}). // on the response
|
||||
Returns(200, "OK", entity.Device{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.GET("/{id}/status").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Device状态信息").Handle(s.GetDeviceStatus)
|
||||
}).
|
||||
Doc("获取Device状态信息").
|
||||
Param(ws.PathParameter("id", "Id").DataType("string")).
|
||||
Param(ws.QueryParameter("classify", "分类").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.DeviceStatusVo{}). // on the response
|
||||
Returns(200, "OK", []entity.DeviceStatusVo{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.GET("/{id}/attribute/down").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Device属性下发").Handle(s.DownAttribute)
|
||||
}).
|
||||
Doc("获取Device属性下发").
|
||||
Param(ws.PathParameter("id", "Id").DataType("string")).
|
||||
Param(ws.QueryParameter("key", "属性KEY").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("value", "属性Value").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加Device信息").Handle(s.InsertDevice)
|
||||
}).
|
||||
Doc("添加Device信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.Device{}))
|
||||
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改Device信息").Handle(s.UpdateDevice)
|
||||
}).
|
||||
Doc("修改Device信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.Device{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除Device信息").Handle(s.DeleteDevice)
|
||||
}).
|
||||
Doc("删除Device信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("id", "多id 1,2,3").DataType("string")))
|
||||
|
||||
ws.Route(ws.GET("/twin").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Device孪生体").Handle(s.ScreenTwinData)
|
||||
}).
|
||||
Doc("获取Device孪生体").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.VisualClass{}). // on the response
|
||||
Returns(200, "OK", []entity.VisualClass{}))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
52
apps/device/router/device_alarm.go
Normal file
52
apps/device/router/device_alarm.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
)
|
||||
|
||||
func InitDeviceAlarmRouter(container *restful.Container) {
|
||||
s := &api.DeviceAlarmApi{
|
||||
DeviceAlarmApp: services.DeviceAlarmModelDao,
|
||||
}
|
||||
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/device/alarm").Produces(restful.MIME_JSON)
|
||||
tags := []string{"alarm"}
|
||||
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取告警分页列表").Handle(s.GetDeviceAlarmList)
|
||||
}).
|
||||
Doc("获取告警分页列表").
|
||||
Param(ws.QueryParameter("pageNum", "页数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("pageSize", "每页条数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("deviceId", "设备Id").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("type", "告警类型").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("level", "告警等级").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("state", "告警状态").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(model.ResultPage{}).
|
||||
Returns(200, "OK", model.ResultPage{}))
|
||||
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改告警信息").Handle(s.UpdateDeviceAlarm)
|
||||
}).
|
||||
Doc("修改告警信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.DeviceAlarm{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除告警信息").Handle(s.DeleteDeviceAlarm)
|
||||
}).
|
||||
Doc("删除告警信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("id", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
51
apps/device/router/device_cmd.go
Normal file
51
apps/device/router/device_cmd.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
)
|
||||
|
||||
func InitDeviceCmdLogRouter(container *restful.Container) {
|
||||
s := &api.DeviceCmdLogApi{
|
||||
DeviceCmdLogApp: services.DeviceCmdLogModelDao,
|
||||
}
|
||||
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/device/cmd").Produces(restful.MIME_JSON)
|
||||
tags := []string{"cmd"}
|
||||
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取命令下发分页列表").Handle(s.GetDeviceCmdLogList)
|
||||
}).
|
||||
Doc("获取命令下发分页列表").
|
||||
Param(ws.QueryParameter("pageNum", "页数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("pageSize", "每页条数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("deviceId", "设备Id").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("type", "命令下发分类").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("state", "命令下发状态").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(model.ResultPage{}).
|
||||
Returns(200, "OK", model.ResultPage{}))
|
||||
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("命令下发").Handle(s.InsertDeviceCmdLog)
|
||||
}).
|
||||
Doc("命令下发").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.DeviceCmdLog{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除命令下发信息").Handle(s.DeleteDeviceCmdLog)
|
||||
}).
|
||||
Doc("删除命令下发信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("id", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
85
apps/device/router/device_group.go
Normal file
85
apps/device/router/device_group.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
)
|
||||
|
||||
func InitDeviceGroupRouter(container *restful.Container) {
|
||||
s := &api.DeviceGroupApi{
|
||||
DeviceGroupApp: services.DeviceGroupModelDao,
|
||||
}
|
||||
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/device/group").Produces(restful.MIME_JSON)
|
||||
tags := []string{"DeviceGroup"}
|
||||
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取DeviceGroup列表").Handle(s.GetDeviceGroupList)
|
||||
}).
|
||||
Doc("获取DeviceGroup列表").
|
||||
Param(ws.QueryParameter("name", "名称").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("status", "状态").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.DeviceGroup{}))
|
||||
|
||||
ws.Route(ws.GET("/list/all").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取DeviceGroup所有列表").Handle(s.GetDeviceGroupAllList)
|
||||
}).
|
||||
Doc("获取DeviceGroup分页列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.DeviceGroup{}))
|
||||
|
||||
ws.Route(ws.GET("/list/tree").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取DeviceGroup树").Handle(s.GetDeviceGroupTree)
|
||||
}).
|
||||
Doc("获取DeviceGroup树").
|
||||
Param(ws.QueryParameter("name", "名称").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("status", "状态").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.DeviceGroup{}))
|
||||
|
||||
ws.Route(ws.GET("/list/tree/label").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取DeviceGroup树").Handle(s.GetDeviceGroupTreeLabel)
|
||||
}).
|
||||
Doc("获取DeviceGroup树").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.DeviceGroupLabel{}))
|
||||
|
||||
ws.Route(ws.GET("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取DeviceGroup信息").Handle(s.GetDeviceGroup)
|
||||
}).
|
||||
Doc("获取DeviceGroup信息").
|
||||
Param(ws.PathParameter("", "Id").DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.DeviceGroup{}). // on the response
|
||||
Returns(200, "OK", entity.DeviceGroup{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加DeviceGroup信息").Handle(s.InsertDeviceGroup)
|
||||
}).
|
||||
Doc("添加DeviceGroup信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.DeviceGroup{}))
|
||||
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改DeviceGroup信息").Handle(s.UpdateDeviceGroup)
|
||||
}).
|
||||
Doc("修改DeviceGroup信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.DeviceGroup{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除DeviceGroup信息").Handle(s.DeleteDeviceGroup)
|
||||
}).
|
||||
Doc("删除DeviceGroup信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("id", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
86
apps/device/router/product.go
Normal file
86
apps/device/router/product.go
Normal file
@@ -0,0 +1,86 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
)
|
||||
|
||||
func InitProductRouter(container *restful.Container) {
|
||||
s := &api.ProductApi{
|
||||
ProductApp: services.ProductModelDao,
|
||||
DeviceApp: services.DeviceModelDao,
|
||||
TemplateApp: services.ProductTemplateModelDao,
|
||||
OtaAPP: services.ProductOtaModelDao,
|
||||
}
|
||||
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/device/product").Produces(restful.MIME_JSON)
|
||||
tags := []string{"product"}
|
||||
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Product分页列表").Handle(s.GetProductList)
|
||||
}).
|
||||
Doc("获取Product分页列表").
|
||||
Param(ws.QueryParameter("pageNum", "页数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("pageSize", "每页条数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("status", "状态").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("name", "名称").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("productCategoryId", "产品分类Id").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("protocolName", "协议名").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("deviceType", "设备类型").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(model.ResultPage{}).
|
||||
Returns(200, "OK", model.ResultPage{}))
|
||||
|
||||
ws.Route(ws.GET("/list/all").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Product分页列表").Handle(s.GetProductListAll)
|
||||
}).
|
||||
Doc("获取Product分页列表").
|
||||
Param(ws.QueryParameter("status", "状态").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("name", "名称").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("productCategoryId", "产品分类Id").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("protocolName", "协议名").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("deviceType", "设备类型").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.Product{}).
|
||||
Returns(200, "OK", entity.Product{}))
|
||||
|
||||
ws.Route(ws.GET("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Product信息").Handle(s.GetProduct)
|
||||
}).
|
||||
Doc("获取Product信息").
|
||||
Param(ws.PathParameter("id", "Id").DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.Product{}). // on the response
|
||||
Returns(200, "OK", entity.Product{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加Product信息").Handle(s.InsertProduct)
|
||||
}).
|
||||
Doc("添加Product信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.Product{}))
|
||||
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改Product信息").Handle(s.UpdateProduct)
|
||||
}).
|
||||
Doc("修改Product信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.Product{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除Product信息").Handle(s.DeleteProduct)
|
||||
}).
|
||||
Doc("删除Product信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("id", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
85
apps/device/router/product_category.go
Normal file
85
apps/device/router/product_category.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
)
|
||||
|
||||
func InitProductCategoryRouter(container *restful.Container) {
|
||||
s := &api.ProductCategoryApi{
|
||||
ProductCategoryApp: services.ProductCategoryModelDao,
|
||||
}
|
||||
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/device/product/category").Produces(restful.MIME_JSON)
|
||||
tags := []string{"ProductCategory"}
|
||||
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取ProductCategory列表").Handle(s.GetProductCategoryList)
|
||||
}).
|
||||
Doc("获取ProductCategory列表").
|
||||
Param(ws.QueryParameter("name", "名称").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("status", "状态").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.ProductCategory{}))
|
||||
|
||||
ws.Route(ws.GET("/list/all").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取ProductCategory所有列表").Handle(s.GetProductCategoryAllList)
|
||||
}).
|
||||
Doc("获取ProductCategory分页列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.ProductCategory{}))
|
||||
|
||||
ws.Route(ws.GET("/list/tree").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取ProductCategory树").Handle(s.GetProductCategoryTree)
|
||||
}).
|
||||
Doc("获取ProductCategory树").
|
||||
Param(ws.QueryParameter("name", "名称").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("status", "状态").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.ProductCategory{}))
|
||||
|
||||
ws.Route(ws.GET("/list/tree/label").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取ProductCategory树").Handle(s.GetProductCategoryTreeLabel)
|
||||
}).
|
||||
Doc("获取ProductCategory树").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.ProductCategoryLabel{}))
|
||||
|
||||
ws.Route(ws.GET("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取ProductCategory信息").Handle(s.GetProductCategory)
|
||||
}).
|
||||
Doc("获取ProductCategory信息").
|
||||
Param(ws.PathParameter("", "Id").DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.ProductCategory{}). // on the response
|
||||
Returns(200, "OK", entity.ProductCategory{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加ProductCategory信息").Handle(s.InsertProductCategory)
|
||||
}).
|
||||
Doc("添加ProductCategory信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.ProductCategory{}))
|
||||
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改ProductCategory信息").Handle(s.UpdateProductCategory)
|
||||
}).
|
||||
Doc("修改ProductCategory信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.ProductCategory{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除ProductCategory信息").Handle(s.DeleteProductCategory)
|
||||
}).
|
||||
Doc("删除ProductCategory信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("id", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
67
apps/device/router/product_ota.go
Normal file
67
apps/device/router/product_ota.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
)
|
||||
|
||||
func InitProductOtaRouter(container *restful.Container) {
|
||||
s := &api.ProductOtaApi{
|
||||
ProductOtaApp: services.ProductOtaModelDao,
|
||||
}
|
||||
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/device/ota").Produces(restful.MIME_JSON)
|
||||
tags := []string{"ota"}
|
||||
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Ota分页列表").Handle(s.GetProductOtaList)
|
||||
}).
|
||||
Doc("获取Ota分页列表").
|
||||
Param(ws.QueryParameter("pageNum", "页数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("pageSize", "每页条数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("pid", "产品Id").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("name", "名称").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(model.ResultPage{}).
|
||||
Returns(200, "OK", model.ResultPage{}))
|
||||
|
||||
ws.Route(ws.GET("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Ota信息").Handle(s.GetProductOta)
|
||||
}).
|
||||
Doc("获取Ota信息").
|
||||
Param(ws.PathParameter("id", "Id").DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.ProductOta{}). // on the response
|
||||
Returns(200, "OK", entity.ProductOta{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加Ota信息").Handle(s.InsertProductOta)
|
||||
}).
|
||||
Doc("添加Ota信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.ProductOta{}))
|
||||
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改Ota信息").Handle(s.UpdateProductOta)
|
||||
}).
|
||||
Doc("修改Ota信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.ProductOta{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除Ota信息").Handle(s.DeleteProductOta)
|
||||
}).
|
||||
Doc("删除Ota信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("id", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
78
apps/device/router/product_template.go
Normal file
78
apps/device/router/product_template.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
)
|
||||
|
||||
func InitProductTemplateRouter(container *restful.Container) {
|
||||
s := &api.ProductTemplateApi{
|
||||
ProductTemplateApp: services.ProductTemplateModelDao,
|
||||
}
|
||||
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/device/template").Produces(restful.MIME_JSON)
|
||||
tags := []string{"template"}
|
||||
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Template分页列表").Handle(s.GetProductTemplateList)
|
||||
}).
|
||||
Doc("获取Template分页列表").
|
||||
Param(ws.QueryParameter("pageNum", "页数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("pageSize", "每页条数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("pid", "产品ID").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("classify", "分类").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("name", "名称").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(model.ResultPage{}).
|
||||
Returns(200, "OK", model.ResultPage{}))
|
||||
|
||||
ws.Route(ws.GET("/list/all").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Template列表").Handle(s.GetProductTemplateListAll)
|
||||
}).
|
||||
Doc("获取Template列表").
|
||||
Param(ws.QueryParameter("pid", "产品ID").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("classify", "分类").Required(false).DataType("string")).
|
||||
Param(ws.QueryParameter("name", "名称").Required(false).DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.ProductTemplate{}))
|
||||
|
||||
ws.Route(ws.GET("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Template信息").Handle(s.GetProductTemplate)
|
||||
}).
|
||||
Doc("获取Template信息").
|
||||
Param(ws.PathParameter("id", "Id").DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.ProductTemplate{}). // on the response
|
||||
Returns(200, "OK", entity.ProductTemplate{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加Template信息").Handle(s.InsertProductTemplate)
|
||||
}).
|
||||
Doc("添加Template信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.ProductTemplate{}))
|
||||
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改Template信息").Handle(s.UpdateProductTemplate)
|
||||
}).
|
||||
Doc("修改Template信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.ProductTemplate{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除Template信息").Handle(s.DeleteProductTemplate)
|
||||
}).
|
||||
Doc("删除Template信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("id", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
Reference in New Issue
Block a user