mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[优化]
This commit is contained in:
@@ -11,9 +11,9 @@ import (
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
"pandax/kit/utils"
|
||||
"pandax/pkg/cache"
|
||||
"pandax/pkg/global"
|
||||
model2 "pandax/pkg/global/model"
|
||||
"pandax/pkg/shadow"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -184,7 +184,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 = model2.GenerateID()
|
||||
data.Id = utils.GenerateID()
|
||||
data.LinkStatus = global.INACTIVE
|
||||
data.LastAt = time.Now()
|
||||
data.Protocol = product.ProtocolName
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
"pandax/kit/utils"
|
||||
"pandax/pkg/global"
|
||||
model2 "pandax/pkg/global/model"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -50,7 +50,7 @@ func (p *DeviceCmdLogApi) InsertDeviceCmdLog(rc *restfulx.ReqCtx) {
|
||||
err := json.Unmarshal([]byte(data.CmdContent), &ms)
|
||||
biz.ErrIsNil(err, "指令格式不正确")
|
||||
biz.IsTrue(len(ms) > 0, "指令格式不正确")
|
||||
data.Id = model2.GenerateID()
|
||||
data.Id = utils.GenerateID()
|
||||
data.State = "2"
|
||||
data.RequestTime = time.Now().Format("2006-01-02 15:04:05")
|
||||
go func() {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"pandax/apps/device/services"
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/restfulx"
|
||||
"pandax/pkg/global/model"
|
||||
"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 = model.GenerateID()
|
||||
data.Id = utils.GenerateID()
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
data.OrgId = rc.LoginAccount.OrganizationId
|
||||
p.DeviceGroupApp.Insert(data)
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
"pandax/kit/utils"
|
||||
"pandax/pkg/cache"
|
||||
"pandax/pkg/global"
|
||||
model2 "pandax/pkg/global/model"
|
||||
"strings"
|
||||
|
||||
"pandax/apps/device/entity"
|
||||
@@ -107,7 +107,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 = model2.GenerateID()
|
||||
data.Id = utils.GenerateID()
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
data.OrgId = rc.LoginAccount.OrganizationId
|
||||
// 如果未设置规则链,默认为主链
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"pandax/apps/device/services"
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/restfulx"
|
||||
"pandax/pkg/global/model"
|
||||
"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 = model.GenerateID()
|
||||
data.Id = utils.GenerateID()
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
data.OrgId = rc.LoginAccount.OrganizationId
|
||||
p.ProductCategoryApp.Insert(data)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
model2 "pandax/pkg/global/model"
|
||||
"pandax/kit/utils"
|
||||
"pandax/pkg/tool"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -53,7 +53,7 @@ func (p *ProductOtaApi) InsertProductOta(rc *restfulx.ReqCtx) {
|
||||
// 生成文件MD5值
|
||||
md5, err := tool.GetFileMd5(path.Join(filePath, data.Url))
|
||||
biz.ErrIsNil(err, "读取文件md5校验值错误")
|
||||
data.Id = model2.GenerateID()
|
||||
data.Id = utils.GenerateID()
|
||||
data.Check = md5
|
||||
p.ProductOtaApp.Insert(data)
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
"pandax/kit/utils"
|
||||
"pandax/pkg/global"
|
||||
model2 "pandax/pkg/global/model"
|
||||
"strings"
|
||||
|
||||
"pandax/apps/device/entity"
|
||||
@@ -58,7 +58,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 = model2.GenerateID()
|
||||
data.Id = utils.GenerateID()
|
||||
if data.Classify == entity.ATTRIBUTES_TSL || data.Classify == entity.TELEMETRY_TSL {
|
||||
// 向超级表及子表中添加字段
|
||||
len := 100
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
model2 "pandax/pkg/global/model"
|
||||
"pandax/kit/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ type JobApi struct {
|
||||
func (j *JobApi) CreateJob(rc *restfulx.ReqCtx) {
|
||||
var job entity.SysJob
|
||||
restfulx.BindQuery(rc, &job)
|
||||
job.Id = model2.GenerateID()
|
||||
job.Id = utils.GenerateID()
|
||||
job.Owner = rc.LoginAccount.UserName
|
||||
job.OrgId = rc.LoginAccount.OrganizationId
|
||||
_, err := j.JobApp.Insert(job)
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
logEntity "pandax/apps/job/entity"
|
||||
"pandax/apps/job/services"
|
||||
logServices "pandax/apps/job/services"
|
||||
"pandax/kit/utils"
|
||||
"pandax/pkg/global"
|
||||
"pandax/pkg/global/model"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -52,7 +52,7 @@ type ExecJob struct {
|
||||
func (e *ExecJob) Run() {
|
||||
startTime := time.Now()
|
||||
jobLog := logEntity.JobLog{Name: e.Name, EntryId: e.EntryId, TargetInvoke: e.InvokeTarget, Status: "0"}
|
||||
jobLog.Id = model.GenerateID()
|
||||
jobLog.Id = utils.GenerateID()
|
||||
jobLog.OrgId = e.OrgId
|
||||
jobLog.Owner = e.Owner
|
||||
var obj = jobList[e.InvokeTarget]
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
model2 "pandax/pkg/global/model"
|
||||
"pandax/kit/utils"
|
||||
"pandax/pkg/rule_engine"
|
||||
"strings"
|
||||
)
|
||||
@@ -81,7 +81,7 @@ func (p *RuleChainApi) GetRuleChain(rc *restfulx.ReqCtx) {
|
||||
func (p *RuleChainApi) InsertRuleChain(rc *restfulx.ReqCtx) {
|
||||
var data entity.RuleChain
|
||||
restfulx.BindJsonAndValid(rc, &data)
|
||||
data.Id = model2.GenerateID()
|
||||
data.Id = utils.GenerateID()
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
data.OrgId = rc.LoginAccount.OrganizationId
|
||||
_, err := p.RuleChainApp.Insert(data)
|
||||
@@ -112,7 +112,7 @@ func (p *RuleChainApi) CloneRuleChain(rc *restfulx.ReqCtx) {
|
||||
one, err := p.RuleChainApp.FindOne(id)
|
||||
biz.ErrIsNil(err, "规则链不存在")
|
||||
one.RuleName = one.RuleName + "-克隆"
|
||||
one.Id = model2.GenerateID()
|
||||
one.Id = utils.GenerateID()
|
||||
one.Root = "0"
|
||||
_, err = p.RuleChainApp.Insert(*one)
|
||||
biz.ErrIsNil(err, "克隆规则链失败")
|
||||
|
||||
Reference in New Issue
Block a user