Skip to content

Commit

Permalink
Merge branch 'develop' into feature/peking
Browse files Browse the repository at this point in the history
  • Loading branch information
taoshuang committed Aug 23, 2024
2 parents 275940e + f6e3778 commit 20ef020
Show file tree
Hide file tree
Showing 214 changed files with 6,880 additions and 2,483 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/server-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,3 @@ jobs:

- name: Lint
run: cd server && npm run lint

- name: Format
run: cd server && npm run format
3 changes: 0 additions & 3 deletions .github/workflows/web-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,3 @@ jobs:

- name: Lint
run: cd web && npm run lint

- name: Format
run: cd web && npm run format
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ pnpm-debug.log*
*.sw?

.history
components.d.ts

# 默认的上传文件夹
userUpload
24 changes: 7 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@

<br />

&ensp;&ensp;**XIAOJUSURVEY**是一套轻量、安全的**问卷系统基座**,提供面向个人和企业的一站式产品级解决方案,快速满足各类线上调研场景。
&ensp;&ensp;**XIAOJUSURVEY**是一套轻量、安全的问卷系统,提供面向个人和企业的一站式产品级解决方案,用于构建各类问卷、考试、测评和复杂表单,快速满足各类线上调研场景。

&ensp;&ensp;内部系统已沉淀 40+种题型,累积精选模板 100+,适用于市场调研、客户满意度调研、在线考试、投票、报道、测评等众多场景。数据能力上,经过上亿量级打磨,沉淀了分题统计、交叉分析、多渠道分析等在线报表能力,快速满足专业化分析。

