mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[优化] 将部分在services中抛出异常使用error返回
This commit is contained in:
@@ -30,11 +30,11 @@ type DeviceApi struct {
|
||||
|
||||
func (p *DeviceApi) GetDevicePanel(rc *restfulx.ReqCtx) {
|
||||
var data entity.DeviceTotalOutput
|
||||
data.DeviceInfo = p.DeviceApp.FindDeviceCount()
|
||||
data.DeviceLinkStatusInfo = p.DeviceApp.FindDeviceCountGroupByLinkStatus()
|
||||
data.DeviceCountType = p.DeviceApp.FindDeviceCountGroupByType()
|
||||
data.AlarmInfo = p.DeviceAlarmApp.FindAlarmCount()
|
||||
data.ProductInfo = p.ProductApp.FindProductCount()
|
||||
data.DeviceInfo, _ = p.DeviceApp.FindDeviceCount()
|
||||
data.DeviceLinkStatusInfo, _ = p.DeviceApp.FindDeviceCountGroupByLinkStatus()
|
||||
data.DeviceCountType, _ = p.DeviceApp.FindDeviceCountGroupByType()
|
||||
data.AlarmInfo, _ = p.DeviceAlarmApp.FindAlarmCount()
|
||||
data.ProductInfo, _ = p.ProductApp.FindProductCount()
|
||||
rc.ResData = data
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ func (p *DeviceApi) GetDeviceList(rc *restfulx.ReqCtx) {
|
||||
|
||||
data.RoleId = rc.LoginAccount.RoleId
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
list, total := p.DeviceApp.FindListPage(pageNum, pageSize, data)
|
||||
|
||||
list, total, err := p.DeviceApp.FindListPage(pageNum, pageSize, data)
|
||||
biz.ErrIsNil(err, "查询设备列表失败")
|
||||
rc.ResData = model.ResultPage{
|
||||
Total: total,
|
||||
PageNum: int64(pageNum),
|
||||
@@ -73,7 +73,8 @@ func (p *DeviceApi) GetDeviceListAll(rc *restfulx.ReqCtx) {
|
||||
data.RoleId = rc.LoginAccount.RoleId
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
|
||||
list := p.DeviceApp.FindList(data)
|
||||
list, err := p.DeviceApp.FindList(data)
|
||||
biz.ErrIsNil(err, "查询所有设备失败")
|
||||
rc.ResData = list
|
||||
}
|
||||
|
||||
@@ -91,7 +92,8 @@ func (p *DeviceApi) GetDeviceStatus(rc *restfulx.ReqCtx) {
|
||||
classify := restfulx.QueryParam(rc, "classify")
|
||||
device, err := p.DeviceApp.FindOne(id)
|
||||
biz.ErrIsNil(err, "获取设备失败")
|
||||
template := p.ProductTemplateApp.FindList(entity.ProductTemplate{Classify: classify, Pid: device.Pid})
|
||||
template, err := p.ProductTemplateApp.FindList(entity.ProductTemplate{Classify: classify, Pid: device.Pid})
|
||||
biz.ErrIsNil(err, "查询设备模板失败")
|
||||
// 从设备影子中读取
|
||||
res := make([]entity.DeviceStatusVo, 0)
|
||||
getDevice := shadow.InitDeviceShadow(device.Name, device.Pid)
|
||||
@@ -113,20 +115,6 @@ func (p *DeviceApi) GetDeviceStatus(rc *restfulx.ReqCtx) {
|
||||
if _, ok := rs[tel.Key]; ok {
|
||||
if classify == global.TslTelemetryType {
|
||||
value := rs[tel.Key].Value
|
||||
// tsl转化
|
||||
/*var tslValue tsl.ValueType
|
||||
err := tool.MapToStruct(tel.Define, &tslValue)
|
||||
if err != nil {
|
||||
value = rs[tel.Key].Value
|
||||
} else {
|
||||
tslValue.Type = tel.Type
|
||||
// 此处rs[tel.Key].Value 变成字符串类型了
|
||||
value = tslValue.ConvertValue(rs[tel.Key].Value)
|
||||
log.Println("value", value)
|
||||
if value == nil {
|
||||
value = rs[tel.Key]
|
||||
}
|
||||
}*/
|
||||
sdv.Time = rs[tel.Key].UpdatedAt
|
||||
sdv.Value = value
|
||||
}
|
||||
@@ -189,36 +177,38 @@ func (p *DeviceApi) DownAttribute(rc *restfulx.ReqCtx) {
|
||||
func (p *DeviceApi) InsertDevice(rc *restfulx.ReqCtx) {
|
||||
var data entity.Device
|
||||
restfulx.BindJsonAndValid(rc, &data)
|
||||
product := p.ProductApp.FindOne(data.Pid)
|
||||
product, _ := p.ProductApp.FindOne(data.Pid)
|
||||
biz.NotNil(product, "未查到所属产品信息")
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
data.OrgId = rc.LoginAccount.OrganizationId
|
||||
list := p.DeviceApp.FindList(entity.Device{Name: data.Name})
|
||||
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.LinkStatus = global.INACTIVE
|
||||
data.LastAt = time.Now()
|
||||
data.Protocol = product.ProtocolName
|
||||
|
||||
p.DeviceApp.Insert(data)
|
||||
_, err := p.DeviceApp.Insert(data)
|
||||
biz.ErrIsNil(err, "添加设备失败")
|
||||
}
|
||||
|
||||
// UpdateDevice 修改Device
|
||||
func (p *DeviceApi) UpdateDevice(rc *restfulx.ReqCtx) {
|
||||
var data entity.Device
|
||||
restfulx.BindQuery(rc, &data)
|
||||
product := p.ProductApp.FindOne(data.Pid)
|
||||
product, _ := p.ProductApp.FindOne(data.Pid)
|
||||
biz.NotNil(product, "未查到所属产品信息")
|
||||
data.Protocol = product.ProtocolName
|
||||
|
||||
p.DeviceApp.Update(data)
|
||||
_, err := p.DeviceApp.Update(data)
|
||||
biz.ErrIsNil(err, "修改失败")
|
||||
}
|
||||
|
||||
// DeleteDevice 删除Device
|
||||
func (p *DeviceApi) DeleteDevice(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
ids := strings.Split(id, ",")
|
||||
p.DeviceApp.Delete(ids)
|
||||
biz.ErrIsNil(p.DeviceApp.Delete(ids), "删除失败")
|
||||
}
|
||||
|
||||
func (p *DeviceApi) ScreenTwinData(rc *restfulx.ReqCtx) {
|
||||
@@ -227,9 +217,9 @@ func (p *DeviceApi) ScreenTwinData(rc *restfulx.ReqCtx) {
|
||||
classId := restfulx.QueryParam(rc, "classId")
|
||||
if classId == "" {
|
||||
vp := make([]entity.VisualClass, 0)
|
||||
list := p.ProductApp.FindList(entity.Product{})
|
||||
list, _ := p.ProductApp.FindList(entity.Product{})
|
||||
for _, pro := range *list {
|
||||
data := p.ProductTemplateApp.FindListAttrs(entity.ProductTemplate{Pid: pro.Id})
|
||||
data, _ := p.ProductTemplateApp.FindListAttrs(entity.ProductTemplate{Pid: pro.Id})
|
||||
vta := make([]entity.VisualTwinAttr, 0)
|
||||
for _, attr := range *data {
|
||||
twinAttr := entity.VisualTwinAttr{
|
||||
@@ -258,7 +248,7 @@ func (p *DeviceApi) ScreenTwinData(rc *restfulx.ReqCtx) {
|
||||
} else {
|
||||
device := entity.Device{Pid: classId, RoleId: rc.LoginAccount.RoleId}
|
||||
device.Owner = rc.LoginAccount.UserName
|
||||
findList, _ := p.DeviceApp.FindListPage(pageNum, pageSize, device)
|
||||
findList, _, _ := p.DeviceApp.FindListPage(pageNum, pageSize, device)
|
||||
vt := make([]entity.VisualTwin, 0)
|
||||
for _, device := range *findList {
|
||||
vt = append(vt, entity.VisualTwin{
|
||||
|
||||
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
// ==========================================================================
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"github.com/PandaXGO/PandaKit/model"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"strings"
|
||||
@@ -15,7 +16,7 @@ type DeviceAlarmApi struct {
|
||||
}
|
||||
|
||||
func (p *DeviceAlarmApi) GetDeviceAlarmPanel(rc *restfulx.ReqCtx) {
|
||||
panel := p.DeviceAlarmApp.FindAlarmPanel()
|
||||
panel, _ := p.DeviceAlarmApp.FindAlarmPanel()
|
||||
rc.ResData = panel
|
||||
}
|
||||
|
||||
@@ -34,8 +35,8 @@ func (p *DeviceAlarmApi) GetDeviceAlarmList(rc *restfulx.ReqCtx) {
|
||||
data.RoleId = rc.LoginAccount.RoleId
|
||||
data.Owner = rc.LoginAccount.UserName
|
||||
|
||||
list, total := p.DeviceAlarmApp.FindListPage(pageNum, pageSize, data)
|
||||
|
||||
list, total, err := p.DeviceAlarmApp.FindListPage(pageNum, pageSize, data)
|
||||
biz.ErrIsNil(err, "设备查询失败")
|
||||
rc.ResData = model.ResultPage{
|
||||
Total: total,
|
||||
PageNum: int64(pageNum),
|
||||
@@ -48,12 +49,14 @@ func (p *DeviceAlarmApi) GetDeviceAlarmList(rc *restfulx.ReqCtx) {
|
||||
func (p *DeviceAlarmApi) UpdateDeviceAlarm(rc *restfulx.ReqCtx) {
|
||||
var data entity.DeviceAlarm
|
||||
restfulx.BindJsonAndValid(rc, &data)
|
||||
p.DeviceAlarmApp.Update(data)
|
||||
err := p.DeviceAlarmApp.Update(data)
|
||||
biz.ErrIsNil(err, "修改告警失败")
|
||||
}
|
||||
|
||||
// DeleteDeviceAlarm 删除告警
|
||||
func (p *DeviceAlarmApi) DeleteDeviceAlarm(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
ids := strings.Split(id, ",")
|
||||
p.DeviceAlarmApp.Delete(ids)
|
||||
err := p.DeviceAlarmApp.Delete(ids)
|
||||
biz.ErrIsNil(err, "删除告警失败")
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ func (p *DeviceCmdLogApi) GetDeviceCmdLogList(rc *restfulx.ReqCtx) {
|
||||
data.State = restfulx.QueryParam(rc, "state")
|
||||
data.Type = restfulx.QueryParam(rc, "type")
|
||||
|
||||
list, total := p.DeviceCmdLogApp.FindListPage(pageNum, pageSize, data)
|
||||
|
||||
list, total, err := p.DeviceCmdLogApp.FindListPage(pageNum, pageSize, data)
|
||||
biz.ErrIsNil(err, "查询告警列表数据失败")
|
||||
rc.ResData = model.ResultPage{
|
||||
Total: total,
|
||||
PageNum: int64(pageNum),
|
||||
@@ -74,5 +74,5 @@ func (p *DeviceCmdLogApi) InsertDeviceCmdLog(rc *restfulx.ReqCtx) {
|
||||
func (p *DeviceCmdLogApi) DeleteDeviceCmdLog(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
ids := strings.Split(id, ",")
|
||||
p.DeviceCmdLogApp.Delete(ids)
|
||||
biz.ErrIsNil(p.DeviceCmdLogApp.Delete(ids), "删除指令失败")
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
@@ -22,16 +23,18 @@ func (p *DeviceGroupApi) GetDeviceGroupTree(rc *restfulx.ReqCtx) {
|
||||
vsg.Id = id
|
||||
vsg.RoleId = rc.LoginAccount.RoleId
|
||||
vsg.Owner = rc.LoginAccount.UserName
|
||||
|
||||
rc.ResData = p.DeviceGroupApp.SelectDeviceGroup(vsg)
|
||||
group, err := p.DeviceGroupApp.SelectDeviceGroup(vsg)
|
||||
biz.ErrIsNil(err, "查询设备组失败")
|
||||
rc.ResData = group
|
||||
}
|
||||
|
||||
func (p *DeviceGroupApi) GetDeviceGroupTreeLabel(rc *restfulx.ReqCtx) {
|
||||
vsg := entity.DeviceGroup{}
|
||||
vsg.RoleId = rc.LoginAccount.RoleId
|
||||
vsg.Owner = rc.LoginAccount.UserName
|
||||
|
||||
rc.ResData = p.DeviceGroupApp.SelectDeviceGroupLabel(vsg)
|
||||
label, err := p.DeviceGroupApp.SelectDeviceGroupLabel(vsg)
|
||||
biz.ErrIsNil(err, "查询设备组失败")
|
||||
rc.ResData = label
|
||||
}
|
||||
|
||||
func (p *DeviceGroupApi) GetDeviceGroupList(rc *restfulx.ReqCtx) {
|
||||
@@ -45,9 +48,13 @@ func (p *DeviceGroupApi) GetDeviceGroupList(rc *restfulx.ReqCtx) {
|
||||
vsg.RoleId = rc.LoginAccount.RoleId
|
||||
vsg.Owner = rc.LoginAccount.UserName
|
||||
if vsg.Name == "" {
|
||||
rc.ResData = p.DeviceGroupApp.SelectDeviceGroup(vsg)
|
||||
group, err := p.DeviceGroupApp.SelectDeviceGroup(vsg)
|
||||
biz.ErrIsNil(err, "查询设备组失败")
|
||||
rc.ResData = group
|
||||
} else {
|
||||
rc.ResData = p.DeviceGroupApp.FindList(vsg)
|
||||
list, err := p.DeviceGroupApp.FindList(vsg)
|
||||
biz.ErrIsNil(err, "查询设备组列表失败")
|
||||
rc.ResData = list
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,14 +63,17 @@ func (p *DeviceGroupApi) GetDeviceGroupAllList(rc *restfulx.ReqCtx) {
|
||||
var vsg entity.DeviceGroup
|
||||
vsg.RoleId = rc.LoginAccount.RoleId
|
||||
vsg.Owner = rc.LoginAccount.UserName
|
||||
|
||||
rc.ResData = p.DeviceGroupApp.FindList(vsg)
|
||||
list, err := p.DeviceGroupApp.FindList(vsg)
|
||||
biz.ErrIsNil(err, "查询设备组列表失败")
|
||||
rc.ResData = list
|
||||
}
|
||||
|
||||
// GetDeviceGroup 获取DeviceGroup
|
||||
func (p *DeviceGroupApi) GetDeviceGroup(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
rc.ResData = p.DeviceGroupApp.FindOne(id)
|
||||
one, err := p.DeviceGroupApp.FindOne(id)
|
||||
biz.ErrIsNil(err, "查询设备组失败")
|
||||
rc.ResData = one
|
||||
}
|
||||
|
||||
// InsertDeviceGroup 添加DeviceGroup
|
||||
|
||||
@@ -38,8 +38,8 @@ func (p *ProductApi) GetProductList(rc *restfulx.ReqCtx) {
|
||||
data.DeviceType = restfulx.QueryParam(rc, "deviceType")
|
||||
data.Name = restfulx.QueryParam(rc, "name")
|
||||
|
||||
list, total := p.ProductApp.FindListPage(pageNum, pageSize, data)
|
||||
|
||||
list, total, err := p.ProductApp.FindListPage(pageNum, pageSize, data)
|
||||
biz.ErrIsNil(err, "查询产品列表失败")
|
||||
rc.ResData = model.ResultPage{
|
||||
Total: total,
|
||||
PageNum: int64(pageNum),
|
||||
@@ -55,15 +55,17 @@ func (p *ProductApi) GetProductListAll(rc *restfulx.ReqCtx) {
|
||||
data.ProtocolName = restfulx.QueryParam(rc, "protocolName")
|
||||
data.DeviceType = restfulx.QueryParam(rc, "deviceType")
|
||||
data.Name = restfulx.QueryParam(rc, "name")
|
||||
|
||||
rc.ResData = p.ProductApp.FindList(data)
|
||||
list, err := p.ProductApp.FindList(data)
|
||||
biz.ErrIsNil(err, "查询产品列表失败")
|
||||
rc.ResData = list
|
||||
}
|
||||
|
||||
// GetProductTsl Template列表数据
|
||||
func (p *ProductApi) GetProductTsl(rc *restfulx.ReqCtx) {
|
||||
data := entity.ProductTemplate{}
|
||||
data.Pid = restfulx.PathParam(rc, "id")
|
||||
templates := p.TemplateApp.FindList(data)
|
||||
templates, err := p.TemplateApp.FindList(data)
|
||||
biz.ErrIsNil(err, "查询产品模板列表失败")
|
||||
attributes := make([]map[string]interface{}, 0)
|
||||
telemetry := make([]map[string]interface{}, 0)
|
||||
commands := make([]map[string]interface{}, 0)
|
||||
@@ -95,7 +97,9 @@ func (p *ProductApi) GetProductTsl(rc *restfulx.ReqCtx) {
|
||||
// GetProduct 获取Product
|
||||
func (p *ProductApi) GetProduct(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
rc.ResData = p.ProductApp.FindOne(id)
|
||||
one, err := p.ProductApp.FindOne(id)
|
||||
biz.ErrIsNil(err, "查询失败")
|
||||
rc.ResData = one
|
||||
}
|
||||
|
||||
// InsertProduct 添加Product
|
||||
@@ -134,7 +138,7 @@ func (p *ProductApi) DeleteProduct(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
ids := strings.Split(id, ",")
|
||||
for _, id := range ids {
|
||||
list := p.DeviceApp.FindList(entity.Device{Pid: id})
|
||||
list, _ := p.DeviceApp.FindList(entity.Device{Pid: id})
|
||||
biz.IsTrue(!(list != nil && len(*list) > 0), fmt.Sprintf("产品ID%s下存在设备,不能被删除", id))
|
||||
}
|
||||
// 删除产品
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/biz"
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
"pandax/apps/device/entity"
|
||||
"pandax/apps/device/services"
|
||||
@@ -39,20 +40,26 @@ func (p *ProductCategoryApi) GetProductCategoryList(rc *restfulx.ReqCtx) {
|
||||
if sg.Name == "" {
|
||||
rc.ResData = p.ProductCategoryApp.SelectProductCategory(sg)
|
||||
} else {
|
||||
rc.ResData = p.ProductCategoryApp.FindList(sg)
|
||||
list, err := p.ProductCategoryApp.FindList(sg)
|
||||
biz.ErrIsNil(err, "查询产品分类列表失败")
|
||||
rc.ResData = list
|
||||
}
|
||||
}
|
||||
|
||||
// GetProductCategoryAllList 查询所有
|
||||
func (p *ProductCategoryApi) GetProductCategoryAllList(rc *restfulx.ReqCtx) {
|
||||
var vsg entity.ProductCategory
|
||||
rc.ResData = p.ProductCategoryApp.FindList(vsg)
|
||||
list, err := p.ProductCategoryApp.FindList(vsg)
|
||||
biz.ErrIsNil(err, "查询产品分类列表失败")
|
||||
rc.ResData = list
|
||||
}
|
||||
|
||||
// GetProductCategory 获取ProductCategory
|
||||
func (p *ProductCategoryApi) GetProductCategory(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
rc.ResData = p.ProductCategoryApp.FindOne(id)
|
||||
one, err := p.ProductCategoryApp.FindOne(id)
|
||||
biz.ErrIsNil(err, "查询产品分类失败")
|
||||
rc.ResData = one
|
||||
}
|
||||
|
||||
// InsertProductCategory 添加ProductCategory
|
||||
|
||||
@@ -28,8 +28,8 @@ func (p *ProductOtaApi) GetProductOtaList(rc *restfulx.ReqCtx) {
|
||||
data.Name = restfulx.QueryParam(rc, "name")
|
||||
data.Pid = restfulx.QueryParam(rc, "pid")
|
||||
|
||||
list, total := p.ProductOtaApp.FindListPage(pageNum, pageSize, data)
|
||||
|
||||
list, total, err := p.ProductOtaApp.FindListPage(pageNum, pageSize, data)
|
||||
biz.ErrIsNil(err, "查询OTA信息列表失败")
|
||||
rc.ResData = model.ResultPage{
|
||||
Total: total,
|
||||
PageNum: int64(pageNum),
|
||||
@@ -41,7 +41,9 @@ func (p *ProductOtaApi) GetProductOtaList(rc *restfulx.ReqCtx) {
|
||||
// GetProductOta 获取Ota
|
||||
func (p *ProductOtaApi) GetProductOta(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
rc.ResData = p.ProductOtaApp.FindOne(id)
|
||||
one, err := p.ProductOtaApp.FindOne(id)
|
||||
biz.ErrIsNil(err, "查询OTA信息失败")
|
||||
rc.ResData = one
|
||||
}
|
||||
|
||||
// InsertProductOta 添加Ota
|
||||
|
||||
@@ -25,8 +25,8 @@ func (p *ProductTemplateApi) GetProductTemplateList(rc *restfulx.ReqCtx) {
|
||||
data.Classify = restfulx.QueryParam(rc, "classify")
|
||||
data.Name = restfulx.QueryParam(rc, "name")
|
||||
|
||||
list, total := p.ProductTemplateApp.FindListPage(pageNum, pageSize, data)
|
||||
|
||||
list, total, err := p.ProductTemplateApp.FindListPage(pageNum, pageSize, data)
|
||||
biz.ErrIsNil(err, "查询产品模板列表失败")
|
||||
rc.ResData = model.ResultPage{
|
||||
Total: total,
|
||||
PageNum: int64(pageNum),
|
||||
@@ -41,14 +41,17 @@ func (p *ProductTemplateApi) GetProductTemplateListAll(rc *restfulx.ReqCtx) {
|
||||
data.Pid = restfulx.QueryParam(rc, "pid")
|
||||
data.Classify = restfulx.QueryParam(rc, "classify")
|
||||
data.Name = restfulx.QueryParam(rc, "name")
|
||||
list := p.ProductTemplateApp.FindList(data)
|
||||
list, err := p.ProductTemplateApp.FindList(data)
|
||||
biz.ErrIsNil(err, "查询产品模板列表失败")
|
||||
rc.ResData = list
|
||||
}
|
||||
|
||||
// GetProductTemplate 获取Template
|
||||
func (p *ProductTemplateApi) GetProductTemplate(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
rc.ResData = p.ProductTemplateApp.FindOne(id)
|
||||
one, err := p.ProductTemplateApp.FindOne(id)
|
||||
biz.ErrIsNil(err, "查询产品模板失败")
|
||||
rc.ResData = one
|
||||
}
|
||||
|
||||
// InsertProductTemplate 添加Template
|
||||
@@ -77,7 +80,8 @@ func (p *ProductTemplateApi) InsertProductTemplate(rc *restfulx.ReqCtx) {
|
||||
func (p *ProductTemplateApi) UpdateProductTemplate(rc *restfulx.ReqCtx) {
|
||||
var data entity.ProductTemplate
|
||||
restfulx.BindJsonAndValid(rc, &data)
|
||||
one := p.ProductTemplateApp.FindOne(data.Id)
|
||||
one, err := p.ProductTemplateApp.FindOne(data.Id)
|
||||
biz.ErrIsNil(err, "查询产品模板失败")
|
||||
stable := ""
|
||||
len := 0
|
||||
if data.Classify == entity.ATTRIBUTES_TSL {
|
||||
@@ -104,7 +108,8 @@ func (p *ProductTemplateApi) UpdateProductTemplate(rc *restfulx.ReqCtx) {
|
||||
// DeleteProductTemplate 删除Template
|
||||
func (p *ProductTemplateApi) DeleteProductTemplate(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
data := p.ProductTemplateApp.FindOne(id)
|
||||
data, err := p.ProductTemplateApp.FindOne(id)
|
||||
biz.ErrIsNil(err, "查询产品模板失败")
|
||||
// 向超级表中删除字段
|
||||
stable := ""
|
||||
if data.Classify == entity.ATTRIBUTES_TSL {
|
||||
|
||||
Reference in New Issue
Block a user