business_conf.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package controllers
  2. import (
  3. "eta/eta_mobile/models"
  4. "eta/eta_mobile/utils"
  5. "fmt"
  6. )
  7. // BusinessConfController 商家配置
  8. type BusinessConfController struct {
  9. BaseAuthController
  10. }
  11. type BusinessConfOpenController struct {
  12. BaseCommonController
  13. }
  14. // Fetch
  15. // @Title 获取配置
  16. // @Description 获取配置
  17. // @Success 200 Ret=200 获取成功
  18. // @router /fetch [get]
  19. func (this *BusinessConfController) Fetch() {
  20. br := new(models.BaseResponse).Init()
  21. defer func() {
  22. if br.ErrMsg == "" {
  23. br.IsSendEmail = false
  24. }
  25. this.Data["json"] = br
  26. this.ServeJSON()
  27. }()
  28. sysUser := this.SysUser
  29. if sysUser == nil {
  30. br.Msg = "请登录"
  31. br.ErrMsg = "请登录,SysUser Is Empty"
  32. br.Ret = 408
  33. return
  34. }
  35. list, e := models.GetBusinessConf()
  36. if e != nil {
  37. br.Msg = "获取失败"
  38. br.ErrMsg = "获取商家配置失败, Err: " + e.Error()
  39. return
  40. }
  41. br.Data = list
  42. br.Ret = 200
  43. br.Success = true
  44. br.Msg = "获取成功"
  45. }
  46. // CodeEncrypt
  47. // @Title 商家编码加密
  48. // @Description 商家编码加密
  49. // @Success 200 Ret=200 获取成功
  50. // @router /code_encrypt [get]
  51. func (this *BusinessConfOpenController) CodeEncrypt() {
  52. br := new(models.BaseResponse).Init()
  53. defer func() {
  54. if br.ErrMsg == "" {
  55. br.IsSendEmail = false
  56. }
  57. this.Data["json"] = br
  58. this.ServeJSON()
  59. }()
  60. res := ""
  61. if utils.BusinessCode != "" {
  62. res = utils.MD5(fmt.Sprintf("%s%s", utils.BusinessCode, utils.BusinessCodeSalt))
  63. }
  64. br.Data = res
  65. br.Ret = 200
  66. br.Success = true
  67. br.Msg = "获取成功"
  68. }