Просмотр исходного кода

Merge remote-tracking branch 'origin/master' into master

# Conflicts:
#	frontend_web/src/router/routes.js
zangkai 5 лет назад
Родитель
Сommit
15670faa27

+ 122 - 0
backend/src/dashoo.cn/modi_webapi/app/api/course/course.go

@@ -0,0 +1,122 @@
+package course
+
+import (
+	"dashoo.cn/micro_libary/response"
+	"dashoo.cn/modi_webapi/app/model/course"
+	service "dashoo.cn/modi_webapi/app/service/course"
+
+	"github.com/gogf/gf/net/ghttp"
+)
+
+// 课程管理API管理对象
+type Controller struct {
+}
+
+// 注册请求参数,用于前后端交互参数格式约定
+type GetListRequest struct {
+	course.AddOrUpdateReq
+}
+
+// 保存课程信息
+func (c *Controller) Save(r *ghttp.Request) {
+	// tenant 租户模式
+	tenant := r.Header.Get("Tenant")
+	var addOrUpdateReq *course.AddOrUpdateReq
+	// 赋值并// 校验参数
+	if err := r.Parse(&addOrUpdateReq); err != nil {
+		response.Json(r, -1, err.Error())
+	}
+
+	// 初始化
+	servcie, err := service.NewCourseService(tenant)
+	if err != nil {
+		response.Json(r, 1, err.Error())
+	}
+
+	// 判断是新增还是删除,获取的id为空新增,不为空则更新
+	if addOrUpdateReq.Id > 0 {
+		if newStudent, err := servcie.Update(addOrUpdateReq); err != nil {
+			response.Json(r, 1, err.Error())
+		} else {
+			response.Json(r, 0, "更新成功", newStudent)
+		}
+	} else {
+		addOrUpdateReq.Id = 0
+		if newId, err := servcie.Add(addOrUpdateReq); err != nil {
+			response.Json(r, 1, err.Error())
+		} else {
+			response.Json(r, 0, "新建成功", newId)
+		}
+	}
+
+}
+
+// DeleteStudentById 删除信息,更新信息删除状态isDel=1
+//func (c *Controller) DeleteById(r *ghttp.Request) {
+//	// tenant 租户模式
+//	tenant := r.Header.Get("Tenant")
+//	id := r.GetInt("id")
+//	glog.Info(id)
+//
+//	// 初始化学生service
+//	servcie, err := service.NewInformationService(tenant)
+//	if err != nil {
+//		response.Json(r, 1, err.Error())
+//	}
+//
+//	if err := servcie.Delete(id); err != nil {
+//		response.Json(r, 1, err.Error())
+//	} else {
+//		response.Json(r, 0, "删除成功")
+//	}
+//}
+//
+//// GetDetailById 根据id信息详情
+//func (c *Controller) GetDetailById(r *ghttp.Request) {
+//	// tenant 租户模式
+//	tenant := r.Header.Get("Tenant")
+//	// 学生id
+//	id := r.GetInt("id")
+//	glog.Info(id)
+//	// 初始化学生service
+//	servcie, err := service.NewInformationService(tenant)
+//	if err != nil {
+//		response.Json(r, 1, err.Error())
+//	}
+//	// 调用service方法
+//	if information, err := servcie.GetByID(id); err != nil {
+//		response.Json(r, 1, err.Error())
+//	} else {
+//		response.Json(r, 0, "ok", information)
+//	}
+//
+//}
+//
+//// GetPageList 分页查询信息列表
+//func (c *Controller) GetPageList(r *ghttp.Request) {
+//	// tenant 租户模式
+//	tenant := r.Header.Get("Tenant")
+//	// 初始化service
+//	servcie, err := service.NewCourseService(tenant)
+//	if err != nil {
+//		response.Json(r, 1, err.Error())
+//	}
+//	// 分页查询信息列表
+//	var selectPageReq information.SelectPageReq
+//	// 赋值并// 校验参数
+//	if err := r.Parse(&selectPageReq); err != nil {
+//		response.Json(r, -1, err.Error())
+//	}
+//	if informationList, total, err := servcie.GetPageList(&selectPageReq); err != nil {
+//		response.Json(r, -1, err.Error())
+//	} else {
+//		var records response.PagedRecords
+//		records.Current = selectPageReq.Page.Current
+//		records.Size = selectPageReq.Page.Size
+//		if total > 0 {
+//			records.Total = total
+//			records.Records = informationList
+//		}
+//		response.Json(r, 0, "ok", records)
+//	}
+//}

