123456789101112131415161718192021222324252627282930313233 |
- package knowledge
- import (
- "eta_gn/eta_api/global"
- "eta_gn/eta_api/utils"
- )
- type KnowledgeResourceFile struct {
- KnowledgeResourceFileId int `gorm:"column:knowledge_resource_file_id;primaryKey;autoIncrement"`
- KnowledgeResourceId int `gorm:"column:knowledge_resource_id"`
- FileUrl string `gorm:"column:file_url"`
- }
- func (k KnowledgeResourceFile) TableName() string {
- return "knowledge_resource_file"
- }
- func (k *KnowledgeResourceFile) BatchAdd(items []*KnowledgeResourceFile) (err error) {
- err = global.DmSQL["rddp"].CreateInBatches(items, utils.MultiAddNum).Error
- return
- }
- func (k *KnowledgeResourceFile) DeleteByResourceId(id int) (err error) {
- sql := "DELETE FROM knowledge_resource_file WHERE knowledge_resource_id =?"
- err = global.DmSQL["rddp"].Exec(sql, id).Error
- return
- }
- func (k *KnowledgeResourceFile) GetByResourceId(id int) (item []*KnowledgeResourceFile, err error) {
- sql := "SELECT * FROM knowledge_resource_file WHERE knowledge_resource_id =?"
- err = global.DmSQL["rddp"].Raw(sql, id).Find(&item).Error
- return
- }
|