|
@@ -17,17 +17,9 @@ type DocumentManageController struct {
|
|
|
controllers.BaseAuthController
|
|
|
}
|
|
|
|
|
|
-// HandleResponseWithValidation
|
|
|
+// ValidateUser
|
|
|
// 处理响应和校验
|
|
|
-func HandleResponseWithValidation(this *DocumentManageController, br *models.BaseResponse) bool {
|
|
|
- defer func() {
|
|
|
- if br.ErrMsg == "" {
|
|
|
- br.IsSendEmail = false
|
|
|
- }
|
|
|
- this.Data["json"] = br
|
|
|
- this.ServeJSON()
|
|
|
- }()
|
|
|
-
|
|
|
+func ValidateUser(this *DocumentManageController, br *models.BaseResponse) bool {
|
|
|
// 验证用户是否已登录
|
|
|
sysUser := this.SysUser
|
|
|
if sysUser == nil {
|
|
@@ -48,7 +40,6 @@ func HandleResponseWithValidation(this *DocumentManageController, br *models.Bas
|
|
|
func (this *DocumentManageController) DocumentClassifyList() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
|
|
|
- // 下面段代码能否统一处理???
|
|
|
defer func() {
|
|
|
if br.ErrMsg == "" {
|
|
|
br.IsSendEmail = false
|
|
@@ -57,11 +48,7 @@ func (this *DocumentManageController) DocumentClassifyList() {
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
|
|
|
- sysUser := this.SysUser
|
|
|
- if sysUser == nil {
|
|
|
- br.Msg = "请登录"
|
|
|
- br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
- br.Ret = 408
|
|
|
+ if !ValidateUser(this, br) {
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -87,7 +74,15 @@ func (this *DocumentManageController) DocumentClassifyList() {
|
|
|
func (this *DocumentManageController) DocumentVarietyList() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
|
|
|
- if !HandleResponseWithValidation(this, br) {
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ if !ValidateUser(this, br) {
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -112,10 +107,18 @@ func (this *DocumentManageController) DocumentVarietyList() {
|
|
|
// @router /document/report/list [get]
|
|
|
func (this *DocumentManageController) DocumentReportList() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
|
|
|
- if !HandleResponseWithValidation(this, br) {
|
|
|
+ if !ValidateUser(this, br) {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
// 文档类型 1-文档管理库 2-战研中心-pci
|
|
|
documentType, err := this.GetInt("DocumentType")
|
|
|
if err != nil {
|
|
@@ -130,10 +133,16 @@ func (this *DocumentManageController) DocumentReportList() {
|
|
|
}
|
|
|
|
|
|
chartPermissionIdString := this.GetString("ChartPermissionIdList")
|
|
|
- chartPermissionIdList := strings.Split(chartPermissionIdString, ",")
|
|
|
+ var chartPermissionIdList []string
|
|
|
+ if strings.TrimSpace(chartPermissionIdString) != "" {
|
|
|
+ chartPermissionIdList = strings.Split(chartPermissionIdString, ",")
|
|
|
+ }
|
|
|
|
|
|
classifyIdString := this.GetString("ClassifyIdList")
|
|
|
- classifyIdList := strings.Split(classifyIdString, ",")
|
|
|
+ var classifyIdList []string
|
|
|
+ if strings.TrimSpace(classifyIdString) != "" {
|
|
|
+ classifyIdList = strings.Split(classifyIdString, ",")
|
|
|
+ }
|
|
|
|
|
|
keyword := this.GetString("Keyword")
|
|
|
orderField := this.GetString("OrderField")
|
|
@@ -169,7 +178,15 @@ func (this *DocumentManageController) DocumentReportList() {
|
|
|
func (this *DocumentManageController) RuiSiReportList() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
|
|
|
- if !HandleResponseWithValidation(this, br) {
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ if !ValidateUser(this, br) {
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -211,9 +228,18 @@ func (this *DocumentManageController) RuiSiReportList() {
|
|
|
func (this *DocumentManageController) DocumentRuiSiDetail() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
|
|
|
- if !HandleResponseWithValidation(this, br) {
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ if !ValidateUser(this, br) {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
// 获取指标数据列表
|
|
|
this.GetString("DocumentRuiSiDetail")
|
|
|
|
|
@@ -244,7 +270,15 @@ func (this *DocumentManageController) DocumentRuiSiDetail() {
|
|
|
func (this *DocumentManageController) DocumentSave() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
|
|
|
- if !HandleResponseWithValidation(this, br) {
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ if !ValidateUser(this, br) {
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -278,7 +312,15 @@ func (this *DocumentManageController) DocumentSave() {
|
|
|
func (this *DocumentManageController) DocumentDetail() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
|
|
|
- if !HandleResponseWithValidation(this, br) {
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ if !ValidateUser(this, br) {
|
|
|
return
|
|
|
}
|
|
|
// 获取指标数据列表
|
|
@@ -310,7 +352,15 @@ func (this *DocumentManageController) DocumentDetail() {
|
|
|
func (this *DocumentManageController) DocumentUpdate() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
|
|
|
- if !HandleResponseWithValidation(this, br) {
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ if !ValidateUser(this, br) {
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -340,7 +390,15 @@ func (this *DocumentManageController) DocumentUpdate() {
|
|
|
func (this *DocumentManageController) DocumentDelete() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
|
|
|
- if !HandleResponseWithValidation(this, br) {
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ if !ValidateUser(this, br) {
|
|
|
return
|
|
|
}
|
|
|
|