|
|
@ -9,6 +9,8 @@ import ( |
|
|
|
"LEIT_PM/grmi" |
|
|
|
meta "LEIT_PM/meta/pj" |
|
|
|
model "LEIT_PM/models/pj" |
|
|
|
"LEIT_PM/utils" |
|
|
|
"strings" |
|
|
|
) |
|
|
|
|
|
|
|
/****************************************************************************** |
|
|
@ -268,6 +270,32 @@ func (impl *ProjectDocumentLstServiceImplement) Select(user *global.User, urlPar |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
for index, data := range result{ |
|
|
|
record, err := dao.SelectOne(data.ProjectId, data.Pos) |
|
|
|
if err != nil { |
|
|
|
return nil,err |
|
|
|
} |
|
|
|
if record == nil { |
|
|
|
return nil,grmi.NewBusinessError("找不到文件") |
|
|
|
} |
|
|
|
|
|
|
|
dirname, err := utils.GetCurrentPath("web/public") |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewBusinessError("文件夹找不到, 错误:" + err.Error()) |
|
|
|
} |
|
|
|
|
|
|
|
filepath := dirname + "/" +record.ProjectId + "/"+ record.Document+"."+record.DocumentType |
|
|
|
|
|
|
|
pathLi := strings.Split(filepath, "web\\") |
|
|
|
if len(pathLi) != 2 { |
|
|
|
return nil, grmi.NewBusinessError("文档损坏") |
|
|
|
} |
|
|
|
|
|
|
|
result[index].Url = pathLi[1] |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result, nil |
|
|
|
} |
|
|
|
|
|
|
@ -363,3 +391,30 @@ func (impl *ProjectDocumentLstServiceImplement) Upload(user *global.User, entity |
|
|
|
|
|
|
|
return result, err |
|
|
|
} |
|
|
|
|
|
|
|
func (impl *ProjectDocumentLstServiceImplement)Download(user *global.User,projectId string,pos int) (result string, err error){ |
|
|
|
engine := db.Eloquent.Master() |
|
|
|
session := engine.NewSession() |
|
|
|
defer session.Close() |
|
|
|
dao := dal.NewProjectDocumentLstDAO(session, user.UserId) |
|
|
|
record, err := dao.SelectOne(projectId, pos) |
|
|
|
if err != nil { |
|
|
|
return "",err |
|
|
|
} |
|
|
|
if record == nil { |
|
|
|
return "",grmi.NewBusinessError("找不到文件") |
|
|
|
} |
|
|
|
|
|
|
|
dirname, err := utils.GetCurrentPath("web/public/uploadxlsx") |
|
|
|
if err != nil { |
|
|
|
return "", grmi.NewBusinessError("文件夹找不到, 错误:" + err.Error()) |
|
|
|
} |
|
|
|
|
|
|
|
filepath := dirname + "/" + record.Document+"."+record.DocumentType |
|
|
|
|
|
|
|
pathLi := strings.Split(filepath, "web\\") |
|
|
|
if len(pathLi) != 2 { |
|
|
|
return "", grmi.NewBusinessError("文档损坏") |
|
|
|
} |
|
|
|
return pathLi[1], nil |
|
|
|
} |