sign_api_controller.go 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package controllers
  2. import (
  3. "XT_New/service"
  4. "encoding/json"
  5. "fmt"
  6. "github.com/astaxie/beego"
  7. )
  8. type SignApiController struct {
  9. BaseAuthAPIController
  10. }
  11. func SignApiRegistRouters() {
  12. //获取短信验证码
  13. beego.Router("/api/sign/getsign", &SignApiController{}, "Get:GetSign")
  14. //创建个人用户并实名
  15. beego.Router("/api/sign/createrusername", &SignApiController{}, "Get:CreateUserName")
  16. //创建个人印章
  17. beego.Router("/api/sign/createpersionseal", &SignApiController{}, "Get:CreatePersionSeal")
  18. //上传文件创建和他
  19. }
  20. // 短信服务接口
  21. func (this *SignApiController) GetSign() {
  22. phone := this.GetString("phone")
  23. fmt.Println("phone", phone)
  24. var tempphone string
  25. tempphone = "13318464642"
  26. sign := service.GetSignNameByPhone(tempphone)
  27. this.ServeSuccessJSON(map[string]interface{}{
  28. "sign": sign,
  29. })
  30. return
  31. }
  32. type Result2121 struct {
  33. Phone string `json:"phone"`
  34. DisPlayName string `json:"dis_play_name"`
  35. Authentication string `json:"authentication"`
  36. TwAuthReq struct {
  37. OneLineAuth string `json:"oneLineAuth"`
  38. ApiAuthReq struct {
  39. RealName float64 `json:"real_name"`
  40. IdCardType string `json:"id_card_type"`
  41. IdCardNum string `json:"id_card_num"`
  42. BankCard string `json:"bank_card"`
  43. CodeNumber string `json:"code_number"`
  44. VerifyCode string `json:"verify_code"`
  45. } `json:"apiAuthReq"`
  46. } `json:"twAuthReq"`
  47. }
  48. type MapData struct {
  49. dat struct {
  50. Code float64 `json:"code"`
  51. data struct {
  52. userId string `json:"userId"`
  53. }
  54. }
  55. }
  56. // 创建个人用户并实名
  57. func (this *SignApiController) CreateUserName() {
  58. phone := this.GetString("phone")
  59. disPlayName := this.GetString("disPlayName")
  60. sign, userId := service.CreateUserName(phone, disPlayName)
  61. var dat map[string]interface{}
  62. if err := json.Unmarshal([]byte(sign), &dat); err == nil {
  63. fmt.Println(dat)
  64. } else {
  65. fmt.Println(err)
  66. }
  67. this.ServeSuccessJSON(map[string]interface{}{
  68. "sign": sign,
  69. "dat": dat,
  70. "userId": userId,
  71. })
  72. return
  73. }
  74. // 创建个人印章
  75. func (this *SignApiController) CreatePersionSeal() {
  76. user_id := this.GetString("user_id")
  77. person_seal_type, _ := this.GetInt64("person_seal_type")
  78. person_seal_name := this.GetString("person_seal_name")
  79. person_seal_base := this.GetString("person_seal_base")
  80. color, _ := this.GetInt64("color")
  81. alpha, _ := this.GetInt64("alpha")
  82. width, _ := this.GetInt64("width")
  83. height, _ := this.GetInt64("height")
  84. border, _ := this.GetInt64("border")
  85. font_type, _ := this.GetInt64("font_type")
  86. sign, personSealId := service.CreatePersionSeal(user_id, person_seal_type, person_seal_name, person_seal_base, color, alpha, width, height, border, font_type)
  87. var dat map[string]interface{}
  88. if err := json.Unmarshal([]byte(sign), &dat); err == nil {
  89. fmt.Println(dat)
  90. } else {
  91. fmt.Println(err)
  92. }
  93. this.ServeSuccessJSON(map[string]interface{}{
  94. "sign": sign,
  95. "dat": dat,
  96. "personSealId": personSealId,
  97. })
  98. return
  99. }