test.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package tencent
  2. import (
  3. SysConfig "mtp2_if/config"
  4. "mtp2_if/global/app"
  5. "mtp2_if/global/e"
  6. "mtp2_if/logger"
  7. "mtp2_if/services/tencent"
  8. "mtp2_if/utils"
  9. "net/http"
  10. "github.com/gin-gonic/gin"
  11. )
  12. // CreateConsoleLoginUrl 创建电子签控制台登录链接
  13. // @Summary 创建电子签控制台登录链接
  14. // @Produce json
  15. // @Security ApiKeyAuth
  16. // @accept application/json
  17. // @Success 200 {object} app.Response
  18. // @Failure 500 {object} app.Response
  19. // @Router /Tencent/CreateConsoleLoginUrl [post]
  20. // @Tags 腾讯电子签
  21. func CreateConsoleLoginUrl(c *gin.Context) {
  22. appG := app.Gin{C: c}
  23. agent := utils.SetAgent()
  24. proxyOrganizationName := SysConfig.SerCfg.TencentCfg.ProxyOrganizationName
  25. response, _ := tencent.CreateConsoleLoginUrl(agent, proxyOrganizationName)
  26. appG.Response(http.StatusOK, e.SUCCESS, *response.Response.ConsoleUrl)
  27. }
  28. type GetTemplateInfoReq struct {
  29. ContractName string `form:"contractName" binding:"required"` // 合同模块名称
  30. }
  31. // GetTemplateInfo 获取合同模板信息(测试)
  32. // @Summary 获取合同模板信息(测试)
  33. // @Produce json
  34. // @Security ApiKeyAuth
  35. // @accept application/json
  36. // @Param contractName query string true "合同模块名称"
  37. // @Success 200 {object} app.Response
  38. // @Failure 500 {object} app.Response
  39. // @Router /Tencent/GetTemplateInfo [get]
  40. // @Tags 腾讯电子签
  41. func GetTemplateInfo(c *gin.Context) {
  42. appG := app.Gin{C: c}
  43. // 获取请求参数
  44. var req GetTemplateInfoReq
  45. if err := appG.C.ShouldBindQuery(&req); err != nil {
  46. logger.GetLogger().Errorf("GetTemplateInfo failed: %s", err.Error())
  47. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  48. return
  49. }
  50. if rsp, err := tencent.GetTemplateInfo(&req.ContractName); err == nil {
  51. appG.Response(http.StatusOK, e.SUCCESS, rsp)
  52. } else {
  53. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  54. }
  55. }