智慧食堂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 line
1.7 KiB

  1. package hdl
  2. import (
  3. "applet/app/customer/lib/validate"
  4. "applet/app/customer/md"
  5. "applet/app/customer/svc"
  6. "applet/app/db"
  7. "applet/app/e"
  8. "applet/app/enum"
  9. "fmt"
  10. "github.com/gin-gonic/gin"
  11. )
  12. func AesDecrypt(c *gin.Context) {
  13. fmt.Println(">>>>>>>>>>>>>>>>>", c.Request.Body)
  14. var req md.CurlAesDecrypt
  15. err := c.ShouldBindJSON(&req)
  16. if err != nil {
  17. err = validate.HandleValidateErr(err)
  18. err1 := err.(e.E)
  19. e.OutErr(c, err1.Code, err1.Error())
  20. return
  21. }
  22. sysCfgDb := db.SysCfgDb{}
  23. sysCfgDb.Set()
  24. sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAppletAesKey)
  25. req.AesKey = sysCfg[enum.OpenAppletAesKey]
  26. err, result := svc.AesDecrypt(req)
  27. if err != nil {
  28. e.OutErr(c, e.ERR, err.Error())
  29. return
  30. }
  31. e.OutSuc(c, result, nil)
  32. return
  33. }
  34. func SystemOauthToken(c *gin.Context) {
  35. var req md.SystemOauthTokenReq
  36. err := c.ShouldBindJSON(&req)
  37. if err != nil {
  38. err = validate.HandleValidateErr(err)
  39. err1 := err.(e.E)
  40. e.OutErr(c, err1.Code, err1.Error())
  41. return
  42. }
  43. sysCfgDb := db.SysCfgDb{}
  44. sysCfgDb.Set()
  45. sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAppletAppid, enum.OpenAppletAppPrivateKey, enum.OpenAppletPublicKey)
  46. req.Config = struct {
  47. AliAppId string `json:"ali_app_id" label:"支付宝开放平台-小程序-appid"`
  48. AliPrivateKey string `json:"ali_private_key" label:"支付宝开放平台-小程序-应用私钥"`
  49. AliPublicKey string `json:"ali_public_key" label:"支付宝开放平台-小程序-支付宝公钥"`
  50. }{
  51. AliAppId: sysCfg[enum.OpenAppletAppid],
  52. AliPrivateKey: sysCfg[enum.OpenAppletAppPrivateKey],
  53. AliPublicKey: sysCfg[enum.OpenAppletPublicKey],
  54. }
  55. err, result := svc.SystemOauthToken(req)
  56. if err != nil {
  57. e.OutErr(c, e.ERR, err.Error())
  58. return
  59. }
  60. e.OutSuc(c, result, nil)
  61. return
  62. }