|
@@ -3,6 +3,7 @@ package controllers
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"eta_gn/eta_api/models"
|
|
|
+ "eta_gn/eta_api/models/system"
|
|
|
"eta_gn/eta_api/services"
|
|
|
"eta_gn/eta_api/utils"
|
|
|
"fmt"
|
|
@@ -37,7 +38,6 @@ func (this *PptV2Controller) ReportClassify() {
|
|
|
if source < 1 || source > 3 {
|
|
|
source = 1
|
|
|
}
|
|
|
- fmt.Println(sysUser.AdminId)
|
|
|
|
|
|
// 获取PPT, source:1-我的;2-协作;3-公共
|
|
|
pptList := make([]*models.PptV2, 0)
|
|
@@ -66,10 +66,36 @@ func (this *PptV2Controller) ReportClassify() {
|
|
|
}
|
|
|
classifyPpt := make(map[int][]*models.PptReportItem)
|
|
|
for _, v := range pptList {
|
|
|
+ // 当前编辑人
|
|
|
+ t := v.Format2ReportItem(v)
|
|
|
+ editor, e := services.UpdatePptEditing(v.PptId, 0, sysUser.AdminId, sysUser.RealName, false)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取PPT编辑状态失败, err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ t.Editor = editor
|
|
|
+
|
|
|
+ // 权限
|
|
|
+ if source == 1 || source == 2 {
|
|
|
+ t.HasAuth = true
|
|
|
+ } else {
|
|
|
+ if v.AdminId == sysUser.AdminId {
|
|
|
+ t.HasAuth = true
|
|
|
+ }
|
|
|
+ if t.HasAuth == false && v.CollaborateUsers != "" {
|
|
|
+ authorArr := strings.Split(v.CollaborateUsers, ",")
|
|
|
+ strId := strconv.Itoa(sysUser.AdminId)
|
|
|
+ if utils.InArrayByStr(authorArr, strId) {
|
|
|
+ t.HasAuth = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if classifyPpt[v.ClassifyId] == nil {
|
|
|
classifyPpt[v.ClassifyId] = make([]*models.PptReportItem, 0)
|
|
|
}
|
|
|
- classifyPpt[v.ClassifyId] = append(classifyPpt[v.ClassifyId], v.Format2ReportItem(v))
|
|
|
+ classifyPpt[v.ClassifyId] = append(classifyPpt[v.ClassifyId], t)
|
|
|
}
|
|
|
|
|
|
resp := make([]*models.PptReportClassifyItem, 0)
|
|
@@ -183,7 +209,33 @@ func (this *PptV2Controller) ReportList() {
|
|
|
resp := new(models.PptPageReportResp)
|
|
|
resp.List = make([]*models.PptReportItem, 0)
|
|
|
for _, v := range pptList {
|
|
|
- resp.List = append(resp.List, v.Format2ReportItem(v))
|
|
|
+ // 当前编辑人
|
|
|
+ t := v.Format2ReportItem(v)
|
|
|
+ editor, e := services.UpdatePptEditing(v.PptId, 0, sysUser.AdminId, sysUser.RealName, false)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取PPT编辑状态失败, err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ t.Editor = editor
|
|
|
+
|
|
|
+ // 权限
|
|
|
+ if source == 1 || source == 2 {
|
|
|
+ t.HasAuth = true
|
|
|
+ } else {
|
|
|
+ if v.AdminId == sysUser.AdminId {
|
|
|
+ t.HasAuth = true
|
|
|
+ }
|
|
|
+ if t.HasAuth == false && v.CollaborateUsers != "" {
|
|
|
+ authorArr := strings.Split(v.CollaborateUsers, ",")
|
|
|
+ strId := strconv.Itoa(sysUser.AdminId)
|
|
|
+ if utils.InArrayByStr(authorArr, strId) {
|
|
|
+ t.HasAuth = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ resp.List = append(resp.List, t)
|
|
|
}
|
|
|
|
|
|
page := paging.GetPaging(currentIndex, pageSize, total)
|
|
@@ -339,3 +391,168 @@ func (this *PptV2Controller) SubmitReport() {
|
|
|
br.Success = true
|
|
|
br.Msg = "操作成功"
|
|
|
}
|
|
|
+
|
|
|
+// AuthList
|
|
|
+// @Title 获取有权限的列表
|
|
|
+// @Description 获取有权限的列表
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param Keyword query string false "搜索关键词"
|
|
|
+// @Param ClassifyId query int false "分类ID"
|
|
|
+// @Success 200 {object} models.PptPageReportResp
|
|
|
+// @router /report/auth_list [get]
|
|
|
+func (this *PptV2Controller) AuthList() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ keyword := this.GetString("Keyword")
|
|
|
+ classifyId, _ := this.GetInt("ClassifyId", 0)
|
|
|
+
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
+
|
|
|
+ var pptList []*models.PptReportItem
|
|
|
+ // 无相关搜索,返回空集
|
|
|
+ //if keyword == `` && classifyId <= 0 {
|
|
|
+ // page := paging.GetPaging(currentIndex, pageSize, 0)
|
|
|
+ // resp := new(models.PptPageReportResp)
|
|
|
+ // resp.Paging = page
|
|
|
+ // resp.List = pptList
|
|
|
+ // br.Ret = 200
|
|
|
+ // br.Success = true
|
|
|
+ // br.Msg = "获取成功"
|
|
|
+ // br.Data = resp
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+
|
|
|
+ // 查询自己创建的以及协作人包含自己的报告
|
|
|
+ var cond string
|
|
|
+ var pars []interface{}
|
|
|
+ cond += ` AND (admin_id = ? OR (admin_id <> ? AND FIND_IN_SET(?, collaborate_users)))`
|
|
|
+ pars = append(pars, sysUser.AdminId, sysUser.AdminId, sysUser.AdminId)
|
|
|
+ if classifyId > 0 {
|
|
|
+ cond += ` AND classify_id = ? `
|
|
|
+ pars = append(pars, classifyId)
|
|
|
+ }
|
|
|
+ keyword = strings.TrimSpace(keyword)
|
|
|
+ if keyword != `` {
|
|
|
+ cond += ` AND title LIKE ? `
|
|
|
+ pars = utils.GetLikeKeywordPars(pars, keyword, 1)
|
|
|
+ }
|
|
|
+ pptOb := new(models.PptV2)
|
|
|
+ total, e := pptOb.GetCountByCondition(cond, pars)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取PPT总数失败, %v", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ list, e := pptOb.GetPageItemsByCondition(cond, pars, models.PptReportQueryFields, "", startSize, pageSize)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取PPT失败, %v", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 分类完整路径、协作人姓名
|
|
|
+ classifyIdFull := make(map[int]string)
|
|
|
+ {
|
|
|
+ ob := new(models.Classify)
|
|
|
+ classifies, e := ob.GetItemsByCondition("", make([]interface{}, 0), []string{}, "")
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取分类失败, %v", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ classifyIdName := make(map[string]string)
|
|
|
+ for _, v := range classifies {
|
|
|
+ classifyIdName[strconv.Itoa(v.Id)] = v.ClassifyName
|
|
|
+ }
|
|
|
+ for _, v := range classifies {
|
|
|
+ arr := strings.Split(v.LevelPath, ",")
|
|
|
+ if len(arr) == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ var nameArr []string
|
|
|
+ for _, a := range arr {
|
|
|
+ n := classifyIdName[a]
|
|
|
+ if n == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ nameArr = append(nameArr, n)
|
|
|
+ }
|
|
|
+ classifyIdFull[v.Id] = strings.Join(nameArr, "/")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ adminIdName := make(map[int]string)
|
|
|
+ {
|
|
|
+ cond := ` AND enabled = 1`
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+ sysAdmin, e := system.GetSysAdminList(cond, pars, []string{}, "")
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取用户失败,Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range sysAdmin {
|
|
|
+ adminIdName[v.AdminId] = v.RealName
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 格式化数据
|
|
|
+ for _, v := range list {
|
|
|
+ t := v.Format2ReportItem(v)
|
|
|
+ t.HasAuth = true // 该列表固定有权限
|
|
|
+ t.FullClassify = classifyIdFull[v.ClassifyId] // 分类的完整路径
|
|
|
+
|
|
|
+ // 协作人
|
|
|
+ if v.CollaborateUsers != "" {
|
|
|
+ var authors []models.PptReportCollaborateUser
|
|
|
+ authorArr := strings.Split(v.CollaborateUsers, ",")
|
|
|
+ for _, au := range authorArr {
|
|
|
+ uid, _ := strconv.Atoi(au)
|
|
|
+ if uid <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ name := adminIdName[uid]
|
|
|
+ if name == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ authors = append(authors, models.PptReportCollaborateUser{
|
|
|
+ AdminId: uid,
|
|
|
+ RealName: name,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ t.CollaborateUsers = authors
|
|
|
+ }
|
|
|
+ pptList = append(pptList, t)
|
|
|
+ }
|
|
|
+
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp := new(models.PptPageReportResp)
|
|
|
+ resp.Paging = page
|
|
|
+ resp.List = pptList
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|