unis_crm/backend/README.md

66 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Backend
当前已经补齐首页所需的 Java 后端基础工程,并调整为常规 Spring Boot 单体项目目录结构,技术栈如下:
- Java 17
- Spring Boot 3.2.2
- MyBatis Plus 3.5.6
- PostgreSQL
- Redis
## 已实现内容
- 首页聚合接口:`GET /api/dashboard/home`
- 首页欢迎信息:姓名、职位、部门、入职天数
- 首页统计卡片
- 首页待办列表
- 首页最新动态
- 通用响应体与全局异常处理
## 目录结构
```text
backend/
├── pom.xml
└── src/main
├── java/com/unis/crm
│ ├── common
│ ├── controller
│ ├── dto
│ ├── mapper
│ ├── service
│ └── UnisCrmBackendApplication.java
└── resources
├── application.yml
└── mapper/dashboard
```
## 启动前准备
1. 执行数据库脚本:
```bash
psql -h 127.0.0.1 -U postgres -d nex_auth -f sql/init_pg17.sql
```
2. 确保 `sys_user`、`work_todo`、`sys_activity_log`、`crm_customer`、`crm_opportunity`、`work_checkin` 中有业务数据。
## 启动项目
```bash
cd backend
mvn spring-boot:run
```
默认启动在 `8081` 端口,供前端开发环境通过 Vite 代理访问;`8080` 可继续保留给现有认证/系统服务。
## 首页接口
请求示例:
```bash
curl -H "X-User-Id: 1" "http://127.0.0.1:8081/api/dashboard/home"
```
首页接口只允许查询当前登录用户自己的数据,必须通过 `X-User-Id` 传入当前用户ID不支持指定其他用户查询。