job.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. }
  35. // FindJobByEnterpriseId 按商家ID查找岗位信息
  36. func FindJobByEnterpriseId(ctx context.Context, job gorm_model.YounggeeJob) ([]*gorm_model.YounggeeJob, error) {
  37. db := GetReadDB(ctx)
  38. var Jobs []*gorm_model.YounggeeJob
  39. whereCondition := gorm_model.YounggeeJob{EnterpriseId: job.EnterpriseId}
  40. err := db.Model(gorm_model.YounggeeJob{}).Where(whereCondition).Find(&Jobs).Error
  41. if err != nil {
  42. return nil, err
  43. }
  44. return Jobs, nil
  45. }
  46. // FindJobByJobId 按照岗位Id查找岗位信息
  47. func FindJobByJobId(ctx context.Context, jobId int) (*gorm_model.YounggeeJob, error) {
  48. db := GetReadDB(ctx)
  49. var Job *gorm_model.YounggeeJob
  50. whereCondition := gorm_model.YounggeeJob{JobId: jobId}
  51. err := db.Model(gorm_model.YounggeeJob{}).Where(whereCondition).Find(&Job).Error
  52. if err != nil {
  53. return nil, err
  54. }
  55. return Job, nil
  56. }
  57. /*
  58. func GetRewardStrategyBySelectionId(ctx context.Context, SelectionId string) ([]*gorm_model.RewardStrategy, error) {
  59. db := GetReadDB(ctx)
  60. var RewardStrategys []*gorm_model.RewardStrategy
  61. err := db.Model(gorm_model.RewardStrategy{}).Where("selection_id = ?", SelectionId).Find(&RewardStrategys).Error
  62. if err != nil {
  63. logrus.WithContext(ctx).Errorf("[GetRewardStrategyBySelectionId] error query, err:%+v", err)
  64. return nil, err
  65. }
  66. return RewardStrategys, nil
  67. }
  68. */