海口龙华志愿者后端管理页面
zhouxiantao
8 days ago 4def10e6567cf651ae333a2a65c497e717c06403
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// API基础配置和服务
import axios from 'axios';
import { generateSign } from '../utils/encrypt';
 
// 创建axios实例
const api = axios.create({
  // baseURL: process.env.REACT_APP_API_BASE_URL || 'http://localhost:9002/grid-hub',
  // baseURL: process.env.REACT_APP_API_BASE_URL || 'http://hkcsdn.hkrxd.com/grid-hub-prod',
  baseURL: process.env.REACT_APP_API_BASE_URL || 'http://sqyy.spoc.haikou.gov.in:9094/grid-hub-prod',
  timeout: 10000,
  headers: {
    'Content-Type': 'application/json',
  },
});
 
// 请求拦截器
api.interceptors.request.use(
  (config) => {
    // 添加token到请求头
    const token = localStorage.getItem('token');
    if (token) {
      config.headers.Authorization = `Bearer ${token}`;
    }
    
    // 添加Sign请求头:对"zyz-时间戳"进行AES加密
    const sign = generateSign();
    if (sign) {
      config.headers.Sign = sign;
    }
    
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);
 
// 响应拦截器
api.interceptors.response.use(
  (response) => {
    const { data } = response;
    // 统一处理响应格式
    if (data.code === 0) {
      return data;
    } else {
      // 业务错误
      return Promise.reject(new Error(data.msg || '请求失败'));
    }
  },
  (error) => {
    // 处理HTTP错误
    if (error.response) {
      const { status, data } = error.response;
      switch (status) {
        case 401:
          // 未授权,清除token并跳转到登录页
          localStorage.removeItem('token');
          localStorage.removeItem('user');
          window.location.href = '/login';
          break;
        case 403:
          return Promise.reject(new Error('没有权限访问'));
        case 404:
          return Promise.reject(new Error('请求的资源不存在'));
        case 500:
          return Promise.reject(new Error('服务器内部错误'));
        default:
          return Promise.reject(new Error(data?.msg || '请求失败'));
      }
    } else if (error.request) {
      return Promise.reject(new Error('网络连接失败'));
    } else {
      return Promise.reject(new Error(error.message));
    }
  }
);
 
// 管理员相关API
export const adminAPI = {
  // 管理员登录
  login: (data) => api.post('/web/api/admins/login', data),
  
  // 管理员列表查询(分页)
  getAdminList: (params) => api.get('/web/api/admins/pageQuery', { params }),
  
  // 根据ID查询管理员详情
  getAdminById: (id) => api.get('/web/api/admins/getById', { params: { id } }),
  
  // 保存/更新管理员
  saveAdmin: (data) => api.post('/web/api/admins/saveAdmin', data),
  
  // 删除管理员
  deleteAdmins: (ids) => api.get('/web/api/admins/removeByIds', { params: { ids } }),
  
  // 重置密码
  resetPassword: (id, newPassword) => api.post('/web/api/admins/resetPassword', null, { 
    params: { id, newPassword } 
  }),
};
 
// 用户管理相关API
export const userAPI = {
  // 用户列表查询(分页)
  getUserList: (params) => api.get('/web/api/users/pageQuery', { params }),
  
  // 根据ID查询用户详情
  getUserById: (id) => api.get('/web/api/users/getById', { params: { id } }),
  
  // 保存/更新用户
  saveUser: (data) => api.post('/web/api/users/saveUser', data),
  
  // 删除用户
  deleteUsers: (ids) => api.get('/web/api/users/removeByIds', { params: { ids } }),
};
 
// 志愿者申请管理API
export const applicationAPI = {
  // 志愿者申请列表查询(分页)
  getApplicationList: (params) => api.get('/web/api/applications/pageQuery', { params }),
  
  // 根据ID查询申请详情
  getApplicationById: (id) => api.get('/web/api/applications/getById', { params: { id } }),
  
  // 审核志愿者申请
  reviewApplication: (data) => api.post('/web/api/applications/review', data),
  
  // 保存/更新申请
  saveApplication: (data) => api.post('/web/api/applications/saveApplication', data),
  
  // 删除申请
  deleteApplications: (ids) => api.get('/web/api/applications/removeByIds', { params: { ids } }),
};
 
// 活动管理相关API
export const activityAPI = {
  // 活动列表查询(分页)
  getActivityList: (params) => api.get('/web/api/activities/pageQuery', { params }),
  
  // 根据ID查询活动详情
  getActivityById: (id) => api.get('/web/api/activities/getById', { params: { id } }),
  
  // 保存/更新活动
  saveActivity: (data) => api.post('/web/api/activities/saveActivity', data),
  
  // 删除活动
  deleteActivities: (ids) => api.get('/web/api/activities/removeByIds', { params: { ids } }),
  
  // 更新活动状态
  updateActivityStatus: (id, status) => api.post('/web/api/activities/updateStatus', null, { 
    params: { id, status } 
  }),
};
 
// 活动报名管理API
export const activityUserAPI = {
  // 根据活动ID查询报名列表
  getRegistrationsByActivityId: (activityId) => api.get('/web/api/activityUser/getByActivityId', { 
    params: { activity_id: activityId } 
  }),
  
  // 签到
  checkIn: (data) => api.post('/web/api/activityUser/checkIn', data),
  
  // 签退
  checkOut: (data) => api.post('/web/api/activityUser/checkOut', data),
  
  // 报名列表查询(分页)
  getRegistrationList: (params) => api.get('/web/api/activityUser/pageQuery', { params }),
  
  // 根据ID查询报名详情
  getRegistrationById: (id) => api.get('/web/api/activityUser/getById', { params: { id } }),
  
  // 保存/更新报名
  saveRegistration: (data) => api.post('/web/api/activityUser/saveActivityUser', data),
  
  // 删除报名
  deleteRegistrations: (ids) => api.get('/web/api/activityUser/removeByIds', { params: { ids } }),
};
 
// 积分申报管理API
export const pointDeclarationAPI = {
  // 积分申报列表查询(分页)
  getDeclarationList: (params) => api.get('/web/api/pointDeclarations/pageQuery', { params }),
  
  // 根据ID查询申报详情
  getDeclarationById: (id) => api.get('/web/api/pointDeclarations/getById', { params: { id } }),
  
  // 审核积分申报
  reviewDeclaration: (data) => api.post('/web/api/pointDeclarations/review', data),
  
  // 保存/更新申报
  saveDeclaration: (data) => api.post('/web/api/pointDeclarations/savePointDeclaration', data),
  
  // 删除申报
  deleteDeclarations: (ids) => api.get('/web/api/pointDeclarations/removeByIds', { params: { ids } }),
};
 
// 统计分析API
export const statisticsAPI = {
  // 获取数据概览
  getOverview: () => api.get('/web/api/statistics/getOverview'),
  
  // 积分趋势分析
  getPointsTrend: (period = 'month') => api.get('/web/api/statistics/getPointsTrend', { 
    params: { period } 
  }),
  
  // 活动参与度分析
  getActivityParticipation: () => api.get('/web/api/statistics/getActivityParticipation'),
  
  // 志愿者活跃度统计
  getVolunteerActivity: () => api.get('/web/api/statistics/getVolunteerActivity'),
  
  // 积分排行榜
  getPointsRanking: (limit = 10) => api.get('/web/api/statistics/getPointsRanking', { 
    params: { limit } 
  }),
  
  // 社区活跃度统计
  getCommunityActivity: () => api.get('/web/api/statistics/getCommunityActivity'),
};
 
// Dashboard专用API
export const dashboardAPI = {
  // 获取最新活动列表
  getRecentActivities: (limit = 5) => api.get('/web/api/dashboard/getRecentActivities', { 
    params: { limit } 
  }),
  
  // 获取最新志愿者列表
  getRecentVolunteers: (limit = 5) => api.get('/web/api/dashboard/getRecentVolunteers', { 
    params: { limit } 
  }),
  
  // 获取待处理事项统计
  getPendingItems: () => api.get('/web/api/dashboard/getPendingItems'),
  
  // 获取系统概览数据
  getSystemOverview: () => api.get('/web/api/dashboard/getSystemOverview'),
  
  // 获取热门活动
  getPopularActivities: (limit = 5) => api.get('/web/api/dashboard/getPopularActivities', { 
    params: { limit } 
  }),
  
  // 获取积分统计
  getPointsStatistics: () => api.get('/web/api/dashboard/getPointsStatistics'),
};
 
// 申报项目配置管理API
export const declarationConfigAPI = {
  // 申报项目配置列表查询(分页)
  getDeclarationConfigList: (params) => api.get('/web/api/declarationConfigs/pageQuery', { params }),
  
  // 根据ID查询申报项目配置详情
  getDeclarationConfigById: (id) => api.get('/web/api/declarationConfigs/getById', { params: { id } }),
  
  // 保存/更新申报项目配置
  saveDeclarationConfig: (data) => api.post('/web/api/declarationConfigs/saveDeclarationConfig', data),
  
  // 删除申报项目配置
  deleteDeclarationConfigs: (ids) => api.get('/web/api/declarationConfigs/removeByIds', { params: { ids } }),
  
  // 批量更新申报项目配置状态
  updateDeclarationConfigStatus: (data) => api.post('/web/api/declarationConfigs/updateStatus', data),
  
  // 获取申报项目配置分类列表
  getDeclarationConfigCategories: () => api.get('/web/api/declarationConfigs/getCategories'),
  
  // 根据分类获取二级选项
  getSecondaryOptions: (category) => api.get('/web/api/declarationConfigs/getSecondaryOptions', { params: { category } }),
  
  // 复制申报项目配置
  copyDeclarationConfig: (data) => api.post('/web/api/declarationConfigs/copyConfig', data),
  
  // 获取申报项目配置统计信息
  getDeclarationConfigStatistics: () => api.get('/web/api/declarationConfigs/getStatistics'),
  
  // 导出申报项目配置
  exportDeclarationConfigs: (params) => api.get('/web/api/declarationConfigs/export', { params }),
};
 
export default api;