12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package db
- import (
- "context"
- "youngee_b_api/model/gorm_model"
- )
- // CreateJob 新建岗位
- func CreateJob(ctx context.Context, job gorm_model.YounggeeJob) error {
- db := GetWriteDB(ctx)
- err := db.Create(&job).Error
- if err != nil {
- return err
- }
- return nil
- }
- // UpdateJob 更新岗位
- func UpdateJob(ctx context.Context, job gorm_model.YounggeeJob) error {
- db := GetWriteDB(ctx)
- whereCondition := gorm_model.YounggeeJob{JobId: job.JobId}
- err := db.Model(&gorm_model.YounggeeJob{}).Where(whereCondition).Updates(job).Error
- if err != nil {
- return err
- }
- return nil
- }
- // DeleteJob 删除岗位
- func DeleteJob(ctx context.Context, job gorm_model.YounggeeJob) error {
- db := GetWriteDB(ctx)
- whereCondition := gorm_model.YounggeeJob{JobId: job.JobId}
- err := db.Where(whereCondition).Delete(&gorm_model.YounggeeJob{}).Error
- if err != nil {
- return err
- }
- return nil
- }
- // FindJobByEnterpriseId 按商家ID查找岗位信息
- func FindJobByEnterpriseId(ctx context.Context, job gorm_model.YounggeeJob) ([]*gorm_model.YounggeeJob, error) {
- db := GetReadDB(ctx)
- var Jobs []*gorm_model.YounggeeJob
- whereCondition := gorm_model.YounggeeJob{EnterpriseId: job.EnterpriseId}
- err := db.Model(gorm_model.YounggeeJob{}).Where(whereCondition).Find(&Jobs).Error
- if err != nil {
- return nil, err
- }
- return Jobs, nil
- }
- // FindJobByJobId 按照岗位Id查找岗位信息
- func FindJobByJobId(ctx context.Context, jobId int) (*gorm_model.YounggeeJob, error) {
- db := GetReadDB(ctx)
- var Job *gorm_model.YounggeeJob
- whereCondition := gorm_model.YounggeeJob{JobId: jobId}
- err := db.Model(gorm_model.YounggeeJob{}).Where(whereCondition).Find(&Job).Error
- if err != nil {
- return nil, err
- }
- return Job, nil
- }
- /*
- func GetRewardStrategyBySelectionId(ctx context.Context, SelectionId string) ([]*gorm_model.RewardStrategy, error) {
- db := GetReadDB(ctx)
- var RewardStrategys []*gorm_model.RewardStrategy
- err := db.Model(gorm_model.RewardStrategy{}).Where("selection_id = ?", SelectionId).Find(&RewardStrategys).Error
- if err != nil {
- logrus.WithContext(ctx).Errorf("[GetRewardStrategyBySelectionId] error query, err:%+v", err)
- return nil, err
- }
- return RewardStrategys, nil
- }
- */
|