job.go 883 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package db
  2. import (
  3. "context"
  4. "youngee_b_api/model/gorm_model"
  5. )
  6. // CreateJob 新建岗位
  7. func CreateJob(ctx context.Context, job gorm_model.YounggeeJob) error {
  8. db := GetWriteDB(ctx)
  9. err := db.Create(&job).Error
  10. if err != nil {
  11. return err
  12. }
  13. return nil
  14. }
  15. // UpdateJob 更新岗位
  16. func UpdateJob(ctx context.Context, job gorm_model.YounggeeJob) error {
  17. db := GetWriteDB(ctx)
  18. whereCondition := gorm_model.YounggeeJob{JobId: job.JobId}
  19. err := db.Model(&gorm_model.YounggeeJob{}).Where(whereCondition).Updates(job).Error
  20. if err != nil {
  21. return err
  22. }
  23. return nil
  24. }
  25. // DeleteJob 删除岗位
  26. func DeleteJob(ctx context.Context, job gorm_model.YounggeeJob) error {
  27. db := GetWriteDB(ctx)
  28. whereCondition := gorm_model.YounggeeJob{JobId: job.JobId}
  29. err := db.Where(whereCondition).Delete(&gorm_model.YounggeeJob{}).Error
  30. if err != nil {
  31. return err
  32. }
  33. return nil
  34. }