12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208 |
- package data_manage
- import (
- "encoding/json"
- "eta/eta_mobile/controllers"
- "eta/eta_mobile/models"
- "eta/eta_mobile/models/data_manage"
- "eta/eta_mobile/models/system"
- "eta/eta_mobile/services/data"
- "eta/eta_mobile/services/data/data_manage_permission"
- "eta/eta_mobile/utils"
- "sort"
- )
- type EdbClassifyController struct {
- controllers.BaseAuthController
- }
- func (this *EdbClassifyController) ListV2() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- rootList, err := data_manage.GetEdbClassifyByParentId(0, 0)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- classifyAll, err := data_manage.GetEdbClassifyAll()
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
-
- classifyMap := make(map[int]*data_manage.EdbClassifyItems)
- for _, v := range classifyAll {
- classifyMap[v.ClassifyId] = v
- }
-
- permissionClassifyIdList, err := data_manage_permission.GetUserEdbClassifyPermissionList(this.SysUser.AdminId, 0)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
- return
- }
-
- 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
- }
- noPermissionEdbInfoIdMap := make(map[int]bool)
- for _, v := range confList {
- noPermissionEdbInfoIdMap[v.EdbInfoId] = true
- }
- allEdbInfo, err := data_manage.GetEdbInfoAll(utils.EDB_INFO_TYPE)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- edbInfoMap := make(map[int][]*data_manage.EdbClassifyItems)
- if len(allEdbInfo) > 0 {
-
- permissionEdbIdList, permissionClassifyIdList, err := data_manage_permission.GetUserEdbAndClassifyPermissionList(this.SysUser.AdminId, 0, 0)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取所有有权限的指标和分类失败,Err:" + err.Error()
- return
- }
- for _, v := range allEdbInfo {
-
- if _, ok := noPermissionEdbInfoIdMap[v.EdbInfoId]; ok {
- continue
- }
-
- if classifyInfo, ok := classifyMap[v.ClassifyId]; ok {
- v.HaveOperaAuth = data_manage_permission.CheckEdbPermissionByPermissionIdList(v.IsJoinPermission, classifyInfo.IsJoinPermission, v.EdbInfoId, v.ClassifyId, permissionEdbIdList, permissionClassifyIdList)
- }
- button := data.GetEdbOpButton(this.SysUser, v.SysUserId, v.EdbType, utils.EDB_INFO_TYPE, v.HaveOperaAuth)
- button.AddButton = false
- v.Button = button
- edbInfoMap[v.ClassifyId] = append(edbInfoMap[v.ClassifyId], v)
- }
- }
- rootChildMap := make(map[int][]*data_manage.EdbClassifyItems)
- for _, v := range classifyAll {
-
- v.HaveOperaAuth = data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ClassifyId, permissionClassifyIdList)
-
- button := data.GetEdbClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
- button.AddButton = false
- v.Button = button
- rootChildMap[v.ParentId] = append(rootChildMap[v.ParentId], v)
- if existItems, ok := edbInfoMap[v.ClassifyId]; ok {
- v.Children = existItems
- } else {
- items := make([]*data_manage.EdbClassifyItems, 0)
- v.Children = items
- }
- }
- nodeAll := make([]*data_manage.EdbClassifyItems, 0)
- for _, v := range rootList {
-
- v.HaveOperaAuth = data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ClassifyId, permissionClassifyIdList)
-
- button := data.GetEdbClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
- v.Button = button
- if existItems, ok := rootChildMap[v.ClassifyId]; ok {
- v.Children = existItems
- } else {
- items := make([]*data_manage.EdbClassifyItems, 0)
- v.Children = items
- }
- nodeAll = append(nodeAll, v)
- }
- resp := new(data_manage.EdbClassifyListResp)
- resp.AllNodes = nodeAll
- resp.CanOpClassify = true
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- func (this *EdbClassifyController) Items() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- rootList, err := data_manage.GetEdbClassifyByParentId(0, 0)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- classifyAll, err := data_manage.GetEdbClassifyAll()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- nodeAll := make([]*data_manage.EdbClassifyItems, 0)
- for k := range rootList {
- rootNode := rootList[k]
- data.EdbClassifyItemsMakeTree(classifyAll, rootNode)
- nodeAll = append(nodeAll, rootNode)
- }
- resp := new(data_manage.EdbClassifyListResp)
- resp.AllNodes = nodeAll
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- func (this *EdbClassifyController) AddEdbClassify() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- var req data_manage.AddEdbClassifyReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.ClassifyName == "" {
- br.Msg = "请输入分类名称"
- br.IsSendEmail = false
- return
- }
- if req.ParentId < 0 {
- br.Msg = "参数错误"
- br.IsSendEmail = false
- return
- }
-
- _, err, errMsg := data.AddEdbClassify(req.ClassifyName, req.ParentId, req.Level, 0, this.SysUser.AdminId, this.SysUser.AdminName, this.Lang)
- if errMsg != `` {
- br.Msg = errMsg
- br.ErrMsg = errMsg
- if err != nil {
- br.ErrMsg = errMsg + ";Err:" + err.Error()
- } else {
- br.IsSendEmail = false
- }
- return
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- br.Ret = 200
- br.Msg = "保存成功"
- br.Success = true
- br.IsAddLog = true
- }
- func (this *EdbClassifyController) EditEdbClassify() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- var req data_manage.EditEdbClassifyReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.ClassifyName == "" {
- br.Msg = "请输入分类名称"
- br.IsSendEmail = false
- return
- }
- if req.ClassifyId < 0 {
- br.Msg = "参数错误"
- br.IsSendEmail = false
- return
- }
- err, errMsg := data.EditEdbClassify(req.ClassifyId, req.ClassifyName, this.Lang, this.SysUser)
- if errMsg != `` {
- br.Msg = errMsg
- br.ErrMsg = errMsg
- if err != nil {
- br.ErrMsg = errMsg + ";Err:" + err.Error()
- } else {
- br.IsSendEmail = false
- }
- return
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- br.Ret = 200
- br.Msg = "保存成功"
- br.Success = true
- br.IsAddLog = true
- }
- func (this *EdbClassifyController) DeleteEdbClassifyCheck() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- var req data_manage.ClassifyDeleteCheckReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.ClassifyId < 0 && req.EdbInfoId <= 0 {
- br.Msg = "参数错误"
- br.IsSendEmail = false
- return
- }
- deleteStatus, tipsMsg, err, errMsg := data.DeleteCheck(req.ClassifyId, req.EdbInfoId, this.SysUser)
- if errMsg != `` {
- br.Msg = errMsg
- br.ErrMsg = errMsg
- if err != nil {
- br.ErrMsg = err.Error()
- } else {
- br.IsSendEmail = false
- }
- return
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- resp := new(data_manage.ClassifyDeleteCheckResp)
- resp.DeleteStatus = deleteStatus
- resp.TipsMsg = tipsMsg
- br.Ret = 200
- br.Msg = "检测成功"
- br.Success = true
- br.Data = resp
- }
- func (this *EdbClassifyController) DeleteEdbClassify() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req data_manage.DeleteEdbClassifyReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.ClassifyId < 0 && req.EdbInfoId <= 0 {
- br.Msg = "参数错误"
- br.IsSendEmail = false
- return
- }
- nextItem, err, errMsg := data.Delete(req.ClassifyId, req.EdbInfoId, sysUser, string(this.Ctx.Input.RequestBody), this.Ctx.Input.URI())
- if errMsg != `` {
- br.Msg = errMsg
- br.ErrMsg = errMsg
- if err != nil {
- br.ErrMsg = err.Error()
- } else {
- br.IsSendEmail = false
- }
- return
- }
- resp := data_manage.AddEdbInfoResp{}
- if nextItem != nil {
- resp = data_manage.AddEdbInfoResp{
- EdbInfoId: nextItem.EdbInfoId,
- UniqueCode: nextItem.UniqueCode,
- }
- }
- br.Ret = 200
- br.Msg = "删除成功"
- br.Success = true
- br.IsAddLog = true
- br.Data = resp
- }
- func (this *EdbClassifyController) EdbClassifyMove() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req data_manage.MoveEdbClassifyReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.ClassifyId <= 0 && req.EdbInfoId <= 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "请选择拖动目标,分类目录或者指标"
- return
- }
- err, errMsg := data.MoveEdbClassify(req, sysUser, 0)
- if errMsg != `` {
- br.Msg = errMsg
- br.ErrMsg = errMsg
- if err != nil {
- br.ErrMsg = err.Error()
- } else {
- br.IsSendEmail = false
- }
- return
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- br.Ret = 200
- br.Success = true
- br.Msg = "移动成功"
- }
- func (this *EdbClassifyController) ItemsV2() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- rootList, err := data_manage.GetEdbClassifyByParentId(0, 0)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- classifyAll, err := data_manage.GetEdbClassifyAll()
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
-
- permissionClassifyIdList, err := data_manage_permission.GetUserEdbClassifyPermissionList(this.SysUser.AdminId, 0)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
- return
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- rootChildMap := make(map[int][]*data_manage.EdbClassifyItems)
- for _, v := range classifyAll {
-
- v.HaveOperaAuth = data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ClassifyId, permissionClassifyIdList)
-
- button := data.GetEdbClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
- button.AddButton = false
- v.Button = button
- rootChildMap[v.ParentId] = append(rootChildMap[v.ParentId], v)
-
-
-
-
-
-
- }
- nodeAll := make([]*data_manage.EdbClassifyItems, 0)
- for _, v := range rootList {
-
- v.HaveOperaAuth = data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ClassifyId, permissionClassifyIdList)
-
- button := data.GetEdbClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
- v.Button = button
- if existItems, ok := rootChildMap[v.ClassifyId]; ok {
- v.Children = existItems
- } else {
- items := make([]*data_manage.EdbClassifyItems, 0)
- v.Children = items
- }
- nodeAll = append(nodeAll, v)
- }
- language := `CN`
-
- {
- configDetail, _ := system.GetConfigDetailByCode(this.SysUser.AdminId, system.EdbLanguageVar)
- if configDetail != nil {
- language = configDetail.ConfigValue
- } else {
- configDetail, _ = system.GetDefaultConfigDetailByCode(system.EdbLanguageVar)
- if configDetail != nil {
- language = configDetail.ConfigValue
- }
- }
- }
-
- canOpClassify := true
-
-
-
-
- resp := data_manage.EdbClassifyListResp{
- AllNodes: nodeAll,
- CanOpClassify: canOpClassify,
- Language: language,
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- func (this *EdbClassifyController) ClassifyEdbInfoList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- classifyId, _ := this.GetInt("ClassifyId")
- if classifyId <= 0 {
- br.Msg = "参数错误,请刷新页面"
- return
- }
- classifyInfo, err := data_manage.GetEdbClassifyById(classifyId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
- return
- }
-
- 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
- }
- noPermissionEdbInfoIdMap := make(map[int]bool)
- for _, v := range confList {
- noPermissionEdbInfoIdMap[v.EdbInfoId] = true
- }
- allEdbInfo, err := data_manage.GetEdbInfoByClassifyId(classifyId, 0, 0)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- list := make([]*data_manage.EdbClassifyItems, 0)
- if len(allEdbInfo) > 0 {
-
- permissionEdbIdList, permissionClassifyIdList, err := data_manage_permission.GetUserEdbAndClassifyPermissionList(this.SysUser.AdminId, 0, 0)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取所有有权限的指标和分类失败,Err:" + err.Error()
- return
- }
- for _, v := range allEdbInfo {
-
- if _, ok := noPermissionEdbInfoIdMap[v.EdbInfoId]; ok {
- continue
- }
- v.HaveOperaAuth = data_manage_permission.CheckEdbPermissionByPermissionIdList(v.IsJoinPermission, classifyInfo.IsJoinPermission, v.EdbInfoId, v.ClassifyId, permissionEdbIdList, permissionClassifyIdList)
- button := data.GetEdbOpButton(this.SysUser, v.SysUserId, v.EdbType, utils.EDB_INFO_TYPE, v.HaveOperaAuth)
- button.AddButton = false
- v.Button = button
- list = append(list, v)
- }
- }
- resp := new(data_manage.ClassifyEdbInfoListResp)
- resp.EdbInfoList = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- func (this *EdbClassifyController) ItemsV3() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- rootList, err := data_manage.GetEdbClassifyByParentId(0, 0)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- rootTwoList, err := data_manage.GetEdbClassifyByParentIdTwo(0)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- classifyAll, err := data_manage.GetEdbClassifyAllV2(0)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
-
- permissionClassifyIdList, err := data_manage_permission.GetUserEdbClassifyPermissionList(this.SysUser.AdminId, 0)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
- return
- }
- rootTwoMap := make(map[int][]*data_manage.EdbClassifyItems)
- for _, v := range rootTwoList {
-
- v.HaveOperaAuth = data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ClassifyId, permissionClassifyIdList)
-
- button := data.GetEdbClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
- v.Button = button
- rootTwoMap[v.ParentId] = append(rootTwoMap[v.ParentId], v)
- }
- rootTwoChildMap := make(map[int][]*data_manage.EdbClassifyItems)
- for _, v := range classifyAll {
-
- v.HaveOperaAuth = data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ClassifyId, permissionClassifyIdList)
-
- button := data.GetEdbClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
- v.Button = button
- if v.Level == 3 {
- rootTwoChildMap[v.ParentId] = append(rootTwoChildMap[v.ParentId], v)
- }
- }
- nodeAll := make([]*data_manage.EdbClassifyItems, 0)
- for _, v := range rootList {
-
- v.HaveOperaAuth = data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ClassifyId, permissionClassifyIdList)
-
- button := data.GetEdbClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
- v.Button = button
- if existItems, ok := rootTwoMap[v.ClassifyId]; ok {
- v.Children = existItems
- for _, item := range existItems {
-
- v.HaveOperaAuth = data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ClassifyId, permissionClassifyIdList)
-
- button := data.GetEdbClassifyOpButton(this.SysUser, item.SysUserId, v.HaveOperaAuth)
- item.Button = button
- if existItems, ok := rootTwoChildMap[item.ClassifyId]; ok {
- for _, existItem := range existItems {
-
- v.HaveOperaAuth = data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ClassifyId, permissionClassifyIdList)
-
- button := data.GetEdbClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
- button.AddButton = false
- existItem.Button = button
- }
- item.Children = existItems
- } else {
- items := make([]*data_manage.EdbClassifyItems, 0)
- item.Children = items
- }
- }
- } else {
- items := make([]*data_manage.EdbClassifyItems, 0)
- v.Children = items
- }
- nodeAll = append(nodeAll, v)
- }
- language := `CN`
-
- {
- configDetail, _ := system.GetConfigDetailByCode(this.SysUser.AdminId, system.EdbLanguageVar)
- if configDetail != nil {
- language = configDetail.ConfigValue
- } else {
- configDetail, _ = system.GetDefaultConfigDetailByCode(system.EdbLanguageVar)
- if configDetail != nil {
- language = configDetail.ConfigValue
- }
- }
- }
-
- canOpClassify := true
- button := data.GetEdbClassifyOpButton(this.SysUser, 0, true)
- if !button.AddButton {
- canOpClassify = false
- }
- resp := new(data_manage.EdbClassifyListResp)
- resp.AllNodes = nodeAll
- resp.Language = language
- resp.CanOpClassify = canOpClassify
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- func (this *EdbClassifyController) SimpleList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
-
-
-
- parentId, _ := this.GetInt("ParentId")
- isOnlyMe, _ := this.GetBool("IsOnlyMe")
-
- sysUserId := 0
- if isOnlyMe {
- sysUserId = this.SysUser.AdminId
- }
- rootList, err := data_manage.GetEdbClassifyByParentId(parentId, 0)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- nodeAll := make([]*data_manage.EdbClassifyItems, 0)
- var sortList data_manage.EdbClassifyItemList
- if parentId > 0 {
-
-
- 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
- }
- noPermissionEdbInfoIdMap := make(map[int]bool)
- for _, v := range confList {
- noPermissionEdbInfoIdMap[v.EdbInfoId] = true
- }
- allEdbInfo, err := data_manage.GetEdbInfoByClassifyId(parentId, 0, sysUserId)
- if err != nil {
- br.Msg = "获取指标数据失败"
- br.ErrMsg = "获取指标数据失败,Err:" + err.Error()
- return
- }
- if len(allEdbInfo) > 0 {
-
- currClassify, err := data_manage.GetEdbClassifyById(parentId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取当前分类信息失败,Err:" + err.Error()
- return
- }
-
- permissionEdbIdList, permissionClassifyIdList, err := data_manage_permission.GetUserEdbAndClassifyPermissionList(this.SysUser.AdminId, 0, 0)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取所有有权限的指标和分类失败,Err:" + err.Error()
- return
- }
- for _, v := range allEdbInfo {
-
- if _, ok := noPermissionEdbInfoIdMap[v.EdbInfoId]; ok {
- continue
- }
- v.HaveOperaAuth = data_manage_permission.CheckEdbPermissionByPermissionIdList(v.IsJoinPermission, currClassify.IsJoinPermission, v.EdbInfoId, v.ClassifyId, permissionEdbIdList, permissionClassifyIdList)
- button := data.GetEdbOpButton(this.SysUser, v.SysUserId, v.EdbType, utils.EDB_INFO_TYPE, v.HaveOperaAuth)
- button.AddButton = false
- v.Button = button
- v.Children = make([]*data_manage.EdbClassifyItems, 0)
- v.ParentId = parentId
- nodeAll = append(nodeAll, v)
- }
- }
- }
- if len(rootList) > 0 {
-
- permissionClassifyIdList, err := data_manage_permission.GetUserEdbClassifyPermissionList(this.SysUser.AdminId, 0)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
- return
- }
- for _, v := range rootList {
-
- v.HaveOperaAuth = data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ClassifyId, permissionClassifyIdList)
-
- button := data.GetEdbClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
- v.Button = button
- v.Children = make([]*data_manage.EdbClassifyItems, 0)
- nodeAll = append(nodeAll, v)
- }
- }
- if len(nodeAll) > 0 {
-
- sortList = nodeAll
- sort.Sort(sortList)
- }
- language := `CN`
-
- {
- configDetail, _ := system.GetConfigDetailByCode(this.SysUser.AdminId, system.EdbLanguageVar)
- if configDetail != nil {
- language = configDetail.ConfigValue
- } else {
- configDetail, _ = system.GetDefaultConfigDetailByCode(system.EdbLanguageVar)
- if configDetail != nil {
- language = configDetail.ConfigValue
- }
- }
- }
-
- canOpClassify := true
- button := data.GetEdbClassifyOpButton(this.SysUser, 0, true)
- if !button.AddButton {
- canOpClassify = false
- }
- resp := new(data_manage.EdbClassifyListResp)
- resp.AllNodes = sortList
- resp.Language = language
- resp.CanOpClassify = canOpClassify
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- func (this *EdbClassifyController) ClassifyTree() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- allList, err := data_manage.GetNormalEdbClassifyAll()
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- nodeAll := make([]*data_manage.EdbClassifyItems, 0)
- var sortList data_manage.EdbClassifyItemList
- if len(allList) > 0 {
-
- permissionClassifyIdList, err := data_manage_permission.GetUserEdbClassifyPermissionList(this.SysUser.AdminId, 0)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
- return
- }
- for k, v := range allList {
-
- v.HaveOperaAuth = data_manage_permission.CheckEdbClassifyPermissionByPermissionIdList(v.IsJoinPermission, v.ClassifyId, permissionClassifyIdList)
-
- button := data.GetEdbClassifyOpButton(this.SysUser, v.SysUserId, v.HaveOperaAuth)
- allList[k].Button = button
- }
- nodeAll = data.GetClassifyTreeRecursive(allList, 0)
-
- sortList = nodeAll
- sort.Sort(sortList)
- }
- language := `CN`
-
- {
- configDetail, _ := system.GetConfigDetailByCode(this.SysUser.AdminId, system.EdbLanguageVar)
- if configDetail != nil {
- language = configDetail.ConfigValue
- } else {
- configDetail, _ = system.GetDefaultConfigDetailByCode(system.EdbLanguageVar)
- if configDetail != nil {
- language = configDetail.ConfigValue
- }
- }
- }
-
- canOpClassify := true
- button := data.GetEdbClassifyOpButton(this.SysUser, 0, true)
- if !button.AddButton {
- canOpClassify = false
- }
- resp := new(data_manage.EdbClassifyListResp)
- resp.AllNodes = sortList
- resp.Language = language
- resp.CanOpClassify = canOpClassify
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|