-
Notifications
You must be signed in to change notification settings - Fork 17
/
db.hr.go
29 lines (23 loc) · 863 Bytes
/
db.hr.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package company
import "github.com/gin-gonic/gin"
func getAllHR(ctx *gin.Context, HRs *[]CompanyHR, cid uint) error {
tx := db.WithContext(ctx).Where("company_id = ?", cid).Find(HRs)
return tx.Error
}
func addHR(ctx *gin.Context, HR *CompanyHR) error {
tx := db.WithContext(ctx).Create(HR)
return tx.Error
}
func deleteHR(ctx *gin.Context, id uint) error {
tx := db.WithContext(ctx).Delete(&CompanyHR{}, "id = ?", id)
return tx.Error
}
// func updateHR(ctx *gin.Context, cid uint, hrid string, req *updateHRRequest) error {
// tx := db.WithContext(ctx).Model(&CompanyHR{}).Where("company_id = ? AND email = ?", cid, hrid).Updates(req)
// return tx.Error
// }
func FetchCompanyIDByEmail(ctx *gin.Context, email string) (uint, error) {
var hr CompanyHR
tx := db.WithContext(ctx).Where("email = ?", email).First(&hr)
return hr.CompanyID, tx.Error
}