sys_flow.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "hongze/hz_crm_api/models"
  5. "hongze/hz_crm_api/models/system"
  6. "hongze/hz_crm_api/services/flow"
  7. )
  8. // 审批配置
  9. type SysFlowController struct {
  10. BaseAuthController
  11. }
  12. // @Title 获取审批配置详情
  13. // @Description 获取审批配置详情接口
  14. // @Param FlowId query int true "节点id"
  15. // @Success 200 {object} system.ApprovalFlowItem
  16. // @router /flow/detail [get]
  17. func (this *SysFlowController) Detail() {
  18. br := new(models.BaseResponse).Init()
  19. defer func() {
  20. this.Data["json"] = br
  21. this.ServeJSON()
  22. }()
  23. sysUser := this.SysUser
  24. if sysUser == nil {
  25. br.Msg = "请登录"
  26. br.ErrMsg = "请登录,SysUser Is Empty"
  27. br.Ret = 408
  28. return
  29. }
  30. flowId, _ := this.GetInt("FlowId")
  31. if flowId <= 0 {
  32. br.Msg = "参数错误"
  33. br.ErrMsg = "请传入审批节点"
  34. return
  35. }
  36. item, err := flow.GetApprovalFlowDetail(flowId)
  37. if err != nil {
  38. br.Msg = "获取信息失败"
  39. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  40. return
  41. }
  42. br.Ret = 200
  43. br.Success = true
  44. br.Msg = "获取成功"
  45. br.Data = item
  46. }
  47. // @Title 编辑审批配置
  48. // @Description 编辑审批配置接口
  49. // @Param request body system.SysRoleAddReq true "type json string"
  50. // @Success 200 流程配置成功
  51. // @router /flow/edit [post]
  52. func (this *SysFlowController) Edit() {
  53. br := new(models.BaseResponse).Init()
  54. defer func() {
  55. this.Data["json"] = br
  56. this.ServeJSON()
  57. }()
  58. var req system.EditFlowReq
  59. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  60. if err != nil {
  61. br.Msg = "参数解析异常!"
  62. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  63. return
  64. }
  65. if req.FlowId <= 0 {
  66. br.Msg = "审批配置不能为空"
  67. return
  68. }
  69. if len(req.NodeList) <= 0 {
  70. br.Msg = "节点配置不能为空"
  71. return
  72. }
  73. err = flow.EditFlow(req)
  74. if err != nil {
  75. br.Msg = "流程配置失败"
  76. br.ErrMsg = "流程配置失败,Err:" + err.Error()
  77. return
  78. }
  79. br.Ret = 200
  80. br.Success = true
  81. br.Msg = "流程配置成功"
  82. }
  83. // @Title 获取用户列表
  84. // @Description 获取审批配置详情接口
  85. // @Param Keyword query string true "关键字"
  86. // @Success 200 {object} system.FlowUserResp
  87. // @router /flow/user [get]
  88. func (this *SysFlowController) List() {
  89. br := new(models.BaseResponse).Init()
  90. defer func() {
  91. this.Data["json"] = br
  92. this.ServeJSON()
  93. }()
  94. sysUser := this.SysUser
  95. if sysUser == nil {
  96. br.Msg = "请登录"
  97. br.ErrMsg = "请登录,SysUser Is Empty"
  98. br.Ret = 408
  99. return
  100. }
  101. keyword := this.GetString("Keyword")
  102. if keyword == "" {
  103. br.Msg = "参数错误"
  104. br.ErrMsg = "请传入搜索关键字"
  105. return
  106. }
  107. //获取用户列表
  108. var condition string
  109. var pars []interface{}
  110. condition += ` AND (real_name LIKE '%` + keyword + `%' OR admin_name LIKE '%` + keyword + `%' OR mobile LIKE '%` + keyword + `%' ) `
  111. adminList, err := system.GetSysuserList(condition, pars, 0, 100)
  112. if err != nil {
  113. br.Msg = "获取失败"
  114. br.ErrMsg = "获取用户列表失败,Err:" + err.Error()
  115. return
  116. }
  117. //获取角色列表
  118. var roleCondition string
  119. var rolePars []interface{}
  120. roleCondition += ` AND role_name LIKE '%` + keyword + `%' `
  121. roleList, err := system.GetSysRoleList(roleCondition, rolePars, 0, 100)
  122. if err != nil {
  123. br.Msg = "获取失败"
  124. br.ErrMsg = "获取角色列表失败,Err:" + err.Error()
  125. return
  126. }
  127. br.Ret = 200
  128. br.Success = true
  129. br.Msg = "获取成功"
  130. br.Data = system.FlowUserResp{
  131. AdminList: adminList,
  132. RoleList: roleList,
  133. }
  134. }