/
account.go
executable file
·84 lines (75 loc) · 1.65 KB
/
account.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package models
import (
"web/models/db"
"web/models/entities"
"time"
)
type Account struct {
Name string
Email string
Phone string
Password string
Type string
Date time.Time
}
// Account Main Function
func (b Account) Account() Account{
acc := Account{}
acc = GetAccount("dada")
return acc
}
// Modify Account - old and new changes
func ModifyAccount(oldAcc *entities.Account, newAcc entities.Account){
if newAcc.Email != ""{
oldAcc.Email = newAcc.Email
}
if newAcc.Phone != ""{
oldAcc.Phone = newAcc.Phone
}
if newAcc.Type != ""{
oldAcc.Type = newAcc.Type
}
if newAcc.Password != ""{
oldAcc.Password = newAcc.Password
}
}
// Account to Entities Account
func AccToEnt(account Account) entities.Account{
a:= entities.Account{}
a.Name = account.Name
a.Email = account.Email
a.Phone = account.Phone
a.Password = account.Password
a.Type = account.Type
a.Date = account.Date
return a
}
// Additional Account
func AddAccount(acc entities.Account){
a := db.Account{acc.Name,acc.Email,acc.Phone,acc.Password,acc.Type,acc.Date}
a.AddAccount()
}
// Update Account
func UpdAccount(acc entities.Account){
a := db.Account{acc.Name,acc.Email,acc.Phone,acc.Password,acc.Type,acc.Date}
a.UpdateAccount()
}
// Delete Account
func DelAccount(acc entities.Account){
a := db.Account{acc.Name,acc.Email,acc.Phone,acc.Password,acc.Type,acc.Date}
a.DeleteAccount()
}
// Retrieve Account
func GetAccount(name string) Account{
b := db.Account{}
a := db.Account{}
b = a.GetAccount(name)
c := Account{}
c.Name = b.Name
c.Email = b.Email
c.Phone = b.Phone
c.Type = b.Type
c.Password = b.Password
c.Date = b.Date
return c
}