Update Partner License
This commit is contained in:
parent
6c912a1021
commit
04a5217400
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LicenseRepository struct {
|
type LicenseRepository struct {
|
||||||
@ -100,8 +101,12 @@ func (r *LicenseRepository) GetAll(ctx context.Context, limit, offset int, statu
|
|||||||
|
|
||||||
func (r *LicenseRepository) FindByPartnerIDMaxEndDate(ctx context.Context, partnerID *int64) (*entity.LicenseDB, error) {
|
func (r *LicenseRepository) FindByPartnerIDMaxEndDate(ctx context.Context, partnerID *int64) (*entity.LicenseDB, error) {
|
||||||
var licenseDB entity.LicenseDB
|
var licenseDB entity.LicenseDB
|
||||||
|
|
||||||
|
today := time.Now().Format("2006-01-02")
|
||||||
|
|
||||||
if err := r.db.WithContext(ctx).
|
if err := r.db.WithContext(ctx).
|
||||||
Where("partner_id = ?", partnerID).
|
Where("partner_id = ?", partnerID).
|
||||||
|
Where("start_date >= ?", today).
|
||||||
Order("end_date DESC").
|
Order("end_date DESC").
|
||||||
First(&licenseDB).Error; err != nil {
|
First(&licenseDB).Error; err != nil {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user