File size: 788 Bytes
f71a293
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package services

import (
	"time"

	"pweb-api.abdanhafidz.com/models"
)

type (
	Services interface {
		Retrieve()
		Update()
		Create()
		Delete()
		Validate()
		Authenticate()
		Authorize()
	}
	IService interface {
		Implements()
	}
	Service[TConstructor any, TResult any] struct {
		Constructor TConstructor
		Result      TResult
		Exception   models.Exception
		Error       error
	}
)

func Construct[TConstructor any, TResult any](constructor ...TConstructor) *Service[TConstructor, TResult] {
	if len(constructor) == 1 {
		return &Service[TConstructor, TResult]{}
	}

	return &Service[TConstructor, TResult]{
		Constructor: constructor[0],
	}
}

func CalculateDueTime(duration time.Duration) time.Time {
	return time.Now().Add(duration)
}