&ensp;&ensp;开源项目以打造**调研基座**为核心,围绕**平台能力****工程架构****研发体系**进行建设,大家可以「快速」打造「专属」问卷系统:[快速了解生态发展理念](https://xiaojusurvey.didi.cn/docs/next/community/%E7%94%9F%E6%80%81%E5%BB%BA%E8%AE%BE)

# 功能简介

- 问卷管理:创、编、投、收、数据分析
Expand All @@ -45,7 +43,7 @@

- 数据安全:传输加密、脱敏等

> 更全的建设请查阅 [官方 Feature](https://github.com/didi/xiaoju-survey/issues/45)
> 更全的建设请查阅 [功能介绍](https://xiaojusurvey.didi.cn/docs/next/document/%E4%BA%A7%E5%93%81%E6%89%8B%E5%86%8C/%E5%8A%9F%E8%83%BD%E4%BB%8B%E7%BB%8D/%E5%9F%BA%E7%A1%80%E6%B5%81%E7%A8%8B)
<img src="https://github.com/didi/xiaoju-survey/assets/16012672/dd427471-368d-49d9-bc44-13c34d84e3be" width="700" />

Expand Down Expand Up @@ -144,13 +142,11 @@ npm run local
### 方案二、(生产推荐)

#### 1、启动数据库

> 项目使用 MongoDB:[MongoDB 安装指导](https://xiaojusurvey.didi.cn/docs/next/document/%E6%A6%82%E8%BF%B0/%E6%95%B0%E6%8D%AE%E5%BA%93#%E5%AE%89%E8%A3%85)
#### 1、配置数据库

- 配置数据库,查看[MongoDB 配置](https://xiaojusurvey.didi.cn/docs/next/document/%E6%A6%82%E8%BF%B0/%E6%95%B0%E6%8D%AE%E5%BA%93)
> 项目使用 MongoDB,需要提前准备,请查看[如何拥有 MongoDB 指南](./数据库#安装)
- 启动本地数据库,查看[MongoDB 启动](https://xiaojusurvey.didi.cn/docs/next/document/%E6%A6%82%E8%BF%B0/%E6%95%B0%E6%8D%AE%E5%BA%93#%E4%BA%94%E5%90%AF%E5%8A%A8)
配置数据库信息,查看[MongoDB 配置](./数据库)

#### 2、安装依赖

Expand Down Expand Up @@ -220,16 +216,10 @@ npm run serve

如果你想成为贡献者或者扩展技术栈,请查看:[贡献者指南](https://xiaojusurvey.didi.cn/docs/next/share/%E5%A6%82%E4%BD%95%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE),你的加入使我们最大的荣幸。

## Feature
## Future Tasks

关注每周推出的建设:[官方 Feature](https://github.com/didi/xiaoju-survey/issues/45)
[欢迎共建](https://github.com/didi/xiaoju-survey/issues/85)

## CHANGELOG

关注重大变更:[MAJOR CHANGELOG](https://github.com/didi/xiaoju-survey/issues/48)

## 文章分享

1、[掘金](https://juejin.cn/user/3705833332160473/posts)、2、[InfoQ](https://www.infoq.cn/profile/7E08AC616A07B2/publish)

[欢迎投稿](https://xiaojusurvey.didi.cn/docs/next/article/%E7%AE%80%E4%BB%8B)
24 changes: 8 additions & 16 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@

<br />

&ensp;&ensp;XIAOJUSURVEY is a lightweight, secure questionnaire system foundation that provides one-stop product-level solutions for individuals and enterprises, quickly meeting various online survey scenarios.
&ensp;&ensp;XIAOJUSURVEY is an open-source form builder and analytics platform to create questionnaires, exams, polls, quizzes, and analyze data online.

&ensp;&ensp;The internal system has accumulated over 40 question types and more than 100 selected templates, suitable for market research, customer satisfaction surveys, online exams, voting, reporting, evaluations, and many other scenarios. In terms of data capabilities, it has been honed through hundreds of millions of iterations, resulting in the ability to provide online reports with per-question statistics, cross-analysis, and multi-channel analysis, quickly meeting professional analysis needs.

&ensp;&ensp;The open-source project focuses on building a survey foundation, constructing around platform capabilities, engineering structure, and development systems, allowing everyone to 「quickly」 create their own 「exclusive」 questionnaire system: [quickly understanding the ecological development philosophy](https://xiaojusurvey.didi.cn/docs/next/community/%E7%94%9F%E6%80%81%E5%BB%BA%E8%AE%BE).

# Function Overview

- Questionnaire Management: Create, edit, distribute, collect, data analysis.
Expand All @@ -45,7 +43,7 @@

- Data Security: Encrypted transmission, data masking, etc.

> For more comprehensive features, please refer to the official Feature documentation.
> For more comprehensive features, please refer to the [documentation](https://xiaojusurvey.didi.cn/docs/next/document/%E4%BA%A7%E5%93%81%E6%89%8B%E5%86%8C/%E5%8A%9F%E8%83%BD%E4%BB%8B%E7%BB%8D/%E5%9F%BA%E7%A1%80%E6%B5%81%E7%A8%8B).
<img src="https://github.com/didi/xiaoju-survey/assets/16012672/508ce30f-0ae8-4f5f-84a7-e96de8238a7f" width="700" />

Expand Down Expand Up @@ -145,12 +143,11 @@ npm run local
### Option 2: (Recommended for Production)

#### 1.Start Database
#### 1.Configure Database

> The project uses MongoDB: [MongoDB Installation Guide](https://xiaojusurvey.didi.cn/docs/next/document/%E6%A6%82%E8%BF%B0/%E6%95%B0%E6%8D%AE%E5%BA%93#%E5%AE%89%E8%A3%85)
> The project uses MongoDB: [MongoDB Guide](https://xiaojusurvey.didi.cn/docs/next/document/%E6%A6%82%E8%BF%B0/%E6%95%B0%E6%8D%AE%E5%BA%93#%E5%AE%89%E8%A3%85)
- Configure the database, check MongoDB configuration.
- Start local database, check MongoDB startup.
Configure the database, check MongoDB configuration.

#### 2.Install Dependencies

Expand Down Expand Up @@ -218,16 +215,11 @@ If you use this project, please leave feedback:[I'm using](https://github.com/di

If you want to become a contributor or expand your technical stack, please check: [Contributor Guide](https://xiaojusurvey.didi.cn/docs/next/share/%E5%A6%82%E4%BD%95%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE). Your participation is our greatest honor.

## Feature
## Future Tasks

Pay attention to weekly construction updates: [Official Feature](https://github.com/didi/xiaoju-survey/issues/45)
1. [Official Feature](https://github.com/didi/xiaoju-survey/issues/45)
2. [WIP](https://github.com/didi/xiaoju-survey/labels/WIP)

## CHANGELOG

Follow major changes: [MAJOR CHANGELOG](https://github.com/didi/xiaoju-survey/issues/48)

## Article Sharing

1、[JueJin](https://juejin.cn/user/3705833332160473/posts)、2、[InfoQ](https://www.infoq.cn/profile/7E08AC616A07B2/publish)

[Welcome to contribute.](https://xiaojusurvey.didi.cn/docs/next/article/%E7%AE%80%E4%BB%8B)
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- xiaoju-survey

xiaoju-survey:
image: "xiaojusurvey/xiaoju-survey:1.1.2-slim"
image: "xiaojusurvey/xiaoju-survey:1.1.6-slim" # 最新版本:https://hub.docker.com/r/xiaojusurvey/xiaoju-survey/tags
container_name: xiaoju-survey
restart: always
ports:
Expand Down
6 changes: 6 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ http {
location /api {
proxy_pass http://127.0.0.1:3000;
}

# 静态文件的默认存储文件夹
# 文件夹的配置在 server/src/modules/file/config/index.ts SERVER_LOCAL_CONFIG.FILE_KEY_PREFIX
location /userUpload {
proxy_pass http://127.0.0.1:3000;
}

error_page 500 502 503 504 /500.html;
client_max_body_size 20M;
Expand Down
6 changes: 3 additions & 3 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"@types/node": "^20.3.1",
"@types/node-forge": "^1.3.11",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"cross-env": "^7.0.3",
"eslint": "^8.42.0",
"eslint-config-prettier": "^9.0.0",
Expand All @@ -78,7 +78,7 @@
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
"typescript": "^5.5.3"
},
"jest": {
"moduleFileExtensions": [
Expand Down
1 change: 1 addition & 0 deletions server/src/enums/exceptionCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum EXCEPTION_CODE {
SURVEY_NOT_FOUND = 3004, // 问卷不存在
SURVEY_CONTENT_NOT_ALLOW = 3005, // 存在禁用内容
CAPTCHA_INCORRECT = 4001, // 验证码不正确
WHITELIST_ERROR = 4002, // 白名单校验错误

RESPONSE_SIGN_ERROR = 9001, // 签名不正确
RESPONSE_CURRENT_TIME_NOT_ALLOW = 9002, // 当前时间不允许提交
Expand Down
37 changes: 37 additions & 0 deletions server/src/enums/question.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @description 问卷题目类型
*/
export enum QUESTION_TYPE {
/**
* 单行输入框
*/
TEXT = 'text',
/**
* 多行输入框
*/
TEXTAREA = 'textarea',
/**
* 单项选择
*/
RADIO = 'radio',
/**
* 多项选择
*/
CHECKBOX = 'checkbox',
/**
* 判断题
*/
BINARY_CHOICE = 'binary-choice',
/**
* 评分
*/
RADIO_STAR = 'radio-star',
/**
* nps评分
*/
RADIO_NPS = 'radio-nps',
/**
* 投票
*/
VOTE = 'vote',
}
29 changes: 29 additions & 0 deletions server/src/interfaces/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,42 @@ export interface SubmitConf {
msgContent: MsgContent;
}

// 白名单类型
export enum WhitelistType {
ALL = 'ALL',
// 空间成员
MEMBER = 'MEMBER',
// 自定义
CUSTOM = 'CUSTOM',
}

// 白名单用户类型
export enum MemberType {
// 手机号
MOBILE = 'MOBILE',
// 邮箱
EMAIL = 'EMAIL',
}

export interface BaseConf {
begTime: string;
endTime: string;
answerBegTime: string;
answerEndTime: string;
tLimit: number;
language: string;
// 访问密码开关
passwordSwitch?: boolean;
// 密码
password?: string | null;
// 白名单类型
whitelistType?: WhitelistType;
// 白名单用户类型
memberType?: MemberType;
// 白名单列表
whitelist?: string[];
// 提示语
whitelistTip?: string;
}

export interface SkinConf {
Expand Down
2 changes: 1 addition & 1 deletion server/src/models/surveyResponse.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class SurveyResponse extends BaseEntity {
data: Record<string, any>;

@Column()
difTime: number;
diffTime: number;

@Column()
clientTime: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ describe('DataStatisticController', () => {
field: 'xxx',
title: 'xxx',
type: 'xxx',
diffTime: 'xxx',
othersCode: 'xxx',
},
],
listBody: [
{ difTime: '0.5', createDate: '2024-02-11' },
{ difTime: '0.5', createDate: '2024-02-11' },
{ diffTime: '0.5', createDate: '2024-02-11' },
{ diffTime: '0.5', createDate: '2024-02-11' },
],
};

Expand Down Expand Up @@ -151,12 +152,13 @@ describe('DataStatisticController', () => {
field: 'xxx',
title: 'xxx',
type: 'xxx',
diffTime: 'xxx',
othersCode: 'xxx',
},
],
listBody: [
{ difTime: '0.5', createDate: '2024-02-11', data123: '15200000000' },
{ difTime: '0.5', createDate: '2024-02-11', data123: '13800000000' },
{ diffTime: '0.5', createDate: '2024-02-11', data123: '15200000000' },
{ diffTime: '0.5', createDate: '2024-02-11', data123: '13800000000' },
],
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('DataStatisticService', () => {
data413: 3,
data863: '109239',
},
difTime: 21278,
diffTime: 21278,
clientTime: 1710340862733.0,
secretKeys: [],
optionTextAndId: {
Expand Down Expand Up @@ -197,7 +197,7 @@ describe('DataStatisticService', () => {
data413_3: expect.any(String),
data413: expect.any(Number),
data863: expect.any(String),
difTime: expect.any(String),
diffTime: expect.any(String),
createDate: expect.any(String),
}),
]),
Expand All @@ -220,7 +220,7 @@ describe('DataStatisticService', () => {
'U2FsdGVkX19bRmf3uEmXAJ/6zXd1Znr3cZsD5v4Nocr2v5XG1taXluz8cohFkDyH',
data770: 'U2FsdGVkX18ldQMhJjFXO8aerjftZLpFnRQ4/FVcCLI=',
},
difTime: 806707,
diffTime: 806707,
clientTime: 1710400229573.0,
secretKeys: ['data458', 'data450', 'data405', 'data770'],
optionTextAndId: {
Expand Down Expand Up @@ -303,7 +303,7 @@ describe('DataStatisticService', () => {
data458: expect.any(String),
data515: expect.any(String),
data770: expect.any(String),
difTime: expect.any(String),
diffTime: expect.any(String),
}),
]),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { HttpException } from 'src/exceptions/httpException';
import { EXCEPTION_CODE } from 'src/enums/exceptionCode';
import { AggregationStatisDto } from '../dto/aggregationStatis.dto';
import { handleAggretionData } from '../utils';
import { QUESTION_TYPE } from 'src/enums/question';
import { SurveyDownloadService } from '../services/surveyDownload.service';

@ApiTags('survey')
Expand Down Expand Up @@ -106,15 +107,15 @@ export class DataStatisticController {
};
}
const allowQuestionType = [
'radio',
'checkbox',
'binary-choice',
'radio-star',
'radio-nps',
'vote',
QUESTION_TYPE.RADIO,
QUESTION_TYPE.CHECKBOX,
QUESTION_TYPE.BINARY_CHOICE,
QUESTION_TYPE.RADIO_STAR,
QUESTION_TYPE.RADIO_NPS,
QUESTION_TYPE.VOTE,
];
const fieldList = responseSchema.code.dataConf.dataList
.filter((item) => allowQuestionType.includes(item.type))
.filter((item) => allowQuestionType.includes(item.type as QUESTION_TYPE))
.map((item) => item.field);
const dataMap = responseSchema.code.dataConf.dataList.reduce((pre, cur) => {
pre[cur.field] = cur;
Expand Down
Loading

0 comments on commit 20ef020

Please sign in to comment.