company_process.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package controllers
  2. import (
  3. "hongze/hz_crm_api/models"
  4. "hongze/hz_crm_api/models/company"
  5. )
  6. // 流程管理
  7. type CompanyProcessController struct {
  8. BaseAuthController
  9. }
  10. // @Title 客户流程列表
  11. // @Description 客户流程列表接口
  12. // @Param CompanyId query int true "客户id"
  13. // @Success 200 {object} company.CompanyOperationRecordListResp
  14. // @router /process/list [get]
  15. func (this *CompanyProcessController) ProcessList() {
  16. br := new(models.BaseResponse).Init()
  17. defer func() {
  18. this.Data["json"] = br
  19. this.ServeJSON()
  20. }()
  21. sysUser := this.SysUser
  22. if sysUser == nil {
  23. br.Msg = "请登录"
  24. br.ErrMsg = "请登录,SysUser Is Empty"
  25. br.Ret = 408
  26. return
  27. }
  28. companyId, _ := this.GetInt("CompanyId")
  29. if companyId <= 0 {
  30. br.Msg = "参数错误"
  31. br.ErrMsg = "客户参数小于等于0"
  32. return
  33. }
  34. list, err := company.GetCompanyOperationRecordList(companyId)
  35. if err != nil {
  36. br.Msg = "获取失败"
  37. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  38. return
  39. }
  40. showButton := true
  41. if len(list) > 0 {
  42. for key, item := range list {
  43. if item.Operation == "approve" {
  44. list[key].Remark = item.ApproveContent
  45. } else if item.Operation == "edit_renewal_reason" || item.Operation == "add_try_out_reason" || item.Operation == "add_renewal_reason" {
  46. showButton = false
  47. }
  48. }
  49. }
  50. resp := new(company.CompanyOperationRecordListResp)
  51. resp.List = list
  52. resp.ShowButton = showButton
  53. br.Ret = 200
  54. br.Success = true
  55. br.Msg = "获取成功"
  56. br.Data = resp
  57. }