优化企业网站功能
This commit is contained in:
@@ -109,47 +109,6 @@ CREATE TABLE IF NOT EXISTS yz_cms_article (
|
||||
return err
|
||||
}
|
||||
|
||||
func EnsureCmsArticleDefaultCategories() error {
|
||||
// 只初始化两级全局分类:文章中心(顶级)和新闻中心(文章中心的子分类)。
|
||||
// 不在启动时创建其它业务分类,后续分类由管理员按需新增。
|
||||
defaults := []struct {
|
||||
name string
|
||||
cid uint64
|
||||
sort int
|
||||
}{
|
||||
{name: "文章中心", cid: 0, sort: 1},
|
||||
{name: "新闻中心", cid: 1, sort: 2},
|
||||
}
|
||||
|
||||
for _, item := range defaults {
|
||||
count, err := Orm.QueryTable(new(CmsArticleCategory)).
|
||||
Filter("tid", 0).
|
||||
Filter("name", item.name).
|
||||
Filter("cid", item.cid).
|
||||
Filter("delete_time__isnull", true).
|
||||
Count()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if count > 0 {
|
||||
continue
|
||||
}
|
||||
now := time.Now()
|
||||
_, err = Orm.Insert(&CmsArticleCategory{
|
||||
Tid: 0,
|
||||
Cid: item.cid,
|
||||
Name: item.name,
|
||||
Sort: item.sort,
|
||||
Status: 1,
|
||||
CreateTime: now,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CmsCategoryNameMap(tid uint64, ids []uint64) map[uint64]string {
|
||||
out := make(map[uint64]string)
|
||||
if len(ids) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user