feat(database): 迁移用户关联字段并优化打卡系统

- 修改数据库配置将MYSQL_DB从mys_info_v3改为mys_info_test
- 新增auth_users表wechat_openid字段并建立唯一索引
- 为plan_checkins表添加计划性能索引(idx_plan_period_student)
- 将checkin_records_old表关联方式从student_id改为user_id
- 将plan_checkins表关联方式从student_id改为user_id并更新附件路径
- 移除routes/auth.py中的uuid导入使用安全token生成函数
- 重构routes/checkin.py打卡逻辑去除course_type字段并优化返回结构
- 添加打卡时间限制验证功能防止过期打卡操作
- 实现小组统计功能支持老师查看各组打卡情况
- 更新主页index.html界面适配新的打卡和计划功能
- 调整计划提交时间规则为周五至周四周期
- 添加月度和年度计划提交状态验证机制
This commit is contained in:
王宏豪
2026-09-10 14:11:58 +08:00
parent 1dd4fa3f41
commit cd04c1b5ef
19 changed files with 1457 additions and 407 deletions

View File

@@ -1,7 +1,43 @@
//const BASE_URL = 'https://muguaclub.cn';
//const BASE_URL = "http://127.0.0.1:8000";
const BASE_URL = 'https://m.muguaclub.cn/clock';
const STATIC_BASE_URL = 'https://m.muguaclub.cn';
// 根据小程序版本自动选择后端地址
function _getBaseUrls() {
let envType = 'release';
try {
const accountInfo = wx.getAccountInfoSync();
envType = accountInfo.miniProgram.envVersion || 'release';
} catch (e) {
// 低版本基础库不支持时默认线上环境
envType = 'release';
}
switch (envType) {
case 'develop':
// 开发版:本地服务
return {
baseUrl: 'https://test.muguaclub.cn/clock',
staticUrl: 'https://test.muguaclub.cn',
h5Url: 'https://test.muguaclub.cn'
};
case 'trial':
// 体验版:测试环境
return {
baseUrl: 'https://test.muguaclub.cn/clock',
staticUrl: 'https://test.muguaclub.cn',
h5Url: 'https://test.muguaclub.cn'
};
case 'release':
default:
// 线上版:正式环境
return {
baseUrl: 'https://m.muguaclub.cn/clock',
staticUrl: 'https://m.muguaclub.cn',
h5Url: 'https://m.muguaclub.cn'
};
}
}
const _urls = _getBaseUrls();
const BASE_URL = _urls.baseUrl;
const STATIC_BASE_URL = _urls.staticUrl;
const H5_BASE_URL = _urls.h5Url;
let redirectingProfile = false;
@@ -73,4 +109,16 @@ function request(options) {
});
}
module.exports = { request, BASE_URL, STATIC_BASE_URL };
/**
* 把计划附件的相对路径转为完整的静态资源 URL。
* 路径格式:attachments/{user_id}/{plan_type}/{period_key}/{filename}
*/
function planFileUrl(path) {
if (!path) return '';
if (/^https?:\/\//i.test(path)) return path;
const parts = String(path).replace(/^attachments\//, '').split('/');
if (parts.length < 4) return '';
return STATIC_BASE_URL + '/clock/static/plan/' + parts.slice(0, 4).map(encodeURIComponent).join('/');
}
module.exports = { request, planFileUrl, BASE_URL, STATIC_BASE_URL, H5_BASE_URL };