data_move.go 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. package data_manage_permission
  2. import (
  3. "encoding/json"
  4. "eta/eta_api/models"
  5. "eta/eta_api/models/data_manage"
  6. data_manage_permissionModel "eta/eta_api/models/data_manage/data_manage_permission"
  7. "eta/eta_api/services/data/data_manage_permission"
  8. "eta/eta_api/utils"
  9. "github.com/rdlucklib/rdluck_tools/paging"
  10. )
  11. // EdbChartClassifyList
  12. // @Title 获取指标/图表分类列表数据接口
  13. // @Description 获取指标/图表分类列表数据接口
  14. // @Param Source query int false "来源 :1:手工数据指标 2:钢联化工数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格"
  15. // @Param SubSource query int false "子来源 :ETA表格中的各种表格类型,以及图表的来源(这个是后续的扩展方向)"
  16. // @Success 200 {object} data_manage.ChartListResp
  17. // @router /edb_chart/classify [get]
  18. func (c *DataMangePermissionController) EdbChartClassifyList() {
  19. br := new(models.BaseResponse).Init()
  20. defer func() {
  21. c.Data["json"] = br
  22. c.ServeJSON()
  23. }()
  24. sysUser := c.SysUser
  25. if sysUser == nil {
  26. br.Msg = "请登录"
  27. br.ErrMsg = "请登录,SysUser Is Empty"
  28. br.Ret = 408
  29. return
  30. }
  31. source, _ := c.GetInt("Source")
  32. if source <= 0 || source > 6 {
  33. br.Msg = "错误的来源"
  34. br.IsSendEmail = false
  35. return
  36. }
  37. // 子来源(目前作用于ETA表格,2024-3-26 14:12:09)
  38. subSource, _ := c.GetInt("SubSource")
  39. if source == 6 && (subSource <= utils.EXCEL_DEFAULT || subSource > utils.CUSTOM_ANALYSIS_TABLE) {
  40. br.Msg = "错误的子来源"
  41. br.IsSendEmail = false
  42. return
  43. }
  44. list, err := data_manage_permission.GetEdbChartClassifyList(source, subSource)
  45. if err != nil {
  46. //br.Success = true
  47. br.Msg = "获取失败"
  48. br.ErrMsg = "获取失败,Err:" + err.Error()
  49. return
  50. }
  51. br.Ret = 200
  52. br.Success = true
  53. br.Msg = "获取成功"
  54. br.Data = list
  55. }
  56. // MoveEdbChartList
  57. // @Title 获取指标/图表创建人列表数据接口
  58. // @Description 获取指标/图表创建人列表数据接口
  59. // @Param PageSize query int true "每页数据条数"
  60. // @Param CurrentIndex query int true "当前页页码,从1开始"
  61. // @Param Source query int false "来源 :1:手工数据指标 2:钢联化工数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格"
  62. // @Param SubSource query int false "子来源 :目前作用于ETA表格,2024-3-26 14:12:09"
  63. // @Param Keyword query string false "关键字,code或者名称"
  64. // @Param Classify query string false "分类id"
  65. // @Param UserId query int false "创建人id"
  66. // @Success 200 {object} data_manage.ChartListResp
  67. // @router /edb_chart/list [get]
  68. func (c *DataMangePermissionController) MoveEdbChartList() {
  69. br := new(models.BaseResponse).Init()
  70. defer func() {
  71. c.Data["json"] = br
  72. c.ServeJSON()
  73. }()
  74. sysUser := c.SysUser
  75. if sysUser == nil {
  76. br.Msg = "请登录"
  77. br.ErrMsg = "请登录,SysUser Is Empty"
  78. br.Ret = 408
  79. return
  80. }
  81. source, _ := c.GetInt("Source")
  82. if source <= 0 || source > 6 {
  83. br.Msg = "错误的来源"
  84. br.IsSendEmail = false
  85. return
  86. }
  87. // 子来源(目前作用于ETA表格,2024-3-26 14:12:09)
  88. subSource, _ := c.GetInt("SubSource")
  89. if source == 6 && (subSource <= utils.EXCEL_DEFAULT || subSource > utils.CUSTOM_ANALYSIS_TABLE) {
  90. br.Msg = "错误的子来源"
  91. br.IsSendEmail = false
  92. return
  93. }
  94. userId, _ := c.GetInt("UserId")
  95. keyword := c.GetString("Keyword")
  96. classify := c.GetString("Classify")
  97. pageSize, _ := c.GetInt("PageSize")
  98. currentIndex, _ := c.GetInt("CurrentIndex")
  99. var startSize int
  100. if pageSize <= 0 {
  101. pageSize = utils.PageSize20
  102. }
  103. if currentIndex <= 0 {
  104. currentIndex = 1
  105. }
  106. startSize = paging.StartIndex(currentIndex, pageSize)
  107. resp := data_manage.MoveEdbChartListResp{}
  108. var total int
  109. page := paging.GetPaging(currentIndex, pageSize, total)
  110. defaultList := make([]data_manage.MoveEdbChartList, 0)
  111. resp.List = defaultList
  112. resp.Paging = page
  113. // 没有传入条件,那就默认自动返回
  114. //if userId <= 0 && keyword == `` && classify == `` {
  115. // br.Ret = 200
  116. // br.Success = true
  117. // br.Msg = "获取成功"
  118. // br.Data = resp
  119. // return
  120. //}
  121. list, total, err := data_manage_permission.GetMoveEdbChartList(source, subSource, userId, keyword, classify, startSize, pageSize)
  122. if err != nil {
  123. //br.Success = true
  124. br.Msg = "获取失败"
  125. br.ErrMsg = "获取失败,Err:" + err.Error()
  126. return
  127. }
  128. if list == nil {
  129. list = defaultList
  130. }
  131. page = paging.GetPaging(currentIndex, pageSize, total)
  132. resp.Paging = page
  133. resp.List = list
  134. br.Ret = 200
  135. br.Success = true
  136. br.Msg = "获取成功"
  137. br.IsAddLog = false
  138. br.Data = resp
  139. }
  140. // MoveEdbChartUser
  141. // @Title 指标/图表创建人变更接口
  142. // @Description 指标/图表创建人变更接口
  143. // @Param request body data_manage_permissionModel.MoveEdbChartReq true "type json string"
  144. // @Success 200 {object} data_manage.ChartListResp
  145. // @router /edb_chart/change_user [post]
  146. func (c *DataMangePermissionController) MoveEdbChartUser() {
  147. br := new(models.BaseResponse).Init()
  148. defer func() {
  149. c.Data["json"] = br
  150. c.ServeJSON()
  151. }()
  152. sysUser := c.SysUser
  153. if sysUser == nil {
  154. br.Msg = "请登录"
  155. br.ErrMsg = "请登录,SysUser Is Empty"
  156. br.Ret = 408
  157. return
  158. }
  159. var req data_manage_permissionModel.MoveEdbChartReq
  160. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  161. if err != nil {
  162. br.Msg = "参数解析异常!"
  163. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  164. return
  165. }
  166. if req.Source <= 0 || req.Source > 6 {
  167. br.Msg = "错误的来源"
  168. br.IsSendEmail = false
  169. return
  170. }
  171. // 子来源(目前作用于ETA表格,2024-3-26 14:12:09)
  172. if req.Source == 6 && (req.SubSource <= utils.EXCEL_DEFAULT || req.SubSource > utils.CUSTOM_ANALYSIS_TABLE) {
  173. br.Msg = "错误的子来源"
  174. br.IsSendEmail = false
  175. return
  176. }
  177. if !req.IsSelectAll && len(req.DataIdList) <= 0 {
  178. br.Msg = "请勾选数据项"
  179. br.IsSendEmail = false
  180. return
  181. }
  182. if req.NewUserId <= 0 {
  183. br.Msg = "请选择新的创建人"
  184. br.IsSendEmail = false
  185. return
  186. }
  187. err, errMsg := data_manage_permission.MoveEdbChart(req.Source, req.SubSource, req.UserId, req.NewUserId, req.IsSelectAll, req.DataIdList, req.NoDataIdList, req.Keyword, req.ClassifyId, sysUser.AdminId)
  188. if err != nil {
  189. //br.Success = true
  190. br.Msg = "移动失败"
  191. if errMsg != `` {
  192. br.Msg = errMsg
  193. }
  194. br.ErrMsg = "移动失败,Err:" + err.Error()
  195. return
  196. }
  197. br.Ret = 200
  198. br.IsAddLog = true
  199. br.Success = true
  200. br.Msg = "修改成功"
  201. }
  202. // MoveAllEdbChartUser
  203. // @Title 通过原创建人转移指标/图表创建人接口
  204. // @Description 通过原创建人转移指标/图表创建人接口
  205. // @Param request body data_manage_permission.MoveAllEdbChartReq true "type json string"
  206. // @Success 200 {object} data_manage.ChartListResp
  207. // @router /edb_chart/all/change_user [post]
  208. func (c *DataMangePermissionController) MoveAllEdbChartUser() {
  209. br := new(models.BaseResponse).Init()
  210. defer func() {
  211. c.Data["json"] = br
  212. c.ServeJSON()
  213. }()
  214. sysUser := c.SysUser
  215. if sysUser == nil {
  216. br.Msg = "请登录"
  217. br.ErrMsg = "请登录,SysUser Is Empty"
  218. br.Ret = 408
  219. return
  220. }
  221. var req data_manage_permissionModel.MoveAllEdbChartReq
  222. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  223. if err != nil {
  224. br.Msg = "参数解析异常!"
  225. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  226. return
  227. }
  228. if len(req.Source) < 0 {
  229. br.Msg = "请选择来源"
  230. br.IsSendEmail = false
  231. return
  232. }
  233. if len(req.OldUserId) <= 0 {
  234. br.Msg = "请选择旧的创建人"
  235. br.IsSendEmail = false
  236. return
  237. }
  238. if req.NewUserId <= 0 {
  239. br.Msg = "请选择新的创建人"
  240. br.IsSendEmail = false
  241. return
  242. }
  243. err, errMsg := data_manage_permission.MoveAllEdbChart(req.Source, req.OldUserId, req.NewUserId, sysUser.AdminId)
  244. if err != nil {
  245. //br.Success = true
  246. br.Msg = "移动失败"
  247. if errMsg != `` {
  248. br.Msg = errMsg
  249. }
  250. br.ErrMsg = "移动失败,Err:" + err.Error()
  251. return
  252. }
  253. br.Ret = 200
  254. br.IsAddLog = true
  255. br.Success = true
  256. br.Msg = "移动成功"
  257. }
  258. // MoveEdbChartCount
  259. // @Title 获取指标/图表创建人汇总数据接口
  260. // @Description 获取指标/图表创建人汇总数据接口
  261. // @Param Source query int false "来源 :1:手工数据指标 2:钢联化工数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格"
  262. // @Param UserId query int false "创建人id"
  263. // @Success 200 {object} data_manage.ChartListResp
  264. // @router /edb_chart/count [get]
  265. func (c *DataMangePermissionController) MoveEdbChartCount() {
  266. br := new(models.BaseResponse).Init()
  267. defer func() {
  268. c.Data["json"] = br
  269. c.ServeJSON()
  270. }()
  271. sysUser := c.SysUser
  272. if sysUser == nil {
  273. br.Msg = "请登录"
  274. br.ErrMsg = "请登录,SysUser Is Empty"
  275. br.Ret = 408
  276. return
  277. }
  278. userId, _ := c.GetInt("UserId")
  279. // 没有传入条件,那就默认自动返回
  280. if userId <= 0 {
  281. br.Ret = 200
  282. br.Success = true
  283. br.Msg = "获取成功"
  284. //br.Data = resp
  285. return
  286. }
  287. resp, err := data_manage_permission.GetMoveEdbChartCount(userId)
  288. if err != nil {
  289. //br.Success = true
  290. br.Msg = "获取失败"
  291. br.ErrMsg = "获取失败,Err:" + err.Error()
  292. return
  293. }
  294. br.Ret = 200
  295. br.Success = true
  296. br.Msg = "获取成功"
  297. br.Data = resp
  298. }