Przeglądaj źródła

值班详情的增删改查

liuyang 5 lat temu
rodzic
commit
9b359923b7

+ 117 - 0
backend/src/dashoo.cn/modi_webapi/app/api/duty/detail.go

@@ -0,0 +1,117 @@
+package duty
+
+import (
+	"dashoo.cn/modi_webapi/app/common"
+	"dashoo.cn/modi_webapi/app/model/duty/detail"
+	detailService "dashoo.cn/modi_webapi/app/service/duty"
+	"dashoo.cn/modi_webapi/library/request"
+	"dashoo.cn/modi_webapi/library/response"
+	"github.com/gogf/gf/net/ghttp"
+)
+
+// 值周详情控制器
+type DetailController struct {
+}
+
+// 分页查询
+func (c *DetailController) GetPageList(r *ghttp.Request) {
+	// tenant 租户模式
+	tenant := r.Header.Get("Tenant")
+	page := request.GetPageInfo(r)
+	// 初始化service
+	service, err := detailService.NewDetailService(tenant)
+	if err != nil {
+		response.Json(r, 1, err.Error())
+	}
+
+	pageInfo := common.PageInfo{
+		Current:   page.Current,
+		PagesSize: page.Size,
+	}
+
+	selectPageReq := common.SelectPageReq{
+		Tenant: tenant,
+		Page:   &pageInfo,
+		Order:  r.GetString("order"),
+	}
+
+	if dutyList, total, err := service.GetPageList(&selectPageReq); err != nil {
+		response.Json(r, -1, err.Error())
+	} else {
+		var records response.PagedRecords
+		records.Current = page.Current
+		records.Size = page.Size
+		records.Total = total
+		records.Records = dutyList
+		response.Json(r, 0, "ok", records)
+	}
+}
+
+// 添加值班
+func (c *DetailController) AddDetail(r *ghttp.Request) {
+	// tenant 租户模式
+	tenant := r.Header.Get("Tenant")
+	var entity *detail.Entity
+	// 赋值并校验参数
+	if err := r.Parse(&entity); err != nil {
+		response.Json(r, -1, err.Error())
+	}
+	// 初始化课程详情service
+	service, err := detailService.NewDetailService(tenant)
+	if err != nil {
+		response.Json(r, -1, err.Error())
+	}
+	// 获取操作人
+	realName := r.GetParamVar("realname").String()
+	entity.CreatedBy = realName
+	if newId, err := service.Add(entity); err != nil {
+		response.Json(r, 1, err.Error())
+	} else {
+		response.Json(r, 0, "新增成功", newId)
+	}
+
+}
+
+// 获取详情
+func (c *DetailController) GetDetailById(r *ghttp.Request) {
+	// tenant 租户模式
+	tenant := r.Header.Get("Tenant")
+	Id := r.GetInt("Id")
+	// 初始化课程详情service
+	service, err := detailService.NewDetailService(tenant)
+	if err != nil {
+		response.Json(r, -1, err.Error())
+	}
+	if duty, err := service.GetDetailById(Id); err != nil {
+		response.Json(r, 1, err.Error())
+	} else {
+		response.Json(r, 0, "ok", duty)
+	}
+
+}
+
+// 更新
+func (c *DetailController) UpdateDetail(r *ghttp.Request) {
+	// tenant 租户模式
+	tenant := r.Header.Get("Tenant")
+	var entity *detail.Entity
+	// 赋值并校验参数
+	if err := r.Parse(&entity); err != nil {
+		response.Json(r, -1, err.Error())
+	}
+	// 初始化课程详情service
+	service, err := detailService.NewDetailService(tenant)
+	if err != nil {
+		response.Json(r, -1, err.Error())
+	}
+	// 获取操作人
+	realName := r.GetParamVar("realname").String()
+	entity.UpdatedBy = realName
+
+	if detail, err := service.Save(entity); err != nil {
+		response.Json(r, 1, err.Error())
+	} else {
+		response.Json(r, 0, "更新成功", detail)
+	}
+
+}

+ 9 - 6
backend/src/dashoo.cn/modi_webapi/app/api/duty/duty.go

@@ -26,13 +26,16 @@ func (c *DutyController) GetPageList(r *ghttp.Request) {
 		Current:   page.Current,
 		PagesSize: page.Size,
 	}
