|
@@ -50,7 +50,7 @@ func Tick(c *gin.Context) {
|
|
|
numStr := param.PositionY
|
|
|
_, _ = fmt.Sscanf(numStr, "%e", &positionY)
|
|
|
if !util.ContainsKey(cacheTeamName, teamName) && math.Abs(positionX-InitialPositionX) < 5.00 && math.Abs(positionY-InitialPositionY) < 5.00 { // (在起点开始)
|
|
|
- sqlTemplate, _ := util.ReadFile(c_db.SqlFilesMap["exam-insert-begin_time-and-topic-by-team_name.sql"])
|
|
|
+ sqlTemplate, _ := util.ReadFile(c_db.SqlFilesMap["exam-insert-begin_time-and-topic-and-equipment_no-by-team_name.sql"])
|
|
|
|
|
|
stage := ""
|
|
|
if time.Now().Before(trialBegin) {
|
|
@@ -63,7 +63,7 @@ func Tick(c *gin.Context) {
|
|
|
competitionBegin := time.Now()
|
|
|
cacheTeamName[teamName] = competitionBegin
|
|
|
c_log.GlobalLogger.Infof("当前比赛阶段为 %v ,队伍 %v 在起始点范围内第一次启动,保存新一条比赛记录的开始时间 %v", stage, teamName, competitionBegin)
|
|
|
- if err := c_db.DoTx(sqlTemplate, []any{param.TeamName, stage, competitionBegin}); err != nil {
|
|
|
+ if err := c_db.DoTx(sqlTemplate, []any{param.TeamName, stage, competitionBegin, param.EquipmentNo}); err != nil {
|
|
|
c_log.GlobalLogger.Error("保存比赛开始时间报错:", err)
|
|
|
c.JSON(http.StatusBadRequest, commonEntity.Response{Code: 500, Msg: "保存比赛开始时间报错。"})
|
|
|
return
|
|
@@ -188,97 +188,97 @@ func ExamEndTicker() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 考试开始时间
|
|
|
-func Begin(c *gin.Context) {
|
|
|
- param := new(webServerEntity.ExamPao)
|
|
|
- // 映射到结构体
|
|
|
- if err := c.ShouldBindJSON(¶m); err != nil {
|
|
|
- c_log.GlobalLogger.Error("项目启动接收请求参数报错:", err)
|
|
|
- c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
- Code: 500,
|
|
|
- Msg: "请求体解析失败。",
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- // 插入到数据库
|
|
|
- sqlTemplate, _ := util.ReadFile(c_db.SqlFilesMap["exam-insert-begin_time-by-team_name.sql"])
|
|
|
- c_log.GlobalLogger.Info("插入比赛开始时间", sqlTemplate)
|
|
|
- if err := c_db.DoTx(sqlTemplate, []any{
|
|
|
- param.TeamName,
|
|
|
- time.Now(),
|
|
|
- }); err != nil {
|
|
|
- c_log.GlobalLogger.Error("插入数据报错:", err)
|
|
|
- c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
- Code: 500,
|
|
|
- Msg: "插入数据报错。",
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- c.JSON(http.StatusOK, commonEntity.Response{
|
|
|
- Code: 200,
|
|
|
- Msg: "插入数据成功。",
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// 考试结束时间
|
|
|
-func End(c *gin.Context) {
|
|
|
- param := new(webServerEntity.ExamPao)
|
|
|
- // 映射到结构体
|
|
|
- if err := c.ShouldBindJSON(¶m); err != nil {
|
|
|
- c_log.GlobalLogger.Error("项目启动接收请求参数报错:", err)
|
|
|
- c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
- Code: 500,
|
|
|
- Msg: "请求体解析失败。",
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- // 1 查询指定队伍的开始时间最新的考试是否有结束时间,如果有则不在处理,如果没有则更新
|
|
|
- var result []webServerEntity.ExamPo
|
|
|
- selectSql, err := util.ReadFile(c_db.SqlFilesMap["exam-select-latest-by-team_name.sql"])
|
|
|
- if err != nil {
|
|
|
- c_log.GlobalLogger.Error("读取sql文件报错:", err)
|
|
|
- c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
- Code: 500,
|
|
|
- Msg: "读取sql文件报错。",
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- // 可以传参数
|
|
|
- if err = c_db.MysqlDb.Select(&result, selectSql, param.TeamName); err != nil {
|
|
|
- c_log.GlobalLogger.Error("数据库查询报错:", err)
|
|
|
- c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
- Code: 500,
|
|
|
- Msg: "数据库查询报错。",
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- c_log.GlobalLogger.Info("数据库查询成功:", result)
|
|
|
- if !result[0].EndTime.Equal(defaultTime) {
|
|
|
- c_log.GlobalLogger.Error("赛队", param.TeamName, "重复请求考试结束接口!")
|
|
|
- c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
- Code: 500,
|
|
|
- Msg: "重复请求。",
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- // 更新到数据库
|
|
|
- sqlTemplate, _ := util.ReadFile(c_db.SqlFilesMap["exam-update-end_time-by-team_name.sql"])
|
|
|
- if err := c_db.DoTx(sqlTemplate, []any{
|
|
|
- time.Now(),
|
|
|
- param.TeamName,
|
|
|
- }); err != nil {
|
|
|
- c_log.GlobalLogger.Error("插入数据报错:", err)
|
|
|
- c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
- Code: 500,
|
|
|
- Msg: "插入数据报错。",
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- c.JSON(http.StatusOK, commonEntity.Response{
|
|
|
- Code: 200,
|
|
|
- Msg: "插入数据成功。",
|
|
|
- })
|
|
|
-}
|
|
|
+//// 考试开始时间
|
|
|
+//func Begin(c *gin.Context) {
|
|
|
+// param := new(webServerEntity.ExamPao)
|
|
|
+// // 映射到结构体
|
|
|
+// if err := c.ShouldBindJSON(¶m); err != nil {
|
|
|
+// c_log.GlobalLogger.Error("项目启动接收请求参数报错:", err)
|
|
|
+// c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
+// Code: 500,
|
|
|
+// Msg: "请求体解析失败。",
|
|
|
+// })
|
|
|
+// return
|
|
|
+// }
|
|
|
+// // 插入到数据库
|
|
|
+// sqlTemplate, _ := util.ReadFile(c_db.SqlFilesMap["exam-insert-begin_time-by-team_name.sql"])
|
|
|
+// c_log.GlobalLogger.Info("插入比赛开始时间", sqlTemplate)
|
|
|
+// if err := c_db.DoTx(sqlTemplate, []any{
|
|
|
+// param.TeamName,
|
|
|
+// time.Now(),
|
|
|
+// }); err != nil {
|
|
|
+// c_log.GlobalLogger.Error("插入数据报错:", err)
|
|
|
+// c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
+// Code: 500,
|
|
|
+// Msg: "插入数据报错。",
|
|
|
+// })
|
|
|
+// return
|
|
|
+// }
|
|
|
+// c.JSON(http.StatusOK, commonEntity.Response{
|
|
|
+// Code: 200,
|
|
|
+// Msg: "插入数据成功。",
|
|
|
+// })
|
|
|
+//}
|
|
|
+//
|
|
|
+//// 考试结束时间
|
|
|
+//func End(c *gin.Context) {
|
|
|
+// param := new(webServerEntity.ExamPao)
|
|
|
+// // 映射到结构体
|
|
|
+// if err := c.ShouldBindJSON(¶m); err != nil {
|
|
|
+// c_log.GlobalLogger.Error("接收请求参数报错:", err)
|
|
|
+// c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
+// Code: 500,
|
|
|
+// Msg: "请求体解析失败。",
|
|
|
+// })
|
|
|
+// return
|
|
|
+// }
|
|
|
+// // 1 查询指定队伍的开始时间最新的考试是否有结束时间,如果有则不在处理,如果没有则更新
|
|
|
+// var result []webServerEntity.ExamPo
|
|
|
+// selectSql, err := util.ReadFile(c_db.SqlFilesMap["exam-select-latest-by-team_name.sql"])
|
|
|
+// if err != nil {
|
|
|
+// c_log.GlobalLogger.Error("读取sql文件报错:", err)
|
|
|
+// c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
+// Code: 500,
|
|
|
+// Msg: "读取sql文件报错。",
|
|
|
+// })
|
|
|
+// return
|
|
|
+// }
|
|
|
+// // 可以传参数
|
|
|
+// if err = c_db.MysqlDb.Select(&result, selectSql, param.TeamName); err != nil {
|
|
|
+// c_log.GlobalLogger.Error("数据库查询报错:", err)
|
|
|
+// c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
+// Code: 500,
|
|
|
+// Msg: "数据库查询报错。",
|
|
|
+// })
|
|
|
+// return
|
|
|
+// }
|
|
|
+// c_log.GlobalLogger.Info("数据库查询成功:", result)
|
|
|
+// if !result[0].EndTime.Equal(defaultTime) {
|
|
|
+// c_log.GlobalLogger.Error("赛队", param.TeamName, "重复请求考试结束接口!")
|
|
|
+// c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
+// Code: 500,
|
|
|
+// Msg: "重复请求。",
|
|
|
+// })
|
|
|
+// return
|
|
|
+// }
|
|
|
+// // 更新到数据库
|
|
|
+// sqlTemplate, _ := util.ReadFile(c_db.SqlFilesMap["exam-update-end_time-by-team_name.sql"])
|
|
|
+// if err := c_db.DoTx(sqlTemplate, []any{
|
|
|
+// time.Now(),
|
|
|
+// param.TeamName,
|
|
|
+// }); err != nil {
|
|
|
+// c_log.GlobalLogger.Error("插入数据报错:", err)
|
|
|
+// c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
+// Code: 500,
|
|
|
+// Msg: "插入数据报错。",
|
|
|
+// })
|
|
|
+// return
|
|
|
+// }
|
|
|
+// c.JSON(http.StatusOK, commonEntity.Response{
|
|
|
+// Code: 200,
|
|
|
+// Msg: "插入数据成功。",
|
|
|
+// })
|
|
|
+//}
|
|
|
|
|
|
// 分页查询
|
|
|
// 如果日期为默认值,则返回空""
|