@@ -739,16 +739,19 @@ func (this *BookController) Release() {
739
739
//加锁,防止用户不停地点击生成下载文档造成服务器资源开销.
740
740
func (this * BookController ) Generate () {
741
741
identify := this .GetString (":key" )
742
- book , err := models .NewBook ().FindByIdentify (identify )
743
742
744
- //书籍正在生成离线文档
745
- if isGenerating := utils .BooksGenerate .Exist (book .BookId ); isGenerating {
746
- this .JsonResult (1 , "上一次下载文档生成任务正在后台执行,请您稍后再执行新的下载文档生成操作" )
743
+ if ! models .NewBook ().HasProjectAccess (identify , this .Member .MemberId , conf .BookAdmin ) {
744
+ this .JsonResult (1 , "您没有操作权限,只有项目创始人和项目管理员才有权限" )
747
745
}
748
746
749
- if err != nil || book .MemberId != this .Member .MemberId {
747
+ book , err := models .NewBook ().FindByIdentify (identify )
748
+ if err != nil {
750
749
beego .Error (err )
751
- this .JsonResult (1 , "项目不存在;或您不是文档创始人,没有文档生成权限" )
750
+ this .JsonResult (1 , "项目不存在" )
751
+ }
752
+ //书籍正在生成离线文档
753
+ if isGenerating := utils .BooksGenerate .Exist (book .BookId ); isGenerating {
754
+ this .JsonResult (1 , "上一次下载文档生成任务正在后台执行,请您稍后再执行新的下载文档生成操作" )
752
755
}
753
756
754
757
baseUrl := "http://localhost:" + beego .AppConfig .String ("httpport" )
@@ -811,6 +814,7 @@ func (this *BookController) SaveSort() {
811
814
this .JsonResult (0 , "ok" )
812
815
}
813
816
817
+ // 判断是否具有管理员或管理员以上权限
814
818
func (this * BookController ) IsPermission () (* models.BookResult , error ) {
815
819
816
820
identify := this .GetString ("identify" )
@@ -876,16 +880,12 @@ func (this *BookController) GitPull() {
876
880
//2、解压zip到当前目录,然后移除非图片文件
877
881
//3、将文件夹移动到uploads目录下
878
882
879
- if _ , err := this .IsPermission (); err != nil {
880
- this .JsonResult (1 , err .Error ())
881
- }
883
+ identify := this .GetString ("identify" )
882
884
883
- //普通用户没有权限
884
- if this .Member .Role > 1 {
885
- this .JsonResult (1 , "您没有操作权限" )
885
+ if ! models .NewBook ().HasProjectAccess (identify , this .Member .MemberId , conf .BookEditor ) {
886
+ this .JsonResult (1 , "无操作权限" )
886
887
}
887
888
888
- identify := this .GetString ("identify" )
889
889
book , _ := models .NewBookResult ().FindByIdentify (identify , this .Member .MemberId )
890
890
if book .BookId == 0 {
891
891
this .JsonResult (1 , "导入失败,只有项目创建人才有权限导入项目" )
@@ -910,21 +910,18 @@ func (this *BookController) UploadProject() {
910
910
//1、接受上传上来的zip文件,并存放到store/temp目录下
911
911
//2、解压zip到当前目录,然后移除非图片文件
912
912
//3、将文件夹移动到uploads目录下
913
- if _ , err := this .IsPermission (); err != nil {
914
- this .JsonResult (1 , err .Error ())
915
- }
916
-
917
- //普通用户没法上传项目
918
- if this .Member .Role > 1 {
919
- this .JsonResult (1 , "您没有操作权限" )
920
- }
921
913
922
914
identify := this .GetString ("identify" )
923
915
916
+ if ! models .NewBook ().HasProjectAccess (identify , this .Member .MemberId , conf .BookEditor ) {
917
+ this .JsonResult (1 , "无操作权限" )
918
+ }
919
+
924
920
book , _ := models .NewBookResult ().FindByIdentify (identify , this .Member .MemberId )
925
921
if book .BookId == 0 {
926
- this .JsonResult (1 , "导入失败,只有项目创建人才有权限导入项目 " )
922
+ this .JsonResult (1 , "项目不存在 " )
927
923
}
924
+
928
925
f , h , err := this .GetFile ("zipfile" )
929
926
if err != nil {
930
927
this .JsonResult (1 , err .Error ())
0 commit comments