|
|
@@ -62,7 +62,9 @@ func DeviceList(c *gin.Context) { |
|
|
|
} |
|
|
|
var m []*db.DeviceWithEnterprise |
|
|
|
total, err := sess. |
|
|
|
Join("LEFT", "enterprise", "enterprise.id = device.enterprise_id").Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m) |
|
|
|
Join("LEFT", "enterprise", "enterprise.id = device.enterprise_id"). |
|
|
|
Join("LEFT", "merchant", "merchant.id = device.merchant_id"). |
|
|
|
Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
@@ -75,10 +77,12 @@ func DeviceList(c *gin.Context) { |
|
|
|
"name": v.Device.Name, |
|
|
|
"device_sn": v.Device.DeviceSn, |
|
|
|
"enterprise_id": v.Device.EnterpriseId, |
|
|
|
"merchant_id": v.Device.MerchantId, |
|
|
|
"memo": v.Device.Memo, |
|
|
|
"create_at": v.Device.CreateAt, |
|
|
|
"update_at": v.Device.UpdateAt, |
|
|
|
"enterprise_name": v.Enterprise.Name, |
|
|
|
"merchant_name": v.Merchant.Name, |
|
|
|
}) |
|
|
|
} |
|
|
|
e.OutSuc(c, map[string]interface{}{ |
|
|
@@ -110,6 +114,7 @@ func DeviceSave(c *gin.Context) { |
|
|
|
Name: req.Name, |
|
|
|
DeviceSn: req.DeviceSn, |
|
|
|
EnterpriseId: req.EnterpriseId, |
|
|
|
MerchantId: req.MerchantId, |
|
|
|
Memo: req.Memo, |
|
|
|
CreateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
@@ -126,8 +131,9 @@ func DeviceSave(c *gin.Context) { |
|
|
|
device.EnterpriseId = req.EnterpriseId |
|
|
|
device.Name = req.Name |
|
|
|
device.Memo = req.Memo |
|
|
|
device.MerchantId = req.MerchantId |
|
|
|
device.UpdateAt = time.Now().Format("2006-01-02 15:04:05") |
|
|
|
updateAffected, err1 := deviceDd.DeviceUpdate(device, "enterprise_id", "name", "memo", "update_at") |
|
|
|
updateAffected, err1 := deviceDd.DeviceUpdate(device, "enterprise_id", "merchant_id", "name", "memo", "update_at") |
|
|
|
if err1 != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
@@ -158,3 +164,17 @@ func DeviceDelete(c *gin.Context) { |
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func EnterPriseMerchantList(c *gin.Context) { |
|
|
|
enterpriseId := c.DefaultQuery("enterprise_id", "0") |
|
|
|
var m []model2.Merchant |
|
|
|
if err := db.Db.Where("enterprise_id = ?", enterpriseId).Find(&m); err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
e.OutSuc(c, map[string]interface{}{ |
|
|
|
"list": m, |
|
|
|
}, nil) |
|
|
|
return |
|
|
|
} |