1 Star 1 Fork 1

xiaoyutab / xgotool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
menu_create.go 1021 Bytes
一键复制 编辑 原始数据 按行查看 历史
xiaoyutab 提交于 2024-04-30 10:16 . 调整目录结构和依赖位置
package xbook
import (
"errors"
"time"
"gitee.com/xiaoyutab/xgotool/individual/xlog"
)
// 创建章节信息
//
// c 章节信息
// cn 内容信息(该项的ID字段会直接进行覆盖)
func MenuCreate(c *BookChapter, cn *BookContent) error {
if c == nil {
return errors.New("书籍章节为空")
}
if c.BookId <= 0 {
return errors.New("所属书籍不能为空")
}
if c.Title == "" {
return errors.New("章节标题不能为空")
}
c.UpdatedAt = time.Now().Format(time.DateTime)
if c.CreatedAt != "" {
c.CreatedAt = time.Now().Format(time.DateTime)
}
// 使用fid组无限分类式菜单,而不是使用type组分卷式菜单
// 插入数据
err := _default.DB.Table(_default.TitlesName).Save(c).Error
if err != nil {
return xlog.AE("章节信息存储失败", err)
}
// 更新内容信息
if cn != nil {
cn.Id = c.Id
err = _default.DB.Table(_default.ContentName).Save(cn).Error
if err != nil {
return xlog.AE("章节内容信息存储失败", err)
}
}
return nil
}
Go
1
https://gitee.com/xiaoyutab/xgotool.git
git@gitee.com:xiaoyutab/xgotool.git
xiaoyutab
xgotool
xgotool
v0.3.13

搜索帮助