+ 42 - 0
backend/src/dashoo.cn/modi_webapi/app/model/course/course.go

@@ -0,0 +1,42 @@
+package course
+
+import (
+	"dashoo.cn/modi_webapi/library/request"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/os/gtime"
+)
+
+
+var (
+	recordsTable = g.DB().Table("course").Safe()
+)
+
+func GetAllCourse(page request.PageInfo, where string, result *[]Entity)(err error){
+	err = recordsTable.Where(where).Limit((page.Current-1)*page.Size, page.Size).Scan(result)
+	return err
+}
+
+func FindCourseCount(where string)(int, error){
+	return recordsTable.Where(where).Count()
+}
+// 新增/修改课程参数
+type AddOrUpdateReq struct {
+	Id         int         `json:"id"`
+	CourseId   int         `json:"courseId"`               // 课程表ID
+	Year       int         `json:"year"`                   // 学年
+	Term       int         `json:"term"`                   // 学期
+	CourseName string      `json:"coursename"`             // 课程名
+	Teacher    int         `json:"teacher"`                // 授课老师
+	Local      int         `json:"local"`                  // 实验地点
+	Class      int         `json:"class"`                  // 授课班级
+	Mark       int         `json:"mark"`                   // 学分
+	Num        int         `json:"num"`                    // 人数
+	WeekTitle  string      `json:"weektitle"`              // 教学周
+	DayOfWeek  int         `json:"dayofweek"`              // 周次1-7
+	Time       string      `json:"time"`                   // 节次
+	Status     int         `v:"required"     json:"status"`// 状态 发布状态
+	IsDel      int         `orm:"IsDel"`                     // 是否删除 0未删除 1已删除
+	Content    string      `v:"required"     json:"content"` // 信息内容
+	CreateTime *gtime.Time `orm:"CreatedTime"`               //
+	UpdateTime *gtime.Time `orm:"UpdatedTime"`               //
+}

+ 68 - 0
backend/src/dashoo.cn/modi_webapi/app/model/course/course_entity.go

