浏览代码

feature:培训考试添加移动端资料发布记录接口

liuyaqi 3 年之前
父节点
当前提交
14cb9133b4

+ 411 - 0
dao/learning/internal/learning_material_publish_record.go

@@ -0,0 +1,411 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/frame/gmvc"
+	"time"
+
+	model "lims_adapter/model/learning"
+)
+
+// LearningMaterialPublishRecordDao is the manager for logic model data accessing
+// and custom defined data operations functions management.
+type LearningMaterialPublishRecordDao struct {
+	gmvc.M
+	DB      gdb.DB
+	Table   string
+	Columns learningMaterialPublishRecordColumns
+}
+
+// LearningMaterialPublishRecordColumns defines and stores column names for table learning_material_publish_record.
+type learningMaterialPublishRecordColumns struct {
+	Id         string // Id
+	MaterialId string // 资料 Id
+	OperateBy  string // 操作人
+	CreatedAt  string // 创建时间
+	UpdatedAt  string // 更新时间
+	DeletedAt  string // 删除时间
+}
+
+var (
+	// LearningMaterialPublishRecord is globally public accessible object for table learning_material_publish_record operations.
+	LearningMaterialPublishRecord = LearningMaterialPublishRecordDao{
+		M:     g.DB("default").Model("learning_material_publish_record").Safe(),
+		DB:    g.DB("default"),
+		Table: "learning_material_publish_record",
+		Columns: learningMaterialPublishRecordColumns{
+			Id:         "Id",
+			MaterialId: "MaterialId",
+			OperateBy:  "OperateBy",
+			CreatedAt:  "CreatedAt",
+			UpdatedAt:  "UpdatedAt",
+			DeletedAt:  "DeletedAt",
+		},
+	}
+)
+
+func NewLearningMaterialPublishRecordDao(tenant string) LearningMaterialPublishRecordDao {
+	var dao LearningMaterialPublishRecordDao
+	dao = LearningMaterialPublishRecordDao{
+		M:     g.DB(tenant).Model("learning_material_publish_record").Safe(),
+		DB:    g.DB(tenant),
+		Table: "learning_material_publish_record",
+		Columns: learningMaterialPublishRecordColumns{
+			Id:         "Id",
+			MaterialId: "MaterialId",
+			OperateBy:  "OperateBy",
+			CreatedAt:  "CreatedAt",
+			UpdatedAt:  "UpdatedAt",
+			DeletedAt:  "DeletedAt",
+		},
+	}
+	return dao
+}
+
+// Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
+// of current DB object and with given context in it.
+// Note that this returned DB object can be used only once, so do not assign it to
+// a global or package variable for long using.
+func (d *LearningMaterialPublishRecordDao) Ctx(ctx context.Context) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Ctx(ctx)}
+}
+
+// As sets an alias name for current table.
+func (d *LearningMaterialPublishRecordDao) As(as string) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (d *LearningMaterialPublishRecordDao) TX(tx *gdb.TX) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (d *LearningMaterialPublishRecordDao) Master() *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (d *LearningMaterialPublishRecordDao) Slave() *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Slave()}
+}
+
+// Args sets custom arguments for model operation.
+func (d *LearningMaterialPublishRecordDao) Args(args ...interface{}) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Args(args...)}
+}
+
+// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *LearningMaterialPublishRecordDao) LeftJoin(table ...string) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.LeftJoin(table...)}
+}
+
+// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *LearningMaterialPublishRecordDao) RightJoin(table ...string) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.RightJoin(table...)}
+}
+
+// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *LearningMaterialPublishRecordDao) InnerJoin(table ...string) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.InnerJoin(table...)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *LearningMaterialPublishRecordDao) Fields(fieldNamesOrMapStruct ...interface{}) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *LearningMaterialPublishRecordDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
+}
+
+// Option sets the extra operation option for the model.
+func (d *LearningMaterialPublishRecordDao) Option(option int) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (d *LearningMaterialPublishRecordDao) OmitEmpty() *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (d *LearningMaterialPublishRecordDao) Filter() *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Filter()}
+}
+
+// Where sets the condition statement for the model. The parameter <where> can be type of
+// string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
+// multiple conditions will be joined into where statement using "AND".
+// Eg:
+// Where("uid=10000")
+// Where("uid", 10000)
+// Where("money>? AND name like ?", 99999, "vip_%")
+// Where("uid", 1).Where("name", "john")
+// Where("status IN (?)", g.Slice{1,2,3})
+// Where("age IN(?,?)", 18, 50)
+// Where(User{ Id : 1, UserName : "john"})
+func (d *LearningMaterialPublishRecordDao) Where(where interface{}, args ...interface{}) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Where(where, args...)}
+}
+
+// WherePri does the same logic as M.Where except that if the parameter <where>
+// is a single condition like int/string/float/slice, it treats the condition as the primary
+// key value. That is, if primary key is "id" and given <where> parameter as "123", the
+// WherePri function treats the condition as "id=123", but M.Where treats the condition
+// as string "123".
+func (d *LearningMaterialPublishRecordDao) WherePri(where interface{}, args ...interface{}) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.WherePri(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (d *LearningMaterialPublishRecordDao) And(where interface{}, args ...interface{}) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (d *LearningMaterialPublishRecordDao) Or(where interface{}, args ...interface{}) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (d *LearningMaterialPublishRecordDao) Group(groupBy string) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (d *LearningMaterialPublishRecordDao) Order(orderBy ...string) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Order(orderBy...)}
+}
+
+// Limit sets the "LIMIT" statement for the model.
+// The parameter <limit> can be either one or two number, if passed two number is passed,
+// it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
+// statement.
+func (d *LearningMaterialPublishRecordDao) Limit(limit ...int) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (d *LearningMaterialPublishRecordDao) Offset(offset int) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Offset(offset)}
+}
+
+// Page sets the paging number for the model.
+// The parameter <page> is started from 1 for paging.
+// Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
+func (d *LearningMaterialPublishRecordDao) Page(page, limit int) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (d *LearningMaterialPublishRecordDao) Batch(batch int) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Batch(batch)}
+}
+
+// Cache sets the cache feature for the model. It caches the result of the sql, which means
+// if there's another same sql request, it just reads and returns the result from cache, it
+// but not committed and executed into the database.
+//
+// If the parameter <duration> < 0, which means it clear the cache with given <name>.
+// If the parameter <duration> = 0, which means it never expires.
+// If the parameter <duration> > 0, which means it expires after <duration>.
+//
+// The optional parameter <name> is used to bind a name to the cache, which means you can later
+// control the cache like changing the <duration> or clearing the cache with specified <name>.
+//
+// Note that, the cache feature is disabled if the model is operating on a transaction.
+func (d *LearningMaterialPublishRecordDao) Cache(duration time.Duration, name ...string) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Cache(duration, name...)}
+}
+
+// Data sets the operation data for the model.
+// The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
+// Eg:
+// Data("uid=10000")
+// Data("uid", 10000)
+// Data(g.Map{"uid": 10000, "name":"john"})
+// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
+func (d *LearningMaterialPublishRecordDao) Data(data ...interface{}) *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Data(data...)}
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*model.LearningMaterialPublishRecord.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *LearningMaterialPublishRecordDao) All(where ...interface{}) ([]*model.LearningMaterialPublishRecord, error) {
+	all, err := d.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.LearningMaterialPublishRecord
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// One retrieves one record from table and returns the result as *model.LearningMaterialPublishRecord.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *LearningMaterialPublishRecordDao) One(where ...interface{}) (*model.LearningMaterialPublishRecord, error) {
+	one, err := d.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.LearningMaterialPublishRecord
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindOne retrieves and returns a single Record by M.WherePri and M.One.
+// Also see M.WherePri and M.One.
+func (d *LearningMaterialPublishRecordDao) FindOne(where ...interface{}) (*model.LearningMaterialPublishRecord, error) {
+	one, err := d.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.LearningMaterialPublishRecord
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by M.WherePri and M.All.
+// Also see M.WherePri and M.All.
+func (d *LearningMaterialPublishRecordDao) FindAll(where ...interface{}) ([]*model.LearningMaterialPublishRecord, error) {
+	all, err := d.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.LearningMaterialPublishRecord
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// Struct retrieves one record from table and converts it into given struct.
+// The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
+// it can create the struct internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not nil.
+//
+// Eg:
+// user := new(User)
+// err  := dao.User.Where("id", 1).Struct(user)
+//
+// user := (*User)(nil)
+// err  := dao.User.Where("id", 1).Struct(&user)
+func (d *LearningMaterialPublishRecordDao) Struct(pointer interface{}, where ...interface{}) error {
+	return d.M.Struct(pointer, where...)
+}
+
+// Structs retrieves records from table and converts them into given struct slice.
+// The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
+// slice internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not empty.
+//
+// Eg:
+// users := ([]User)(nil)
+// err   := dao.User.Structs(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Structs(&users)
+func (d *LearningMaterialPublishRecordDao) Structs(pointer interface{}, where ...interface{}) error {
+	return d.M.Structs(pointer, where...)
+}
+
+// Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
+// It calls function Struct if <pointer> is type of *struct/**struct.
+// It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
+//
+// Eg:
+// user  := new(User)
+// err   := dao.User.Where("id", 1).Scan(user)
+//
+// user  := (*User)(nil)
+// err   := dao.User.Where("id", 1).Scan(&user)
+//
+// users := ([]User)(nil)
+// err   := dao.User.Scan(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Scan(&users)
+func (d *LearningMaterialPublishRecordDao) Scan(pointer interface{}, where ...interface{}) error {
+	return d.M.Scan(pointer, where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (d *LearningMaterialPublishRecordDao) Chunk(limit int, callback func(entities []*model.LearningMaterialPublishRecord, err error) bool) {
+	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*model.LearningMaterialPublishRecord
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}
+
+// LockUpdate sets the lock for update for current operation.
+func (d *LearningMaterialPublishRecordDao) LockUpdate() *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (d *LearningMaterialPublishRecordDao) LockShared() *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (d *LearningMaterialPublishRecordDao) Unscoped() *LearningMaterialPublishRecordDao {
+	return &LearningMaterialPublishRecordDao{M: d.M.Unscoped()}
+}

+ 36 - 0
dao/learning/learning_material_publish_record.go

@@ -0,0 +1,36 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package dao
+
+import (
+	"lims_adapter/dao/learning/internal"
+)
+
+// learningMaterialPublishRecordDao is the manager for logic model data accessing
+// and custom defined data operations functions management. You can define
+// methods on it to extend its functionality as you wish.
+type learningMaterialPublishRecordDao struct {
+	internal.LearningMaterialPublishRecordDao
+}
+
+var (
+	// LearningMaterialPublishRecord is globally public accessible object for table learning_material_publish_record operations.
+	LearningMaterialPublishRecord = learningMaterialPublishRecordDao{
+		internal.LearningMaterialPublishRecord,
+	}
+)
+
+type LearningMaterialPublishRecordDao struct {
+	internal.LearningMaterialPublishRecordDao
+}
+
+func NewLearningMaterialPublishRecordDao(tenant string) *LearningMaterialPublishRecordDao {
+	dao := internal.NewLearningMaterialPublishRecordDao(tenant)
+	return &LearningMaterialPublishRecordDao{
+		dao,
+	}
+}
+
+// Fill with you ideas below.

+ 36 - 0
handler/learning/material_pulish_record.go

@@ -0,0 +1,36 @@
+package learning
+
+import (
+	"context"
+	"lims_adapter/model/learning"
+	learningSrv "lims_adapter/service/learning"
+
+	"dashoo.cn/common_definition/comm_def"
+	"dashoo.cn/micro_libary/myerrors"
+	"github.com/gogf/gf/frame/g"
+)
+
+type LearningMaterialPublishRecord struct{}
+
+func (c *LearningMaterialPublishRecord) List(ctx context.Context, req *learning.LearningMaterialPublishRecordListReq, rsp *comm_def.CommonMsg) error {
+	g.Log().Infof("LearningMaterialPublishRecord.List request %#v ", *req)
+	s, err := learningSrv.NewLearningMaterialPublishRecordService(ctx)
+	if err != nil {
+		return err
+	}
+	total, ent, err := s.List(ctx, req)
+	_, err, code, msg := myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	if ent == nil {
+		ent = []*learning.LearningMaterialPublishRecordRsp{}
+	}
+	rsp.Code = code
+	rsp.Msg = msg
+	rsp.Data = map[string]interface{}{
+		"total": total,
+		"list":  ent,
+	}
+	return nil
+}

+ 2 - 0
main.go

@@ -69,6 +69,8 @@ func main() {
 		new((learning.LearningLearningRecord)), "")
 	s.RegisterName("LearningTestpaper",
 		new((learning.LearningTestpaper)), "")
+	s.RegisterName("LearningMaterialPublishRecord",
+		new((learning.LearningMaterialPublishRecord)), "")
 
 	// 注册auth处理
 	s.AuthFunc = handleAuth

+ 19 - 0
model/learning/internal/learning_material_publish_record.go

@@ -0,0 +1,19 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"github.com/gogf/gf/os/gtime"
+)
+
+// LearningMaterialPublishRecord is the golang structure for table learning_material_publish_record.
+type LearningMaterialPublishRecord struct {
+	Id         int         `orm:"Id,primary" json:"id"`         // Id
+	MaterialId int         `orm:"MaterialId" json:"materialId"` // 资料 Id
+	OperateBy  string      `orm:"OperateBy"  json:"operateBy"`  // 操作人
+	CreatedAt  *gtime.Time `orm:"CreatedAt"  json:"createdAt"`  // 创建时间
+	UpdatedAt  *gtime.Time `orm:"UpdatedAt"  json:"updatedAt"`  // 更新时间
+	DeletedAt  *gtime.Time `orm:"DeletedAt"  json:"deletedAt"`  // 删除时间
+}

+ 23 - 0
model/learning/learning_material_pulish_record.go

@@ -0,0 +1,23 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package learning
+
+import (
+	"lims_adapter/model"
+	"lims_adapter/model/learning/internal"
+)
+
+// LearningMaterialPublishRecord is the golang structure for table learning_material_pulish_record.
+type LearningMaterialPublishRecord internal.LearningMaterialPublishRecord
+
+// Fill with you ideas below.
+type LearningMaterialPublishRecordListReq struct {
+	Page *model.Page `json:"page"`
+}
+
+type LearningMaterialPublishRecordRsp struct {
+	LearningMaterialPublishRecord
+	MaterialName string `json:"materialName"` // 资料名称
+}

+ 12 - 0
service/learning/material.go

@@ -16,6 +16,7 @@ import (
 type LearningMaterialService struct {
 	Dao               *dao.LearningMaterialDao
 	FileDao           *dao.LearningMaterialFileDao
+	PublishRecordDao  *dao.LearningMaterialPublishRecordDao
 	LearningRecordDao *dao.LearningLearningRecordDao
 	LearningRecordSrv *LearningLearningRecordService
 	Tenant            string
@@ -39,6 +40,7 @@ func NewLearningMaterialService(ctx context.Context) (*LearningMaterialService,
 	return &LearningMaterialService{
 		Dao:               dao.NewLearningMaterialDao(tenant),
 		FileDao:           dao.NewLearningMaterialFileDao(tenant),
+		PublishRecordDao:  dao.NewLearningMaterialPublishRecordDao(tenant),
 		LearningRecordDao: dao.NewLearningLearningRecordDao(tenant),
 		LearningRecordSrv: lrSrv,
 		Tenant:            tenant,
@@ -176,6 +178,16 @@ func (s LearningMaterialService) Add(ctx context.Context, req *learning.Learning
 	if err != nil {
 		return 0, err
 	}
+	_, err = s.PublishRecordDao.Insert(learning.LearningMaterialPublishRecord{
+		MaterialId: int(id),
+		OperateBy:  s.userInfo.RealName,
+		CreatedAt:  gtime.Now(),
+		UpdatedAt:  gtime.Now(),
+	})
+	if err != nil {
+		return 0, err
+	}
+
 	if len(req.File) == 0 {
 		return int(id), err
 	}

+ 66 - 0
service/learning/material_publish_record.go

@@ -0,0 +1,66 @@
+package learning
+
+import (
+	"context"
+	"fmt"
+	"lims_adapter/dao/learning"
+	"lims_adapter/model/learning"
+
+	"dashoo.cn/micro_libary/micro_srv"
+	"dashoo.cn/micro_libary/myerrors"
+	"dashoo.cn/micro_libary/request"
+	"github.com/gogf/gf/util/gvalid"
+)
+
+type LearningMaterialPublishRecordService struct {
+	Dao      *dao.LearningMaterialPublishRecordDao
+	Tenant   string
+	userInfo request.UserInfo
+}
+
+func NewLearningMaterialPublishRecordService(ctx context.Context) (*LearningMaterialPublishRecordService, error) {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return nil, fmt.Errorf("获取组合码异常:%s", err.Error())
+	}
+	// 获取用户信息
+	userInfo, err := micro_srv.GetUserInfo(ctx)
+	if err != nil {
+		return nil, fmt.Errorf("获取用户信息异常:%s", err.Error())
+	}
+	return &LearningMaterialPublishRecordService{
+		Dao:      dao.NewLearningMaterialPublishRecordDao(tenant),
+		Tenant:   tenant,
+		userInfo: userInfo,
+	}, nil
+}
+
+func (s LearningMaterialPublishRecordService) List(ctx context.Context, req *learning.LearningMaterialPublishRecordListReq) (int, []*learning.LearningMaterialPublishRecordRsp, error) {
+	validErr := gvalid.CheckStruct(ctx, req, nil)
+	if validErr != nil {
+		return 0, nil, myerrors.NewMsgError(nil, validErr.Current().Error())
+	}
+
+	dao := s.Dao.LearningMaterialPublishRecordDao.
+		LeftJoin("learning_material", "learning_material.Id=learning_material_publish_record.MaterialId")
+	total, err := dao.Count()
+	if err != nil {
+		return 0, nil, err
+	}
+
+	if req.Page != nil {
+		if req.Page.Current == 0 {
+			req.Page.Current = 1
+		}
+		if req.Page.Size == 0 {
+			req.Page.Size = 10
+		}
+		dao = dao.Page(req.Page.Current, req.Page.Size)
+	}
+	list := []*learning.LearningMaterialPublishRecordRsp{}
+	err = dao.
+		Order("learning_material_publish_record.CreatedAt", "desc").
+		Fields("learning_material_publish_record.*, learning_material.Name as MaterialName").
+		Structs(&list)
+	return total, list, err
+}

+ 11 - 0
sql/create.sql

@@ -130,3 +130,14 @@ CREATE TABLE `learning_learning_record` (
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='学习记录表';
 
+
+CREATE TABLE `learning_material_publish_record` (
+  `Id` int NOT NULL AUTO_INCREMENT COMMENT 'Id',
+  `MaterialId` int NOT NULL COMMENT '资料 Id',
+  `OperateBy` varchar(255) COMMENT '操作人',
+  `CreatedAt` datetime COMMENT '创建时间',
+  `UpdatedAt` datetime COMMENT '更新时间',
+  `DeletedAt` datetime COMMENT '删除时间',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='资料发布记录表';
+

+ 36 - 0
swaggerui/swagger.yml

@@ -230,6 +230,31 @@ paths:
                   success:
                     $ref: "#/components/examples/success"
 
+    /LearningMaterialPublishRecord.List:
+      post:
+        tags:
+          - 考试培训-资料
+        operationId: LearningMaterialPublishRecordList
+        summary: 资料发布记录
+        requestBody:
+          required: true
+          content:
+            application/json:
+              schema:
+                oneOf:
+                  - $ref: '#/components/schemas/LearningMaterialPublishRecordList'
+              examples:
+                LearningMaterialPublishRecordList:
+                  $ref: '#/components/examples/NoArgs'
+        responses:
+          200:
+            description: 请求成功
+            content:
+              application/json:
+                examples:
+                  success:
+                    $ref: "#/components/examples/success"
+
     /LearningMaterial.Get:
       post:
         tags:
@@ -934,6 +959,17 @@ components:
         skillId:
           type: integer
           description: 按技能 Id 查询
+    LearningMaterialPublishRecordList:
+        page:
+          type: object
+          description: 分页信息,不传默认不分页,返回所有数据
+          properties:
+            current:
+              type: integer
+              description: 当前页面
+            size:
+              type: integer
+              description: 每页条数
     LearningMaterialGet:
       type: object
       properties: