DengBiao преди 8 месеца
родител
ревизия
6f4158764e
променени са 6 файла, в които са добавени 31 реда и са изтрити 7 реда
  1. +22
    -2
      app/admin/hdl/hdl_device.go
  2. +1
    -1
      app/admin/hdl/hdl_merchant.go
  3. +1
    -0
      app/admin/md/md_device.go
  4. +1
    -0
      app/db/db_device.go
  5. +1
    -0
      app/db/model/device.go
  6. +5
    -4
      app/router/admin_router.go

+ 22
- 2
app/admin/hdl/hdl_device.go Целия файл

@@ -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
}

+ 1
- 1
app/admin/hdl/hdl_merchant.go Целия файл

@@ -32,7 +32,7 @@ func MerchantList(c *gin.Context) {
engine = engine.And("merchant.enterprise_id =?", req.EnterpriseId)
}
if req.Name != "" {
engine = engine.And("merchant.name like =?", "%"+req.Name+"%")
engine = engine.And("merchant.name like ?", "%"+req.Name+"%")
}
total, err := engine.Join("LEFT", "enterprise", "enterprise.id = merchant.enterprise_id").
Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)


+ 1
- 0
app/admin/md/md_device.go Целия файл

@@ -13,5 +13,6 @@ type DeviceSaveReq struct {
Name string `json:"name" binding:"required"`
DeviceSn string `json:"device_sn" binding:"required"`
EnterpriseId int `json:"enterprise_id" binding:"required"`
MerchantId int `json:"merchant_id" binding:"required"`
Memo string `json:"memo"`
}

+ 1
- 0
app/db/db_device.go Целия файл

@@ -96,6 +96,7 @@ func (deviceOrdDb *Device) DeviceUpdate(m *model.Device, forceColums ...string)
type DeviceWithEnterprise struct {
model.Device `xorm:"extends"`
model.Enterprise `xorm:"extends"`
model.Merchant `xorm:"extends"`
}

func (DeviceWithEnterprise) TableName() string {


+ 1
- 0
app/db/model/device.go Целия файл

@@ -4,6 +4,7 @@ type Device struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Name string `json:"name" xorm:"not null default '' comment('档口名称') VARCHAR(255)"`
DeviceSn string `json:"device_sn" xorm:"not null default '' comment('设备编号') unique VARCHAR(255)"`
MerchantId int `json:"merchant_id" xorm:"not null default 0 comment('商家id') INT(11)"`
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('校企id') INT(11)"`
Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(255)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`


+ 5
- 4
app/router/admin_router.go Целия файл

@@ -111,9 +111,10 @@ func rFinanceManage(r *gin.RouterGroup) {
}

func rDeviceManage(r *gin.RouterGroup) {
r.POST("/save", hdl2.DeviceSave) //设备管理-编辑/新增
r.POST("/list", hdl2.DeviceList) //设备管理-列表
r.DELETE("/delete/:device_sn", hdl2.DeviceDelete) //设备管理-删除
r.POST("/save", hdl2.DeviceSave) //设备管理-编辑/新增
r.POST("/list", hdl2.DeviceList) //设备管理-列表
r.GET("/enterPriseMerchantList", hdl2.EnterPriseMerchantList) //设备管理-学校下商家列表
r.DELETE("/delete/:device_sn", hdl2.DeviceDelete) //设备管理-删除
}

func rMerchant(r *gin.RouterGroup) {
@@ -318,5 +319,5 @@ func AdminRoute(r *gin.RouterGroup) {
rFinanceManage(r.Group("/financeManage")) //财务管理
rDeviceManage(r.Group("/deviceManage")) //设备管理
rDataStatistics(r.Group("/dataStatistics")) //数据统计
rMerchant(r.Group("/merchant"))
rMerchant(r.Group("/merchant")) //商家管理
}

Зареждане…
Отказ
Запис