-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathorg-signature.go
60 lines (49 loc) · 1.51 KB
/
org-signature.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package controllers
import (
"fmt"
"github.com/opensourceways/app-cla-server/pdf"
"github.com/opensourceways/app-cla-server/util"
)
type OrgSignatureController struct {
baseController
}
func (this *OrgSignatureController) Prepare() {
this.apiPrepare(PermissionOwnerOfOrg)
}
// @Title Get
// @Description download org signature
// @Param org_cla_id path string true "org cla id"
// @router /:link_id/:language [get]
func (this *OrgSignatureController) Get() {
action := "download org signature"
linkID := this.GetString(":link_id")
claLang := this.GetString(":language")
pl, fr := this.tokenPayloadBasedOnCodePlatform()
if fr != nil {
this.sendFailedResultAsResp(fr, action)
return
}
if fr := pl.isOwnerOfLink(linkID); fr != nil {
this.sendFailedResultAsResp(fr, action)
return
}
path := genOrgSignatureFilePath(linkID, claLang)
if util.IsFileNotExist(path) {
this.sendFailedResponse(400, errFileNotExists, fmt.Errorf(errFileNotExists), action)
return
}
this.downloadFile(path)
}
// @Title BlankSignature
// @Description get blank pdf of org signature
// @Param language path string true "The language which the signature applies to"
// @router /blank/:language [get]
func (this *OrgSignatureController) BlankSignature() {
lang := this.GetString(":language")
path := pdf.GetPDFGenerator().GetBlankSignaturePath(lang)
if util.IsFileNotExist(path) {
this.sendFailedResponse(400, errFileNotExists, fmt.Errorf(errFileNotExists), "download blank signature")
return
}
this.downloadFile(path)
}