143 lines
3.5 KiB
Markdown
143 lines
3.5 KiB
Markdown
# CRM Customer Management System
|
||
|
||
A web-based CRM system built with Go backend and HTML/CSS/JavaScript frontend.
|
||
|
||
## Features
|
||
|
||
1. **Customer Management**
|
||
- Create customers with fields: Customer Name, Intended Product
|
||
- Customer list with fields: Time, Customer, Version, Description, Solution, Type, Module, Status & Progress, Reporter (all editable)
|
||
- Import customers from CSV files
|
||
|
||
2. **Customer Dashboard**
|
||
- Visual charts (pie charts, line charts) for data analysis
|
||
- Filter data by date range
|
||
- View customer distribution by status, trends, product interest, and customer types
|
||
|
||
## Technology Stack
|
||
|
||
- Backend: Go
|
||
- Frontend: HTML, CSS, JavaScript
|
||
- Charts: Chart.js (via CDN)
|
||
- Data Storage: MySQL数据库(默认)或本地JSON文件
|
||
|
||
## 数据存储
|
||
|
||
系统支持两种存储模式:
|
||
|
||
### 1. MySQL数据库(推荐)
|
||
|
||
1. 创建数据库并执行迁移脚本:
|
||
```bash
|
||
mysql -u root -p < ./data/migration.sql
|
||
```
|
||
|
||
2. 配置环境变量:
|
||
```bash
|
||
export DB_HOST=localhost
|
||
export DB_PORT=3306
|
||
export DB_USER=root
|
||
export DB_PASSWORD=your_password
|
||
export DB_NAME=crm_db
|
||
export STORAGE_MODE=mysql
|
||
```
|
||
|
||
### 2. JSON文件存储(向后兼容)
|
||
|
||
设置环境变量使用JSON存储:
|
||
```bash
|
||
export STORAGE_MODE=json
|
||
```
|
||
|
||
数据将存储在 `./data/` 目录下的JSON文件中。
|
||
|
||
## How to Run
|
||
|
||
### 方法一:使用启动脚本
|
||
|
||
1. 复制并修改配置文件:
|
||
```bash
|
||
cp .env.example .env
|
||
# 编辑 .env 文件设置数据库密码等
|
||
```
|
||
|
||
2. 运行启动脚本:
|
||
```bash
|
||
./start.sh
|
||
```
|
||
|
||
### 方法二:手动启动
|
||
|
||
1. 设置环境变量:
|
||
```bash
|
||
export DB_PASSWORD=your_password
|
||
export STORAGE_MODE=mysql
|
||
```
|
||
|
||
2. 构建并运行:
|
||
```bash
|
||
go build -o crm-server ./cmd/server/
|
||
./crm-server
|
||
```
|
||
|
||
3. Open your browser and go to:
|
||
```
|
||
http://localhost:8081
|
||
```
|
||
|
||
## 环境变量说明
|
||
|
||
| 变量名 | 说明 | 默认值 |
|
||
|--------|------|--------|
|
||
| `STORAGE_MODE` | 存储模式: `mysql` 或 `json` | `mysql` |
|
||
| `DB_HOST` | MySQL主机地址 | `localhost` |
|
||
| `DB_PORT` | MySQL端口 | `3306` |
|
||
| `DB_USER` | MySQL用户名 | `root` |
|
||
| `DB_PASSWORD` | MySQL密码 | 空 |
|
||
| `DB_NAME` | 数据库名称 | `crm_db` |
|
||
| `PORT` | 服务端口 | `8081` |
|
||
|
||
## Usage
|
||
|
||
### Customer Management
|
||
- Click "Customer Management" in the navigation
|
||
- Add new customers using the form
|
||
- Edit existing customers by clicking "Edit" button
|
||
- Delete customers by clicking "Delete" button
|
||
- Import customers from CSV file using the import form
|
||
|
||
### Dashboard
|
||
- Click "Dashboard" in the navigation
|
||
- View various charts showing customer data
|
||
- Filter data by date range
|
||
|
||
## Data Storage
|
||
|
||
Customer data is stored in `./data/customers.json` in JSON format.
|
||
|
||
## File Structure
|
||
|
||
```
|
||
crm-go/
|
||
├── cmd/
|
||
│ └── server/
|
||
│ └── main.go # Main application entry point
|
||
├── models/
|
||
│ └── customer.go # Customer data models
|
||
├── internal/
|
||
│ ├── handlers/
|
||
│ │ └── customer_handler.go # HTTP request handlers
|
||
│ └── storage/
|
||
│ └── customer_storage.go # Data storage implementation
|
||
├── frontend/
|
||
│ ├── index.html # Main HTML page
|
||
│ ├── css/
|
||
│ └── style.css # Stylesheet
|
||
│ └── js/
|
||
│ └── main.js # Client-side JavaScript
|
||
├── data/
|
||
│ └── customers.json # Customer data storage
|
||
├── bin/
|
||
│ └── server # Compiled binary
|
||
└── go.mod # Go module file
|
||
``` |