mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[优化]
This commit is contained in:
@@ -7,10 +7,10 @@ package api
|
||||
// ==========================================================================
|
||||
import (
|
||||
"fmt"
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
"pandax/kit/utils"
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"github.com/PandaXGO/PandaKit/utils"
|
||||
"pandax/pkg/cache"
|
||||
"pandax/pkg/global"
|
||||
"strings"
|
||||
@@ -166,7 +166,7 @@ func (p *DeviceApi) InsertDevice(rc *restfulx.ReqCtx) {
|
||||
data.OrgId = rc.LoginAccount.OrganizationId
|
||||
list, _ := p.DeviceApp.FindList(entity.Device{Name: data.Name})
|
||||
biz.IsTrue(!(list != nil && len(*list) > 0), fmt.Sprintf("名称%s已存在,设置其他命名", data.Name))
|
||||
data.Id = utils.GenerateTdID("d")
|
||||
data.Id = utils.GenerateID("d")
|
||||
data.LinkStatus = global.INACTIVE
|
||||
data.LastAt = time.Now()
|
||||
data.Protocol = product.ProtocolName
|
||||
|
||||
@@ -2,9 +2,9 @@ package api
|
||||
|
||||
// ==========================================================================
|
||||
import (
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"strings"
|
||||
|
||||
"pandax/apps/device/entity"
|
||||
|
||||
@@ -3,9 +3,9 @@ package api
|
||||
// ==========================================================================
|
||||
import (
|
||||
"encoding/json"
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
devicerpc "pandax/pkg/device_rpc"
|
||||
"strings"
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"github.com/PandaXGO/PandaKit/utils"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/restfulx"
|
||||
"pandax/kit/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -80,7 +80,7 @@ func (p *DeviceGroupApi) GetDeviceGroup(rc *restfulx.ReqCtx) {
|
||||
func (p *DeviceGroupApi) InsertDeviceGroup(rc *restfulx.ReqCtx) {
|
||||
var data entity.DeviceGroup
|
||||
restfulx.BindJsonAndValid(rc, &data)
|
||||
data.Id = utils.GenerateID()
|
||||
data.Id = utils.GenerateID("dg")
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
data.OrgId = rc.LoginAccount.OrganizationId
|
||||
p.DeviceGroupApp.Insert(data)
|
||||
|
||||
@@ -7,10 +7,10 @@ package api
|
||||
// ==========================================================================
|
||||
import (
|
||||
"fmt"
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
"pandax/kit/utils"
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"github.com/PandaXGO/PandaKit/utils"
|
||||
"pandax/pkg/global"
|
||||
"strings"
|
||||
|
||||
@@ -112,7 +112,7 @@ func (p *ProductApi) GetProduct(rc *restfulx.ReqCtx) {
|
||||
func (p *ProductApi) InsertProduct(rc *restfulx.ReqCtx) {
|
||||
var data entity.Product
|
||||
restfulx.BindJsonAndValid(rc, &data)
|
||||
data.Id = utils.GenerateTdID("p")
|
||||
data.Id = utils.GenerateID("p")
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
data.OrgId = rc.LoginAccount.OrganizationId
|
||||
// 如果未设置规则链,默认为主链
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"github.com/PandaXGO/PandaKit/utils"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/restfulx"
|
||||
"pandax/kit/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -66,7 +66,7 @@ func (p *ProductCategoryApi) GetProductCategory(rc *restfulx.ReqCtx) {
|
||||
func (p *ProductCategoryApi) InsertProductCategory(rc *restfulx.ReqCtx) {
|
||||
var data entity.ProductCategory
|
||||
restfulx.BindJsonAndValid(rc, &data)
|
||||
data.Id = utils.GenerateID()
|
||||
data.Id = utils.GenerateID("pc")
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
data.OrgId = rc.LoginAccount.OrganizationId
|
||||
p.ProductCategoryApp.Insert(data)
|
||||
|
||||
@@ -2,10 +2,10 @@ package api
|
||||
|
||||
// ==========================================================================
|
||||
import (
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
"pandax/kit/utils"
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"github.com/PandaXGO/PandaKit/utils"
|
||||
"pandax/pkg/tool"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -56,7 +56,7 @@ func (p *ProductOtaApi) InsertProductOta(rc *restfulx.ReqCtx) {
|
||||
// 生成文件MD5值
|
||||
md5, err := tool.GetFileMd5(path.Join(filePath, data.Url))
|
||||
biz.ErrIsNil(err, "读取文件md5校验值错误")
|
||||
data.Id = utils.GenerateID()
|
||||
data.Id = utils.GenerateID("ota")
|
||||
data.Check = md5
|
||||
p.ProductOtaApp.Insert(data)
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
"pandax/kit/utils"
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"github.com/PandaXGO/PandaKit/utils"
|
||||
"pandax/pkg/global"
|
||||
"strings"
|
||||
|
||||
@@ -59,7 +59,7 @@ func (p *ProductTemplateApi) GetProductTemplate(rc *restfulx.ReqCtx) {
|
||||
func (p *ProductTemplateApi) InsertProductTemplate(rc *restfulx.ReqCtx) {
|
||||
var data entity.ProductTemplate
|
||||
restfulx.BindJsonAndValid(rc, &data)
|
||||
data.Id = utils.GenerateID()
|
||||
data.Id = utils.GenerateID("pt")
|
||||
if data.Classify == entity.ATTRIBUTES_TSL || data.Classify == entity.TELEMETRY_TSL {
|
||||
// 向超级表及子表中添加字段
|
||||
len := 100
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
"pandax/kit/restfulx"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
ruleService "pandax/apps/rule/services"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
"pandax/kit/restfulx"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"pandax/apps/device/api"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
|
||||
@@ -2,8 +2,8 @@ package services
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/kit/biz"
|
||||
"pandax/pkg/global"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user