mirror of
https://github.com/mindoc-org/mindoc.git
synced 2026-02-27 17:03:57 +08:00
feat:实现团队功能
This commit is contained in:
@@ -171,7 +171,6 @@ func (c *BookController) SaveBook() {
|
||||
book.HistoryCount = historyCount
|
||||
book.IsDownload = 0
|
||||
|
||||
|
||||
if autoRelease {
|
||||
book.AutoRelease = 1
|
||||
} else {
|
||||
@@ -194,7 +193,7 @@ func (c *BookController) SaveBook() {
|
||||
}
|
||||
if autoSave {
|
||||
book.AutoSave = 1
|
||||
}else{
|
||||
} else {
|
||||
book.AutoSave = 0
|
||||
}
|
||||
if err := book.Update(); err != nil {
|
||||
@@ -329,7 +328,7 @@ func (c *BookController) UploadCover() {
|
||||
fileName := "cover_" + strconv.FormatInt(time.Now().UnixNano(), 16)
|
||||
|
||||
//附件路径按照项目组织
|
||||
filePath := filepath.Join("uploads", book.Identify,"images", fileName+ext)
|
||||
filePath := filepath.Join("uploads", book.Identify, "images", fileName+ext)
|
||||
|
||||
path := filepath.Dir(filePath)
|
||||
|
||||
@@ -394,7 +393,7 @@ func (c *BookController) Users() {
|
||||
pageIndex, _ := c.GetInt("page", 1)
|
||||
|
||||
if key == "" {
|
||||
c.Abort("404")
|
||||
c.ShowErrorPage(404, "项目不存在或已删除")
|
||||
}
|
||||
|
||||
book, err := models.NewBookResult().FindByIdentify(key, c.Member.MemberId)
|
||||
@@ -407,7 +406,7 @@ func (c *BookController) Users() {
|
||||
|
||||
c.Data["Model"] = *book
|
||||
|
||||
members, totalCount, err := models.NewMemberRelationshipResult().FindForUsersByBookId(book.BookId, pageIndex, 15)
|
||||
members, totalCount, err := models.NewMemberRelationshipResult().FindForUsersByBookId(book.BookId, pageIndex, conf.PageSize)
|
||||
|
||||
if totalCount > 0 {
|
||||
pager := pagination.NewPagination(c.Ctx.Request, totalCount, conf.PageSize, c.BaseUrl())
|
||||
@@ -819,6 +818,61 @@ func (c *BookController) SaveSort() {
|
||||
c.JsonResult(0, "ok")
|
||||
}
|
||||
|
||||
func (c *BookController) Team() {
|
||||
c.Prepare()
|
||||
c.TplName = "book/team.tpl"
|
||||
|
||||
key := c.Ctx.Input.Param(":key")
|
||||
pageIndex, _ := c.GetInt("page", 1)
|
||||
|
||||
if key == "" {
|
||||
c.ShowErrorPage(404, "项目不存在或已删除")
|
||||
}
|
||||
|
||||
book, err := models.NewBookResult().FindByIdentify(key, c.Member.MemberId)
|
||||
if err != nil {
|
||||
if err == models.ErrPermissionDenied {
|
||||
c.ShowErrorPage(403, "权限不足")
|
||||
}
|
||||
c.ShowErrorPage(500, "系统错误")
|
||||
}
|
||||
|
||||
c.Data["Model"] = book
|
||||
|
||||
members, totalCount, err := models.NewTeamRelationship().FindByBookToPager(book.BookId, pageIndex, conf.PageSize)
|
||||
|
||||
if totalCount > 0 {
|
||||
pager := pagination.NewPagination(c.Ctx.Request, totalCount, conf.PageSize, c.BaseUrl())
|
||||
c.Data["PageHtml"] = pager.HtmlPages()
|
||||
} else {
|
||||
c.Data["PageHtml"] = ""
|
||||
}
|
||||
b, err := json.Marshal(members)
|
||||
|
||||
if err != nil {
|
||||
c.Data["Result"] = template.JS("[]")
|
||||
} else {
|
||||
c.Data["Result"] = template.JS(string(b))
|
||||
}
|
||||
}
|
||||
|
||||
func (c *BookController) TeamAdd() {
|
||||
c.Prepare()
|
||||
|
||||
c.JsonResult(0, "OK")
|
||||
}
|
||||
|
||||
func (c *BookController) TeamDelete() {
|
||||
c.Prepare()
|
||||
|
||||
c.JsonResult(0, "OK")
|
||||
}
|
||||
|
||||
func (c *BookController) TeamSearch() {
|
||||
c.Prepare()
|
||||
|
||||
}
|
||||
|
||||
func (c *BookController) IsPermission() (*models.BookResult, error) {
|
||||
identify := c.GetString("identify")
|
||||
|
||||
|
||||
@@ -982,15 +982,109 @@ func (c *ManagerController) TeamChangeMemberRole() {
|
||||
|
||||
}
|
||||
|
||||
//团队项目列表.
|
||||
func (c *ManagerController) TeamBookList() {
|
||||
c.Prepare()
|
||||
c.TplName = "manager/team_book_list.tpl"
|
||||
|
||||
}
|
||||
func (c *ManagerController) TeamBookAdd() {
|
||||
c.Prepare()
|
||||
teamId, _ := strconv.Atoi(c.Ctx.Input.Param(":id"))
|
||||
pageIndex, _ := c.GetInt("page", 0)
|
||||
|
||||
if teamId <= 0 {
|
||||
c.JsonResult(5002, "团队标识不能为空")
|
||||
}
|
||||
|
||||
team, err := models.NewTeam().First(teamId)
|
||||
|
||||
if err == orm.ErrNoRows {
|
||||
c.ShowErrorPage(404, "团队不存在")
|
||||
}
|
||||
c.CheckErrorResult(500, err)
|
||||
c.Data["Model"] = team
|
||||
|
||||
teams, totalCount, err := models.NewTeamRelationship().FindToPager(teamId, pageIndex, conf.PageSize)
|
||||
|
||||
if err != nil && err != orm.ErrNoRows {
|
||||
c.ShowErrorPage(500, err.Error())
|
||||
}
|
||||
if err == orm.ErrNoRows || len(teams) <= 0 {
|
||||
c.Data["Result"] = template.JS("[]")
|
||||
c.Data["PageHtml"] = ""
|
||||
return
|
||||
}
|
||||
|
||||
if totalCount > 0 {
|
||||
pager := pagination.NewPagination(c.Ctx.Request, totalCount, conf.PageSize, c.BaseUrl())
|
||||
c.Data["PageHtml"] = pager.HtmlPages()
|
||||
} else {
|
||||
c.Data["PageHtml"] = ""
|
||||
}
|
||||
|
||||
b, err := json.Marshal(teams)
|
||||
|
||||
if err != nil {
|
||||
beego.Error("编码 JSON 结果失败 ->", err)
|
||||
c.Data["Result"] = template.JS("[]")
|
||||
} else {
|
||||
c.Data["Result"] = template.JS(string(b))
|
||||
}
|
||||
}
|
||||
|
||||
//给团队增加项目.
|
||||
func (c *ManagerController) TeamBookAdd() {
|
||||
c.Prepare()
|
||||
|
||||
teamId, _ := c.GetInt("teamId")
|
||||
bookId, _ := c.GetInt("bookId")
|
||||
|
||||
if teamId <= 0 || bookId <= 0 {
|
||||
c.JsonResult(500, "参数错误")
|
||||
}
|
||||
teamRel := models.NewTeamRelationship()
|
||||
teamRel.BookId = bookId
|
||||
teamRel.TeamId = teamId
|
||||
|
||||
err := teamRel.Save()
|
||||
|
||||
if err != nil {
|
||||
c.JsonResult(5001, err.Error())
|
||||
} else {
|
||||
teamRel.Include()
|
||||
c.JsonResult(0, "OK", teamRel)
|
||||
}
|
||||
}
|
||||
|
||||
//搜索未参与的项目.
|
||||
func (c *ManagerController) TeamSearchBook() {
|
||||
c.Prepare()
|
||||
|
||||
teamId, _ := c.GetInt("teamId")
|
||||
keyword := strings.TrimSpace(c.GetString("q"))
|
||||
|
||||
if teamId <= 0 {
|
||||
c.JsonResult(500, "参数错误")
|
||||
}
|
||||
|
||||
searchResult, err := models.NewTeamRelationship().FindNotJoinBookByName(teamId, keyword, 10)
|
||||
|
||||
if err != nil {
|
||||
c.JsonResult(500, err.Error())
|
||||
}
|
||||
c.JsonResult(0, "OK", searchResult)
|
||||
|
||||
}
|
||||
func (c *ManagerController) TeamBookDelete() {
|
||||
c.Prepare()
|
||||
teamRelationshipId, _ := c.GetInt("teamRelId")
|
||||
|
||||
if teamRelationshipId <= 0 {
|
||||
c.JsonResult(500, "参数错误")
|
||||
}
|
||||
|
||||
err := models.NewTeamRelationship().Delete(teamRelationshipId)
|
||||
|
||||
if err != nil {
|
||||
c.JsonResult(5001, "删除失败")
|
||||
}
|
||||
c.JsonResult(0, "OK")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user