12345678910111213141516171819202122232425262728293031 |
- package db
- import (
- "context"
- "gorm.io/gorm"
- "youngee_b_api/model/gorm_model"
- )
- //实物邮寄
- func CreateLogistics(ctx context.Context, logistics gorm_model.YoungeeTaskLogistics, RecruitStrategyID int64) (*int64, error) {
- db := GetReadDB(ctx)
- err := db.Create(&logistics).Error
- err1 := db.Model(gorm_model.RecruitStrategy{}).Where("recruit_strategy_id = ?", RecruitStrategyID).Updates(map[string]interface{}{"delivered_number": gorm.Expr("delivered_number + ?", 1), "waiting_number": gorm.Expr("waiting_number - ?", 1)}).Error
- if err != nil {
- return nil, err
- }
- if err1 != nil {
- return nil, err1
- }
- return &logistics.LogisticsID, nil
- }
- //修改接口
- func UpdateLogistics(ctx context.Context, logistics gorm_model.YoungeeTaskLogistics) (*int64, error) {
- db := GetReadDB(ctx)
- err := db.Model(&logistics).Updates(logistics).Error
- if err != nil {
- return nil, err
- }
- return &logistics.LogisticsID, nil
- }
|