智慧食堂
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.

75 rivejä
2.0 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. "applet/app/utils"
  10. "encoding/json"
  11. "fmt"
  12. "github.com/gin-gonic/gin"
  13. )
  14. func AesDecrypt(c *gin.Context) {
  15. fmt.Println(">>>>>>>>>>>>>>>>>", c.Request.Body)
  16. var req md.CurlAesDecrypt
  17. err := c.ShouldBindJSON(&req)
  18. if err != nil {
  19. err = validate.HandleValidateErr(err)
  20. err1 := err.(e.E)
  21. e.OutErr(c, err1.Code, err1.Error())
  22. return
  23. }
  24. sysCfgDb := db.SysCfgDb{}
  25. sysCfgDb.Set()
  26. sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAppletAesKey)
  27. req.AesKey = sysCfg[enum.OpenAppletAesKey]
  28. err, result := svc.AesDecrypt(req)
  29. if err != nil {
  30. e.OutErr(c, e.ERR, err.Error())
  31. return
  32. }
  33. resByre, _ := json.Marshal(result)
  34. var aesStruct md.AesStruct
  35. json.Unmarshal(resByre, &aesStruct)
  36. aesStruct.Mobile = utils.Base64StdEncode(aesStruct.Mobile)
  37. e.OutSuc(c, aesStruct, nil)
  38. return
  39. }
  40. func SystemOauthToken(c *gin.Context) {
  41. var req md.SystemOauthTokenReq
  42. err := c.ShouldBindJSON(&req)
  43. if err != nil {
  44. err = validate.HandleValidateErr(err)
  45. err1 := err.(e.E)
  46. e.OutErr(c, err1.Code, err1.Error())
  47. return
  48. }
  49. utils.FilePutContents("SystemOauthToken", utils.SerializeStr(req))
  50. sysCfgDb := db.SysCfgDb{}
  51. sysCfgDb.Set()
  52. sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAppletAppid, enum.OpenAppletAppPrivateKey, enum.OpenAppletPublicKey)
  53. req.Config = struct {
  54. AliAppId string `json:"ali_app_id" label:"支付宝开放平台-小程序-appid"`
  55. AliPrivateKey string `json:"ali_private_key" label:"支付宝开放平台-小程序-应用私钥"`
  56. AliPublicKey string `json:"ali_public_key" label:"支付宝开放平台-小程序-支付宝公钥"`
  57. }{
  58. AliAppId: sysCfg[enum.OpenAppletAppid],
  59. AliPrivateKey: sysCfg[enum.OpenAppletAppPrivateKey],
  60. AliPublicKey: sysCfg[enum.OpenAppletPublicKey],
  61. }
  62. err, result := svc.SystemOauthToken(req)
  63. if err != nil {
  64. e.OutErr(c, e.ERR, err.Error())
  65. return
  66. }
  67. e.OutSuc(c, result, nil)
  68. return
  69. }