diff --git a/commands/install.go b/commands/install.go index 336c4b0f..51166fe0 100644 --- a/commands/install.go +++ b/commands/install.go @@ -145,7 +145,7 @@ func initialization() { item.ItemName = "默认项目" item.MemberId = 1 if err := item.Save(); err != nil { - panic("初始化项目集失败 -> " + err.Error()) + panic("初始化项目空间失败 -> " + err.Error()) os.Exit(1) } } diff --git a/controllers/BookController.go b/controllers/BookController.go index 2a05c8ed..455574fe 100644 --- a/controllers/BookController.go +++ b/controllers/BookController.go @@ -159,7 +159,7 @@ func (c *BookController) SaveBook() { } } if !models.NewItemsets().Exist(itemId) { - c.JsonResult(6006,"项目集不存在") + c.JsonResult(6006,"项目空间不存在") } if editor != "markdown" && editor != "html" { editor = "markdown" @@ -458,7 +458,7 @@ func (c *BookController) Create() { privatelyOwned = 1 } if !models.NewItemsets().Exist(itemId) { - c.JsonResult(6005, "项目集不存在") + c.JsonResult(6005, "项目空间不存在") } if commentStatus != "open" && commentStatus != "closed" && commentStatus != "group_only" && commentStatus != "registered_only" { commentStatus = "closed" @@ -588,7 +588,7 @@ func (c *BookController) Import() { c.JsonResult(6003, "项目标识只能包含小写字母、数字,以及“-”和“_”符号,并且只能小写字母开头") } if !models.NewItemsets().Exist(itemId) { - c.JsonResult(6007, "项目集不存在") + c.JsonResult(6007, "项目空间不存在") } if strings.Count(identify, "") > 50 { c.JsonResult(6004, "文档标识不能超过50字") @@ -950,7 +950,7 @@ func (c *BookController) TeamSearch() { } -//项目集搜索. +//项目空间搜索. func (c *BookController) ItemsetsSearch() { c.Prepare() diff --git a/controllers/ManagerController.go b/controllers/ManagerController.go index 77d7e8a1..0d8104a1 100644 --- a/controllers/ManagerController.go +++ b/controllers/ManagerController.go @@ -355,7 +355,7 @@ func (c *ManagerController) EditBook() { } } if !models.NewItemsets().Exist(itemId) { - c.JsonResult(6006,"项目集不存在") + c.JsonResult(6006,"项目空间不存在") } book.Publisher = publisher book.HistoryCount = historyCount @@ -1097,7 +1097,7 @@ func (c *ManagerController) TeamBookDelete() { c.JsonResult(0, "OK") } -//项目集列表. +//项目空间列表. func (c *ManagerController) Itemsets() { c.Prepare() c.TplName = "manager/itemsets.tpl" @@ -1126,7 +1126,7 @@ func (c *ManagerController) Itemsets() { } -//编辑或添加项目集. +//编辑或添加项目空间. func (c *ManagerController) ItemsetsEdit() { c.Prepare() itemId, _ := c.GetInt("itemId") @@ -1140,9 +1140,9 @@ func (c *ManagerController) ItemsetsEdit() { if itemId > 0 { if item, err = models.NewItemsets().First(itemId); err != nil { if err == orm.ErrNoRows { - c.JsonResult(5002, "项目集不存在") + c.JsonResult(5002, "项目空间不存在") } else { - c.JsonResult(5003, "查询项目集出错") + c.JsonResult(5003, "查询项目空间出错") } } } else { @@ -1161,7 +1161,7 @@ func (c *ManagerController) ItemsetsEdit() { c.JsonResult(0, "OK") } -//删除项目集. +//删除项目空间. func (c *ManagerController) ItemsetsDelete() { c.Prepare() itemId, _ := c.GetInt("itemId") diff --git a/models/BookModel.go b/models/BookModel.go index edbc7936..8018760b 100644 --- a/models/BookModel.go +++ b/models/BookModel.go @@ -31,7 +31,7 @@ type Book struct { BookId int `orm:"pk;auto;unique;column(book_id)" json:"book_id"` // BookName 项目名称. BookName string `orm:"column(book_name);size(500)" json:"book_name"` - //所属项目集 + //所属项目空间 ItemId int `orm:"column(item_id);type(int);default(1)" json:"item_id"` // Identify 项目唯一标识. Identify string `orm:"column(identify);size(100);unique" json:"identify"` diff --git a/models/Itemsets.go b/models/Itemsets.go index c8abd1ac..afddc5fb 100644 --- a/models/Itemsets.go +++ b/models/Itemsets.go @@ -9,7 +9,7 @@ import ( "github.com/lifei6671/mindoc/utils/cryptil" ) -//项目集 +//项目空间 type Itemsets struct { ItemId int `orm:"column(item_id);pk;auto;unique" json:"item_id"` ItemName string `orm:"column(item_name);size(500)" json:"item_name"` @@ -22,6 +22,7 @@ type Itemsets struct { BookNumber int `orm:"-" json:"book_number"` CreateTimeString string `orm:"-" json:"create_time_string"` + CreateName string `orm:"-" json:"create_name"` } // TableName 获取对应数据库表名. @@ -51,21 +52,21 @@ func (item *Itemsets) First(itemId int) (*Itemsets, error) { } err := item.QueryTable().Filter("item_id", itemId).One(item) if err != nil { - beego.Error("查询项目集失败 -> item_id=", itemId, err) + beego.Error("查询项目空间失败 -> item_id=", itemId, err) } else { item.Include() } return item, err } -func (item *Itemsets) FindFirst(itemKey string) (*Itemsets,error) { - err := item.QueryTable().Filter("item_key",itemKey).One(item) +func (item *Itemsets) FindFirst(itemKey string) (*Itemsets, error) { + err := item.QueryTable().Filter("item_key", itemKey).One(item) if err != nil { - beego.Error("查询项目集失败 -> itemKey=", itemKey, err) + beego.Error("查询项目空间失败 -> itemKey=", itemKey, err) } else { item.Include() } - return item,err + return item, err } func (item *Itemsets) Exist(itemId int) bool { @@ -76,14 +77,14 @@ func (item *Itemsets) Exist(itemId int) bool { func (item *Itemsets) Save() (err error) { if item.ItemName == "" { - return errors.New("项目集名称不能为空") + return errors.New("项目空间名称不能为空") } if item.ItemKey == "" { item.ItemKey = cryptil.NewRandChars(16) } if item.QueryTable().Filter("item_id__ne", item.ItemId).Filter("item_key", item.ItemKey).Exist() { - return errors.New("项目集标识已存在") + return errors.New("项目空间标识已存在") } if item.ItemId > 0 { _, err = orm.NewOrm().Update(item) @@ -99,10 +100,10 @@ func (item *Itemsets) Delete(itemId int) (err error) { return ErrInvalidParameter } if itemId == 1 { - return errors.New("默认项目集不能删除") + return errors.New("默认项目空间不能删除") } if !item.Exist(itemId) { - return errors.New("项目集不存在") + return errors.New("项目空间不存在") } o := orm.NewOrm() if err := o.Begin(); err != nil { @@ -111,12 +112,12 @@ func (item *Itemsets) Delete(itemId int) (err error) { } _, err = o.QueryTable(item.TableNameWithPrefix()).Filter("item_id", itemId).Delete() if err != nil { - beego.Error("删除项目集失败 -> item_id=", itemId, err) + beego.Error("删除项目空间失败 -> item_id=", itemId, err) o.Rollback() } _, err = o.Raw("update md_books set item_id=1 where item_id=?;", itemId).Exec() if err != nil { - beego.Error("删除项目集失败 -> item_id=", itemId, err) + beego.Error("删除项目空间失败 -> item_id=", itemId, err) o.Rollback() } @@ -127,6 +128,16 @@ func (item *Itemsets) Include() (*Itemsets, error) { item.CreateTimeString = item.CreateTime.Format("2006-01-02 15:04:05") + if item.MemberId > 0 { + if m,err := NewMember().Find(item.MemberId,"account","real_name");err == nil { + if m.RealName != "" { + item.CreateName = m.RealName + } else { + item.CreateName = m.Account + } + } + } + i, err := NewBook().QueryTable().Filter("item_id", item.ItemId).Count() if err != nil && err != orm.ErrNoRows { return item, err @@ -159,7 +170,7 @@ func (item *Itemsets) FindToPager(pageIndex, pageSize int) (list []*Itemsets, to return } -//根据项目集名称查询. +//根据项目空间名称查询. func (item *Itemsets) FindItemsetsByName(name string, limit int) (*SelectMemberResult, error) { result := SelectMemberResult{} @@ -172,7 +183,7 @@ func (item *Itemsets) FindItemsetsByName(name string, limit int) (*SelectMemberR _, err = item.QueryTable().Filter("item_name__icontains", name).Limit(limit).All(&itemsets) } if err != nil { - beego.Error("查询项目集失败 ->", err) + beego.Error("查询项目空间失败 ->", err) return &result, err } @@ -189,14 +200,14 @@ func (item *Itemsets) FindItemsetsByName(name string, limit int) (*SelectMemberR return &result, err } -//根据项目集标识查询项目集的项目列表. -func (item *Itemsets) FindItemsetsByItemKey(key string, pageIndex, pageSize, memberId int) (books []*BookResult, totalCount int, err error){ +//根据项目空间标识查询项目空间的项目列表. +func (item *Itemsets) FindItemsetsByItemKey(key string, pageIndex, pageSize, memberId int) (books []*BookResult, totalCount int, err error) { o := orm.NewOrm() - err = item.QueryTable().Filter("item_key",key).One(item) + err = item.QueryTable().Filter("item_key", key).One(item) if err != nil { - return nil,0,err + return nil, 0, err } offset := (pageIndex - 1) * pageSize //如果是登录用户 @@ -248,4 +259,4 @@ WHERE book.item_id = ? AND (relationship_id > 0 OR book.privately_owned = 0 or t return } -} \ No newline at end of file +} diff --git a/static/css/main.css b/static/css/main.css index 70a793b6..d67b6729 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -947,7 +947,34 @@ textarea{ margin: 0; padding: 1em 0 } - +/**************项目空间样式******************/ +.ui-card{ + display: inline-block; + width: 22%; + margin: 10px 15px; + border: solid 1px #d4d4d5; + border-radius: 4px; + padding: 15px 25px; + text-align: center; + color: #333333; +} +.ui-card:hover{ + -webkit-box-shadow: 0 1px 3px 0 #d4d4d5,0 0 0 1px #d4d4d5; + box-shadow: 0 1px 3px 0 #d4d4d5,0 0 0 1px #d4d4d5; + -webkit-transition: -webkit-box-shadow .1s ease,-webkit-transform .1s ease; + transition: -webkit-box-shadow .1s ease,-webkit-transform .1s ease; + transition: box-shadow .1s ease,transform .1s ease; + transition: box-shadow .1s ease,transform .1s ease,-webkit-box-shadow .1s ease,-webkit-transform .1s ease; +} +.ui-card>.header{ + font-weight: 500; + font-size: 18px; +} +.ui-card>.description{ + font-size: 12px; + color: #666; + text-align: left; +} /**************网站底部样式*************************/ .footer{ color: #777; diff --git a/views/book/index.tpl b/views/book/index.tpl index 453cfb2f..473d0c1c 100644 --- a/views/book/index.tpl +++ b/views/book/index.tpl @@ -139,7 +139,7 @@
- +
@@ -207,7 +207,7 @@