博客
关于我
Golang项目:客户信息管理系统(附源码) (Golang经典编程案例)
阅读量:733 次
发布时间:2019-03-22

本文共 5098 字,大约阅读时间需要 16 分钟。

《客户关系管理软件》项目文档

1. 项目需求分析

本项目旨在开发并实现一个基于文本界面的客户关系管理软件(CRM)。系统将支持客户信息的增删改查,并提供详细的客户信息查询功能。

功能需求

  • 客户信息存储:系统需支持存储客户的基本信息,包括但不限于姓名、性别、年龄、电话号码和电子邮件地址。
  • 信息操作
    • 添加客户:支持新建客户信息,并自动分配唯一的客户编号。
    • 修改客户:允许用户对已有客户信息进行修改。
    • 删除客户:用户可选择删除单个客户,系统需确认操作并提供回退选项。
  • 信息查询:提供客户列表功能,用户可按编号、姓名或其他字段进行筛选和排序。

2. 项目界面设计

系统界面分为主界面和功能操作界面设计,具体如下:

主界面

展示系统名称及功能菜单,用户可通过输入选择不同的操作。

功能操作界面

分为添加客户、修改客户、删除客户和客户列表四个主要界面,分别对应不同的操作流程。

客户列表界面

显示所有客户信息,用户可进行筛选和排序,支持查看单个客户详情。

3. 系统程序框架图

系统采用MVC模式设计,包含以下主要模块:

  • 模型(Model):定义客户数据结构及相关操作。
  • 服务(Service):实现客户数据的增删改查逻辑。
  • 视图(View):提供用户界面和数据展示功能。

4. 功能实现代码

项目结构

customerManager/
├── model/
│ ├── customer.go
│ └── customer_service.go
├── service/
│ └── customer_service.go
└── view/
└── customer_view.go

代码实现

模型层

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: id,
Name: name,
Gender: gender,
Age: age,
Phone: phone,
Email: email,
}
}
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,
}
}
func (this Customer) GetInfo() string {
return 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.Email)
}

服务层

package service
import (
"mygotest/customerManager/model"
)
type CustomerService struct {
customers []model.Customer
customerNum int
}
func NewCustomerService() *CustomerService {
service := &CustomerService{}
service.customerNum = 1
customer := model.NewCustomer(1, "张三", "男", 20, "010-56253825", "zs@sohu.com")
service.customers = append(service.customers, customer)
return service
}
func (this *CustomerService) List() []model.Customer {
return this.customers
}
func (this *CustomerService) Add(customer model.Customer) bool {
this.customerNum++
customer.Id = this.customerNum
this.customers = append(this.customers, customer)
return true
}
func (this *CustomerService) Delete(id int) bool {
index := this.FindById(id)
if index == -1 {
return false
}
this.customers = append(this.customers[:index], this.customers[index+1:]...)
return true
}
func (this *CustomerService) FindById(id int) int {
index := -1
for i := 0; i < len(this.customers); i++ {
if this.customers[i].Id == id {
index = i
}
}
return index
}

视图层

