diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..dd97961 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/ras-backend.iml b/.idea/ras-backend.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/ras-backend.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/company/admin.HR.go b/company/admin.HR.go index a258642..a985c4c 100644 --- a/company/admin.HR.go +++ b/company/admin.HR.go @@ -66,3 +66,22 @@ func addHRHandler(ctx *gin.Context) { ctx.JSON(http.StatusOK, gin.H{"status": "Successfully added"}) } + +func getInactiveHRsHandler(ctx *gin.Context) { + var HR []CompanyHR + + cid, err := strconv.ParseUint(ctx.Param("cid"), 10, 32) + if err != nil { + ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + err = getInactiveHR(ctx, uint(cid), &HR) + + if err != nil { + ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + ctx.JSON(http.StatusOK, HR) +} diff --git a/company/db.hr.go b/company/db.hr.go index bdb7739..4253d01 100644 --- a/company/db.hr.go +++ b/company/db.hr.go @@ -3,7 +3,7 @@ package company import "github.com/gin-gonic/gin" func getAllHRUserDB(ctx *gin.Context, HRs *[]CompanyHR) error { - tx := db.WithContext(ctx).Select("ID","CreatedAt","UpdatedAt","DeletedAt","Name","Email","Phone").Find(HRs) + tx := db.WithContext(ctx).Select("ID", "CreatedAt", "UpdatedAt", "DeletedAt", "Name", "Email", "Phone").Find(HRs) return tx.Error } @@ -17,6 +17,11 @@ func addHR(ctx *gin.Context, HR *CompanyHR) error { return tx.Error } +func getInactiveHR(ctx *gin.Context, cid uint, HR *[]CompanyHR) error { + tx := db.WithContext(ctx).Unscoped().Where("company_id = ?", cid).Find(HR) + return tx.Error +} + func deleteHR(ctx *gin.Context, id uint) error { tx := db.WithContext(ctx).Delete(&CompanyHR{}, "id = ?", id) return tx.Error diff --git a/company/model.go b/company/model.go index 885c29e..483a7d3 100644 --- a/company/model.go +++ b/company/model.go @@ -12,6 +12,7 @@ type Company struct { type CompanyHR struct { gorm.Model + DeletedAt gorm.DeletedAt CompanyID uint `json:"company_id"` Company Company `gorm:"foreignkey:CompanyID" json:"-"` Name string `json:"name"` diff --git a/company/router.go b/company/router.go index 9994c4c..e1ca7e5 100644 --- a/company/router.go +++ b/company/router.go @@ -27,6 +27,7 @@ func AdminRouter(r *gin.Engine) { admin.GET("/:cid/history", ras.PlaceHolderController) admin.PUT("/:cid/history/:hid", ras.PlaceHolderController) admin.DELETE("/:cid/history/:hid", ras.PlaceHolderController) + admin.GET("/:cid/inactive-hrs", getInactiveHRsHandler) } } diff --git a/container/Dockerfile b/container/Dockerfile index 425a560..17ae0f1 100644 --- a/container/Dockerfile +++ b/container/Dockerfile @@ -17,7 +17,7 @@ RUN go mod download && go mod verify COPY . . -RUN cp $GOPATH/src/github.com/spo-iitk/ras-backend/secret.yml.template $GOPATH/src/github.com/spo-iitk/ras-backend/secret.yml +#RUN #cp $GOPATH/src/github.com/spo-iitk/ras-backend/secret.yml.template $GOPATH/src/github.com/spo-iitk/ras-backend/secret.yml # Configure nginx RUN rm /etc/nginx/sites-enabled/default diff --git a/docker-compose.yml b/docker-compose.yml index a042957..41c0a73 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,7 +22,7 @@ services: networks: - default ports: - - "80" + - "80:80" volumes: - ./:/go/src/github.com/spo-iitk/ras-backend privileged: true