|
@@ -9,7 +9,10 @@ import (
|
|
|
"eta/eta_api/services/data"
|
|
|
"eta/eta_api/services/data/data_manage_permission"
|
|
|
"eta/eta_api/utils"
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"sort"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
)
|
|
|
|
|
|
// EdbClassifyController 数据管理-分类模块
|
|
@@ -288,7 +291,7 @@ func (this *EdbClassifyController) EditEdbClassify() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- err, errMsg := data.EditEdbClassify(req.ClassifyId, req.ClassifyName, this.Lang, this.SysUser)
|
|
|
+ err, errMsg := data.EditEdbClassify(req.ClassifyId, req.ParentId, req.ClassifyName, this.Lang, this.SysUser)
|
|
|
if errMsg != `` {
|
|
|
br.Msg = errMsg
|
|
|
br.ErrMsg = errMsg
|
|
@@ -1109,7 +1112,7 @@ func (this *EdbClassifyController) ClassifyTree() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
-
|
|
|
+ level, _ := this.GetInt(`Level`)
|
|
|
allList, err := data_manage.GetNormalEdbClassifyAll()
|
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
br.Msg = "获取失败"
|
|
@@ -1135,7 +1138,7 @@ func (this *EdbClassifyController) ClassifyTree() {
|
|
|
button := data.GetEdbClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
|
|
|
allList[k].Button = button
|
|
|
}
|
|
|
- nodeAll = data.GetClassifyTreeRecursive(allList, 0)
|
|
|
+ nodeAll = data.GetClassifyTreeRecursive(allList, 0, level)
|
|
|
//根据sort值排序
|
|
|
sortList = nodeAll
|
|
|
sort.Sort(sortList)
|
|
@@ -1221,3 +1224,158 @@ func (this *EdbClassifyController) ClassifyTree() {
|
|
|
// br.Success = true
|
|
|
// br.Msg = "移动成功"
|
|
|
//}
|
|
|
+
|
|
|
+// EdbInfoList
|
|
|
+// @Title 批量编辑指标列表接口
|
|
|
+// @Description 批量编辑指标列表接口
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param EdbInfoId query int true "指标id"
|
|
|
+// @Param KeyWord query string false "搜索关键词:指标ID/指标名称"
|
|
|
+// @Success 200 {object} data_manage.EdbInfoListResp
|
|
|
+// @router /classify/edb/list [get]
|
|
|
+func (this *EdbInfoController) ClassifyEdbInfoList() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = paging.StartIndex(currentIndex, pageSize)
|
|
|
+
|
|
|
+ subClassify, _ := this.GetBool("SubClassify")
|
|
|
+ sources := this.GetString("Sources")
|
|
|
+ keyWord := this.GetString("KeyWord")
|
|
|
+ sysUserIds := this.GetString("SysUserIds")
|
|
|
+ classifyIdsStr := this.GetString("ClassifyIds")
|
|
|
+ classifyIds := strings.Split(classifyIdsStr, ",")
|
|
|
+
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+
|
|
|
+ // 已授权分类id
|
|
|
+ //permissionClassifyIdList, err := data_manage_permission.GetUserEdbClassifyPermissionList(this.SysUser.AdminId, 0)
|
|
|
+ //if err != nil {
|
|
|
+ // br.Msg = "获取失败"
|
|
|
+ // br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ classifyIdsArr := make([]int, 0)
|
|
|
+ for _, v := range classifyIds {
|
|
|
+ if v != `` {
|
|
|
+ id, _ := strconv.Atoi(v)
|
|
|
+ classifyIdsArr = append(classifyIdsArr, id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //if len(permissionClassifyIdList) > 0 {
|
|
|
+ // classifyIdsArr = utils.IntersectInt(permissionClassifyIdList, classifyIdsArr)
|
|
|
+ //}
|
|
|
+
|
|
|
+ condition += " AND edb_info_type = 0 "
|
|
|
+ if len(classifyIdsArr) > 0 {
|
|
|
+ if !subClassify {
|
|
|
+ condition += " AND classify_id IN(" + utils.GetOrmInReplace(len(classifyIdsArr)) + ") "
|
|
|
+ pars = append(pars, classifyIdsArr)
|
|
|
+ } else {
|
|
|
+ classifyAll, err := data_manage.GetNormalEdbClassifyAll()
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ finalClassifyIds := make([]int, 0)
|
|
|
+ parents := data.GetEdbClassifyChildrenRecursiveByParentIds(classifyAll, classifyIds)
|
|
|
+ sort.Slice(parents, func(i, j int) bool {
|
|
|
+ return parents[i].Level < parents[i].Level
|
|
|
+ })
|
|
|
+ for _, v := range parents {
|
|
|
+ finalClassifyIds = append(finalClassifyIds, v.ClassifyId)
|
|
|
+ }
|
|
|
+
|
|
|
+ condition += " AND classify_id IN(" + utils.GetOrmInReplace(len(finalClassifyIds)) + ") "
|
|
|
+ pars = append(pars, finalClassifyIds)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if keyWord != "" {
|
|
|
+ keyWordArr := strings.Split(keyWord, " ")
|
|
|
+ if len(keyWordArr) > 0 {
|
|
|
+ for _, v := range keyWordArr {
|
|
|
+ condition += ` AND edb_name LIKE '%` + v + `%' `
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if sources != "" {
|
|
|
+ condition += " AND source IN(" + utils.GetOrmInReplace(len(strings.Split(sources, ","))) + ") "
|
|
|
+ pars = append(pars, strings.Split(sources, ","))
|
|
|
+ }
|
|
|
+ if sysUserIds != "" {
|
|
|
+ adminIds := strings.Split(sysUserIds, ",")
|
|
|
+ if len(adminIds) == 0 {
|
|
|
+ br.Msg = "请选择正确的创建人"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ adminIdsSlice := make([]int, 0)
|
|
|
+ for _, adminId := range adminIds {
|
|
|
+ adminIdInt, e := strconv.Atoi(adminId)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "请选择正确的创建人"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ adminIdsSlice = append(adminIdsSlice, adminIdInt)
|
|
|
+ }
|
|
|
+ condition += " AND sys_user_id in (" + utils.GetOrmInReplace(len(adminIds)) + ") "
|
|
|
+ pars = append(pars, adminIdsSlice)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取当前账号的不可见指标
|
|
|
+ obj := data_manage.EdbInfoNoPermissionAdmin{}
|
|
|
+ confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ noPermissionEdbInfoIds := make([]int, 0)
|
|
|
+ for _, v := range confList {
|
|
|
+ noPermissionEdbInfoIds = append(noPermissionEdbInfoIds, v.EdbInfoId)
|
|
|
+ }
|
|
|
+ if len(noPermissionEdbInfoIds) > 0 {
|
|
|
+ condition += " AND edb_info_id NOT IN(" + utils.GetOrmInReplace(len(noPermissionEdbInfoIds)) + ") "
|
|
|
+ pars = append(pars, noPermissionEdbInfoIds)
|
|
|
+ }
|
|
|
+
|
|
|
+ count, err := data_manage.GetEdbInfoByConditionCount(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, count)
|
|
|
+
|
|
|
+ list, err := data_manage.GetEdbInfoListByCondition(condition, pars, startSize, pageSize, "")
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := new(data_manage.EdbInfoFilterDataResp)
|
|
|
+ resp.List = list
|
|
|
+ resp.Paging = page
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|