Browse Source

12月11日客户端首页查询接口编写(未从token获取jwcode)

client_ljk
lijikun 5 months ago
parent
commit
940d3bfcab
  1. 10
      link_homework/api/v1/ClientPage/ClientPage.go
  2. 2
      link_homework/hack/config.yaml
  3. 43
      link_homework/internal/cmd/cmd.go
  4. 28
      link_homework/internal/controller/clientPage/clientPage.go
  5. 24
      link_homework/internal/dao/internal/activity_interactive_form.go
  6. 24
      link_homework/internal/dao/internal/activity_interactive_group.go
  7. 24
      link_homework/internal/dao/internal/activity_interactive_record.go
  8. 22
      link_homework/internal/dao/internal/fx_article.go
  9. 24
      link_homework/internal/dao/internal/live.go
  10. 22
      link_homework/internal/dao/internal/member_info.go
  11. 36
      link_homework/internal/logic/homework/homeworkList.go
  12. 4
      link_homework/internal/logic/logic.go
  13. 32
      link_homework/internal/service/homework.go
  14. 8
      link_homework/internal/service/middleware.go

10
link_homework/api/v1/ClientPage/ClientPage.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
}

2
link_homework/hack/config.yaml

@ -5,7 +5,7 @@ gfcli:
gen:
dao:
- link: "mysql:live:p4jMAMShNM8HTrbX@tcp(39.101.133.168:3306)/live?charset=utf8mb4&parseTime=True&loc=Local"
group: "live"
group: "default"
tables: "live, activity_interactive_form, activity_interactive_group, activity_interactive_record"
descriptionTag: true
- link: "mysql:cms:AF42R3ib6YkFaemm@tcp(39.101.133.168:3306)/cms?charset=utf8mb4&parseTime=True&loc=Local"

43
link_homework/internal/cmd/cmd.go

@ -2,10 +2,11 @@ package cmd
import (
"context"
"github.com/goflyfox/gtoken/gtoken"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gcmd"
"link_homework/internal/controller/clientPage"
"link_homework/internal/logic/middleware"
)
var (
@ -17,32 +18,34 @@ var (
s := g.Server()
//后台
//启动gtoken
// 创建一个GfToken对象,用于处理用户登录、登出、权限验证等操作
gfToken := &gtoken.GfToken{
// 设置登录路径,即用户登录接口登入成功后会获得一个Token
LoginPath: "/login",
//// 设置登录前执行的函数,在用户登录之前会调用这个函数进行一些预处理,比如验证用户名和密码等。
//LoginBeforeFunc: loginFunc, //手动编写 没有同时配置登入路径,登入方法,登出路径启动时会报错
// 设置登出路径,即用户登出接口登入成功后会删除Token
LogoutPath: "/user/logout",
//// 设置需要拦截的路径,按照前缀拦截,所有以/user或/system开头的路径都需要进行Token认证。
//AuthPaths: g.SliceStr{"/user", "/system"},
//// 设置不需要拦截的路径,所有以/user/info或/system/user/开头的路径都不需要进行Token认证。
//AuthExcludePaths: g.SliceStr{"/user/info", "/system/user/*"},
//// 开启全局拦截,默认关闭,如果设置为true,则所有请求都会经过Token认证中间件,如果设置为false,则只有指定路径的请求会经过Token认证中间件。
//GlobalMiddleware: true,
}
////启动gtoken
//// 创建一个GfToken对象,用于处理用户登录、登出、权限验证等操作
//gfToken := &gtoken.GfToken{
// // 设置登录路径,即用户登录接口登入成功后会获得一个Token
// LoginPath: "/login",
// //// 设置登录前执行的函数,在用户登录之前会调用这个函数进行一些预处理,比如验证用户名和密码等。
// //LoginBeforeFunc: loginFunc, //手动编写 没有同时配置登入路径,登入方法,登出路径启动时会报错
// // 设置登出路径,即用户登出接口登入成功后会删除Token
// LogoutPath: "/user/logout",
// //// 设置需要拦截的路径,按照前缀拦截,所有以/user或/system开头的路径都需要进行Token认证。
// //AuthPaths: g.SliceStr{"/user", "/system"},
// //// 设置不需要拦截的路径,所有以/user/info或/system/user/开头的路径都不需要进行Token认证。
// //AuthExcludePaths: g.SliceStr{"/user/info", "/system/user/*"},
// //// 开启全局拦截,默认关闭,如果设置为true,则所有请求都会经过Token认证中间件,如果设置为false,则只有指定路径的请求会经过Token认证中间件。
// //GlobalMiddleware: true,
//}
s.Group("/api/homework_manage", func(group *ghttp.RouterGroup) {
//group.Middleware(middleware.MiddlewareIsLogin)
gfToken.Middleware(ctx, group)
group.Middleware(middleware.MiddlewareIsLogin)
//gfToken.Middleware(ctx, group)
//直接写接口,不用再分组
})
//客户端
s.Group("/api/homework_client", func(group *ghttp.RouterGroup) {
group.Middleware(middleware.MiddlewareCORS)
//group.Middleware(middleware.MiddlewareIsLogin)
gfToken.Middleware(ctx, group)
//gfToken.Middleware(ctx, group)
//直接写接口,不用再分组
group.POST("/gethomeworklist", clientPage.NewClientPage().GetHomeworkList)
})
s.Run()

28
link_homework/internal/controller/clientPage/clientPage.go

@ -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,
})
}

