package business import ( "fmt" "time" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" //"device-manage/app/admin/models" "device-manage/app/admin/models/busmodels" "device-manage/tools" "device-manage/tools/app" ) func GetAppDeviceBindedList(c *gin.Context) { var data busmodels.BusAppDeviceBind var params busmodels.QueryBindedDeviceParams err := c.MustBindWith(¶ms, binding.JSON) pageSize := params.PageSize pageIndex := params.PageIndex gids := params.Gids deviceSn := params.DeviceSn data.AppId = params.AppId fmt.Println(data) result, count, err := data.GetBindedPage(pageSize, pageIndex, deviceSn, gids) tools.HasError(err, "", -1) app.PageOK(c, result, count, pageIndex, pageSize, "") } //deviceSn是查询参数 func GetAppDeviceUnBindedList(c *gin.Context) { var data busmodels.BusAppDeviceBind var params busmodels.QueryBindedDeviceParams err := c.MustBindWith(¶ms, binding.JSON) pageSize := params.PageSize pageIndex := params.PageIndex gids := params.Gids deviceSn := params.DeviceSn data.AppId = params.AppId result, count, err := data.GetUnBindedPage(pageSize, pageIndex, deviceSn, gids) tools.HasError(err, "", -1) app.PageOK(c, result, count, pageIndex, pageSize, "") } func InsertAppDeviceBinded(c *gin.Context) { var data busmodels.AppDeviceData var bindInfo busmodels.BusAppDeviceBind err := c.ShouldBindWith(&data, binding.JSON) tools.HasError(err, "非法数据格式", 500) user := tools.GetUserIdStr(c) bindInfo.CreateBy = user bindInfo.UpdateBy = user fmt.Println(user) times := time.Now() bindInfo.CreatedAt = times bindInfo.UpdatedAt = times id, err := bindInfo.Insert(data) fmt.Println(id) tools.HasError(err, "绑定失败", 500) app.OK(c, id, "绑定成功") } func DeleteAppDeviceBinded(c *gin.Context) { var data busmodels.BusAppDeviceBind data.UpdateBy = tools.GetUserIdStr(c) IDS := tools.IdsStrToIdsIntGroup("bindId", c) fmt.Println(IDS) result, err := data.BatchDelete(IDS) tools.HasError(err, "解绑定失败", 500) app.OK(c, result, "解绑定成功") }