+
 	selectPageReq := duty.SelectPageReq{
-		Tenant: tenant,
-		Title:  "",
-		Year:   0,
-		Term:   0,
-		Page:   &pageInfo,
-		Order:  r.GetString("order"),
+		Title: "",
+		Year:  0,
+		Term:  0,
+		Common: common.SelectPageReq{
+			Tenant: tenant,
+			Page:   &pageInfo,
+			Order:  r.GetString("order"),
+		},
 	}
 	if Title := r.GetString("Title"); Title != "" {
 		selectPageReq.Title = Title

+ 8 - 0
backend/src/dashoo.cn/modi_webapi/app/common/utils.go

@@ -73,3 +73,11 @@ type DeleteUpdReq struct {
 	UpdatedBy   string      `orm:"UpdatedBy"`   // 更新人
 	UpdatedTime *gtime.Time `orm:"UpdatedTime"` // 更新时间
 }
+
+// 搜索请求
+type SelectPageReq struct {
+	Tenant string    `protobuf:"bytes,1,opt,name=tenant,proto3" json:"tenant,omitempty"`
+	Page   *PageInfo `protobuf:"bytes,3,opt,name=page" json:"page,omitempty"`
+	Prop   string    `json:prop`
+	Order  string    `json:order`
+}

+ 14 - 0
backend/src/dashoo.cn/modi_webapi/app/model/duty/detail/detail.go

@@ -0,0 +1,14 @@
+package detail
+
+import "dashoo.cn/modi_webapi/app/common"
+
+// 搜索请求
+type SelectPageReq struct {
+	Tenant string           `protobuf:"bytes,1,opt,name=tenant,proto3" json:"tenant,omitempty"`
+	Title  string           `protobuf:"bytes,2,opt,name=Title,proto3" json:"Title,omitempty"`
+	Year   int              `protobuf:"bytes,2,opt,name=Year,proto3" json:"Year,omitempty"`
+	Term   int              `protobuf:"bytes,2,opt,name=Term,proto3" json:"Term,omitempty"`
+	Page   *common.PageInfo `protobuf:"bytes,3,opt,name=page" json:"page,omitempty"`
+	Prop   string           `json:prop`
+	Order  string           `json:order`
+}

+ 71 - 0
backend/src/dashoo.cn/modi_webapi/app/model/duty/detail/detail_entity.go

@@ -0,0 +1,71 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. You may not really want to edit it.
+// ==========================================================================
+
+package detail
+
+import (
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/os/gtime"
+)
+
+// Entity is the golang structure for table instrument.
+type Entity struct {
+	Id          int         `xorm:"not null pk autoincr INT(10)"` // id
+	DutyId      int         `xorm:"INT(10)"`                      // 值周ID
+	Local       string      `xorm:"INT(10)"`                      // 地点
+	Time        int         `xorm:"INT(10)"`                      // 时间段
+	Status      string      `xorm:"VARCHAR(32)"`                  // 状态
+	People      string      `xorm:"VARCHAR(32)"`                  // 值班人员
+	Monday      int         `xorm:"INT(10)"`                      // 周一
+	Tuesday     int         `xorm:"INT(10)"`                      // 周二
+	Wednesday   int         `xorm:"INT(10)"`                      // 周三
+	Thursday    int         `xorm:"INT(10)"`                      // 周四
+	Friday      int         `xorm:"INT(10)"`                      // 周五
+	Saturday    int         `xorm:"INT(10)"`                      // 周六
+	Sunday      int         `xorm:"INT(10)"`                      // 周天
+	CreatedBy   string      `xorm:"VARCHAR(32)"`                  // 创建人
+	CreatedTime *gtime.Time `xorm:"DATETIME created"`             // 创建时间
+	UpdatedBy   string      `xorm:"VARCHAR(32)"`                  // 更新人
+	UpdatedTime *gtime.Time `xorm:"DATETIME updated"`             // 更新时间
+	IsDel       int         `xorm:"INT(11)"`                      // 删除标志
+
+}
+
+// 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()
+}
+
+// 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()
+}

+ 369 - 0
backend/src/dashoo.cn/modi_webapi/app/model/duty/detail/detail_model.go