24
link_homework/internal/dao/internal/activity_interactive_form.go

@ -11,14 +11,14 @@ import (
"github.com/gogf/gf/v2/frame/g"
)
// ActivityInteractiveFormDao is the data access object for the table activity_interactive_form.
// ActivityInteractiveFormDao is the data access object for table activity_interactive_form.
type ActivityInteractiveFormDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
group string // group is the database configuration group name of current DAO.
columns ActivityInteractiveFormColumns // columns contains all the column names of Table for convenient usage.
}
// ActivityInteractiveFormColumns defines and stores column names for the table activity_interactive_form.
// ActivityInteractiveFormColumns defines and stores column names for table activity_interactive_form.
type ActivityInteractiveFormColumns struct {
Id string //
Name string // 名称
@ -32,7 +32,7 @@ type ActivityInteractiveFormColumns struct {
GroupId string // 问题分组id
}
// activityInteractiveFormColumns holds the columns for the table activity_interactive_form.
// activityInteractiveFormColumns holds the columns for table activity_interactive_form.
var activityInteractiveFormColumns = ActivityInteractiveFormColumns{
Id: "id",
Name: "name",
@ -49,42 +49,42 @@ var activityInteractiveFormColumns = ActivityInteractiveFormColumns{
// NewActivityInteractiveFormDao creates and returns a new DAO object for table data access.
func NewActivityInteractiveFormDao() *ActivityInteractiveFormDao {
return &ActivityInteractiveFormDao{
group: "live",
group: "default",
table: "activity_interactive_form",
columns: activityInteractiveFormColumns,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *ActivityInteractiveFormDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
// Table returns the table name of current dao.
func (dao *ActivityInteractiveFormDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
// Columns returns all column names of current dao.
func (dao *ActivityInteractiveFormDao) Columns() ActivityInteractiveFormColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
// Group returns the configuration group name of database of current dao.
func (dao *ActivityInteractiveFormDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *ActivityInteractiveFormDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *ActivityInteractiveFormDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)

24
link_homework/internal/dao/internal/activity_interactive_group.go

@ -11,14 +11,14 @@ import (
"github.com/gogf/gf/v2/frame/g"
)
// ActivityInteractiveGroupDao is the data access object for the table activity_interactive_group.
// ActivityInteractiveGroupDao is the data access object for table activity_interactive_group.
type ActivityInteractiveGroupDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
group string // group is the database configuration group name of current DAO.
columns ActivityInteractiveGroupColumns // columns contains all the column names of Table for convenient usage.
}
// ActivityInteractiveGroupColumns defines and stores column names for the table activity_interactive_group.
// ActivityInteractiveGroupColumns defines and stores column names for table activity_interactive_group.
type ActivityInteractiveGroupColumns struct {
Id string //
Name string // 表单名称
@ -32,7 +32,7 @@ type ActivityInteractiveGroupColumns struct {
EndDate string // 作业结束时间
}
// activityInteractiveGroupColumns holds the columns for the table activity_interactive_group.
// activityInteractiveGroupColumns holds the columns for table activity_interactive_group.
var activityInteractiveGroupColumns = ActivityInteractiveGroupColumns{
Id: "id",
Name: "name",
@ -49,42 +49,42 @@ var activityInteractiveGroupColumns = ActivityInteractiveGroupColumns{
// NewActivityInteractiveGroupDao creates and returns a new DAO object for table data access.
func NewActivityInteractiveGroupDao() *ActivityInteractiveGroupDao {
return &ActivityInteractiveGroupDao{
group: "live",
group: "default",
table: "activity_interactive_group",
columns: activityInteractiveGroupColumns,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *ActivityInteractiveGroupDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
// Table returns the table name of current dao.
func (dao *ActivityInteractiveGroupDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
// Columns returns all column names of current dao.
func (dao *ActivityInteractiveGroupDao) Columns() ActivityInteractiveGroupColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
// Group returns the configuration group name of database of current dao.
func (dao *ActivityInteractiveGroupDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *ActivityInteractiveGroupDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *ActivityInteractiveGroupDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)

24
link_homework/internal/dao/internal/activity_interactive_record.go

@ -11,14 +11,14 @@ import (
"github.com/gogf/gf/v2/frame/g"
)
// ActivityInteractiveRecordDao is the data access object for the table activity_interactive_record.
// ActivityInteractiveRecordDao is the data access object for table activity_interactive_record.
type ActivityInteractiveRecordDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
group string // group is the database configuration group name of current DAO.
columns ActivityInteractiveRecordColumns // columns contains all the column names of Table for convenient usage.
}
// ActivityInteractiveRecordColumns defines and stores column names for the table activity_interactive_record.
// ActivityInteractiveRecordColumns defines and stores column names for table activity_interactive_record.
type ActivityInteractiveRecordColumns struct {
Id string //
Jwcode string //
@ -30,7 +30,7 @@ type ActivityInteractiveRecordColumns struct {
ContentTitle string //
}
// activityInteractiveRecordColumns holds the columns for the table activity_interactive_record.
// activityInteractiveRecordColumns holds the columns for table activity_interactive_record.
var activityInteractiveRecordColumns = ActivityInteractiveRecordColumns{
Id: "id",
Jwcode: "jwcode",
@ -45,42 +45,42 @@ var activityInteractiveRecordColumns = ActivityInteractiveRecordColumns{
// NewActivityInteractiveRecordDao creates and returns a new DAO object for table data access.
func NewActivityInteractiveRecordDao() *ActivityInteractiveRecordDao {
return &ActivityInteractiveRecordDao{
group: "live",
group: "default",
table: "activity_interactive_record",
columns: activityInteractiveRecordColumns,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *ActivityInteractiveRecordDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
// Table returns the table name of current dao.
func (dao *ActivityInteractiveRecordDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
// Columns returns all column names of current dao.
func (dao *ActivityInteractiveRecordDao) Columns() ActivityInteractiveRecordColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
// Group returns the configuration group name of database of current dao.
func (dao *ActivityInteractiveRecordDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *ActivityInteractiveRecordDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *ActivityInteractiveRecordDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)

22
link_homework/internal/dao/internal/fx_article.go

@ -11,14 +11,14 @@ import (
"github.com/gogf/gf/v2/frame/g"
)
// FxArticleDao is the data access object for the table fx_article.
// FxArticleDao is the data access object for table fx_article.
type FxArticleDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
group string // group is the database configuration group name of current DAO.
columns FxArticleColumns // columns contains all the column names of Table for convenient usage.
}
// FxArticleColumns defines and stores column names for the table fx_article.
// FxArticleColumns defines and stores column names for table fx_article.
type FxArticleColumns struct {
Id string //
Title string // 标题
@ -117,7 +117,7 @@ type FxArticleColumns struct {
VideoType string // 视频类型 1 横屏 2 竖屏
}
// fxArticleColumns holds the columns for the table fx_article.
// fxArticleColumns holds the columns for table fx_article.
var fxArticleColumns = FxArticleColumns{
Id: "id",
Title: "title",
@ -225,36 +225,36 @@ func NewFxArticleDao() *FxArticleDao {
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *FxArticleDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
// Table returns the table name of current dao.
func (dao *FxArticleDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
// Columns returns all column names of current dao.
func (dao *FxArticleDao) Columns() FxArticleColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
// Group returns the configuration group name of database of current dao.
func (dao *FxArticleDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *FxArticleDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *FxArticleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)

24
link_homework/internal/dao/internal/live.go

@ -11,14 +11,14 @@ import (
"github.com/gogf/gf/v2/frame/g"
)
// LiveDao is the data access object for the table live.
// LiveDao is the data access object for table live.
type LiveDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
group string // group is the database configuration group name of current DAO.
columns LiveColumns // columns contains all the column names of Table for convenient usage.
}
// LiveColumns defines and stores column names for the table live.
// LiveColumns defines and stores column names for table live.
type LiveColumns struct {
Id string //
Jwcode string //
@ -106,7 +106,7 @@ type LiveColumns struct {
JoinClassButton string // 进群按钮 1:开启
}
// liveColumns holds the columns for the table live.
// liveColumns holds the columns for table live.
var liveColumns = LiveColumns{
Id: "id",
Jwcode: "jwcode",
@ -197,42 +197,42 @@ var liveColumns = LiveColumns{
// NewLiveDao creates and returns a new DAO object for table data access.
func NewLiveDao() *LiveDao {
return &LiveDao{
group: "live",
group: "default",
table: "live",
columns: liveColumns,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *LiveDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
// Table returns the table name of current dao.
func (dao *LiveDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
// Columns returns all column names of current dao.
func (dao *LiveDao) Columns() LiveColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
// Group returns the configuration group name of database of current dao.
func (dao *LiveDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *LiveDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *LiveDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)

22
link_homework/internal/dao/internal/member_info.go

@ -11,14 +11,14 @@ import (
"github.com/gogf/gf/v2/frame/g"
)
// MemberInfoDao is the data access object for the table member_info.
// MemberInfoDao is the data access object for table member_info.
type MemberInfoDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
group string // group is the database configuration group name of current DAO.
columns MemberInfoColumns // columns contains all the column names of Table for convenient usage.
}
// MemberInfoColumns defines and stores column names for the table member_info.
// MemberInfoColumns defines and stores column names for table member_info.
type MemberInfoColumns struct {
Id string //
Jwcode string //
@ -60,7 +60,7 @@ type MemberInfoColumns struct {
CreateTime string // 账号注册时间
}
// memberInfoColumns holds the columns for the table member_info.
// memberInfoColumns holds the columns for table member_info.
var memberInfoColumns = MemberInfoColumns{
Id: "id",
Jwcode: "jwcode",
@ -111,36 +111,36 @@ func NewMemberInfoDao() *MemberInfoDao {
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *MemberInfoDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
// Table returns the table name of current dao.
func (dao *MemberInfoDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
// Columns returns all column names of current dao.
func (dao *MemberInfoDao) Columns() MemberInfoColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
// Group returns the configuration group name of database of current dao.
func (dao *MemberInfoDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *MemberInfoDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *MemberInfoDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)

36
link_homework/internal/logic/homework/homeworkList.go

@ -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
}

4
link_homework/internal/logic/logic.go

@ -1 +1,5 @@
package logic
import (
_ "link_homework/internal/logic/homework"
)

32
link_homework/internal/service/homework.go

@ -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
}

8
link_homework/internal/service/middleware.go

@ -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 ()
Loading…
Cancel
Save