zhangqian
2024-07-03 f45e4cb8045fe60f96f467dc4ea1e2ae57445712
默认位置parent_id为视图位置id
1个文件已修改
28 ■■■■ 已修改文件
controllers/warehouse.go 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/warehouse.go
@@ -41,19 +41,21 @@
        util.ResponseFormat(c, code.RequestParamError, err.Error())
        return
    }
    //创建视图
    view := &models.Location{
        Name:      params.Code,
        JointName: params.Code,
        Type:      constvar.LocationTypeView,
    }
    id, err := models.NewLocationSearch().CreateReturnId(view)
    if err != nil {
        util.ResponseFormat(c, code.SaveFail, "视图创建失败")
        return
    }
    err = models.WithTransaction(func(tx *gorm.DB) error {
    err := models.WithTransaction(func(tx *gorm.DB) error {
        err := models.NewWarehouseSearch().SetOrm(tx).Create(&params)
        if err != nil {
            return err
        }
        //创建视图
        view := &models.Location{
            Name:        params.Code,
            JointName:   params.Code,
            Type:        constvar.LocationTypeView,
            WarehouseId: params.Id,
        }
        viewId, err := models.NewLocationSearch().CreateReturnId(view)
        if err != nil {
            return err
        }
@@ -64,7 +66,7 @@
            JointName:         params.Name,
            Type:              constvar.LocationTypeInternal,
            ReplenishLocation: true,
            ParentId:          id,
            ParentId:          viewId,
            WarehouseId:       params.Id,
        }
        locationId, err := models.NewLocationSearch().SetOrm(tx).CreateReturnId(location)