@@ -0,0 +1,369 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. You may not really want to edit it.
+// ==========================================================================
+
+package detail
+
+import (
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"time"
+)
+
+// arModel is a active record design model for table instrument operations.
+type arModel struct {
+	M *gdb.Model
+}
+
+var (
+	// Table is the table name of instrument.
+	Table = "duty_detail"
+	// Model is the model object of instrument.
+	Model = &arModel{g.DB("default").Table(Table).Safe()}
+	// Columns defines and stores column names for table instrument.
+)
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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.
+func (m *arModel) LeftJoin(joinTable string, on string) *arModel {
+	return &arModel{m.M.LeftJoin(joinTable, on)}
+}
+
+// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
+func (m *arModel) RightJoin(joinTable string, on string) *arModel {
+	return &arModel{m.M.RightJoin(joinTable, on)}
+}
+
+// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
+func (m *arModel) InnerJoin(joinTable string, on string) *arModel {
+	return &arModel{m.M.InnerJoin(joinTable, on)}
+}
+
+// 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(expire time.Duration, name ...string) *arModel {
+	return &arModel{m.M.Cache(expire, 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...)}
+}
+
+// Insert does "INSERT INTO ..." statement for the model.
+// The optional parameter <data> is the same as the parameter of Model.Data function,
+// see Model.Data.
+func (m *arModel) Insert(data ...interface{}) (result sql.Result, err error) {
+	return m.M.Insert(data...)
+}
+
+// Replace does "REPLACE INTO ..." statement for the model.
+// The optional parameter <data> is the same as the parameter of Model.Data function,
+// see Model.Data.
+func (m *arModel) Replace(data ...interface{}) (result sql.Result, err error) {
+	return m.M.Replace(data...)
+}
+
+// Save does "INSERT INTO ... ON DUPLICATE KEY UPDATE..." statement for the model.
+// It updates the record if there's primary or unique index in the saving data,
+// or else it inserts a new record into the table.
+//
+// The optional parameter <data> is the same as the parameter of Model.Data function,
+// see Model.Data.
+func (m *arModel) Save(data ...interface{}) (result sql.Result, err error) {
+	return m.M.Save(data...)
+}
+
+// Update does "UPDATE ... " statement for the model.
+//
+// If the optional parameter <dataAndWhere> is given, the dataAndWhere[0] is the updated
+// data field, and dataAndWhere[1:] is treated as where condition fields.
+// Also see Model.Data and Model.Where functions.
+func (m *arModel) Update(dataAndWhere ...interface{}) (result sql.Result, err error) {
+	return m.M.Update(dataAndWhere...)
+}
+
+// Delete does "DELETE FROM ... " statement for the model.
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+func (m *arModel) Delete(where ...interface{}) (result sql.Result, err error) {
+	return m.M.Delete(where...)
+}
+
+// Count does "SELECT COUNT(x) FROM ..." statement for the model.
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+func (m *arModel) Count(where ...interface{}) (int, error) {
+	return m.M.Count(where...)
+}
+
+// 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
+}
+
+// Value retrieves a specified record value from table and returns the result as interface type.
+// It returns nil if there's no record found with the given conditions from table.
+//
+// If the optional parameter <fieldsAndWhere> is given, the fieldsAndWhere[0] is the selected fields
+// and fieldsAndWhere[1:] is treated as where condition fields.
+// Also see Model.Fields and Model.Where functions.
+func (m *arModel) Value(fieldsAndWhere ...interface{}) (gdb.Value, error) {
+	return m.M.Value(fieldsAndWhere...)
+}
+
+// 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
+}
+
+// FindValue retrieves and returns single field value by Model.WherePri and Model.Value.
+// Also see Model.WherePri and Model.Value.
+func (m *arModel) FindValue(fieldsAndWhere ...interface{}) (gdb.Value, error) {
+	return m.M.FindValue(fieldsAndWhere...)
+}
+
+// FindCount retrieves and returns the record number by Model.WherePri and Model.Count.
+// Also see Model.WherePri and Model.Count.
+func (m *arModel) FindCount(where ...interface{}) (int, error) {
+	return m.M.FindCount(where...)
+}
+
+// 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)
+	})
+
+}

+ 5 - 25
backend/src/dashoo.cn/modi_webapi/app/model/duty/duty.go

@@ -4,32 +4,12 @@
 
 package duty
 
