编辑代码

package main

import (
	"encoding/json"
	"time"
    "fmt"
)

type JSON json.RawMessage
type NullTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not NULL
}
type Model struct {
    Id int `json:"id" gorm:"primaryKey;autoIncrement;comment:主键编码"`
    CreateBy int `json:"createBy" gorm:"index;comment:创建者"`
	UpdateBy int `json:"updateBy" gorm:"index;comment:更新者"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt NullTime `gorm:"index:delete_at"`
}
type A struct{
    Model
    Path     string `json:"path" gorm:"type:varchar(768);comment:文件路径"`
	Status   string `json:"status" gorm:"type:varchar(10);comment:状态"`
	FolderId string `json:"folderId" gorm:"type:varchar(768);comment:文件夹id"`
	Title    string `json:"title" gorm:"type:varchar(768);comment:标题"`
	PictureFiles []B `json:"picture_files" gorm:"foreignKey:PictureId;references:Id"`
}
type B struct{
     Model
    Path      string `json:"path" gorm:"type:varchar(768);comment:文件路径"`
	PictureId int64  `json:"pictureId" gorm:"type:int(11);comment:文件id"`
	Type      string `json:"type" gorm:"type:varchar(100);comment:类型"`
	Size      int64  `json:"size" gorm:"type:int(11);comment:大小kb"`
	IsBigFile string `json:"isBigFile" gorm:"type:varchar(10);comment:是否大文件"`

	Picture A `json:"picture" gorm:"foreignKey:PictureId;references:Id"`
	PictureFileSearch
	PictureFileResp
}
type PictureFileSearch struct {
	IdList []int `json:"id_list" gorm:"-"`
}
type PictureFileResp struct {
	Url string `json:"url" gorm:"-"`
}
func main() {
	v1 := make([]B,1)
    // v1[0].PictureFiles = []B{B{}}
	j, _ := json.Marshal(v1)
	fmt.Println(string(j))
}