package main
import (
"fmt"
"mygotest/customerManager/model"
"mygotest/customerManager/service"
)
type customerView struct {
key string
loop bool
customerService *service.CustomerService
}
func (this *customerView) list() {
customers := this.customerService.List()
fmt.Println("---------------------------客户列表---------------------------")
fmt.Println("编号\t姓名\t性别\t年龄\t电话\t邮箱")
for i := 0; i < len(customers); i++ {
fmt.Println(customers[i].GetInfo())
}
fmt.Printf("\n-------------------------客户列表完成-------------------------\n\n")
}
func (this *customerView) add() {
fmt.Println("---------------------添加客户---------------------")
name := ""
fmt.Scanln(&name)
gender := ""
fmt.Scanln(&gender)
age := 0
fmt.Scanln(&age)
phone := ""
fmt.Scanln(&phone)
email := ""
fmt.Scanln(&email)
customer := model.NewCustomer2(name, gender, age, phone, email)
if this.customerService.Add(customer) {
fmt.Println("---------------------添加完成---------------------")
} else {
fmt.Println("---------------------添加失败---------------------")
}
}
func (this *customerView) delete() {
fmt.Println("---------------------删除客户---------------------")
id := -1
fmt.Scanln(&id)
if id == -1 {
return
}
fmt.Println("确认是否删除(Y/N):")
choice := ""
fmt.Scanln(&choice)
if choice == "y" || choice == "Y" {
if this.customerService.Delete(id) {
fmt.Println("---------------------删除完成---------------------")
} else {
fmt.Println("---------------------删除失败,输入的id号不存在----")
}
}
}
func (this *customerView) exit() {
fmt.Print("确认是否退出(Y/N):")
for {
fmt.Scanln(&this.key)
if this.key == "Y" || this.key == "y" || this.key == "N" || this.key == "n" {
break
}
fmt.Print("你的输入有误,确认是否退出(Y/N):")
}
if this.key == "Y" || this.key == "y" {
this.loop = false
}
}
func (this *customerView) mainMenu() {
for {
fmt.Println("-----------------客户信息管理软件-----------------")
fmt.Println(" 1 添 加 客 户")
fmt.Println(" 2 修 改 客 户")
fmt.Println(" 3 删 除 客 户")
fmt.Println(" 4 客 户 列 表")
fmt.Println(" 5 退 出")
fmt.Print("请选择(1-5):")
fmt.Scanln(&this.key)
switch this.key {
case "1":
this.add()
case "2":
fmt.Println("修 改 客 户")
case "3":
this.delete()
case "4":
this.list()
case "5":
this.exit()
default:
fmt.Println("你的输入有误,请重新输入...")
}
if !this.loop {
break
}
}
fmt.Println("已退出了客户关系管理系统...")
}

5. 执行结果

系统运行后,用户将看到以下界面和功能:

  • 主界面:显示操作菜单。
  • 添加客户:提示输入信息并添加新客户。
  • 修改客户:提示修改信息并更新客户资料。
  • 删除客户:确认操作并删除指定客户。
  • 客户列表:显示所有客户信息,支持筛选和排序。

通过以上设计和实现,完成了一个功能完善的客户关系管理系统,满足用户对客户信息管理的基本需求。

转载地址:http://ctkwk.baihongyu.com/

你可能感兴趣的文章
mysql中int、bigint、smallint 和 tinyint的区别、char和varchar的区别详细介绍
查看>>
mysql中json_extract的使用方法
查看>>
mysql中json_extract的使用方法
查看>>
mysql中kill掉所有锁表的进程
查看>>
mysql中like % %模糊查询
查看>>
MySql中mvcc学习记录
查看>>
mysql中null和空字符串的区别与问题!
查看>>
MySQL中ON DUPLICATE KEY UPDATE的介绍与使用、批量更新、存在即更新不存在则插入
查看>>
MYSQL中TINYINT的取值范围
查看>>
MySQL中UPDATE语句的神奇技巧,让你操作数据库如虎添翼!
查看>>
Mysql中varchar类型数字排序不对踩坑记录
查看>>
MySQL中一条SQL语句到底是如何执行的呢?
查看>>
MySQL中你必须知道的10件事,1.5万字!
查看>>
MySQL中使用IN()查询到底走不走索引?
查看>>
Mysql中使用存储过程插入decimal和时间数据递增的模拟数据
查看>>
MySql中关于geometry类型的数据_空的时候如何插入处理_需用null_空字符串插入会报错_Cannot get geometry object from dat---MySql工作笔记003
查看>>
mysql中出现Incorrect DECIMAL value: '0' for column '' at row -1错误解决方案
查看>>
mysql中出现Unit mysql.service could not be found 的解决方法
查看>>
mysql中出现update-alternatives: 错误: 候选项路径 /etc/mysql/mysql.cnf 不存在 dpkg: 处理软件包 mysql-server-8.0的解决方法(全)
查看>>
Mysql中各类锁的机制图文详细解析(全)
查看>>