Browse Source

12月20日添加返回结构体注解,去除日志

dev_ljk
lijikun 5 months ago
parent
commit
bfcfb32e89
  1. 12
      link_homework/api/v1/record/Record.go
  2. 10
      link_homework/utility/utility.go

12
link_homework/api/v1/record/Record.go

@ -59,10 +59,10 @@ type ExcelExportReq struct {
}
type Reply struct {
FormId int `json:"formId"`
Type int `json:"type"`
FormTitle string `json:"formTitle"`
ContentTitle string `json:"contentTitle"`
Content string `json:"content"`
SubmitTime gtime.Time `json:"submitTime"`
FormId int `json:"formId" dc:"作业题目id"`
Type int `json:"type" dc:"作业类型"`
FormTitle string `json:"formTitle" dc:"作业题目名"`
ContentTitle string `json:"contentTitle" dc:"作答题目名"`
Content string `json:"content" dc:"作答内容"`
SubmitTime gtime.Time `json:"submitTime" dc:"提交时间"`
}

10
link_homework/utility/utility.go

@ -21,7 +21,7 @@ func getUrl(key, hashKey string) *dto.Result {
// 1. 从 Redis 获取 URL
redisUrl, err := g.Redis().Do(ctx, "HGET", key, hashKey)
if err == nil && redisUrl.String() != "" {
g.Log().Infof(ctx, "从 Redis 获取到 URL: %s", redisUrl.String())
//g.Log().Infof(ctx, "从 Redis 获取到 URL: %s", redisUrl.String())
return dto.SuccessWithData(redisUrl.String())
}
@ -34,16 +34,16 @@ func getUrl(key, hashKey string) *dto.Result {
// 3. 将 URL 存入 Redis
if _, err = g.Redis().Do(ctx, "HSET", key, hashKey, url); err != nil {
g.Log().Warningf(ctx, "将数据存入 Redis 失败: %v", err)
//g.Log().Warningf(ctx, "将数据存入 Redis 失败: %v", err)
}
g.Log().Infof(ctx, "将 URL 存入 Redis: %s", url)
//g.Log().Infof(ctx, "将 URL 存入 Redis: %s", url)
return dto.SuccessWithData(url)
}
// 查询数据库中的 URL
func selectBaseUrl(hashKey string) *dto.Result {
ctx := gctx.New()
//ctx := gctx.New()
// 查询数据库
value, err := g.DB("cms").Model("env").Where("`key` = ?", hashKey).Value("value")
@ -53,7 +53,7 @@ func selectBaseUrl(hashKey string) *dto.Result {
}
if value.IsNil() || value.String() == "" {
g.Log().Errorf(ctx, "未找到对应数据, key: %s", hashKey)
//g.Log().Errorf(ctx, "未找到对应数据, key: %s", hashKey)
return dto.Error("未找到对应数据")
}

Loading…
Cancel
Save