下面是一个简要的客服系统,主要是演示分层计。。
model : 数据部份:
package model import "fmt" //声明一个结构体,表示一个客户信息 type Customer struct{ Id int Name string Gender string Age int Phone string Emaill string } func NewCustomer(id int,name string, gender string, age int, phone string,email string) Customer{ return Customer{ Id : id, Name : name, Gender : gender, Age : age, Phone:phone, } } func NewCustomer2(name string, gender string, age int, phone string,email string) Customer{ return Customer{ Name : name, Gender : gender, Age : age, Phone:phone, } } func (this Customer) GetInfo() string{ info := fmt.Sprintf("%v\t%v\t%v\t%v\t%v\t%v\t",this.Id, this.Name,this.Gender,this.Age,this.Phone,this.Emaill) return info }