golang基于控制台的增删改查系统

客户结构体

package model

import "fmt"

//客户结构体
type Customer struct {
   
	Id int
	Name string
	Gender string
	Age int
	Phone string
	Email string
}

//工厂模式创建
func NewCustomer(id int,name string,gender string,age int,phone string,email string) Customer {
   
	return Customer{
   
		id,
		name,
		gender,
		age,
		phone,
		email,
	}
}
//工厂模式创建,不带id
func NewCustomer2(name string,gender string,age int,phone string,email string) Customer {
   
	return Customer{
   
		Name:name,
		Gender: gender,
		Age: age,
		Phone: phone,
		Email: email,
	}
}
//tosTring()
func (this Customer)GetInfo() string  {
   
	info := fmt.Sprintln(this.Id,this.Name,this.Gender,this.Age, this.Phone,this.Email)
	return info

}

客户管理结构体以及操作方法

package service

import "客户信息管理系统/src/model"

type CustomerService struct {
   
	customers []model.Customer
	customerNum int
}

func (this *CustomerService) List() []model.Customer {
   
	return this.customers
}
//初始化
func NewCustomerService() *CustomerService  {
   
	customerService := &CustomerService{
   }
	customerService.customerNum = 1
	customer := model.<

你可能感兴趣的:(golang,go,golang)