Compare commits
merge into: donghanyang:master
donghanyang:client_ljk
donghanyang:details_ljk
donghanyang:dev
donghanyang:dev_ljk
donghanyang:dhy
donghanyang:lijikun
donghanyang:majun
donghanyang:master
pull from: donghanyang:dev_ljk
donghanyang:client_ljk
donghanyang:details_ljk
donghanyang:dev
donghanyang:dev_ljk
donghanyang:dhy
donghanyang:lijikun
donghanyang:majun
donghanyang:master
71 Commits
49 changed files with 2199 additions and 408 deletions
-
38link_homework/api/v1/ClientPage/ClientPage.go
-
5link_homework/api/v1/article/article.go
-
1link_homework/api/v1/hello.go
-
36link_homework/api/v1/homework/homework.go
-
1link_homework/api/v1/homework/login.go
-
68link_homework/api/v1/record/Record.go
-
20link_homework/go.mod
-
109link_homework/go.sum
-
2link_homework/hack/config.yaml
-
57link_homework/internal/cmd/cmd.go
-
6link_homework/internal/consts/consts.go
-
36link_homework/internal/controller/article/article.go
-
56link_homework/internal/controller/auth/login.go
-
84link_homework/internal/controller/clientPage/clientPage.go
-
105link_homework/internal/controller/homework/homework.go
-
28link_homework/internal/controller/live/live.go
-
95link_homework/internal/controller/record/manageRecord.go
-
24link_homework/internal/dao/internal/activity_interactive_form.go
-
24link_homework/internal/dao/internal/activity_interactive_group.go
-
24link_homework/internal/dao/internal/activity_interactive_record.go
-
22link_homework/internal/dao/internal/fx_article.go
-
24link_homework/internal/dao/internal/live.go
-
22link_homework/internal/dao/internal/member_info.go
-
25link_homework/internal/logic/article/article.go
-
121link_homework/internal/logic/client/client.go
-
0link_homework/internal/logic/homework/.gitkeep
-
260link_homework/internal/logic/homework/homework.go
-
36link_homework/internal/logic/live/live.go
-
14link_homework/internal/logic/logic.go
-
76link_homework/internal/logic/login/login.go
-
43link_homework/internal/logic/middleware/JWTMiddleware.go
-
21link_homework/internal/logic/middleware/interceptor.go
-
256link_homework/internal/logic/record/record.go
-
31link_homework/internal/model/dto/Result.go
-
24link_homework/internal/model/dto/ToolStruct.go
-
24link_homework/internal/model/entity/activity_interactive_group.go
-
194link_homework/internal/model/entity/fx_article.go
-
172link_homework/internal/model/entity/live.go
-
32link_homework/internal/service/article.go
-
34link_homework/internal/service/client.go
-
37link_homework/internal/service/homework.go
-
32link_homework/internal/service/live.go
-
34link_homework/internal/service/login.go
-
8link_homework/internal/service/middleware.go
-
43link_homework/internal/service/record.go
-
36link_homework/main.go
-
17link_homework/manifest/config/config.yaml
-
8link_homework/manifest/deploy/kustomize/overlays/develop/configmap.yaml
-
142link_homework/utility/utility.go
@ -0,0 +1,38 @@ |
|||||
|
package ClientPage |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/os/gtime" |
||||
|
) |
||||
|
|
||||
|
type GetHomeworkListRse struct { |
||||
|
Id int `json:"groupId" orm:"table:activity_interactive_group;column:id" dc:"id" ` |
||||
|
Name string `json:"name" orm:"table:activity_interactive_group;column:name" dc:"作业题目"` |
||||
|
EndDate *gtime.Time `json:"endData" orm:"table:activity_interactive_group;column:end_date;time_format:yy-MM-dd" dc:"作业截止时间"` |
||||
|
Submit int `json:"submit"` |
||||
|
} |
||||
|
|
||||
|
type GetHomeworkQuestionReq struct { |
||||
|
Id int `json:"id" dc:"作业id"` |
||||
|
} |
||||
|
|
||||
|
type GetHomeworkQuestionRes struct { |
||||
|
Id int `json:"id" orm:"table:activity_interactive_form;column:id" dc:"题目id"` |
||||
|
Name string `json:"name" orm:"table:activity_interactive_form;column:name" dc:"作业名称"` |
||||
|
Description string `json:"description" orm:"table:activity_interactive_form;column:description" dc:"作业题目名字"` |
||||
|
Content string `json:"content" orm:"table:activity_interactive_form;column:content" dc:"题目内容"` |
||||
|
Status int `json:"status"` |
||||
|
Type int `json:"type" orm:"table:activity_interactive_form;column:type" dc:"题目类型"` |
||||
|
} |
||||
|
|
||||
|
//需要id(group_id)(form表),查id,form.name是作业的题目,form.description是作业题目的名字,content, status,type
|
||||
|
|
||||
|
type CommitHomeworkReq struct { |
||||
|
GroupId int `json:"id" v:"required:#作业id不能为空" dc:"作业id"` |
||||
|
CommitedAnswer []CommitAnswer `json:"homework" dc:"传过来的答案"` |
||||
|
} |
||||
|
|
||||
|
type CommitAnswer struct { |
||||
|
Id int `json:"id" orm:"table:activity_interactive_record;column:form_id" dc:"作业题目id"` |
||||
|
Answer []string `json:"answer" v:"required:#答案不能为空" dc:"作业答案,包含两部分,第一部分是题目,第二部分是答案,使用','分割的"` |
||||
|
Type int `json:"type" v:"required:#题目类型不能为空" dc:"题目类型,1:单选,2:多选,3:简答"` |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
package article |
||||
|
|
||||
|
type GetArticleListReq struct { |
||||
|
Name string `dc:"文章模糊查询名称"` |
||||
|
} |
@ -1 +0,0 @@ |
|||||
package v1 |
|
@ -0,0 +1,36 @@ |
|||||
|
package homework |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/os/gtime" |
||||
|
"link_homework/internal/model/entity" |
||||
|
) |
||||
|
|
||||
|
type GetHomeworkListReq struct { |
||||
|
PageNo int `v:"required#页码不能为空" dc:"页码"` |
||||
|
PageSize int `v:"required#页面大小不能为空" dc:"页面大小"` |
||||
|
} |
||||
|
|
||||
|
type GetHomeworkReq struct { |
||||
|
Id int `v:"required#作业id不能为空" dc:"作业id"` |
||||
|
} |
||||
|
|
||||
|
type AddHomeworkReq struct { |
||||
|
Name string `v:"required#作业名称不能为空" dc:"作业名称"` |
||||
|
ClubType int `v:"required|min:1|max:9#作业归属不能为空|作业归属不存在|作业归属不存在" dc:"作业归属"` |
||||
|
ArticleId int `v:"required-without:LiveId|min:1#请选择关联的文章或直播|关联文章不存在" dc:"关联文章id"` |
||||
|
LiveId int `v:"required-without:ArticleId|min:1#请选择关联的文章或直播|关联直播不存在" dc:"关联直播id"` |
||||
|
StartDate *gtime.Time `v:"required#作业开始时间不能为空" dc:"作业开始时间"` |
||||
|
EndDate *gtime.Time `v:"required|after-equal:StartDate#作业结束时间不能为空|作业结束时间必须晚于作业开始时间" dc:"作业结束时间"` |
||||
|
Questions []*entity.ActivityInteractiveForm `v:"required#题目集不能为空" dc:"题目集"` |
||||
|
} |
||||
|
|
||||
|
type EditHomeworkReq struct { |
||||
|
Id int `v:"required#作业id不能为空" dc:"作业id"` |
||||
|
Name string `v:"required#作业名称不能为空" dc:"作业名称"` |
||||
|
ClubType int `v:"required|min:1|max:9#作业所属不能为空|作业所属不存在|作业所属不存在" dc:"作业所属"` |
||||
|
ArticleId int `v:"required-without:LiveId|min:1#请选择关联的文章或直播|关联文章不存在" dc:"关联文章id"` |
||||
|
LiveId int `v:"required-without:ArticleId|min:1#请选择关联的文章或直播|关联直播不存在" dc:"关联直播id"` |
||||
|
StartDate *gtime.Time `v:"required#作业开始时间不能为空" dc:"作业开始时间"` |
||||
|
EndDate *gtime.Time `v:"required|after-equal:StartDate#作业结束时间不能为空|作业结束时间必须晚于作业开始时间" dc:"作业结束时间"` |
||||
|
Questions []*entity.ActivityInteractiveForm `v:"required#题目集不能为空" dc:"题目集"` |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
package homework |
@ -0,0 +1,68 @@ |
|||||
|
package record |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/os/gtime" |
||||
|
"link_homework/internal/model/dto" |
||||
|
) |
||||
|
|
||||
|
type GetRecordListReq struct { |
||||
|
Id int `json:"id" orm:"" dc:"作业id"` |
||||
|
PageNo int `json:"pageNo" dc:"当前页"` |
||||
|
PageSize int `json:"pageSize" dc:"每页条数"` |
||||
|
} |
||||
|
|
||||
|
// 合并并返回的提交详情所用信息
|
||||
|
type GetRecordListRes struct { |
||||
|
Total int `json:"total" dc:"总条数"` |
||||
|
Jwcode int `json:"jwcode" orm:"db:cms;table:member_info;column:jwcode" dc:"精网号"` |
||||
|
Name string `json:"name" orm:"db:cms;table:member_info;column:name" dc:"用户名字"` |
||||
|
DeptId string `json:"deptId" orm:"db:cms;table:member_info;column:deptId" dc:"部门id"` |
||||
|
DeptName string `json:"deptName" orm:"db:cms;member_info;column:deptName" dc:"部门名"` |
||||
|
ShopId string `json:"shopId" orm:"db:cms;member_info;column:shopId" dc:"门店id"` |
||||
|
ShopName string `json:"shopName" orm:"db:cms;member_info;column:shopName" dc:"门店名"` |
||||
|
Reply []dto.RecordInfo |
||||
|
} |
||||
|
|
||||
|
type GetRecordByConditionReq struct { |
||||
|
Id int `json:"id" orm:"" dc:"作业id"` |
||||
|
Jwcode int `json:"jwcode" dc:"精网号"` |
||||
|
DeptId string `json:"deptId" dc:"部门id"` |
||||
|
ShopId string `json:"shopId" dc:"门店id"` |
||||
|
PageNo int `json:"pageNo" dc:"当前页"` |
||||
|
PageSize int `json:"pageSize" dc:"每页条数"` |
||||
|
} |
||||
|
|
||||
|
/*GetRecordByConditionRes的返回值与GetRecordListRes的一致,所以直接套用*/ |
||||
|
|
||||
|
type GetDeptInfoRes struct { |
||||
|
DeptId string `json:"deptId" orm:"db:cms;table:member_info;column:deptId" dc:"部门id"` |
||||
|
DeptName string `json:"deptName" orm:"db:cms;member_info;column:deptName" dc:"部门名"` |
||||
|
} |
||||
|
|
||||
|
type GetShopInfoByDeptIdReq struct { |
||||
|
DeptId string `json:"deptId" dc:"部门id"` |
||||
|
} |
||||
|
|
||||
|
type GetShopInfoByDeptIdRes struct { |
||||
|
ShopId string `json:"shopId" orm:"db:cms;table:member_info;column:shopId" dc:"门店id"` |
||||
|
ShopName string `json:"shopName" orm:"db:cms;member_info;column:shopName" dc:"门店名"` |
||||
|
} |
||||
|
|
||||
|
type ExcelExportReq struct { |
||||
|
Jwcode int `json:"jwcode" dc:"精网号"` |
||||
|
Name string `json:"name" dc:"用户名字"` |
||||
|
DeptId string `json:"deptId" dc:"部门id"` |
||||
|
DeptName string `json:"deptName" dc:"部门名"` |
||||
|
ShopId string `json:"shopId" dc:"门店id"` |
||||
|
ShopName string `json:"shopName" dc:"门店名"` |
||||
|
Reply []Reply `json:"Reply" dc:"答案详情"` |
||||
|
} |
||||
|
|
||||
|
type Reply struct { |
||||
|
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:"提交时间"` |
||||
|
} |
@ -1,134 +1,87 @@ |
|||||
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= |
|
||||
|
github.com/360EntSecGroup-Skylar/excelize v1.4.1 h1:l55mJb6rkkaUzOpSsgEeKYtS6/0gHwBYyfo5Jcjv/Ks= |
||||
|
github.com/360EntSecGroup-Skylar/excelize v1.4.1/go.mod h1:vnax29X2usfl7HHkBrX5EvSCJcmH3dT9luvxzu8iGAE= |
||||
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= |
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= |
||||
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= |
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= |
||||
|
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= |
||||
|
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= |
||||
|
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= |
||||
|
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= |
||||
|
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= |
||||
|
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= |
||||
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= |
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= |
||||
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= |
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= |
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= |
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= |
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= |
||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= |
||||
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= |
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= |
||||
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= |
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= |
||||
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= |
|
||||
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= |
|
||||
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= |
|
||||
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= |
|
||||
|
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= |
||||
|
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= |
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= |
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= |
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= |
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= |
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= |
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= |
||||
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= |
|
||||
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= |
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= |
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= |
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= |
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= |
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= |
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= |
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= |
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= |
||||
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= |
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= |
||||
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= |
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= |
||||
github.com/goflyfox/gtoken v1.5.10 h1:oj/v5r/1TjMMZvxpyEZYdsEvG2ZK/SGGnyjvsKi4uHk= |
|
||||
github.com/goflyfox/gtoken v1.5.10/go.mod h1:YpoSAn9tbfrSBoQnY7raQP0HaiRjQAE+4J179ecRH5I= |
|
||||
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1 h1:jbaPawkb8qmaYzrmBDbTa8Zkhzacq1RBOZw+qRJExI4= |
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1 h1:jbaPawkb8qmaYzrmBDbTa8Zkhzacq1RBOZw+qRJExI4= |
||||
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1/go.mod h1:s2aI1fV9AvKi4NtMpv3pV0EHtazkvfUNVQmzapr7UJQ= |
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1/go.mod h1:s2aI1fV9AvKi4NtMpv3pV0EHtazkvfUNVQmzapr7UJQ= |
||||
github.com/gogf/gf/v2 v2.5.4/go.mod h1:7yf5qp0BznfsYx7Sw49m3mQvBsHpwAjJk3Q9ZnKoUEc= |
|
||||
|
github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.1 h1:1vPFyN0GLv24JD3WGhvKzXvKG+fmuixDTawbtfzCzRQ= |
||||
|
github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.1/go.mod h1:IWyGxzplp06tRc6Ah/eCLuBntnKSw9sn1maH0vzPPtw= |
||||
github.com/gogf/gf/v2 v2.8.1 h1:1oVQg3G5OgCats4qWFTH3pHLe92nfUQeUDta05tUs1g= |
github.com/gogf/gf/v2 v2.8.1 h1:1oVQg3G5OgCats4qWFTH3pHLe92nfUQeUDta05tUs1g= |
||||
github.com/gogf/gf/v2 v2.8.1/go.mod h1:6iYuZZ+A0ZcH8+4MDS/P0SvTPCvKzRvyAsY1kbkJYJc= |
github.com/gogf/gf/v2 v2.8.1/go.mod h1:6iYuZZ+A0ZcH8+4MDS/P0SvTPCvKzRvyAsY1kbkJYJc= |
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= |
|
||||
|
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= |
||||
|
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= |
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= |
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= |
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= |
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= |
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= |
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= |
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= |
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= |
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= |
||||
github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78= |
|
||||
github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= |
github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= |
||||
github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= |
github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= |
||||
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= |
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= |
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= |
|
||||
|
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= |
||||
|
github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= |
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= |
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= |
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= |
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= |
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= |
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= |
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= |
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= |
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= |
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= |
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= |
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= |
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= |
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= |
||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= |
|
||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= |
|
||||
|
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= |
||||
|
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= |
||||
|
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= |
||||
|
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= |
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= |
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= |
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= |
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= |
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= |
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= |
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
||||
|
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= |
||||
|
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= |
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= |
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= |
||||
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= |
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= |
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= |
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= |
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= |
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= |
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= |
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= |
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= |
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= |
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= |
|
||||
|
github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= |
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= |
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= |
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= |
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= |
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= |
|
||||
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= |
|
||||
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= |
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= |
||||
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= |
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= |
||||
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= |
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= |
||||
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= |
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= |
||||
go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM= |
|
||||
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= |
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= |
||||
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= |
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= |
||||
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= |
|
||||
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= |
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= |
||||
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= |
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= |
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= |
|
||||
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= |
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= |
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= |
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= |
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= |
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= |
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= |
|
||||
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= |
|
||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= |
|
||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= |
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
|
||||
|
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= |
||||
|
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= |
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
|
||||
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= |
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= |
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= |
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= |
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= |
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= |
|
||||
golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= |
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= |
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= |
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= |
|
||||
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= |
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= |
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= |
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= |
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= |
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= |
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
|
||||
|
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= |
||||
|
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= |
||||
|
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= |
||||
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= |
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= |
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= |
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
@ -1 +1,7 @@ |
|||||
package consts |
package consts |
||||
|
|
||||
|
// Redis和其他配置常量
|
||||
|
const ( |
||||
|
URL_KEY = "jingwang:cms:env" // Redis中的键
|
||||
|
URL_HASH_KEY = "HLJW_BASE_URL" // Redis中的hashKey
|
||||
|
) |
@ -0,0 +1,36 @@ |
|||||
|
package article |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/net/ghttp" |
||||
|
"link_homework/api/v1/article" |
||||
|
"link_homework/internal/model/dto" |
||||
|
"link_homework/internal/service" |
||||
|
) |
||||
|
|
||||
|
type cArticle struct{} |
||||
|
|
||||
|
func Article() *cArticle { |
||||
|
return &cArticle{} |
||||
|
} |
||||
|
|
||||
|
func (c cArticle) GetArticleList(r *ghttp.Request) { |
||||
|
var req *article.GetArticleListReq |
||||
|
if err := r.Parse(&req); err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 400, |
||||
|
Message: err.Error(), |
||||
|
}) |
||||
|
} |
||||
|
res, err := service.Article().GetArticleList(r.Context(), req.Name) |
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 400, |
||||
|
Message: err.Error(), |
||||
|
}) |
||||
|
} |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 200, |
||||
|
Message: "success", |
||||
|
Data: res, |
||||
|
}) |
||||
|
} |
@ -0,0 +1,56 @@ |
|||||
|
package auth |
||||
|
|
||||
|
import ( |
||||
|
"net/http" |
||||
|
|
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
"github.com/gogf/gf/v2/net/ghttp" |
||||
|
"link_homework/internal/model/dto" |
||||
|
"link_homework/internal/service" |
||||
|
) |
||||
|
|
||||
|
type LoginController struct { |
||||
|
} |
||||
|
|
||||
|
func NewLoginController() *LoginController { |
||||
|
return &LoginController{} |
||||
|
} |
||||
|
|
||||
|
// 登录接口
|
||||
|
|
||||
|
func (c *LoginController) Login(r *ghttp.Request) { |
||||
|
var ( |
||||
|
username = r.Get("username").String() |
||||
|
password = r.Get("password").String() |
||||
|
) |
||||
|
|
||||
|
token, err := service.LoginLogic().Login(r.Context(), username, password) |
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
|
||||
|
r.Response.WriteJsonExit(dto.SuccessWithData(g.Map{ |
||||
|
"token": token, |
||||
|
})) |
||||
|
} |
||||
|
|
||||
|
// 退出接口
|
||||
|
func (c *LoginController) Logout(r *ghttp.Request) { |
||||
|
// 获取请求中的 context
|
||||
|
ctx := r.Context() |
||||
|
|
||||
|
// 从请求头中获取 token
|
||||
|
token := r.Header.Get("token") |
||||
|
if token == "" { |
||||
|
r.Response.WriteJsonExit(dto.ErrorWithCode(http.StatusUnauthorized, "Token 不能为空")) |
||||
|
} |
||||
|
|
||||
|
// 校验 Token 是否有效
|
||||
|
valid, err := service.LoginLogic().ValidateToken(ctx, token) |
||||
|
if err != nil || !valid { |
||||
|
r.Response.WriteJsonExit(dto.ErrorWithCode(http.StatusUnauthorized, "Token 无效")) |
||||
|
} |
||||
|
|
||||
|
// 返回登出成功
|
||||
|
r.Response.WriteJsonExit(dto.Success()) |
||||
|
} |
@ -1 +1,85 @@ |
|||||
package clientPage |
package clientPage |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/net/ghttp" |
||||
|
CPage "link_homework/api/v1/ClientPage" |
||||
|
"link_homework/internal/model/dto" |
||||
|
"link_homework/internal/service" |
||||
|
"link_homework/utility" |
||||
|
) |
||||
|
|
||||
|
type ClientPage struct{} |
||||
|
|
||||
|
func NewClientPage() *ClientPage { |
||||
|
return &ClientPage{} |
||||
|
} |
||||
|
|
||||
|
// 查询作业列表
|
||||
|
func (c *ClientPage) GetHomeworkList(r *ghttp.Request) { |
||||
|
// 获取请求头中的token
|
||||
|
token := r.Header.Get("token") |
||||
|
// 调用utility包中的GetJwcodeJSON函数,传入token,获取jwcode
|
||||
|
jwcode, err := utility.GetJwcodeJSON(token) |
||||
|
// 如果出现错误,则返回错误信息
|
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
// 调用service包中的ClientGetHomeworkList函数,传入r.Context()和jwcode,获取作业列表
|
||||
|
result, err := service.Client().ClientGetHomeworkList(r.Context(), jwcode) |
||||
|
// 如果出现错误,则返回错误信息
|
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
// 返回作业列表
|
||||
|
r.Response.WriteJsonExit(dto.SuccessWithData(result)) |
||||
|
} |
||||
|
|
||||
|
// 查询题目列表
|
||||
|
func (c *ClientPage) GetHomeworkQuestion(r *ghttp.Request) { |
||||
|
// 定义一个CPage.GetHomeworkQuestionReq类型的变量req
|
||||
|
var req CPage.GetHomeworkQuestionReq |
||||
|
// 解析请求参数,将解析结果赋值给req
|
||||
|
if err := r.Parse(&req); err != nil { |
||||
|
// 如果解析失败,返回错误信息
|
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
// 调用service.Client().GetHomeworkQuestion方法,传入req.Id作为参数,获取作业题目
|
||||
|
result, err := service.Client().GetHomeworkQuestion(r.Context(), req.Id) |
||||
|
// 如果获取作业题目失败,返回错误信息
|
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
// 如果获取的作业题目为空,返回错误信息
|
||||
|
if result == nil { |
||||
|
r.Response.WriteJsonExit(dto.Error("该作业没有题目")) |
||||
|
} |
||||
|
// 返回作业题目
|
||||
|
r.Response.WriteJsonExit(dto.SuccessWithData(result)) |
||||
|
} |
||||
|
|
||||
|
func (c *ClientPage) CommitHomework(r *ghttp.Request) { |
||||
|
// 获取请求头中的token
|
||||
|
token := r.Request.Header.Get("token") |
||||
|
// 根据token获取jwcode
|
||||
|
jwcode, err := utility.GetJwcodeJSON(token) |
||||
|
// 如果获取失败,返回错误信息
|
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
// 定义提交作业请求结构体
|
||||
|
var req CPage.CommitHomeworkReq |
||||
|
// 解析请求参数
|
||||
|
if err := r.Parse(&req); err != nil { |
||||
|
// 如果解析失败,返回错误信息
|
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
|
||||
|
// 调用服务提交作业
|
||||
|
err = service.Client().CommitHomework(r.Context(), req, jwcode) |
||||
|
// 如果提交失败,返回错误信息
|
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
// 提交成功,返回成功信息
|
||||
|
r.Response.WriteJsonExit(dto.SuccessWithMsg("提交作业成功")) |
||||
|
} |
@ -0,0 +1,105 @@ |
|||||
|
package homework |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
"github.com/gogf/gf/v2/net/ghttp" |
||||
|
"link_homework/api/v1/homework" |
||||
|
"link_homework/internal/model/dto" |
||||
|
"link_homework/internal/service" |
||||
|
) |
||||
|
|
||||
|
type cHomework struct{} |
||||
|
|
||||
|
func Homework() *cHomework { |
||||
|
return &cHomework{} |
||||
|
} |
||||
|
|
||||
|
func (c cHomework) GetHomeworkList(r *ghttp.Request) { |
||||
|
var req *homework.GetHomeworkListReq |
||||
|
if err := r.Parse(&req); err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 400, |
||||
|
Message: err.Error(), |
||||
|
}) |
||||
|
} |
||||
|
res, err := service.Homework().GetHomeworkList(r.Context(), req.PageNo, req.PageSize) |
||||
|
total, err := service.Homework().GetHomeworkListTotal(r.Context()) |
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 400, |
||||
|
Message: err.Error(), |
||||
|
}) |
||||
|
} |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 200, |
||||
|
Message: "success", |
||||
|
Data: g.Map{ |
||||
|
"list": res, |
||||
|
"total": total, |
||||
|
}, |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
func (c cHomework) GetHomework(r *ghttp.Request) { |
||||
|
var req *homework.GetHomeworkReq |
||||
|
if err := r.Parse(&req); err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 400, |
||||
|
Message: err.Error(), |
||||
|
}) |
||||
|
} |
||||
|
res, err := service.Homework().GetHomework(r.Context(), req.Id) |
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 400, |
||||
|
Message: err.Error(), |
||||
|
}) |
||||
|
} |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 200, |
||||
|
Message: "success", |
||||
|
Data: res, |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
func (c cHomework) AddHomework(r *ghttp.Request) { |
||||
|
var req *homework.AddHomeworkReq |
||||
|
if err := r.Parse(&req); err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 400, |
||||
|
Message: err.Error(), |
||||
|
}) |
||||
|
} |
||||
|
err := service.Homework().AddHomework(r.Context(), req) |
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 400, |
||||
|
Message: err.Error(), |
||||
|
}) |
||||
|
} |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 200, |
||||
|
Message: "success", |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
func (c cHomework) EditHomework(r *ghttp.Request) { |
||||
|
var req *homework.EditHomeworkReq |
||||
|
if err := r.Parse(&req); err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 400, |
||||
|
Message: err.Error(), |
||||
|
}) |
||||
|
} |
||||
|
err := service.Homework().EditHomework(r.Context(), req) |
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 400, |
||||
|
Message: err.Error(), |
||||
|
}) |
||||
|
} |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 200, |
||||
|
Message: "success", |
||||
|
}) |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package live |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/net/ghttp" |
||||
|
"link_homework/internal/model/dto" |
||||
|
"link_homework/internal/service" |
||||
|
) |
||||
|
|
||||
|
type cLive struct{} |
||||
|
|
||||
|
func Live() *cLive { |
||||
|
return &cLive{} |
||||
|
} |
||||
|
|
||||
|
func (c cLive) GetLiveList(r *ghttp.Request) { |
||||
|
res, err := service.Live().GetLiveList(r.Context()) |
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 400, |
||||
|
Message: err.Error(), |
||||
|
}) |
||||
|
} |
||||
|
r.Response.WriteJsonExit(dto.Result{ |
||||
|
Code: 200, |
||||
|
Message: "success", |
||||
|
Data: res, |
||||
|
}) |
||||
|
} |
@ -0,0 +1,95 @@ |
|||||
|
package record |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/net/ghttp" |
||||
|
"link_homework/api/v1/record" |
||||
|
"link_homework/internal/model/dto" |
||||
|
"link_homework/internal/service" |
||||
|
) |
||||
|
|
||||
|
type ManageRecord struct{} |
||||
|
|
||||
|
func NewManageRecord() *ManageRecord { |
||||
|
return &ManageRecord{} |
||||
|
} |
||||
|
|
||||
|
// 查询所有提交记录
|
||||
|
func (m *ManageRecord) GetRecordList(r *ghttp.Request) { |
||||
|
// 定义一个record.GetRecordListReq类型的变量req
|
||||
|
var req record.GetRecordListReq |
||||
|
// 解析请求参数,如果解析失败,则返回错误信息
|
||||
|
if err := r.Parse(&req); err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error("参数解析失败: " + err.Error())) |
||||
|
} |
||||
|
// 调用service.Record().GetRecordList方法,获取记录列表,如果获取失败,则返回错误信息
|
||||
|
result, err := service.Record().GetRecordList(r.Context(), req.Id, req.PageNo, req.PageSize) |
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
// 返回成功信息,并附带记录列表
|
||||
|
r.Response.WriteJsonExit(dto.SuccessWithData(result)) |
||||
|
} |
||||
|
|
||||
|
// 根据条件查询提交记录
|
||||
|
func (m *ManageRecord) GetRecordByCondition(r *ghttp.Request) { |
||||
|
// 定义一个record.GetRecordByConditionReq类型的变量req
|
||||
|
var req record.GetRecordByConditionReq |
||||
|
// 解析请求参数,将解析结果赋值给req
|
||||
|
if err := r.Parse(&req); err != nil { |
||||
|
// 如果解析失败,返回错误信息
|
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
// 调用service.Record().GetRecordByCondition方法,根据req中的参数查询记录
|
||||
|
result, err := service.Record().GetRecordByCondition(r.Context(), req.Id, req.Jwcode, req.DeptId, req.ShopId, req.PageNo, req.PageSize) |
||||
|
// 如果查询失败,返回错误信息
|
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
// 如果查询结果为空,返回错误信息
|
||||
|
if result == nil { |
||||
|
r.Response.WriteJsonExit(dto.Error("没有查询到记录")) |
||||
|
} |
||||
|
// 返回查询结果
|
||||
|
r.Response.WriteJsonExit(dto.SuccessWithData(result)) |
||||
|
} |
||||
|
|
||||
|
// 查询用户部门信息
|
||||
|
func (m *ManageRecord) GetDeptInfo(r *ghttp.Request) { |
||||
|
// 调用service.Record().GetDeptInfo()方法,获取部门信息
|
||||
|
result, err := service.Record().GetDeptInfo(r.Context()) |
||||
|
// 如果出现错误,则返回错误信息
|
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
// 如果没有错误,则返回成功信息
|
||||
|
r.Response.WriteJsonExit(dto.SuccessWithData(result)) |
||||
|
} |
||||
|
|
||||
|
// 查询用户门店信息
|
||||
|
func (m *ManageRecord) GetShopInfo(r *ghttp.Request) { |
||||
|
// 定义一个结构体变量req,用于存储请求参数
|
||||
|
var req record.GetShopInfoByDeptIdReq |
||||
|
// 解析请求参数,如果解析失败,则返回错误信息
|
||||
|
if err := r.Parse(&req); err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
// 调用service.Record().GetShopInfoByDeptId方法,根据部门ID获取店铺信息,如果获取失败,则返回错误信息
|
||||
|
result, err := service.Record().GetShopInfoByDeptId(r.Context(), req.DeptId) |
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error(err.Error())) |
||||
|
} |
||||
|
// 返回成功信息,包含获取到的店铺信息
|
||||
|
r.Response.WriteJsonExit(dto.SuccessWithData(result)) |
||||
|
} |
||||
|
|
||||
|
// ExportRecordByCondition 导出记录
|
||||
|
func (m *ManageRecord) ExportRecordByCondition(r *ghttp.Request) { |
||||
|
var req record.GetRecordByConditionReq |
||||
|
// 解析查询条件
|
||||
|
if err := r.Parse(&req); err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error("参数解析失败: " + err.Error())) |
||||
|
return |
||||
|
} |
||||
|
//查询数据,创建excel文件,设置表头,写入数据,设置文件名,保存到缓冲区并返回,设置响应头,指定内容类型为excel文件,指定文件名为fileName,将buffer中的内容写入响应
|
||||
|
service.Record().ExportExcel(r, req.Id, req.Jwcode, req.DeptId, req.ShopId, req.PageNo, req.PageSize) |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package article |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"link_homework/internal/dao" |
||||
|
"link_homework/internal/model/entity" |
||||
|
"link_homework/internal/service" |
||||
|
) |
||||
|
|
||||
|
type ( |
||||
|
sArticle struct{} |
||||
|
) |
||||
|
|
||||
|
func init() { |
||||
|
service.RegisterArticle(New()) |
||||
|
} |
||||
|
|
||||
|
func New() service.IArticle { |
||||
|
return &sArticle{} |
||||
|
} |
||||
|
|
||||
|
func (s *sArticle) GetArticleList(ctx context.Context, name string) (articleList []*entity.FxArticle, err error) { |
||||
|
err = dao.FxArticle.Ctx(ctx).Where("title like ?", "%"+name+"%").OrderDesc("update_time").Limit(8).Scan(&articleList) |
||||
|
return |
||||
|
} |
@ -0,0 +1,121 @@ |
|||||
|
package client |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"encoding/json" |
||||
|
"errors" |
||||
|
"fmt" |
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
"github.com/gogf/gf/v2/os/gtime" |
||||
|
"link_homework/api/v1/ClientPage" |
||||
|
"link_homework/internal/dao" |
||||
|
"link_homework/internal/service" |
||||
|
) |
||||
|
|
||||
|
type sClient struct{} |
||||
|
|
||||
|
func init() { |
||||
|
service.RegisterClient(&sClient{}) |
||||
|
} |
||||
|
|
||||
|
func (s *sClient) ClientGetHomeworkList(ctx context.Context, jwcode int) (homeworkList []ClientPage.GetHomeworkListRse, err error) { |
||||
|
// 从Redis中获取数据
|
||||
|
value, _ := g.Redis().Get(ctx, fmt.Sprintf("%d ClientHomeworkList", jwcode)) //从Redis中获取ClientHomeworkList的值
|
||||
|
if value.String() != "" { //如果值不为空
|
||||
|
err = json.Unmarshal(value.Bytes(), &homeworkList) //JSON -> Go数据结构
|
||||
|
if err != nil { //如果解析失败
|
||||
|
return nil, errors.New("从Redis获取数据,JSON解析失败") //返回错误信息
|
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 如果Redis中没有数据,查询数据库
|
||||
|
// 查询活动互动组表,根据条件查询id、name、end_date字段,并按照end_date降序排列
|
||||
|
err = dao.ActivityInteractiveGroup.Ctx(ctx).Fields("id", "name", "DATE_FORMAT(end_date, '%Y-%m-%d') as end_date"). |
||||
|
Where("end_date>?", gtime.Now()).Where("status", 1).OrderDesc("end_date").Scan(&homeworkList) |
||||
|
if err != nil { |
||||
|
return |
||||
|
} |
||||
|
//计算提交次数
|
||||
|
for i, item := range homeworkList { |
||||
|
result, _ := dao.ActivityInteractiveRecord.Ctx(ctx).Where("group_id", item.Id).Where("jwcode", jwcode). |
||||
|
Group("form_id").Limit(1).Value("COUNT(*)") |
||||
|
homeworkList[i].Submit = result.Int() |
||||
|
} |
||||
|
|
||||
|
// 将查询结果JSON化并存入Redis
|
||||
|
ClientHomeworkListJSON, _ := json.Marshal(homeworkList) |
||||
|
_, err = g.Redis().Set(ctx, "ClientHomeworkList", ClientHomeworkListJSON) |
||||
|
if err != nil { |
||||
|
return nil, errors.New("Redis存储失败") |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
func (s *sClient) GetHomeworkQuestion(ctx context.Context, groupId int) (questions []ClientPage.GetHomeworkQuestionRes, err error) { |
||||
|
// 从Redis中获取数据
|
||||
|
value, _ := g.Redis().Get(ctx, fmt.Sprintf("%d HomeworkQuestions", groupId)) |
||||
|
if value.String() != "" { |
||||
|
err = json.Unmarshal(value.Bytes(), &questions) //JSON -> Go数据结构
|
||||
|
if err != nil { |
||||
|
return nil, errors.New("从Redis获取数据,JSON解析失败") |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 如果Redis中没有数据,查询数据库
|
||||
|
err = dao.ActivityInteractiveForm.Ctx(ctx).Fields("id", "name", "content", "status", "type", "description"). |
||||
|
Where("group_id", groupId).Scan(&questions) |
||||
|
|
||||
|
// 将查询结果JSON化并存入Redis
|
||||
|
HomeworkQuestionsJSON, _ := json.Marshal(questions) |
||||
|
_, err = g.Redis().Set(ctx, fmt.Sprintf("%d HomeworkQuestions", groupId), HomeworkQuestionsJSON) |
||||
|
|
||||
|
return |
||||
|
} |
||||
|
|
||||
|
func (s *sClient) CommitHomework(ctx context.Context, req ClientPage.CommitHomeworkReq, jwcode int) (err error) { |
||||
|
//req中需要有:作业id,提交的每一个题的答案,每一个提的类型
|
||||
|
for _, answer := range req.CommitedAnswer { |
||||
|
if answer.Type == 1 { //单选或者多选
|
||||
|
// 插入单选或者多选答案
|
||||
|
_, err := dao.ActivityInteractiveRecord.Ctx(ctx).Data(g.Map{ |
||||
|
"jwcode": jwcode, // 问卷编号
|
||||
|
"form_id": answer.Id, // 答案编号
|
||||
|
"group_id": req.GroupId, // 组编号
|
||||
|
"content": answer.Answer[0], // 答案内容
|
||||
|
}).Insert() |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
} else if answer.Type == 2 { //多选
|
||||
|
// 插入多选答案
|
||||
|
_, err := dao.ActivityInteractiveRecord.Ctx(ctx).Data(g.Map{ |
||||
|
"jwcode": jwcode, // 问卷编号
|
||||
|
"form_id": answer.Id, // 答案编号
|
||||
|
"group_id": req.GroupId, // 组编号
|
||||
|
"content": answer.Answer, // 答案内容
|
||||
|
}).Insert() |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
} else if answer.Type == 3 { //简答
|
||||
|
// 插入简答答案
|
||||
|
_, err := dao.ActivityInteractiveRecord.Ctx(ctx).Data(g.Map{ |
||||
|
"jwcode": jwcode, // 问卷编号
|
||||
|
"form_id": answer.Id, // 答案编号
|
||||
|
"group_id": req.GroupId, // 组编号
|
||||
|
"content_title": answer.Answer[0], // 答案标题
|
||||
|
"content": answer.Answer[1], // 答案内容
|
||||
|
}).Insert() |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
key, _ := g.Redis().Keys(ctx, fmt.Sprintf("%d ClientHomeworkList", jwcode)) |
||||
|
if len(key) > 0 { |
||||
|
_, _ = g.Redis().Del(ctx, key...) |
||||
|
} |
||||
|
return |
||||
|
} |
@ -0,0 +1,260 @@ |
|||||
|
package homework |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"encoding/json" |
||||
|
"fmt" |
||||
|
"github.com/gogf/gf/v2/database/gdb" |
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
"github.com/gogf/gf/v2/os/gtime" |
||||
|
"link_homework/api/v1/homework" |
||||
|
"link_homework/internal/dao" |
||||
|
"link_homework/internal/model/do" |
||||
|
"link_homework/internal/model/entity" |
||||
|
"link_homework/internal/service" |
||||
|
) |
||||
|
|
||||
|
type ( |
||||
|
sHomework struct{} |
||||
|
) |
||||
|
|
||||
|
func init() { |
||||
|
service.RegisterHomework(New()) |
||||
|
} |
||||
|
|
||||
|
func New() service.IHomework { |
||||
|
return &sHomework{} |
||||
|
} |
||||
|
|
||||
|
func (s *sHomework) GetHomeworkList(ctx context.Context, pageNo int, pageSize int) (homeworkList []*entity.ActivityInteractiveGroup, err error) { |
||||
|
// 从Redis中获取数据
|
||||
|
value, _ := g.Redis().Get(ctx, fmt.Sprintf("%d-%d homeworklist", pageNo, pageSize)) |
||||
|
if value.String() != "" { |
||||
|
// 如果Redis中有数据,尝试解析为ActivityInteractiveGroup列表
|
||||
|
err = json.Unmarshal(value.Bytes(), &homeworkList) //反序列化
|
||||
|
homeworklist, cnt := UpdateHomework(ctx, homeworkList) |
||||
|
|
||||
|
if cnt > 0 { |
||||
|
// 将修改后的作业列表序列化并存储到Redis,更新频繁变更的数据
|
||||
|
homeworkListJson, _ := json.Marshal(homeworklist) |
||||
|
_, err = g.Redis().Set(ctx, fmt.Sprintf("%d-%d homeworklist", pageNo, pageSize), homeworkListJson) |
||||
|
} |
||||
|
|
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return homeworklist, err |
||||
|
} |
||||
|
|
||||
|
// 如果Redis中没有数据,查询数据库
|
||||
|
err = dao.ActivityInteractiveGroup.Ctx(ctx).With(entity.Live{}).OrderDesc("created_at").Page(pageNo, pageSize).Scan(&homeworkList) |
||||
|
err = g.DB("cms").Model("fx_article").Where("id", gdb.ListItemValuesUnique(homeworkList, "ArticleId")).ScanList(&homeworkList, "Article", "id:ArticleId") |
||||
|
homeworkList = InitHomework(ctx, homeworkList) |
||||
|
homeworkList, _ = UpdateHomework(ctx, homeworkList) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
// 将查询到的作业列表序列化并存储到Redis,更新频繁变更的数据
|
||||
|
homeworkListJson, _ := json.Marshal(homeworkList) |
||||
|
_, err = g.Redis().Set(ctx, fmt.Sprintf("%d-%d homeworklist", pageNo, pageSize), homeworkListJson) |
||||
|
|
||||
|
return |
||||
|
} |
||||
|
|
||||
|
func UpdateHomework(ctx context.Context, homeworkList []*entity.ActivityInteractiveGroup) ([]*entity.ActivityInteractiveGroup, int) { |
||||
|
cnt := 0 |
||||
|
for _, v := range homeworkList { |
||||
|
if v.Status != 2 { |
||||
|
if v.StartDate.After(gtime.Now()) { |
||||
|
v.Status = 0 |
||||
|
} else if v.EndDate.Before(gtime.Now().AddDate(0, 0, -1)) { |
||||
|
v.Status = 2 |
||||
|
cnt++ |
||||
|
_, _ = dao.ActivityInteractiveGroup.Ctx(ctx).Data(do.ActivityInteractiveGroup{ |
||||
|
Status: 2, |
||||
|
}).WherePri(v.Id).Update() |
||||
|
} else { |
||||
|
v.Status = 1 |
||||
|
} |
||||
|
if v.Status != 0 { |
||||
|
result, _ := dao.ActivityInteractiveRecord.Ctx(ctx).Where("group_id", v.Id).Group("form_id").Limit(1).Value("COUNT(*)") |
||||
|
v.Count = result.Int() |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return homeworkList, cnt |
||||
|
} |
||||
|
|
||||
|
func InitHomework(ctx context.Context, homeworkList []*entity.ActivityInteractiveGroup) []*entity.ActivityInteractiveGroup { |
||||
|
for _, v := range homeworkList { |
||||
|
if v.Status == 2 { |
||||
|
if v.Status != 0 { |
||||
|
result, _ := dao.ActivityInteractiveRecord.Ctx(ctx).Where("group_id", v.Id).Group("form_id").Limit(1).Value("COUNT(*)") |
||||
|
v.Count = result.Int() |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return homeworkList |
||||
|
} |
||||
|
|
||||
|
func (s *sHomework) GetHomeworkListTotal(ctx context.Context) (total int, err error) { |
||||
|
total, err = dao.ActivityInteractiveGroup.Ctx(ctx).Count() |
||||
|
if err != nil { |
||||
|
return 0, err |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
func (s *sHomework) GetHomework(ctx context.Context, id int) (homework *entity.ActivityInteractiveGroup, err error) { |
||||
|
err = dao.ActivityInteractiveGroup.Ctx(ctx).Where("id", id).With(entity.Live{}, entity.ActivityInteractiveForm{}).Scan(&homework) |
||||
|
err = g.DB("cms").Model("fx_article").Where("id", homework.ArticleId).Scan(&homework.Article) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
func (s *sHomework) AddHomework(ctx context.Context, req *homework.AddHomeworkReq) (err error) { |
||||
|
// 判断作业是否已结束
|
||||
|
status := 0 |
||||
|
if req.StartDate.Before(gtime.Now()) { |
||||
|
if req.EndDate.Before(gtime.Now().AddDate(0, 0, -1)) { |
||||
|
return fmt.Errorf("作业时间已过期,无法添加!") |
||||
|
} else { |
||||
|
status = 1 |
||||
|
} |
||||
|
} |
||||
|
var Id int64 |
||||
|
if req.ArticleId == 0 { // 关联文章
|
||||
|
Id, err = dao.ActivityInteractiveGroup.Ctx(ctx).Data(do.ActivityInteractiveGroup{ |
||||
|
Name: req.Name, |
||||
|
Status: status, |
||||
|
ClubType: req.ClubType, |
||||
|
LiveId: req.LiveId, |
||||
|
StartDate: req.StartDate, |
||||
|
EndDate: req.EndDate, |
||||
|
}).InsertAndGetId() |
||||
|
} else if req.LiveId == 0 { // 关联直播
|
||||
|
Id, err = dao.ActivityInteractiveGroup.Ctx(ctx).Data(do.ActivityInteractiveGroup{ |
||||
|
Name: req.Name, |
||||
|
Status: status, |
||||
|
ClubType: req.ClubType, |
||||
|
ArticleId: req.ArticleId, |
||||
|
StartDate: req.StartDate, |
||||
|
EndDate: req.EndDate, |
||||
|
}).InsertAndGetId() |
||||
|
} else { |
||||
|
return fmt.Errorf("不能同时关联文章和直播!") |
||||
|
} |
||||
|
// 添加所有题目
|
||||
|
for _, v := range req.Questions { |
||||
|
_, err = dao.ActivityInteractiveForm.Ctx(ctx).Data(do.ActivityInteractiveForm{ |
||||
|
Name: req.Name, |
||||
|
Description: v.Description, |
||||
|
Content: v.Content, |
||||
|
Status: status, |
||||
|
Type: v.Type, |
||||
|
GroupId: Id, |
||||
|
}).Insert() |
||||
|
} |
||||
|
// 添加数据后,删除所有缓存
|
||||
|
keys, err := g.Redis().Keys(ctx, "*-* homeworklist") |
||||
|
if len(keys) > 0 { |
||||
|
_, err = g.Redis().Del(ctx, keys...) |
||||
|
} |
||||
|
|
||||
|
//删除客户端缓存
|
||||
|
keys, err = g.Redis().Keys(ctx, "* ClientHomeworkList") |
||||
|
if len(keys) > 0 { |
||||
|
_, err = g.Redis().Del(ctx, keys...) |
||||
|
} |
||||
|
|
||||
|
return |
||||
|
} |
||||
|
|
||||
|
func (s *sHomework) EditHomework(ctx context.Context, req *homework.EditHomeworkReq) (err error) { |
||||
|
// 判断作业是否已结束
|
||||
|
var nowhomework *entity.ActivityInteractiveGroup |
||||
|
err = dao.ActivityInteractiveGroup.Ctx(ctx).WherePri(req.Id).Scan(&nowhomework) |
||||
|
if nowhomework.EndDate.Before(gtime.Now()) { |
||||
|
return fmt.Errorf("作业已结束,无法修改!") |
||||
|
} else { |
||||
|
// 判断作业是否已开始
|
||||
|
flag := true |
||||
|
if nowhomework.StartDate.Before(gtime.Now()) { |
||||
|
flag = false |
||||
|
} |
||||
|
// 判断提交修改表单状态
|
||||
|
status := 0 |
||||
|
if req.StartDate.Before(gtime.Now()) { |
||||
|
if req.EndDate.Before(gtime.Now()) { |
||||
|
status = 2 |
||||
|
} else { |
||||
|
status = 1 |
||||
|
} |
||||
|
} |
||||
|
// 判断是否关联文章或直播
|
||||
|
if req.ArticleId == 0 { |
||||
|
_, err = g.Model("activity_interactive_group").Data(g.Map{ |
||||
|
"name": req.Name, |
||||
|
"status": status, |
||||
|
"club_type": req.ClubType, |
||||
|
"article_id": nil, |
||||
|
"live_id": req.LiveId, |
||||
|
"start_date": req.StartDate, |
||||
|
"end_date": req.EndDate, |
||||
|
}).WherePri(req.Id).Update() |
||||
|
} else if req.LiveId == 0 { |
||||
|
_, err = g.Model("activity_interactive_group").Data(g.Map{ |
||||
|
"name": req.Name, |
||||
|
"status": status, |
||||
|
"club_type": req.ClubType, |
||||
|
"article_id": req.ArticleId, |
||||
|
"live_id": nil, |
||||
|
"start_date": req.StartDate, |
||||
|
"end_date": req.EndDate, |
||||
|
}).WherePri(req.Id).Update() |
||||
|
} else { |
||||
|
return fmt.Errorf("不能同时关联文章和直播!") |
||||
|
} |
||||
|
if flag { // 未开始
|
||||
|
_, err = dao.ActivityInteractiveForm.Ctx(ctx).Where("group_id", req.Id).Delete() |
||||
|
for _, v := range req.Questions { |
||||
|
_, err = dao.ActivityInteractiveForm.Ctx(ctx).Data(do.ActivityInteractiveForm{ |
||||
|
Name: req.Name, |
||||
|
Description: v.Description, |
||||
|
Content: v.Content, |
||||
|
Status: status, |
||||
|
Type: v.Type, |
||||
|
GroupId: req.Id, |
||||
|
}).Insert() |
||||
|
} |
||||
|
} else { // 已开始
|
||||
|
for _, v := range req.Questions { |
||||
|
_, err = dao.ActivityInteractiveForm.Ctx(ctx).Data(do.ActivityInteractiveForm{ |
||||
|
Name: req.Name, |
||||
|
Description: v.Description, |
||||
|
Content: v.Content, |
||||
|
Status: status, |
||||
|
}).WherePri(v.Id).Update() |
||||
|
} |
||||
|
} |
||||
|
// 修改数据后,删除所有缓存
|
||||
|
keys, _ := g.Redis().Keys(ctx, "*-* homeworklist") |
||||
|
if len(keys) > 0 { |
||||
|
_, _ = g.Redis().Del(ctx, keys...) |
||||
|
} |
||||
|
|
||||
|
//删除客户端缓存
|
||||
|
keys, err = g.Redis().Keys(ctx, "* ClientHomeworkList") |
||||
|
if len(keys) > 0 { |
||||
|
_, err = g.Redis().Del(ctx, keys...) |
||||
|
} |
||||
|
keys, err = g.Redis().Keys(ctx, "* HomeworkQuestions") |
||||
|
if len(keys) > 0 { |
||||
|
_, err = g.Redis().Del(ctx, keys...) |
||||
|
} |
||||
|
|
||||
|
return |
||||
|
} |
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package live |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"link_homework/internal/dao" |
||||
|
"link_homework/internal/model/entity" |
||||
|
"link_homework/internal/service" |
||||
|
"time" |
||||
|
) |
||||
|
|
||||
|
type ( |
||||
|
sLive struct{} |
||||
|
) |
||||
|
|
||||
|
func init() { |
||||
|
service.RegisterLive(New()) |
||||
|
} |
||||
|
|
||||
|
func New() service.ILive { |
||||
|
return &sLive{} |
||||
|
} |
||||
|
|
||||
|
func (s *sLive) GetLiveList(ctx context.Context) (liveList []*entity.Live, err error) { |
||||
|
// 获取当前时间
|
||||
|
now := time.Now() |
||||
|
|
||||
|
// 获取当天时间的0点
|
||||
|
now = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) |
||||
|
|
||||
|
// 计算时间范围
|
||||
|
startTime := now.AddDate(0, 0, -1).Unix() |
||||
|
endTime := now.AddDate(0, 0, 8).Unix() |
||||
|
|
||||
|
err = dao.Live.Ctx(ctx).Where("start_time >= ? and start_time < ?", startTime, endTime).OrderAsc("start_time").Scan(&liveList) |
||||
|
return |
||||
|
} |
@ -1 +1,15 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
package logic |
package logic |
||||
|
|
||||
|
import ( |
||||
|
_ "link_homework/internal/logic/article" |
||||
|
_ "link_homework/internal/logic/client" |
||||
|
_ "link_homework/internal/logic/homework" |
||||
|
_ "link_homework/internal/logic/live" |
||||
|
_ "link_homework/internal/logic/login" |
||||
|
_ "link_homework/internal/logic/middleware" |
||||
|
_ "link_homework/internal/logic/record" |
||||
|
) |
@ -0,0 +1,76 @@ |
|||||
|
package login |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"errors" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/golang-jwt/jwt/v4" |
||||
|
"link_homework/internal/service" |
||||
|
) |
||||
|
|
||||
|
type sLoginLogic struct{} |
||||
|
|
||||
|
var ( |
||||
|
SecretKey = []byte("HomilyLink") // 用于签名和验证 JWT 的密钥
|
||||
|
) |
||||
|
|
||||
|
// 自定义声明结构
|
||||
|
type CustomClaims struct { |
||||
|
Username string `json:"username"` |
||||
|
jwt.RegisteredClaims |
||||
|
} |
||||
|
|
||||
|
func NewLoginLogic() *sLoginLogic { |
||||
|
return &sLoginLogic{} |
||||
|
} |
||||
|
|
||||
|
// 确保在初始化时注册该实现
|
||||
|
func init() { |
||||
|
service.RegisterLoginLogic(&sLoginLogic{}) |
||||
|
} |
||||
|
|
||||
|
// Login 方法实现用户登录并生成 Token
|
||||
|
func (l *sLoginLogic) Login(ctx context.Context, username, password string) (string, error) { |
||||
|
if username != "admin" || password != "12345" { |
||||
|
return "", errors.New("用户名或密码错误") |
||||
|
} |
||||
|
|
||||
|
// 创建 JWT Token
|
||||
|
token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ |
||||
|
"username": username, |
||||
|
"exp": time.Now().Add(time.Hour * 8).Unix(), // 8 小时后过期
|
||||
|
}) |
||||
|
|
||||
|
// 签名并获取完整的编码后的字符串 token
|
||||
|
tokenString, err := token.SignedString(SecretKey) |
||||
|
if err != nil { |
||||
|
return "", err |
||||
|
} |
||||
|
|
||||
|
return tokenString, nil |
||||
|
} |
||||
|
|
||||
|
// ValidateToken 验证 Token 是否有效
|
||||
|
func (l *sLoginLogic) ValidateToken(ctx context.Context, tokenString string) (bool, error) { |
||||
|
// 解析 token
|
||||
|
token, err := jwt.ParseWithClaims(tokenString, &CustomClaims{}, func(token *jwt.Token) (interface{}, error) { |
||||
|
return SecretKey, nil |
||||
|
}) |
||||
|
|
||||
|
if err != nil { |
||||
|
return false, errors.New("Token 无效: " + err.Error()) |
||||
|
} |
||||
|
|
||||
|
// 如果 token 有效,返回 true
|
||||
|
if token.Valid { |
||||
|
// 提取 CustomClaims 并打印 username
|
||||
|
//if claims, ok := token.Claims.(*CustomClaims); ok {
|
||||
|
// log.Printf("解析到的用户名: %s", claims.Username) // 打印解析到的用户名
|
||||
|
//}
|
||||
|
return true, nil |
||||
|
} |
||||
|
|
||||
|
// 如果 token 无效
|
||||
|
return false, errors.New("Token 验证失败") |
||||
|
} |
@ -0,0 +1,43 @@ |
|||||
|
package middleware |
||||
|
|
||||
|
import ( |
||||
|
"link_homework/internal/logic/login" |
||||
|
"net/http" |
||||
|
"strings" |
||||
|
|
||||
|
"github.com/gogf/gf/v2/net/ghttp" |
||||
|
"github.com/golang-jwt/jwt/v4" |
||||
|
) |
||||
|
|
||||
|
// JWT 验证中间件
|
||||
|
func JWTMiddleware(r *ghttp.Request) { |
||||
|
// 从请求头中获取 token
|
||||
|
authHeader := r.Header.Get("Authorization") |
||||
|
if authHeader == "" { |
||||
|
r.Response.WriteStatusExit(http.StatusUnauthorized, "Authorization header missing") |
||||
|
} |
||||
|
|
||||
|
// 检查 token 前缀
|
||||
|
parts := strings.SplitN(authHeader, " ", 2) |
||||
|
if len(parts) != 2 || parts[0] != "Bearer" { |
||||
|
r.Response.WriteStatusExit(http.StatusUnauthorized, "Invalid Authorization header format") |
||||
|
} |
||||
|
|
||||
|
tokenString := parts[1] |
||||
|
|
||||
|
// 解析 token
|
||||
|
token, err := jwt.ParseWithClaims(tokenString, &login.CustomClaims{}, func(token *jwt.Token) (interface{}, error) { |
||||
|
return login.SecretKey, nil |
||||
|
}) |
||||
|
|
||||
|
if err != nil || !token.Valid { |
||||
|
r.Response.WriteStatusExit(http.StatusUnauthorized, "Invalid token") |
||||
|
} |
||||
|
|
||||
|
// 将用户信息存储在上下文中
|
||||
|
if claims, ok := token.Claims.(*login.CustomClaims); ok { |
||||
|
r.SetCtxVar("username", claims.Username) |
||||
|
} |
||||
|
|
||||
|
r.Middleware.Next() |
||||
|
} |
@ -0,0 +1,256 @@ |
|||||
|
package record |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"encoding/json" |
||||
|
"errors" |
||||
|
"fmt" |
||||
|
"github.com/360EntSecGroup-Skylar/excelize" |
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
"github.com/gogf/gf/v2/net/ghttp" |
||||
|
pkgRecord "link_homework/api/v1/record" |
||||
|
"link_homework/internal/dao" |
||||
|
"link_homework/internal/model/dto" |
||||
|
"link_homework/internal/service" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
) |
||||
|
|
||||
|
type sRecord struct{} |
||||
|
|
||||
|
func init() { |
||||
|
service.RegisterRecord(&sRecord{}) |
||||
|
} |
||||
|
|
||||
|
func NewRecord() *sRecord { |
||||
|
return &sRecord{} |
||||
|
} |
||||
|
|
||||
|
// 无条件全查
|
||||
|
func (s *sRecord) GetRecordList(ctx context.Context, groupId, pageNo, pageSize int) (record []pkgRecord.GetRecordListRes, err error) { |
||||
|
//从record表中查询出jwcode,根据group_id
|
||||
|
if pageNo == 0 && pageSize == 0 { |
||||
|
err = dao.ActivityInteractiveRecord.Ctx(ctx).Fields("jwcode").Where("group_id", groupId).Group("jwcode").Scan(&record) |
||||
|
} else { |
||||
|
err = dao.ActivityInteractiveRecord.Ctx(ctx).Fields("jwcode").Where("group_id", groupId).Group("jwcode"). |
||||
|
Page(pageNo, pageSize).Scan(&record) |
||||
|
} |
||||
|
if err != nil { |
||||
|
return nil, errors.New("无条件查jwcode失败") |
||||
|
} |
||||
|
|
||||
|
//fmt.Println(record)
|
||||
|
//根据jwcode在member_info表中查询姓名(name), 部门id(deptId), 部门名(deptName), 门店id(shopId), 门店名(shopName)
|
||||
|
for i, info := range record { |
||||
|
err = g.DB("cms").Model("member_info").Fields("jwcode", "name", "deptId", "deptName", "shopId", "shopName"). |
||||
|
Where("jwcode", info.Jwcode).Scan(&record[i]) |
||||
|
if err != nil { |
||||
|
return nil, errors.New("无条件根据jwcode查member_info表失败") |
||||
|
} |
||||
|
total, err1 := dao.ActivityInteractiveRecord.Ctx(ctx).Fields("jwcode").Where("group_id", groupId).Group("jwcode").Count() |
||||
|
if err1 != nil { |
||||
|
return nil, errors.New("无条件查询总数失败") |
||||
|
} |
||||
|
record[i].Total = total |
||||
|
//根据jwcode,groupId在record表中查询最新的提交记录进行存放
|
||||
|
var recordInfo []dto.RecordInfo |
||||
|
err = dao.ActivityInteractiveRecord.Ctx(ctx).Fields("content", "content_title", "updated_at", "form_id"). |
||||
|
Where("jwcode", info.Jwcode).Where("group_id", groupId).Group("form_id").Order("updated_at desc").Scan(&recordInfo) |
||||
|
if err != nil { |
||||
|
return nil, errors.New("根据jwcode查询提交记录失败") |
||||
|
} |
||||
|
for i, title := range recordInfo { |
||||
|
err = dao.ActivityInteractiveForm.Ctx(ctx).Fields("description", "type").Where("id", title.FormId).Scan(&recordInfo[i]) |
||||
|
if err != nil { |
||||
|
return nil, errors.New("根据jwcode查询作业题目信息失败") |
||||
|
} |
||||
|
} |
||||
|
record[i].Reply = recordInfo |
||||
|
//fmt.Println(record)
|
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 根据条件查询 对所有结果进行筛选
|
||||
|
func (s *sRecord) GetRecordByCondition(ctx context.Context, groupId, jwcode int, deptId, shopId string, pageNo, pageSize int) (record []pkgRecord.GetRecordListRes, err error) { |
||||
|
//全查
|
||||
|
recordList, err := s.GetRecordList(ctx, groupId, pageNo, pageSize) |
||||
|
if err != nil { |
||||
|
return recordList, err |
||||
|
} |
||||
|
//判断传来的jwcode, deptId, shopId是否为空,根据情况进行不同的筛选
|
||||
|
if jwcode == 0 { //没有传jwcode
|
||||
|
if deptId == "" && shopId == "" { //000
|
||||
|
return recordList, err |
||||
|
} else if deptId != "" && shopId == "" { //010
|
||||
|
for _, info := range recordList { |
||||
|
if info.DeptId == deptId { |
||||
|
record = append(record, info) |
||||
|
} |
||||
|
} |
||||
|
if record == nil { |
||||
|
return nil, errors.New("只部门没有查询到相关记录") |
||||
|
} |
||||
|
return record, err |
||||
|
} else if deptId != "" && shopId != "" { //011
|
||||
|
for _, info := range recordList { |
||||
|
if info.DeptId == deptId && info.ShopId == shopId { |
||||
|
record = append(record, info) |
||||
|
} |
||||
|
} |
||||
|
if record == nil { |
||||
|
return nil, errors.New("部门,门店 没有查询到相关记录") |
||||
|
} |
||||
|
return record, err |
||||
|
} |
||||
|
} else { //传了jwcode
|
||||
|
if deptId == "" && shopId == "" { //100
|
||||
|
for _, info := range recordList { |
||||
|
if info.Jwcode == jwcode { |
||||
|
record = append(record, info) |
||||
|
} |
||||
|
} |
||||
|
if record == nil { |
||||
|
return nil, errors.New("只精网号没有查询到相关记录") |
||||
|
} |
||||
|
return record, err |
||||
|
} else if deptId != "" && shopId == "" { //110
|
||||
|
for _, info := range recordList { |
||||
|
if info.Jwcode == jwcode && info.DeptId == deptId { |
||||
|
record = append(record, info) |
||||
|
} |
||||
|
} |
||||
|
if record == nil { |
||||
|
return nil, errors.New("精网号,部门 没有查询到相关记录") |
||||
|
} |
||||
|
return record, err |
||||
|
} else if deptId != "" && shopId != "" { //111
|
||||
|
for _, info := range recordList { |
||||
|
if info.Jwcode == jwcode && info.DeptId == deptId && info.ShopId == shopId { |
||||
|
record = append(record, info) |
||||
|
} |
||||
|
} |
||||
|
if record == nil { |
||||
|
return nil, errors.New("精网号,部门,门店 没有查询到相关记录") |
||||
|
} |
||||
|
return record, err |
||||
|
} |
||||
|
} |
||||
|
return nil, errors.New("检查一下穿的参数是否正常") |
||||
|
} |
||||
|
|
||||
|
// 查询部门信息
|
||||
|
func (s *sRecord) GetDeptInfo(ctx context.Context) (depts []pkgRecord.GetDeptInfoRes, err error) { |
||||
|
// 从Redis中获取数据
|
||||
|
value, _ := g.Redis().Get(ctx, "deptinfo") |
||||
|
if value.String() != "" { |
||||
|
err = json.Unmarshal(value.Bytes(), &depts) |
||||
|
if err != nil { |
||||
|
return nil, errors.New("从Redis获取数据,JSON解析失败") |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 如果Redis中没有数据,查询数据库
|
||||
|
err = g.DB("cms").Model("member_info").Fields("deptId", "deptName").Group("deptId").Scan(&depts) |
||||
|
if err != nil { |
||||
|
return nil, errors.New("查询部门信息失败") |
||||
|
} |
||||
|
|
||||
|
// 将查询结果JSON化并存入Redis
|
||||
|
deptJSON, _ := json.Marshal(depts) |
||||
|
_, err = g.Redis().Set(ctx, "deptinfo", deptJSON) |
||||
|
if err != nil { |
||||
|
return nil, errors.New("Redis存储失败") |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 根据部门信息查询门店信息
|
||||
|
func (s *sRecord) GetShopInfoByDeptId(ctx context.Context, deptId string) (shops []pkgRecord.GetShopInfoByDeptIdRes, err error) { |
||||
|
// 从Redis中获取数据
|
||||
|
value, _ := g.Redis().Get(ctx, fmt.Sprintf("%s shopinfo", deptId)) |
||||
|
if value.String() != "" { |
||||
|
err = json.Unmarshal(value.Bytes(), &shops) |
||||
|
if err != nil { |
||||
|
return nil, errors.New("从Redis获取数据,JSON解析失败") |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 如果Redis中没有数据,查询数据库
|
||||
|
err = g.DB("cms").Model("member_info").Fields("shopId", "shopName"). |
||||
|
Where("deptId", deptId).Group("shopId").Scan(&shops) |
||||
|
|
||||
|
// 将查询结果JSON化并存入Redis
|
||||
|
shopJSON, _ := json.Marshal(shops) |
||||
|
_, err = g.Redis().Set(ctx, fmt.Sprintf("%s shopinfo", deptId), shopJSON) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// ExportExcel 查询数据,创建excel文件,设置表头,写入数据,设置文件名,保存到缓冲区并返回,设置响应头,指定内容类型为excel文件,指定文件名为fileName,将buffer中的内容写入响应
|
||||
|
func (s *sRecord) ExportExcel(r *ghttp.Request, groupId, jwcode int, deptId, shopId string, pageNo, pageSize int) { |
||||
|
// 调用查询服务
|
||||
|
records, err := service.Record().GetRecordByCondition( |
||||
|
r.Context(), groupId, jwcode, deptId, shopId, pageNo, pageSize) |
||||
|
if err != nil { |
||||
|
//g.Log().Error(r.Context(), "查询记录失败: ", err)
|
||||
|
r.Response.WriteJsonExit(dto.Error("查询记录失败: " + err.Error())) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
if len(records) == 0 { |
||||
|
//g.Log().Warning(r.Context(), "查询结果为空: 参数 = ", req)
|
||||
|
r.Response.WriteJsonExit(dto.Error("查询结果为空")) |
||||
|
return |
||||
|
} |
||||
|
// 创建 Excel 文件
|
||||
|
excelFile := excelize.NewFile() // 默认会创建一个 Sheet1
|
||||
|
sheetName := "Sheet1" // 使用默认的 Sheet1
|
||||
|
|
||||
|
// 设置表头
|
||||
|
headers := []string{"序号", "精网号", "名字", "部门ID", "部门名称", "门店ID", "门店名称", "题目ID", "题目类型", "题目名称", "简答题标题", "作答内容", "提交时间"} |
||||
|
for i, header := range headers { |
||||
|
col := string('A' + i) // 将索引转换为 Excel 列名
|
||||
|
excelFile.SetCellValue(sheetName, col+"1", header) |
||||
|
} |
||||
|
/*写入数据*/ |
||||
|
// 写入数据
|
||||
|
rowIndex := 2 // 从第二行开始写入数据
|
||||
|
for _, record := range records { |
||||
|
for _, reply := range record.Reply { // 遍历每个 `Reply`
|
||||
|
excelFile.SetCellValue(sheetName, "A"+strconv.Itoa(rowIndex), rowIndex-1) |
||||
|
excelFile.SetCellValue(sheetName, "B"+strconv.Itoa(rowIndex), record.Jwcode) |
||||
|
excelFile.SetCellValue(sheetName, "C"+strconv.Itoa(rowIndex), record.Name) |
||||
|
excelFile.SetCellValue(sheetName, "D"+strconv.Itoa(rowIndex), record.DeptId) |
||||
|
excelFile.SetCellValue(sheetName, "E"+strconv.Itoa(rowIndex), record.DeptName) |
||||
|
excelFile.SetCellValue(sheetName, "F"+strconv.Itoa(rowIndex), record.ShopId) |
||||
|
excelFile.SetCellValue(sheetName, "G"+strconv.Itoa(rowIndex), record.ShopName) |
||||
|
excelFile.SetCellValue(sheetName, "H"+strconv.Itoa(rowIndex), reply.FormId) |
||||
|
excelFile.SetCellValue(sheetName, "I"+strconv.Itoa(rowIndex), reply.Type) |
||||
|
excelFile.SetCellValue(sheetName, "J"+strconv.Itoa(rowIndex), reply.Description) |
||||
|
excelFile.SetCellValue(sheetName, "K"+strconv.Itoa(rowIndex), reply.ContentTitle) |
||||
|
excelFile.SetCellValue(sheetName, "L"+strconv.Itoa(rowIndex), reply.Content) |
||||
|
excelFile.SetCellValue(sheetName, "M"+strconv.Itoa(rowIndex), reply.UpdatedAt.String()) |
||||
|
rowIndex++ |
||||
|
} |
||||
|
} |
||||
|
/*写入数据*/ |
||||
|
|
||||
|
// 设置文件名
|
||||
|
fileName := "Records_" + time.Now().Format("20060102150405") + ".xlsx" |
||||
|
|
||||
|
// 保存到缓冲区并返回
|
||||
|
buffer, err := excelFile.WriteToBuffer() |
||||
|
if err != nil { |
||||
|
r.Response.WriteJsonExit(dto.Error("生成 Excel 文件失败: " + err.Error())) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 设置响应头,指定内容类型为Excel文件
|
||||
|
r.Response.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") |
||||
|
// 设置响应头,指定文件名为fileName
|
||||
|
r.Response.Header().Set("Content-Disposition", "attachment; filename="+fileName) |
||||
|
// 将buffer中的内容写入响应
|
||||
|
r.Response.Write(buffer.Bytes()) |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package dto |
||||
|
|
||||
|
import "github.com/gogf/gf/v2/os/gtime" |
||||
|
|
||||
|
// 从cms库中查询用户信息
|
||||
|
type MemberInfo struct { |
||||
|
Jwcode int `json:"jwcode" orm:"db:cms;table:member_info;column:jwcode" dc:"精网号"` |
||||
|
Name string `json:"name" orm:"db:cms;table:member_info;column:name" dc:"用户名字"` |
||||
|
DeptId string `json:"deptId" orm:"db:cms;table:member_info;column:deptId" dc:"部门id"` |
||||
|
DeptName string `json:"deptName" orm:"db:cms;member_info;column:deptName" dc:"部门名"` |
||||
|
ShopId string `json:"shopId" orm:"db:cms;member_info;column:shopId" dc:"门店id"` |
||||
|
ShopName string `json:"shopName" orm:"db:cms;member_info;column:shopName" dc:"门店名"` |
||||
|
} |
||||
|
|
||||
|
// 从live库里查询作业信息
|
||||
|
type RecordInfo struct { |
||||
|
//Jwcode int `json:"jwcode" orm:"db:default;table:activity_interactive_record;column:jwcode" dc:"精网号"`
|
||||
|
FormId int `json:"formId" orm:"db:default;table:activity_interactive_record;column:form_id" dc:"题目id"` |
||||
|
Type int `json:"type" orm:"db:default;table:activity_interactive_form;column:type" dc:"题目类型"` |
||||
|
Description string `json:"formTitle" orm:"db:default;table:activity_interactive_form;column:description" dc:"题目"` |
||||
|
ContentTitle string `json:"contentTitle" orm:"db:default;table:activity_interactive_record;column:content_title" dc:"作答标题"` |
||||
|
Content string `json:"content" orm:"db:default;table:activity_interactive_record;column:content" dc:"作答内容"` |
||||
|
UpdatedAt gtime.Time `json:"submitTime" orm:"db:default;table:activity_interactive_record;column:updated_at" dc:"提交时间/更新时间"` |
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
// ================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// You can delete these comments if you wish manually maintain this interface file.
|
||||
|
// ================================================================================
|
||||
|
|
||||
|
package service |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"link_homework/internal/model/entity" |
||||
|
) |
||||
|
|
||||
|
type ( |
||||
|
IArticle interface { |
||||
|
GetArticleList(ctx context.Context, name string) (articleList []*entity.FxArticle, err error) |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
localArticle IArticle |
||||
|
) |
||||
|
|
||||
|
func Article() IArticle { |
||||
|
if localArticle == nil { |
||||
|
panic("implement not found for interface IArticle, forgot register?") |
||||
|
} |
||||
|
return localArticle |
||||
|
} |
||||
|
|
||||
|
func RegisterArticle(i IArticle) { |
||||
|
localArticle = i |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
// ================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// You can delete these comments if you wish manually maintain this interface file.
|
||||
|
// ================================================================================
|
||||
|
|
||||
|
package service |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"link_homework/api/v1/ClientPage" |
||||
|
) |
||||
|
|
||||
|
type ( |
||||
|
IClient interface { |
||||
|
ClientGetHomeworkList(ctx context.Context, jwcode int) (homeworkList []ClientPage.GetHomeworkListRse, err error) |
||||
|
GetHomeworkQuestion(ctx context.Context, groupId int) (questions []ClientPage.GetHomeworkQuestionRes, err error) |
||||
|
CommitHomework(ctx context.Context, req ClientPage.CommitHomeworkReq, jwcode int) (err error) |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
localClient IClient |
||||
|
) |
||||
|
|
||||
|
func Client() IClient { |
||||
|
if localClient == nil { |
||||
|
panic("implement not found for interface IClient, forgot register?") |
||||
|
} |
||||
|
return localClient |
||||
|
} |
||||
|
|
||||
|
func RegisterClient(i IClient) { |
||||
|
localClient = i |
||||
|
} |
@ -0,0 +1,37 @@ |
|||||
|
// ================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// You can delete these comments if you wish manually maintain this interface file.
|
||||
|
// ================================================================================
|
||||
|
|
||||
|
package service |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"link_homework/api/v1/homework" |
||||
|
"link_homework/internal/model/entity" |
||||
|
) |
||||
|
|
||||
|
type ( |
||||
|
IHomework interface { |
||||
|
GetHomeworkList(ctx context.Context, pageNo int, pageSize int) (homeworkList []*entity.ActivityInteractiveGroup, err error) |
||||
|
GetHomeworkListTotal(ctx context.Context) (total int, err error) |
||||
|
GetHomework(ctx context.Context, id int) (homework *entity.ActivityInteractiveGroup, err error) |
||||
|
AddHomework(ctx context.Context, req *homework.AddHomeworkReq) (err error) |
||||
|
EditHomework(ctx context.Context, req *homework.EditHomeworkReq) (err error) |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
localHomework IHomework |
||||
|
) |
||||
|
|
||||
|
func Homework() IHomework { |
||||
|
if localHomework == nil { |
||||
|
panic("implement not found for interface IHomework, forgot register?") |
||||
|
} |
||||
|
return localHomework |
||||
|
} |
||||
|
|
||||
|
func RegisterHomework(i IHomework) { |
||||
|
localHomework = i |
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
// ================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// You can delete these comments if you wish manually maintain this interface file.
|
||||
|
// ================================================================================
|
||||
|
|
||||
|
package service |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"link_homework/internal/model/entity" |
||||
|
) |
||||
|
|
||||
|
type ( |
||||
|
ILive interface { |
||||
|
GetLiveList(ctx context.Context) (liveList []*entity.Live, err error) |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
localLive ILive |
||||
|
) |
||||
|
|
||||
|
func Live() ILive { |
||||
|
if localLive == nil { |
||||
|
panic("implement not found for interface ILive, forgot register?") |
||||
|
} |
||||
|
return localLive |
||||
|
} |
||||
|
|
||||
|
func RegisterLive(i ILive) { |
||||
|
localLive = i |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
// ================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// You can delete these comments if you wish manually maintain this interface file.
|
||||
|
// ================================================================================
|
||||
|
|
||||
|
package service |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
) |
||||
|
|
||||
|
type ( |
||||
|
ILoginLogic interface { |
||||
|
// Login 方法实现用户登录并生成 Token
|
||||
|
Login(ctx context.Context, username string, password string) (string, error) |
||||
|
// ValidateToken 验证 Token 是否有效
|
||||
|
ValidateToken(ctx context.Context, tokenString string) (bool, error) |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
localLoginLogic ILoginLogic |
||||
|
) |
||||
|
|
||||
|
func LoginLogic() ILoginLogic { |
||||
|
if localLoginLogic == nil { |
||||
|
panic("implement not found for interface ILoginLogic, forgot register?") |
||||
|
} |
||||
|
return localLoginLogic |
||||
|
} |
||||
|
|
||||
|
func RegisterLoginLogic(i ILoginLogic) { |
||||
|
localLoginLogic = i |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
// ================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// You can delete these comments if you wish manually maintain this interface file.
|
||||
|
// ================================================================================
|
||||
|
|
||||
|
package service |
||||
|
|
||||
|
type () |
@ -0,0 +1,43 @@ |
|||||
|
// ================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// You can delete these comments if you wish manually maintain this interface file.
|
||||
|
// ================================================================================
|
||||
|
|
||||
|
package service |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
pkgRecord "link_homework/api/v1/record" |
||||
|
|
||||
|
"github.com/gogf/gf/v2/net/ghttp" |
||||
|
) |
||||
|
|
||||
|
type ( |
||||
|
IRecord interface { |
||||
|
// 无条件全查
|
||||
|
GetRecordList(ctx context.Context, groupId int, pageNo int, pageSize int) (record []pkgRecord.GetRecordListRes, err error) |
||||
|
// 根据条件查询 对所有结果进行筛选
|
||||
|
GetRecordByCondition(ctx context.Context, groupId int, jwcode int, deptId string, shopId string, pageNo int, pageSize int) (record []pkgRecord.GetRecordListRes, err error) |
||||
|
// 查询部门信息
|
||||
|
GetDeptInfo(ctx context.Context) (depts []pkgRecord.GetDeptInfoRes, err error) |
||||
|
// 根据部门信息查询门店信息
|
||||
|
GetShopInfoByDeptId(ctx context.Context, deptId string) (shops []pkgRecord.GetShopInfoByDeptIdRes, err error) |
||||
|
// ExportExcel 查询数据,创建excel文件,设置表头,写入数据,设置文件名,保存到缓冲区并返回,设置响应头,指定内容类型为excel文件,指定文件名为fileName,将buffer中的内容写入响应
|
||||
|
ExportExcel(r *ghttp.Request, groupId int, jwcode int, deptId string, shopId string, pageNo int, pageSize int) |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
localRecord IRecord |
||||
|
) |
||||
|
|
||||
|
func Record() IRecord { |
||||
|
if localRecord == nil { |
||||
|
panic("implement not found for interface IRecord, forgot register?") |
||||
|
} |
||||
|
return localRecord |
||||
|
} |
||||
|
|
||||
|
func RegisterRecord(i IRecord) { |
||||
|
localRecord = i |
||||
|
} |
@ -0,0 +1,142 @@ |
|||||
|
package utility |
||||
|
|
||||
|
import ( |
||||
|
"encoding/json" |
||||
|
"errors" |
||||
|
"fmt" |
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
"github.com/gogf/gf/v2/os/gctx" |
||||
|
"io/ioutil" |
||||
|
"link_homework/internal/consts" |
||||
|
"link_homework/internal/model/dto" |
||||
|
"net/http" |
||||
|
"strconv" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
// 获取 URL
|
||||
|
func getUrl(key, hashKey string) *dto.Result { |
||||
|
ctx := gctx.New() |
||||
|
|
||||
|
// 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())
|
||||
|
return dto.SuccessWithData(redisUrl.String()) |
||||
|
} |
||||
|
|
||||
|
// 2. 如果 Redis 中没有,查询数据库
|
||||
|
urlResult := selectBaseUrl(hashKey) |
||||
|
if urlResult.Code != 200 { |
||||
|
return urlResult // 数据库查询失败,返回错误
|
||||
|
} |
||||
|
url := urlResult.Data.(string) |
||||
|
|
||||
|
// 3. 将 URL 存入 Redis
|
||||
|
if _, err = g.Redis().Do(ctx, "HSET", key, hashKey, url); err != nil { |
||||
|
//g.Log().Warningf(ctx, "将数据存入 Redis 失败: %v", err)
|
||||
|
} |
||||
|
|
||||
|
//g.Log().Infof(ctx, "将 URL 存入 Redis: %s", url)
|
||||
|
return dto.SuccessWithData(url) |
||||
|
} |
||||
|
|
||||
|
// 查询数据库中的 URL
|
||||
|
func selectBaseUrl(hashKey string) *dto.Result { |
||||
|
//ctx := gctx.New()
|
||||
|
|
||||
|
// 查询数据库
|
||||
|
value, err := g.DB("cms").Model("env").Where("`key` = ?", hashKey).Value("value") |
||||
|
if err != nil { |
||||
|
//g.Log().Errorf(ctx, "数据库查询失败, 错误: %v, key: %s", err, hashKey)
|
||||
|
return dto.Error("数据库查询失败") |
||||
|
} |
||||
|
|
||||
|
if value.IsNil() || value.String() == "" { |
||||
|
//g.Log().Errorf(ctx, "未找到对应数据, key: %s", hashKey)
|
||||
|
return dto.Error("未找到对应数据") |
||||
|
} |
||||
|
|
||||
|
return dto.SuccessWithData(value.String()) |
||||
|
} |
||||
|
|
||||
|
// 获取 jwcode
|
||||
|
// 获取 jwcode
|
||||
|
func GetJwcodeJSON(token string) (int, error) { // 返回类型为 int
|
||||
|
//ctx := gctx.New()
|
||||
|
|
||||
|
// 1. 获取基础 URL
|
||||
|
urlResult := getUrl(consts.URL_KEY, consts.URL_HASH_KEY) |
||||
|
if urlResult.Code != 200 { |
||||
|
//g.Log().Errorf(ctx, "获取基础 URL 失败: %s", urlResult.Message)
|
||||
|
return 0, errors.New("获取基础 URL 失败: " + urlResult.Message) |
||||
|
} |
||||
|
baseUrl := urlResult.Data.(string) |
||||
|
//g.Log().Debugf(ctx, "成功获取基础 URL: %s", baseUrl)
|
||||
|
|
||||
|
// 2. 拼接完整的 URL
|
||||
|
url := baseUrl + "/api/v2/member/info" |
||||
|
requestBody := strings.NewReader(`{"token":"` + token + `"}`) |
||||
|
|
||||
|
// 3. 创建 HTTP 请求
|
||||
|
req, err := http.NewRequest("POST", url, requestBody) |
||||
|
if err != nil { |
||||
|
//g.Log().Errorf(ctx, "HTTP 请求创建失败: %v", err)
|
||||
|
return 0, fmt.Errorf("HTTP 请求创建失败: %w", err) |
||||
|
} |
||||
|
req.Header.Set("Content-Type", "application/json") |
||||
|
|
||||
|
// 4. 发送请求
|
||||
|
client := &http.Client{} |
||||
|
resp, err := client.Do(req) |
||||
|
if err != nil { |
||||
|
//g.Log().Errorf(ctx, "HTTP 请求失败: %v", err)
|
||||
|
return 0, fmt.Errorf("HTTP 请求失败: %w", err) |
||||
|
} |
||||
|
defer resp.Body.Close() |
||||
|
|
||||
|
// 5. 检查 HTTP 状态码
|
||||
|
if resp.StatusCode != http.StatusOK { |
||||
|
//g.Log().Errorf(ctx, "HTTP 状态码错误: %d", resp.StatusCode)
|
||||
|
return 0, fmt.Errorf("HTTP 状态码错误: %d", resp.StatusCode) |
||||
|
} |
||||
|
|
||||
|
// 6. 读取并解析响应体
|
||||
|
body, err := ioutil.ReadAll(resp.Body) |
||||
|
if err != nil { |
||||
|
//g.Log().Errorf(ctx, "读取响应失败: %v", err)
|
||||
|
return 0, fmt.Errorf("读取响应失败: %w", err) |
||||
|
} |
||||
|
//g.Log().Debugf(ctx, "响应体内容: %s", string(body))
|
||||
|
|
||||
|
// 7. 解析 JSON 数据
|
||||
|
var jsonResponse map[string]interface{} |
||||
|
if err = json.Unmarshal(body, &jsonResponse); err != nil { |
||||
|
//g.Log().Errorf(ctx, "解析 JSON 失败: %v", err)
|
||||
|
return 0, fmt.Errorf("解析 JSON 失败: %w", err) |
||||
|
} |
||||
|
//g.Log().Debugf(ctx, "解析后的 JSON: %+v", jsonResponse)
|
||||
|
|
||||
|
// 8. 提取 data 节点
|
||||
|
data, ok := jsonResponse["data"].(map[string]interface{}) |
||||
|
if !ok { |
||||
|
//g.Log().Errorf(ctx, "响应体中没有 data 节点,完整响应: %+v", jsonResponse)
|
||||
|
return 0, errors.New("响应体中没有 data 节点") |
||||
|
} |
||||
|
|
||||
|
// 9. 提取 jwcode 并转换为整数
|
||||
|
jwcode, ok := data["jwcode"].(string) // 首先尝试解析为字符串
|
||||
|
if ok { |
||||
|
jwcodeInt, err := strconv.Atoi(jwcode) // 将字符串转换为整数
|
||||
|
if err != nil { |
||||
|
//g.Log().Errorf(ctx, "解析 jwcode 字段失败: %v", err)
|
||||
|
return 0, fmt.Errorf("解析 jwcode 字段失败: %w", err) |
||||
|
} |
||||
|
//g.Log().Infof(ctx, "成功获取 jwcode: %d", jwcodeInt)
|
||||
|
return jwcodeInt, nil |
||||
|
} |
||||
|
|
||||
|
// 如果 jwcode 不是字符串,记录错误日志
|
||||
|
//g.Log().Errorf(ctx, "data 节点中没有 jwcode 字段,或字段格式不正确,data: %+v", data)
|
||||
|
return 0, errors.New("响应体中没有有效的 jwcode 字段") |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue