|
@@ -20,6 +20,7 @@ type ReportOpenController struct {
|
|
|
// @Title 报告分类
|
|
|
// @Description 报告分类接口
|
|
|
// @Param ClassifyType query int false "分类类型:0-全部(不传默认为0);1-研报;2-PPT"
|
|
|
+// @Param OutId query string false "用户工号Id"
|
|
|
// @Success 200 {object} models.ClassifyTreeItem
|
|
|
// @router /report/classify [get]
|
|
|
func (this *ReportOpenController) ClassifyTree() {
|
|
@@ -32,6 +33,7 @@ func (this *ReportOpenController) ClassifyTree() {
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
classifyType, _ := this.GetInt("ClassifyType", 0)
|
|
|
+ outId := this.GetString("OutId")
|
|
|
if classifyType < 0 || classifyType > 2 {
|
|
|
classifyType = 0
|
|
|
}
|
|
@@ -44,13 +46,49 @@ func (this *ReportOpenController) ClassifyTree() {
|
|
|
cond += ` AND classify_type = ?`
|
|
|
pars = append(pars, classifyType)
|
|
|
}
|
|
|
- list, e := classifyOb.GetItemsByCondition(cond, pars, []string{}, "parent_id ASC, sort ASC, create_time ASC")
|
|
|
+ classifyList, e := classifyOb.GetItemsByCondition(cond, pars, []string{}, "parent_id ASC, sort ASC, create_time ASC")
|
|
|
if e != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = fmt.Sprintf("获取分类列表失败,%v", e)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ if outId == "" {
|
|
|
+ br.Msg = "工号不能为空"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ list := make([]*models.Classify, 0)
|
|
|
+ classifyObj := new(models.ClassifyVisible)
|
|
|
+ visibleUsers, err := classifyObj.GetClassifyVisibleAll()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取可见用户失败,%v", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ adminObj := new(models.Admin)
|
|
|
+ admin, e := adminObj.GetAdminByOutId(outId)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取管理员信息失败,%v", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ visibleUsersMap := make(map[int][]int)
|
|
|
+ for _, v := range visibleUsers {
|
|
|
+ visibleUsersMap[v.ClassifyId] = append(visibleUsersMap[v.ClassifyId], v.AdminId)
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range classifyList {
|
|
|
+ if visibleUser, ok := visibleUsersMap[v.Id]; ok {
|
|
|
+ if !utils.InArrayByInt(visibleUser, admin.AdminId) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list = append(list, v)
|
|
|
+ }
|
|
|
+
|
|
|
resp := services.GetReportClassifyTreeRecursive(list, 0)
|
|
|
+ resp = services.RecursiveFilterNoChildTreeClassify(resp)
|
|
|
|
|
|
br.Data = resp
|
|
|
br.Ret = 200
|