27 lines
436 B
Go
27 lines
436 B
Go
package plan_repository
|
|
|
|
import (
|
|
"netina/models"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type PlanQuery interface{
|
|
GetPlan(id uint)(*models.Plan , error)
|
|
}
|
|
|
|
type PlanQueryRepository struct{
|
|
DB *gorm.DB
|
|
}
|
|
|
|
|
|
func (r *PlanQueryRepository) GetPlan(id uint)(*models.Plan , error){
|
|
var Plan models.Plan
|
|
if err := r.DB.Where("is_removed = ?" , false).Where("plan_id = ?" , id).First(&Plan).Error; err != nil {
|
|
return nil , err
|
|
}
|
|
|
|
return &Plan , nil
|
|
}
|
|
|