From 66e2e4ae5d6b539593a5f3aa7cc05a509ae72ccf Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 3 Dec 2024 19:07:33 +0800 Subject: [PATCH] update --- app/hdl/financial_center/hdl_withdraw.go | 22 ++++++++++++++++++++++ app/router/router.go | 18 +++++++++--------- app/utils/time.go | 7 +++++++ 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/app/hdl/financial_center/hdl_withdraw.go b/app/hdl/financial_center/hdl_withdraw.go index 48505bf..560bd0f 100644 --- a/app/hdl/financial_center/hdl_withdraw.go +++ b/app/hdl/financial_center/hdl_withdraw.go @@ -9,6 +9,7 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" + "errors" "github.com/gin-gonic/gin" "strings" "time" @@ -148,6 +149,27 @@ func UpdateWithdrawSetting(c *gin.Context) { e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) return } + if req.WithdrawTimeInterval.StartAt != "" { + res := utils.IsTimeFormat(req.WithdrawTimeInterval.StartAt) + if req.WithdrawTimeInterval.StartAt > "23:59" { + res = false + } + if !res { + e.OutErr(c, e.ERR_INVALID_ARGS, errors.New("开始时间应为 xx:xx 且不超过 23:59").Error()) + return + } + } + if req.WithdrawTimeInterval.EndAt != "" { + res := utils.IsTimeFormat(req.WithdrawTimeInterval.EndAt) + if req.WithdrawTimeInterval.EndAt > "23:59" { + res = false + } + if !res { + e.OutErr(c, e.ERR_INVALID_ARGS, errors.New("结束时间应为 xx:xx 且不超过 23:59").Error()) + return + } + } + frequencyStr := utils.SerializeStr(req.FrequencySet) withdrawFeeSetStr := utils.SerializeStr(req.WithdrawFeeSet) firstWithdrawSetStr := utils.SerializeStr(req.FirstWithdrawSet) diff --git a/app/router/router.go b/app/router/router.go index b6a0aeb..2e5789c 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -341,21 +341,21 @@ func rFinancialCenter(r *gin.RouterGroup) { func rFriendCircleSettings(r *gin.RouterGroup) { rBasic := r.Group("/basic") { - rBasic.GET("/index", friend_circle.GetFriendCircleBasicSettings) - rBasic.POST("/save", friend_circle.UpdateFriendCircleBasicSettings) + rBasic.GET("/index", friend_circle.GetFriendCircleBasicSettings) // 获取动态基础设置 + rBasic.POST("/save", friend_circle.UpdateFriendCircleBasicSettings) // 更新动态设置 } rBlackList := r.Group("/blackList") { - rBlackList.GET("/index", friend_circle.GetBlackList) - rBlackList.POST("/add", friend_circle.AddBlackList) - rBlackList.DELETE("/del", friend_circle.DeleteBlackList) + rBlackList.GET("/index", friend_circle.GetBlackList) // 获取黑名单 + rBlackList.POST("/add", friend_circle.AddBlackList) // 添加黑名单 + rBlackList.DELETE("/del", friend_circle.DeleteBlackList) // 删除黑名单 } rDynamic := r.Group("/dynamic") { - rDynamic.POST("/index", friend_circle.GetDynamic) - rDynamic.POST("/update", friend_circle.UpdateDynamic) - rDynamic.DELETE("/del", friend_circle.DeleteDynamic) - rDynamic.POST("/release", friend_circle.ReleaseDynamic) + rDynamic.POST("/index", friend_circle.GetDynamic) // 获取动态列表 + rDynamic.POST("/update", friend_circle.UpdateDynamic) // 更新动态 + rDynamic.DELETE("/del", friend_circle.DeleteDynamic) // 删除动态 + rDynamic.POST("/release", friend_circle.ReleaseDynamic) // 发布动态 } } diff --git a/app/utils/time.go b/app/utils/time.go index 8f0d1aa..50fbcf8 100644 --- a/app/utils/time.go +++ b/app/utils/time.go @@ -3,6 +3,7 @@ package utils import ( "errors" "fmt" + "regexp" "strconv" "strings" "time" @@ -240,3 +241,9 @@ func GetWeekInfo(dateStr string) (string, string, string, string) { weekEnd := weekStart.AddDate(0, 0, 6) return IntToStr(year), IntToStr(week), weekStart.Format("2006-01-02"), weekEnd.Format("2006-01-02") } + +func IsTimeFormat(s string) bool { + // 正则表达式匹配HH:MM格式 + re := regexp.MustCompile(`^(\d{2}):(\d{2})$`) + return re.MatchString(s) +}