cert.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package controllers
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "lzyd-user-api/common"
  5. "lzyd-user-api/models"
  6. "lzyd-user-api/services"
  7. )
  8. // @tags cert
  9. // @Description 获取证书列表
  10. // @Summary 获取证书列表
  11. // @Produce json
  12. // @Param type query string false "类型:传1"
  13. // @Success 200 {string} json "{"code":200,"message":"success","data":{"token":"","customer":{"id":"","code":"","name":""}}}"
  14. // @Router /cert/list [get]
  15. func GetCertList(c *gin.Context) {
  16. Ctype := c.Query("type")
  17. var (
  18. code = common.Success
  19. )
  20. if len(Ctype) == 1 {
  21. var (
  22. model []models.LzydCert
  23. )
  24. model = services.QueryCertList(common.DB, Ctype)
  25. common.GenResp(c, code, "SUCCESS", model)
  26. return
  27. }
  28. }
  29. // @tags cert
  30. // @Description 获取用户获得证书列表
  31. // @Summary 获取用户获得证书列表
  32. // @Produce json
  33. // @Param userId query string false "用户id"
  34. // @Success 200 {string} json "{"code":200,"message":"success","data":{"token":"","customer":{"id":"","code":"","name":""}}}"
  35. // @Router /cert/userList [get]
  36. func GetUserCertList(c *gin.Context) {
  37. userId := c.Query("userId")
  38. var (
  39. code = common.Success
  40. )
  41. if len(userId) > 1 {
  42. var (
  43. model []models.LzydCertUser
  44. )
  45. model = services.QueryUserCertList(userId)
  46. common.GenResp(c, code, "SUCCESS", model)
  47. return
  48. }
  49. }