@@ -0,0 +1,68 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. You may not really want to edit it.
+// ==========================================================================
+
+package course
+
+import (
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/os/gtime"
+)
+
+// Entity is the golang structure for table class.
+type Entity struct {
+	Id              int            `orm:"id,primary"         json:"id"`                 //
+	Name            string         `orm:"name"               json:"name"`               // 班级名称
+	Year            int            `orm:"year"               json:"year"`               // 学年
+	Term            int            `orm:"term"               json:"term"`               // 学期
+	ClassId         int            `orm:"class_id"           json:"class_id"`           //班级Id
+	CourseWeek      string         `orm:"course_week"        json:"course_week"`        // 班级名称
+	Title           string         `orm:"title"              json:"title"`              // 标题
+	Status          string         `orm:"status"             json:"status"`             // 状态
+	IsDel           int            `orm:"is_del"             json:"is_del"`             // 是否删除:1删除0未删除
+	CreateTime      *gtime.Time    `orm:"create_time"        json:"create_time"`        // 创建时间
+	UpdateTime      *gtime.Time    `orm:"update_time"        json:"update_time"`        // 更新时间
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (r *Entity) OmitEmpty() *arModel {
+	return Model.Data(r).OmitEmpty()
+}
+
+// Inserts does "INSERT...INTO..." statement for inserting current object into table.
+func (r *Entity) Insert() (result sql.Result, err error) {
+	return Model.Data(r).Insert()
+}
+
+// InsertIgnore does "INSERT IGNORE INTO ..." statement for inserting current object into table.
+func (r *Entity) InsertIgnore() (result sql.Result, err error) {
+	return Model.Data(r).InsertIgnore()
+}
+
+// Replace does "REPLACE...INTO..." statement for inserting current object into table.
+// If there's already another same record in the table (it checks using primary key or unique index),
+// it deletes it and insert this one.
+func (r *Entity) Replace() (result sql.Result, err error) {
+	return Model.Data(r).Replace()
+}
+
+// Save does "INSERT...INTO..." statement for inserting/updating current object into table.
+// It updates the record if there's already another same record in the table
+// (it checks using primary key or unique index).
+func (r *Entity) Save() (result sql.Result, err error) {
+	return Model.Data(r).Save()
+}
+
+// Update does "UPDATE...WHERE..." statement for updating current object from table.
+// It updates the record if there's already another same record in the table
+// (it checks using primary key or unique index).
+func (r *Entity) Update() (result sql.Result, err error) {
+	return Model.Data(r).Where(gdb.GetWhereConditionOfStruct(r)).Update()
+}
+
+// Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
+func (r *Entity) Delete() (result sql.Result, err error) {
+	return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
+}

+ 351 - 0
backend/src/dashoo.cn/modi_webapi/app/model/course/course_model.go

@@ -0,0 +1,351 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. You may not really want to edit it.
+// ==========================================================================
+
+package course
+
+import (
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/frame/gmvc"
+	"time"
+)
+
+// arModel is a active record design model for table information operations.
+type arModel struct {
+	gmvc.M
+}
+
+var (
+	// Table is the table name of information.
+	Table = "course"
+	// Model is the model object of information.
+	Model = &arModel{g.DB("default").Table(Table).Safe()}
+	// Columns defines and stores column names for table information.
+	Columns = struct {
+		Id         string //
+		Name       string // 班级名称
+		IsDel      string // 是否删除:1删除0未删除
+		CreateTime string // 创建时间
+		UpdateTime string // 更新时间
+	}{
+		Id:         "id",
+		Name:       "name",
+		IsDel:      "is_del",
+		CreateTime: "create_time",
+		UpdateTime: "update_time",
+	}
+)
+
+// FindOne is a convenience method for Model.FindOne.
+// See Model.FindOne.
+func FindOne(where ...interface{}) (*Entity, error) {
+	return Model.FindOne(where...)
+}
+
+// FindAll is a convenience method for Model.FindAll.
+// See Model.FindAll.
+func FindAll(where ...interface{}) ([]*Entity, error) {
+	return Model.FindAll(where...)
+}
+
+// FindValue is a convenience method for Model.FindValue.
+// See Model.FindValue.
+func FindValue(fieldsAndWhere ...interface{}) (gdb.Value, error) {
+	return Model.FindValue(fieldsAndWhere...)
+}
+
+// FindArray is a convenience method for Model.FindArray.
+// See Model.FindArray.
+func FindArray(fieldsAndWhere ...interface{}) ([]gdb.Value, error) {
+	return Model.FindArray(fieldsAndWhere...)
+}
+
+// FindCount is a convenience method for Model.FindCount.
+// See Model.FindCount.
+func FindCount(where ...interface{}) (int, error) {
+	return Model.FindCount(where...)
+}
+
+// Insert is a convenience method for Model.Insert.
+func Insert(data ...interface{}) (result sql.Result, err error) {
+	return Model.Insert(data...)
+}
+
+// InsertIgnore is a convenience method for Model.InsertIgnore.
+func InsertIgnore(data ...interface{}) (result sql.Result, err error) {
+	return Model.InsertIgnore(data...)
+}
+
+// Replace is a convenience method for Model.Replace.
+func Replace(data ...interface{}) (result sql.Result, err error) {
+	return Model.Replace(data...)
+}
+
+// Save is a convenience method for Model.Save.
+func Save(data ...interface{}) (result sql.Result, err error) {
+	return Model.Save(data...)
+}
+
+// Update is a convenience method for Model.Update.
+func Update(dataAndWhere ...interface{}) (result sql.Result, err error) {
+	return Model.Update(dataAndWhere...)
+}
+
+// Delete is a convenience method for Model.Delete.
+func Delete(where ...interface{}) (result sql.Result, err error) {
+	return Model.Delete(where...)
+}
+
+// As sets an alias name for current table.
+func (m *arModel) As(as string) *arModel {
+	return &arModel{m.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (m *arModel) TX(tx *gdb.TX) *arModel {
+	return &arModel{m.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (m *arModel) Master() *arModel {
+	return &arModel{m.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (m *arModel) Slave() *arModel {
+	return &arModel{m.M.Slave()}
+}
+
+// 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 (m *arModel) LeftJoin(table ...string) *arModel {
+	return &arModel{m.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 (m *arModel) RightJoin(table ...string) *arModel {
+	return &arModel{m.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 (m *arModel) InnerJoin(table ...string) *arModel {
+	return &arModel{m.M.InnerJoin(table...)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+func (m *arModel) Fields(fields string) *arModel {
+	return &arModel{m.M.Fields(fields)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+func (m *arModel) FieldsEx(fields string) *arModel {
+	return &arModel{m.M.FieldsEx(fields)}
+}
+
+// Option sets the extra operation option for the model.
+func (m *arModel) Option(option int) *arModel {
+	return &arModel{m.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (m *arModel) OmitEmpty() *arModel {
+	return &arModel{m.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (m *arModel) Filter() *arModel {
+	return &arModel{m.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 (m *arModel) Where(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.Where(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (m *arModel) And(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (m *arModel) Or(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (m *arModel) Group(groupBy string) *arModel {
+	return &arModel{m.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (m *arModel) Order(orderBy string) *arModel {
+	return &arModel{m.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 (m *arModel) Limit(limit ...int) *arModel {
+	return &arModel{m.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (m *arModel) Offset(offset int) *arModel {
+	return &arModel{m.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 (m *arModel) Page(page, limit int) *arModel {
+	return &arModel{m.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (m *arModel) Batch(batch int) *arModel {
+	return &arModel{m.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 (m *arModel) Cache(duration time.Duration, name ...string) *arModel {
+	return &arModel{m.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 (m *arModel) Data(data ...interface{}) *arModel {
+	return &arModel{m.M.Data(data...)}
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*Entity.
+// 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 Model.Where function,
+// see Model.Where.
+func (m *arModel) All(where ...interface{}) ([]*Entity, error) {
+	all, err := m.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*Entity
+	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 *Entity.
+// 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 Model.Where function,
+// see Model.Where.
+func (m *arModel) One(where ...interface{}) (*Entity, error) {
+	one, err := m.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *Entity
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindOne retrieves and returns a single Record by Model.WherePri and Model.One.
+// Also see Model.WherePri and Model.One.
+func (m *arModel) FindOne(where ...interface{}) (*Entity, error) {
+	one, err := m.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *Entity
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by Model.WherePri and Model.All.
+// Also see Model.WherePri and Model.All.
+func (m *arModel) FindAll(where ...interface{}) ([]*Entity, error) {
+	all, err := m.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*Entity
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// Chunk iterates the table with given size and callback function.
+func (m *arModel) Chunk(limit int, callback func(entities []*Entity, err error) bool) {
+	m.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*Entity
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}
+
+// LockUpdate sets the lock for update for current operation.
+func (m *arModel) LockUpdate() *arModel {
+	return &arModel{m.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (m *arModel) LockShared() *arModel {
+	return &arModel{m.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (m *arModel) Unscoped() *arModel {
+	return &arModel{m.M.Unscoped()}
+}

+ 101 - 0
backend/src/dashoo.cn/modi_webapi/app/service/course/course.go

@@ -0,0 +1,101 @@
+package service
+
+import (
+	"dashoo.cn/micro_libary/db"
+	"dashoo.cn/modi_webapi/app/common"
+	"dashoo.cn/modi_webapi/app/model/course"
+	"dashoo.cn/modi_webapi/app/model/information"
+	"database/sql"
+	"fmt"
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/os/gtime"
+)
+
+// 课程定义
+type CourseService struct {
+	db.ServiceBase
+}
+
+// NewCourseService 初始化CourseService
+func NewCourseService(tenant string) (CourseService, error) {
+	var servcie CourseService
+	err := servcie.Init(tenant, course.Table)
+	return servcie, err
+}
+
+// GetPageList 分页信息列表
+func (s CourseService) GetPageList(param *course.AddOrUpdateReq) (list []*course.AddOrUpdateReq, total int, err error) {
+
+	where := common.WhereString.ValidWhere
+	if year := param.Year; year != 0 {
+		where += fmt.Sprintf(" AND year LIKE '%%%v%%'", year)
+	}
+	if term := param.Term; term != 0 {
+		where += fmt.Sprintf(" AND term LIKE '%%%v%%'", term)
+	}
+	//if status := param.Status; status > -1 {
+	//	where += fmt.Sprintf(" AND Status = %v", param.Status)
+	//}
+	// 查询总数
+	total, err = s.SafeModel.Where(where).Count()
+	if err != nil {
+		return nil, -1, gerror.New("读取行数失败")
+	}
+	// todo more 增加查询条件
+	// 查询列表
+	model := s.SafeModel.Page(int(param.Page.Current), int(param.Page.Size)).Where(where)
+	var result []*course.AddOrUpdateReq
+	err = model.Structs(&result)
+	// 如果未查到列表返回空
+	if err == sql.ErrNoRows {
+		return nil, 0, nil
+	}
+	return result, total, err
+
+}
+
+// Update 更新信息
+func (s CourseService) Update(param *course.AddOrUpdateReq) (*information.SearchEntity, error) {
+	information, err := s.GetByID(param.Id)
+	if err != nil {
+		return nil, err
+	}
+
+	// 设置更新时间
+	param.UpdateTime = gtime.Now()
+	param.CreateTime = information.CreateTime
+	if _, err = s.SafeModel.WherePri(param.Id).Update(param); err != nil {
+		return nil, err
+	}
+	return information, nil
+}
+
+// GetByID 通过id获取信息
+func (s CourseService) GetByID(id int) (res *course.SearchEntity, err error) {
+	// 关联查询
+	where := common.WhereString.ValidWhere
+	model := s.SafeModel.Where("id", id).Where(where)
+	var result *information.SearchEntity
+	err = model.Struct(&result)
+	return result, nil
+}
+
+// 删除信息
+func (s CourseService) Delete(id int) error {
+	//设置更新时间
+	if _, err := s.SafeModel.WherePri(id).Update(common.WhereString.Invalid); err != nil {
+		return err
+	}
+	return nil
+}
+
+// Add 新增信息
+func (s CourseService) Add(param *course.AddOrUpdateReq) (id int64, err error) {
+	param.CreateTime = gtime.Now()
+	if result, err := s.SafeModel.Insert(param); err != nil {
+		return 0, err
+	} else {
+		id, _ = result.LastInsertId()
+	}
+	return id, nil
+}

+ 39 - 0
frontend_web/src/api/course.js

@@ -0,0 +1,39 @@
+import request from '@/plugin/axios'
+
+export default {
+   // 获取课程列表
+   getPageList(params) {
+    return request({
+      url: process.env.VUE_APP_API + 'course/getpagelist',
+      method: 'get', 
+      params: params
+    })
+  },
+
+  getById(params) {
+    return request({
+      url: process.env.VUE_APP_API + 'information/getdetailbyid',
+      method: 'get', 
+      params: params
+    })
+  },
+
+  //删除产品信息
+   delete(params) {
+    return request({
+      url: process.env.VUE_APP_API + 'information/deletebyid',
+      method: 'delete',
+      params: params
+    })
+  },
+  
+   // 保存产品方案
+  save(data) {
+    return request({
+      url: process.env.VUE_APP_API + 'course/save',
+      method: 'post',
+      data: data
+    })
+  }
+  
+}

+ 11 - 3
frontend_web/src/router/routes.js

@@ -107,7 +107,16 @@ const frameIn = [
         },
         component: _import('information')
       },
-
+        // 课程管理
+        {
+            path: 'course',
+            name: 'course',
+            meta: {
+                title: '课程管理',
+                auth: true
+            },
+            component: _import('course')
+        },
       // 系统 前端日志
       {
         path: 'log',
@@ -302,8 +311,7 @@ const frameIn = [
         },
         component: _import('instrument/confirmandscrap')
       }
-      // ================== add 字典分类 08-12 e ====================
-
+ 
     ]
   }
 ]

+ 191 - 0
frontend_web/src/views/course/components/courseInfoDialog.vue

@@ -0,0 +1,191 @@
+<template>
+  <el-dialog title="新增课程表信息"
+             :visible.sync="dialogvisible"
+             @opened="dialogOpen"
+             @closed="dialogClose"
+             width="65%">
+    <el-form size="mini"
+             :model="course"
+             label-width="100px"
+             ref="courseForm">
+      <el-row :gutter="24"
+              class="donorsaddformcss">
+
+        <el-col :span="6">
+          <el-form-item label="学年"
+                        prop="content">
+            <el-input v-model="course.Year"
+                      placeholder="请输入"></el-input>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="6">
+          <el-form-item label="班级"
+                        prop="title">
+            <el-input v-model="course.Class"
+                      placeholder="请输入"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="学期"
+                        prop="title">
+            <el-input v-model="course.Term"
+                      placeholder="请输入"></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <el-table ref="multipleTable"
+              :data="activities"
+              border
+              fit
+              tooltip-effect="dark"
+              style="width: 100%"
+              @sort-change="orderby"
+              height="100%">
+      <el-table-column prop="title"
+                       fit
+                       min-width="80px"
+                       label="教学周"
+                       align="center"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column prop="content"
+                       label="周次"
+                       align="center"
+                       min-width="160px"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column prop="content"
+                       label="节次"
+                       align="center"
+                       min-width="160px"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column prop="content"
+                       label="实验课程名称"
+                       align="center"
+                       min-width="160px"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column prop="status"
+                       align="center"
+                       min-width="40px"
+                       label="学分"
+                       show-overflow-tooltip
+                       :formatter="formatStatus"></el-table-column>
+      <el-table-column prop="createdtime"
+                       align="center"
+                       min-width="120px"
+                       label="授课老师"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column prop="createdtime"
+                       align="center"
+                       min-width="120px"
+                       label="人数"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column prop="createdtime"
+                       align="center"
+                       min-width="120px"
+                       label="实验地点"
+                       show-overflow-tooltip></el-table-column>
+    </el-table>
+
+    <span slot="footer">
+      <el-button size="mini"
+                 @click="save(0)">保存</el-button>
+      <el-button size="mini"
+                 @click="dialogClose">关闭</el-button>
+
+    </span>
+  </el-dialog>
+</template>
+
+<script>
+
+import CourseApi from '@/api/course'
+export default {
+  name: 'courseInfoDialog',
+  props: {
+    informationId: Number
+  },
+  data () {
+    return {
+      dialogvisible: false,
+      course: {
+        CourseId: '',
+        Year: '',
+        Term: '',
+        CourseName: '',
+        Teacher: '',
+        Local: '',
+        Class: '',
+        Mark: '',
+        Num: '',
+        WeekTitle: '',
+        DayOfWeek: '',
+        Time: '',
+        Status: ''
+      },
+
+    }
+  },
+  created () {
+    this.getData()
+  },
+  methods: {
+    dialogOpen () {
+      this.course = {}
+      console.log("informationId:" + this.informationId)
+      this.$refs.courseForm.resetFields()
+      this.getData()
+    },
+    dialogClose () {
+      this.course = {}
+      console.log("informationId:" + this.informationId)
+      this.$refs.courseForm.resetFields()
+      this.$emit('handleClose')
+      this.dialogVisible = false
+    },
+    save (flag) {
+      this.$refs.courseForm.validate(valid => {
+        if (valid) {
+          this.course.status = flag
+          InformationApi.save(this.course, {})
+            .then(res => {
+              this.$emit('handleClose')
+              this.dialogvisible = false
+            })
+            .catch(err => {
+              // handle error
+              console.error(err)
+            })
+        } else {
+          console.log("error submit!!");
+          return false;
+        }
+      });
+
+    },
+    getData () {
+      if (this.informationId > 0) {
+        var id = {
+          id: this.informationId
+        }
+        InformationApi.getById(id)
+          .then(res => {
+            this.course = res
+          })
+      }
+    }
+  }
+}
+
+</script>
+
+<style lang="scss">
+.button {
+  padding: 0;
+  float: right;
+}
+
+.donorsaddformcss .el-col-8 {
+  height: 58px;
+}
+</style>

+ 305 - 0
frontend_web/src/views/course/index.vue

@@ -0,0 +1,305 @@
+<template>
+  <d2-container>
+    <template slot="header"
+              style="padding: 5px;">
+      <el-form size="mini"
+               ref="form"
+               :inline="true"
+               class="sbutton_padding"
+               style="margin-top: -7px;text-align:right;">
+        <el-form-item label="学年"
+                      class="sbutton_margin">
+          <el-input style="width: 140px;"
+                    v-model="search.Year"
+                    placeholder="请输入"></el-input>
+        </el-form-item>
+        <el-form-item label="学期"
+                      class="sbutton_margin">
+          <el-input style="width: 140px;"
+                    v-model="search.Term"
+                    placeholder="请输入"></el-input>
+        </el-form-item>
+        <el-form-item label="班级"
+                      class="sbutton_margin">
+          <el-input style="width: 140px;"
+                    v-model="search.class"
+                    placeholder="请输入"></el-input>
+        </el-form-item>
+        <el-button size="mini"
+                   type="primary"
+                   @click="initDatas()"
+                   style="margin-left:10px"
+                   @command="searchCommand"
+                   class="sbutton_margin">查 询</el-button>
+        <el-button size="mini"
+                   type="primary"
+                   @click="clearSearch"
+                   class="sbutton_margin">重 置</el-button>
+        <el-button size="mini"
+                   type="primary"
+                   style="margin-right:6px"
+                   @click="openinformationadd()"
+                   class="sbutton_margin">添加</el-button>
+      </el-form>
+    </template>
+    <el-table ref="multipleTable"
+              :data="activities"
+              border
+              fit
+              tooltip-effect="dark"
+              style="width: 100%"
+              @sort-change="orderby"
+              height="100%">
+      <el-table-column label="操作"
+                       width="160px"
+                       align="center"
+                       fixed='right'>
+        <template slot-scope="scope">
+          <el-button size="mini"
+                     title="编辑"
+                     type="primary"
+                     @click="informationedit(scope.row.id)"
+                     icon="el-icon-edit"
+                     circle></el-button>
+          <el-button size="mini"
+                     type="primary"
+                     title="发布"
+                     @click="publish(scope.row)"
+                     style="margin-left:5px;"
+                     icon="el-icon-s-promotion"
+                     circle></el-button>
+          <el-button size="mini"
+                     type="danger"
+                     title="删除"
+                     @click="deleteinformation(scope.row)"
+                     style="margin-left:5px;"
+                     icon="el-icon-delete"
+                     circle></el-button>
+
+        </template>
+      </el-table-column>
+      <el-table-column prop="title"
+                       fit
+                       min-width="80px"
+                       label="学年"
+                       align="center"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column prop="content"
+                       label="学期"
+                       align="center"
+                       min-width="160px"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column prop="content"
+                       label="标题"
+                       align="center"
+                       min-width="160px"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column prop="content"
+                       label="班级"
+                       align="center"
+                       min-width="160px"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column prop="status"
+                       align="center"
+                       min-width="40px"
+                       label="状态"
+                       show-overflow-tooltip
+                       :formatter="formatStatus"></el-table-column>
+      <el-table-column prop="createdtime"
+                       align="center"
+                       min-width="120px"
+                       label="创建时间"
+                       show-overflow-tooltip></el-table-column>
+    </el-table>
+    <!-- </el-card> -->
+    <courseInfoDialog ref="informationDialog"
+                      @handleClose="handleClose"
+                      :informationId="informationId"
+                      width="75"></courseInfoDialog>
+    <!-- </div> -->
+    <template slot="footer">
+      <el-pagination style="margin: -10px;"
+                     @size-change="handleSizeChange"
+                     @current-change="handleCurrentChange"
+                     :current-page="search.page.current"
+                     :page-sizes="[10, 15, 20]"
+                     :page-size="search.page.size"
+                     layout="total, sizes, prev, pager, next, jumper"
+                     :total="search.page.total">
+      </el-pagination>
+    </template>
+  </d2-container>
+</template>
+
+<script>
+
+import CourseApi from '@/api/course'
+import courseInfoDialog from './components/courseInfoDialog'
+export default {
+  name: 'course',
+  components: {
+    courseInfoDialog
+  },
+  data () {
+    return {
+      dialogvisible: false,
+      details: false,
+      activities: [],
+      informationId: -1,
+      search: {
+        Term: '',
+        Year: '',
+        title: '',
+        status: -1,
+        content: '',
+        page: {
+          total: 0,
+          current: 1,
+          size: 10
+        }
+      },
+      status: [{
+        key: '全部',
+        value: -1
+      },
+      {
+        key: '草稿',
+        value: 0
+      },
+      {
+        key: '已发布',
+        value: 1
+      }
+      ],
+      // 列表排序
+      Column: {
+        Order: '',
+        Prop: ''
+      }
+    }
+  },
+  mounted () {
+    // this.initDatas()
+  },
+  methods: {
+    formatStatus (row, column) {
+      for (var i = 0; i < this.status.length; i++) {
+        if (this.status[i].value == row.status) {
+          return this.status[i].key;
+        }
+      }
+    },
+    initSearchInfo () {
+      this.search = {
+        Title: '',
+        Status: -1,
+        Content: '',
+      }
+    },
+    //初始化分页分页对象
+    initPageInfo () {
+      this.search.page = {
+        total: 0,
+        current: 1,
+        size: 10
+      }
+    },
+    // 打开 添加弹窗
+    openinformationadd () {
+      this.$refs.informationDialog.dialogvisible = true
+    },
+    // 打开 编辑弹窗
+    informationedit (informationId) {
+      this.informationId = informationId
+      this.$refs.informationDialog.dialogvisible = true
+    },
+    // 新增修改弹窗关闭 返回页面
+    handleClose () {
+      this.informationId = -1
+      this.$refs.informationDialog.dialogvisible = false
+      this.initPageInfo()
+      this.initDatas()
+      console.log("handleClose informationId" + this.informationId)
+    },
+    publish (information) {
+      information.status = 1
+      InformationApi.save(information)
+    },
+    // 初始化列表数据
+    initDatas () {
+      CourseApi.getPageList(this.search)
+        .then(res => {
+          this.activities = res.records
+          this.search.page = res
+        })
+    },
+    handleSizeChange (val) {
+      this.search.page.size = val
+      this.search.page.current = 1
+      this.initDatas()
+    },
+    handleCurrentChange (val) {
+      this.search.page.current = val
+      this.initDatas()
+    },
+
+
+    deleteinformation (val) {
+      let _this = this
+      let params = {
+        id: val.id
+      }
+      _this.$confirm('此操作将永久删除该信息, 是否继续?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '关闭',
+        type: 'warning'
+      }).then(() => {
+        console.log(JSON.stringify(params))
+        InformationApi.delete(params)
+          .then(data => {
+            _this.initDatas()
+          })
+          .catch(function (error) {
+            console.log(error)
+          })
+      })
+        .catch(() => { })
+    },
+    // 列表排序功能
+    orderby (column) {
+      if (column.order === 'ascending') {
+        this.Column.Order = 'asc'
+      } else if (column.order === 'descending') {
+        this.Column.Order = 'desc'
+      }
+      this.Column.Prop = column.prop
+      this.initDatas()
+    },
+    searchCommand (command) {
+      if (command === 'search') {
+        this.dialogvisible = true
+      } else if (command === 'clear') {
+        this.clearSearch()
+      }
+    },
+    clearSearch () {
+      this.initSearchInfo()
+      this.initPageInfo()
+      this.initDatas()
+    }
+
+  }
+}
+</script>
+
+<style lang="scss">
+.el-pagination {
+  margin: 1rem 0 2rem;
+  text-align: right;
+}
+
+.plab {
+  font-size: 13px;
+  color: #999;
+}
+</style>