mirror of
https://github.com/mindoc-org/mindoc.git
synced 2026-02-27 17:03:57 +08:00
feat:1、实现自定义模板功能
2、实现项目附件和图片按照项目组织 3、优化自动发布功能解决大项目发布时的性能问题 4、修复删除项目没有删除附件的问题 5、增加项目封面大小 6、增加部分项目操作日志
This commit is contained in:
@@ -14,12 +14,15 @@ type Template struct {
|
||||
TemplateName string `orm:"column(template_name);size(500);" json:"template_name"`
|
||||
MemberId int `orm:"column(member_id);index" json:"member_id"`
|
||||
BookId int `orm:"column(book_id);index" json:"book_id"`
|
||||
BookName string `orm:"-" json:"book_name"`
|
||||
//是否是全局模板:0 否/1 是; 全局模板在所有项目中都可以使用;否则只能在创建模板的项目中使用
|
||||
IsGlobal int `orm:"column(is_global);default(0)" json:"is_global"`
|
||||
TemplateContent string `orm:"column(template_content);type(text);null" json:"template_content"`
|
||||
CreateTime time.Time `orm:"column(create_time);type(datetime);auto_now_add" json:"create_time"`
|
||||
CreateName string `orm:"-" json:"create_name"`
|
||||
ModifyTime time.Time `orm:"column(modify_time);type(datetime);auto_now" json:"modify_time"`
|
||||
ModifyAt int `orm:"column(modify_at);type(int)" json:"-"`
|
||||
ModifyName string `orm:"-" json:"modify_name"`
|
||||
Version int64 `orm:"type(bigint);column(version)" json:"version"`
|
||||
}
|
||||
|
||||
@@ -125,14 +128,15 @@ func (t *Template) Save(cols ...string) (err error) {
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
|
||||
if !o.QueryTable(NewBook()).Filter("book_id",t.BookId).Exist() {
|
||||
if !o.QueryTable(NewBook().TableNameWithPrefix()).Filter("book_id",t.BookId).Exist() {
|
||||
return errors.New("项目不存在")
|
||||
}
|
||||
if !o.QueryTable(NewMember()).Filter("member_id",t.MemberId).Filter("status",0).Exist() {
|
||||
if !o.QueryTable(NewMember().TableNameWithPrefix()).Filter("member_id",t.MemberId).Filter("status",0).Exist() {
|
||||
return errors.New("用户已被禁用")
|
||||
}
|
||||
t.Version = time.Now().Unix()
|
||||
|
||||
if t.TemplateId > 0 {
|
||||
t.Version = time.Now().Unix()
|
||||
t.ModifyTime = time.Now()
|
||||
_,err = o.Update(t,cols...)
|
||||
}else{
|
||||
@@ -143,8 +147,38 @@ func (t *Template) Save(cols ...string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
//预加载一些数据
|
||||
func (t *Template) Preload() *Template {
|
||||
if t != nil {
|
||||
if t.MemberId > 0 {
|
||||
m,err := NewMember().Find(t.MemberId,"account","real_name");
|
||||
if err == nil {
|
||||
if m.RealName != "" {
|
||||
t.CreateName = m.RealName
|
||||
}else{
|
||||
t.CreateName = m.Account
|
||||
}
|
||||
}else{
|
||||
beego.Error("加载模板所有者失败 ->",err)
|
||||
}
|
||||
}
|
||||
if t.ModifyAt > 0 {
|
||||
if m,err := NewMember().Find(t.ModifyAt,"account","real_name"); err == nil {
|
||||
if m.RealName != "" {
|
||||
t.ModifyName = m.RealName
|
||||
}else{
|
||||
t.ModifyName = m.Account
|
||||
}
|
||||
}
|
||||
}
|
||||
if t.BookId > 0 {
|
||||
if b,err := NewBook().Find(t.BookId,"book_name");err == nil {
|
||||
t.BookName = b.BookName
|
||||
}
|
||||
}
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user