utils.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package guangzuan
  2. import (
  3. "mtp2_if/global/app"
  4. "mtp2_if/global/e"
  5. "mtp2_if/logger"
  6. "mtp2_if/models"
  7. "net/http"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // PriceCalc
  11. // @Summary 钻石价格计算器
  12. // @Produce json
  13. // @Security ApiKeyAuth
  14. // @Security LoginID
  15. // @Security Group
  16. // @Param zsshape query int true "形状 - 1:BR(圆形) 2:PS(异形)"
  17. // @Param zscolor query string true "颜色(D-M)"
  18. // @Param zsclarity query string true "净度"
  19. // @Param weight query float64 true "重量"
  20. // @Param rate query float64 true "汇率"
  21. // @Param discount query float64 false "折扣(%), 方向(加:10, 减:-10 )"
  22. // @Success 200 {array} models.Gzrapaportprice
  23. // @Failure 500 {object} app.Response
  24. // @Router /Guangzuan/PriceCalc [get]
  25. // @Tags 广钻
  26. func PriceCalc(c *gin.Context) {
  27. a := app.GinUtils{Gin: app.Gin{C: c}}
  28. m := models.Gzrapaportprice{}
  29. a.DoBindReq(&m)
  30. a.DoGetDataI(&m)
  31. }
  32. // GzCertAddressConfig
  33. // @Summary Rapaport最新报价表(广钻)
  34. // @Produce json
  35. // @Security ApiKeyAuth
  36. // @Security LoginID
  37. // @Security Group
  38. // @Success 200 {array} models.Gzcertaddressconfig
  39. // @Failure 500 {object} app.Response
  40. // @Router /Guangzuan/GzCertAddressConfig [get]
  41. // @Tags 广钻
  42. func GzCertAddressConfig(c *gin.Context) {
  43. a := app.GinUtils{Gin: app.Gin{C: c}}
  44. m := models.Gzcertaddressconfig{}
  45. if d, err := m.GetAll(); err == nil {
  46. a.Gin.Response(http.StatusOK, e.SUCCESS, d)
  47. } else {
  48. logger.GetLogger().Errorf("query fail, %v", err)
  49. a.Gin.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  50. }
  51. }
  52. // GzCertAddressParam
  53. // @Summary 钻石证书地址参数
  54. // @Produce json
  55. // @Security ApiKeyAuth
  56. // @Security LoginID
  57. // @Security Group
  58. // @Success 200 {array} models.Gzcertaddressparam
  59. // @Failure 500 {object} app.Response
  60. // @Router /Guangzuan/GzCertAddressParam [get]
  61. // @Tags 广钻
  62. func GzCertAddressParam(c *gin.Context) {
  63. a := app.GinUtils{Gin: app.Gin{C: c}}
  64. m := models.Gzcertaddressparam{}
  65. if d, err := m.GetAll(); err == nil {
  66. a.Gin.Response(http.StatusOK, e.SUCCESS, d)
  67. } else {
  68. logger.GetLogger().Errorf("query fail, %v", err)
  69. a.Gin.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  70. }
  71. }