company.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package controller
  2. import (
  3. "crawler/model"
  4. "net/http"
  5. "github.com/gin-gonic/gin"
  6. )
  7. type Company struct {
  8. Kobis model.Kobis
  9. }
  10. /**
  11. * 영화사 목록 조회
  12. * /company/searchCompanyList
  13. */
  14. func (this *Company) SearchCompanyList(c *gin.Context) {
  15. var req model.SearchCompanyListParams
  16. if err := c.ShouldBind(&req); err != nil {
  17. c.JSON(http.StatusBadRequest, err.Error())
  18. return
  19. }
  20. data, err := this.Kobis.CompanyListAPI(req)
  21. if err != nil {
  22. c.JSON(http.StatusBadRequest, err.Error())
  23. return
  24. }
  25. c.JSON(http.StatusOK, gin.H{
  26. "total": data.CompanyListResult.TotCnt,
  27. "rows": len(data.CompanyListResult.CompanyList),
  28. "list": data.CompanyListResult.CompanyList,
  29. })
  30. }
  31. /**
  32. * 영화사 상세 조회
  33. * /company/searchCompanyInfo
  34. */
  35. func (this *Company) SearchCompanyInfo(c *gin.Context) {
  36. var req model.SearchCompanyInfoParams
  37. if err := c.ShouldBind(&req); err != nil {
  38. c.JSON(http.StatusBadRequest, err.Error())
  39. return
  40. }
  41. data, err := this.Kobis.CompanyInfoAPI(req)
  42. if err != nil {
  43. c.JSON(http.StatusBadRequest, err.Error())
  44. return
  45. }
  46. c.JSON(http.StatusOK, gin.H{
  47. "info": data.CompanyInfoResult.CompanyInfo,
  48. })
  49. }