Skip to content

Commit

Permalink
Create API to fetch career page images and show them on career page
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-jagruti-a committed Nov 6, 2023
1 parent b388e94 commit be42953
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 9 deletions.
68 changes: 68 additions & 0 deletions api-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,71 @@
- Headers : none
- Message : Acceptence mail has been sent successfully
```

### 9. Get Career Page LifeatCanopas Section Images

```
- Method : GET
- Endpoint : /api/lifeimages
- Description : API for get images of lifeat canopas section of career page
- Request:
- Headers : none
- Body : none
- Response :
- If API is not found or image data not found then,
- Status Code: 404 not found
- Data: no response data
- If any server error is there then,
- Status Code: 500 Internal server error
- Data: no response data
- If request will success ,
- Status Code: 200 Ok
- Headers : none
- Data :
[
{
"id": 1,
"image_urls": "https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-400.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-800.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-1600.webp",
"index": 0
},
]
```

### 10. Get Career Page Perks and Benefit Section Images

```
- Method : GET
- Endpoint : /api/perksimages
- Description : API for get images of perks and benefit section of career page
- Request:
- Headers : none
- Body : none
- Response :
- If API is not found or image data not found then,
- Status Code: 404 not found
- Data: no response data
- If any server error is there then,
- Status Code: 500 Internal server error
- Data: no response data
- If request will success ,
- Status Code: 200 Ok
- Headers : none
- Data :
[
{
"id": 1,
"image_urls": "https://canopas-website.s3.ap-south-1.amazonaws.com/perksBenefits/1-400.webp,https://canopas-website.s3.ap-south-1.amazonaws.com//perksBenefits/1-800.webp",
"index": 0
},
]
```
6 changes: 3 additions & 3 deletions jobs/life_perks_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

type LifePerksImages struct {
Id int `json:"id"`
ImageUrls string `json:"imageUrls"`
ImageUrls string `json:"image_urls"`
Index int `json:"index"`
}

Expand All @@ -25,7 +25,7 @@ func NewLifePerksImages(db *sqlx.DB) *LifeandPerksRepository {

func (repository *LifeandPerksRepository) LifeImages(c *gin.Context) {
lifeImages := []LifePerksImages{}
err := repository.Db.Select(&lifeImages, "SELECT l.id, l.imageUrls, l.index FROM lifeatcanopas l")
err := repository.Db.Select(&lifeImages, "SELECT l.id, l.image_urls, l.index FROM lifeatcanopas l")
if err != nil {
log.Error(err)
c.AbortWithStatus(http.StatusInternalServerError)
Expand All @@ -36,7 +36,7 @@ func (repository *LifeandPerksRepository) LifeImages(c *gin.Context) {

func (repository *LifeandPerksRepository) PerksImages(c *gin.Context) {
perksImages := []LifePerksImages{}
err := repository.Db.Select(&perksImages, "SELECT p.id, p.imageUrls, p.index FROM perks p")
err := repository.Db.Select(&perksImages, "SELECT p.id, p.image_urls, p.index FROM perks p")
if err != nil {
log.Error(err)
c.AbortWithStatus(http.StatusInternalServerError)
Expand Down
4 changes: 2 additions & 2 deletions jobs/life_perks_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ func TestGetAllPerksImages(t *testing.T) {
func expectedLifeImages() map[string]interface{} {
lifeImages := make(map[string]interface{})
lifeImages["id"] = 1.0
lifeImages["imageUrls"] = "https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-400.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-800.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-1600.webp"
lifeImages["image_urls"] = "https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-400.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-800.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-1600.webp"
lifeImages["index"] = 0.0
return lifeImages
}
func expectedPerkImages() map[string]interface{} {
perkImages := make(map[string]interface{})
perkImages["id"] = 1.0
perkImages["imageUrls"] = "https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-400.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-800.webp"
perkImages["image_urls"] = "https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-400.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-800.webp"
perkImages["index"] = 0.0
return perkImages
}
8 changes: 4 additions & 4 deletions utils/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ func CreateTables(db *sqlx.DB) error {
_, err = db.Exec(jobsIcons)


lifeatCanopas := "CREATE TABLE lifeatcanopas (id SERIAL PRIMARY KEY, imageUrls varchar, index int4 NOT NULL DEFAULT 0, created_at timestamptz DEFAULT CURRENT_TIMESTAMP,updated_at timestamptz DEFAULT CURRENT_TIMESTAMP)"
lifeatCanopas := "CREATE TABLE lifeatcanopas (id SERIAL PRIMARY KEY, image_urls varchar, index int4 NOT NULL DEFAULT 0, created_at timestamptz DEFAULT CURRENT_TIMESTAMP,updated_at timestamptz DEFAULT CURRENT_TIMESTAMP)"

_, err = db.Exec(lifeatCanopas)

if err != nil {
return err
}

perkImages := "CREATE TABLE perks (id SERIAL PRIMARY KEY, imageUrls varchar, index int4 NOT NULL DEFAULT 0, created_at timestamptz DEFAULT CURRENT_TIMESTAMP,updated_at timestamptz DEFAULT CURRENT_TIMESTAMP)"
perkImages := "CREATE TABLE perks (id SERIAL PRIMARY KEY, image_urls varchar, index int4 NOT NULL DEFAULT 0, created_at timestamptz DEFAULT CURRENT_TIMESTAMP,updated_at timestamptz DEFAULT CURRENT_TIMESTAMP)"

_, err = db.Exec(perkImages)

Expand All @@ -142,8 +142,8 @@ func PrepareTablesData(db *sqlx.DB) {
db.MustExec("INSERT INTO job_applications(id, name, email, phone, place,reference, resumeURL, position, message, status, created_at, updated_at) VALUES(1, 'New Web Developer', '[email protected]', '1234567890', 'surat', 'From canopas', '', 'Web Developer from testing', 'I m a very good programer', '1',current_timestamp, current_timestamp)")
db.MustExec("INSERT INTO job_applicant_statuses(id, applicant_id, status, index, rejection_with_mail, created_at, updated_at) VALUES(1, 1, 1, 0, false, current_timestamp,current_timestamp )")
db.MustExec("INSERT INTO job_icons (id,name,value,createdAt,updatedAt) VALUES ('1','iOS','fab fa-apple',NULL,NULL);")
db.MustExec("INSERT INTO lifeatcanopas (id,imageUrls,created_at,updated_at) VALUES(1,'https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-400.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-800.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-1600.webp',current_timestamp, current_timestamp)")
db.MustExec("INSERT INTO perks (id,imageUrls,created_at,updated_at) VALUES(1,'https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-400.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-800.webp',current_timestamp, current_timestamp)")
db.MustExec("INSERT INTO lifeatcanopas (id,image_urls,created_at,updated_at) VALUES(1,'https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-400.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-800.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-1600.webp',current_timestamp, current_timestamp)")
db.MustExec("INSERT INTO perks (id,image_urls,created_at,updated_at) VALUES(1,'https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-400.webp,https://canopas-website.s3.ap-south-1.amazonaws.com/lifeCanopas/1-800.webp',current_timestamp, current_timestamp)")
}

func PrepareTextFileFormData() (string, *bytes.Buffer) {
Expand Down

0 comments on commit be42953

Please sign in to comment.