-import (
-	"dashoo.cn/modi_webapi/app/common"
-	"dashoo.cn/modi_webapi/library/request"
-	"github.com/gogf/gf/frame/g"
-)
-
-var (
-	recordsTable = g.DB().Table(Table).Safe()
-)
-
-func GetAllDuty(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 FindDutyCount(where string) (int, error) {
-	return recordsTable.Where(where).Count()
-}
+import "dashoo.cn/modi_webapi/app/common"
 
 // 搜索请求
 type SelectPageReq struct {
-	Tenant string           `protobuf:"bytes,1,opt,name=tenant,proto3" json:"tenant,omitempty"`
-	Title  string           `protobuf:"bytes,2,opt,name=Title,proto3" json:"Title,omitempty"`
-	Year   int              `protobuf:"bytes,2,opt,name=Year,proto3" json:"Year,omitempty"`
-	Term   int              `protobuf:"bytes,2,opt,name=Term,proto3" json:"Term,omitempty"`
-	Page   *common.PageInfo `protobuf:"bytes,3,opt,name=page" json:"page,omitempty"`
-	Prop   string           `json:prop`
-	Order  string           `json:order`
+	Title  string `protobuf:"bytes,2,opt,name=Title,proto3" json:"Title,omitempty"`
+	Year   int    `protobuf:"bytes,2,opt,name=Year,proto3" json:"Year,omitempty"`
+	Term   int    `protobuf:"bytes,2,opt,name=Term,proto3" json:"Term,omitempty"`
+	Common common.SelectPageReq
 }

+ 88 - 0
backend/src/dashoo.cn/modi_webapi/app/service/duty/detail.go

@@ -0,0 +1,88 @@
+package duty
+
+import (
+	"dashoo.cn/micro_libary/db"
+	"dashoo.cn/modi_webapi/app/common"
+	"dashoo.cn/modi_webapi/app/model/duty/detail"
+	"database/sql"
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/os/gtime"
+)
+
+// 值班详情定义
+type DetailService struct {
+	db.ServiceBase
+}
+
+// 初始化service
+func NewDetailService(tenant string) (DetailService, error) {
+	var service DetailService
+	err := service.Init(tenant, detail.Table)
+	return service, err
+}
+
+// 分页查询值班表
+func (s DetailService) GetPageList(param *common.SelectPageReq) (list []*detail.Entity, total int, err error) {
+	model := s.SafeModel
+	// 查询总数
+	total, err = model.Where("isDel", 0).Count()
+	if err != nil {
+		return nil, -1, gerror.New("读取行数失败")
+	}
+	// 排序
+	orderby := "Id asc" // 默认排序
+	// 列表查询
+	model = model.Page(int(param.Page.Current), int(param.Page.PagesSize)).Order(orderby)
+	var result []*detail.Entity
+	err = model.Struct(&result)
+	// 如果未查到列表返回空
+	if err == sql.ErrNoRows {
+		return nil, 0, nil
+	}
+	return result, total, err
+}
+
+// 新增
+func (s DetailService) Add(param *detail.Entity) (id int64, err error) {
+	param.CreatedTime = gtime.Now()
+	if result, err := s.SafeModel.Insert(param); err != nil {
+		return 0, err
+	} else {
+		id, _ = result.LastInsertId()
+	}
+	return id, nil
+}
+
+// 获取详情
+func (s DetailService) GetDetailById(id int) (res *detail.Entity, err error) {
+	model := s.SafeModel.Where("Id", id).Where("isDel", 0)
+	var result *detail.Entity
+	err = model.Struct(&result)
+	return result, nil
+}
+
+// 删除
+func (s DetailService) DeleteById(Ids *common.DeleteIdsReq, param *common.DeleteUpdReq) error {
+	//设置更新时间
+	param.UpdatedTime = gtime.Now()
+	// 修改删除状态
+	param.IsDel = 1
+	if _, err := s.SafeModel.WherePri(Ids).Update(param); err != nil {
+		return err
+	}
+	return nil
+}
+
+// 更新
+func (s DetailService) Save(param *detail.Entity) (*detail.Entity, error) {
+	detail, err := s.GetDetailById(param.Id)
+	if err != nil {
+		return nil, err
+	}
+	// 设置更新时间
+	param.UpdatedTime = gtime.Now()
+	if _, err = s.SafeModel.Where(param.Id).Update(param); err != nil {
+		return nil, err
+	}
+	return detail, nil
+}

+ 1 - 1
backend/src/dashoo.cn/modi_webapi/app/service/duty/duty.go

@@ -43,7 +43,7 @@ func (s DutyService) GetPageList(param *duty.SelectPageReq) (list []*duty.Entity
 	// 排序
 	orderby := "Id asc" // 默认排序
 	// 列表查询
-	model = model.Page(int(param.Page.Current), int(param.Page.PagesSize)).Order(orderby)
+	model = model.Page(int(param.Common.Page.Current), int(param.Common.Page.PagesSize)).Order(orderby)
 	var result []*duty.Entity
 	err = model.Struct(&result)
 	// 如果未查到列表返回空