14 changed files with 212 additions and 91 deletions
-
10link_homework/api/v1/ClientPage/ClientPage.go
-
2link_homework/hack/config.yaml
-
43link_homework/internal/cmd/cmd.go
-
28link_homework/internal/controller/clientPage/clientPage.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
-
36link_homework/internal/logic/homework/homeworkList.go
-
4link_homework/internal/logic/logic.go
-
32link_homework/internal/service/homework.go
-
8link_homework/internal/service/middleware.go
@ -0,0 +1,10 @@ |
|||
package ClientPage |
|||
|
|||
import "github.com/gogf/gf/v2/os/gtime" |
|||
|
|||
type GetHomewordListRse struct { |
|||
Id int `json:"id" orm:"table:activity_interactive_group;column:id" dc:"id" ` |
|||
Name string `json:"content" 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:"作业截止时间"` |
|||
Status int |
|||
} |
@ -1 +1,29 @@ |
|||
package clientPage |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/net/ghttp" |
|||
"link_homework/internal/model/dto" |
|||
"link_homework/internal/service" |
|||
) |
|||
|
|||
type ClientPage struct{} |
|||
|
|||
func NewClientPage() *ClientPage { |
|||
return &ClientPage{} |
|||
} |
|||
|
|||
func (c *ClientPage) GetHomeworkList(r *ghttp.Request) { |
|||
//请求中不需要携带任何参数
|
|||
result, err := service.Homework().GetHomeworkList(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: result, |
|||
}) |
|||
} |
@ -0,0 +1,36 @@ |
|||
package homework |
|||
|
|||
import ( |
|||
"context" |
|||
"fmt" |
|||
"github.com/gogf/gf/v2/os/gtime" |
|||
"link_homework/api/v1/ClientPage" |
|||
"link_homework/internal/dao" |
|||
"link_homework/internal/service" |
|||
) |
|||
|
|||
type sHomework struct{} |
|||
|
|||
func init() { |
|||
service.RegisterHomework(&sHomework{}) |
|||
} |
|||
|
|||
func (s *sHomework) GetHomeworkList(ctx context.Context) (homeworkList []ClientPage.GetHomewordListRse, err error) { |
|||
var jwcode = 90038794 //需要从token中获取当前的数据
|
|||
err = dao.ActivityInteractiveGroup.Ctx(ctx).Fields("id", "name", "DATE_FORMAT(end_date, '%Y-%m-%d') as end_date"). |
|||
Where("end_date>?", gtime.Now()).OrderDesc("end_date").Scan(&homeworkList) |
|||
if err != nil { |
|||
fmt.Println("作业列表查询失败:", err) |
|||
return |
|||
} |
|||
for i, item := range homeworkList { |
|||
var count int |
|||
count, err = dao.ActivityInteractiveRecord.Ctx(ctx).Where("group_id=?", item.Id).Where("jwcode", jwcode).Count() |
|||
if err != nil { |
|||
fmt.Println("提交记录数查询失败:", err) |
|||
return |
|||
} |
|||
homeworkList[i].Status = count |
|||
} |
|||
return |
|||
} |
@ -1 +1,5 @@ |
|||
package logic |
|||
|
|||
import ( |
|||
_ "link_homework/internal/logic/homework" |
|||
) |
@ -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/api/v1/ClientPage" |
|||
) |
|||
|
|||
type ( |
|||
IHomework interface { |
|||
GetHomeworkList(ctx context.Context) (homeworkList []ClientPage.GetHomewordListRse, 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,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 () |
Write
Preview
Loading…
Cancel
Save
Reference in new issue