博客
关于我
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/

你可能感兴趣的文章
MongoDB学习笔记(8)--索引及优化索引
查看>>
mongodb定时备份数据库
查看>>
mppt算法详解-ChatGPT4o作答
查看>>
mpvue的使用(一)必要的开发环境
查看>>
MQ 重复消费如何解决?
查看>>
mqtt broker服务端
查看>>
MQTT 保留消息
查看>>
MQTT 持久会话与 Clean Session 详解
查看>>
MQTT工作笔记0007---剩余长度
查看>>
MQTT工作笔记0009---订阅主题和订阅确认
查看>>
Mqtt搭建代理服务器进行通信-浅析
查看>>
MS Edge浏览器“STATUS_INVALID_IMAGE_HASH“兼容性问题
查看>>
ms sql server 2008 sp2更新异常
查看>>
MS UC 2013-0-Prepare Tool
查看>>
MSBuild 教程(2)
查看>>
msbuild发布web应用程序
查看>>
MSB与LSB
查看>>
MSCRM调用外部JS文件
查看>>
MSCRM调用外部JS文件
查看>>
MSEdgeDriver (Chromium) 不适用于版本 >= 79.0.313 (Canary)
查看>>