From 8e352cfe58342f9d09b02407a3699db76dd050f2 Mon Sep 17 00:00:00 2001 From: govolokatliai Date: Mon, 28 Apr 2025 17:13:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=AD=E5=BB=BA=E5=A5=BD=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=A1=86=E6=9E=B6=EF=BC=8C=E5=87=86=E5=A4=87=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9B=B8=E5=85=B3=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yaml | 2 +- handler/unit/tweaks.go | 30 ++++++++++++++++++++++++++++++ handler/unit/unit_entry.go | 16 ++++++++++++++++ handler/utils.go | 6 ++++++ model/tweak.go | 25 +++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 handler/unit/tweaks.go create mode 100644 handler/unit/unit_entry.go create mode 100644 model/tweak.go diff --git a/config.yaml b/config.yaml index 5b0519d..955265c 100644 --- a/config.yaml +++ b/config.yaml @@ -2,7 +2,7 @@ ListenPort: 25005 DB: Type: "SQLite" - Path: "" # not need if use SQLite + Path: "./scheduler.db" # not need if use SQLite Port: "" # not need if use SQLite User: "" # not need if use SQLite Password: "" # not need if use SQLite diff --git a/handler/unit/tweaks.go b/handler/unit/tweaks.go new file mode 100644 index 0000000..48f498e --- /dev/null +++ b/handler/unit/tweaks.go @@ -0,0 +1,30 @@ +package handler + +import ( + "zsxyww.com/scheduler/model" +) + +// 增加一项tweak +func (uo *uoPrototype) addTweak(in *model.Tweak) error { + return nil +} + +// 删除一项tweak +func (uo *uoPrototype) deleteTweak(in *model.Tweak) error { + return nil +} + +// 查询一些tweak,通过IssueID +func (uo *uoPrototype) getTweakByIssueID(in *model.Tweak) (result []*model.Tweak, err error) { + return nil, nil +} + +// 查询一些tweak,通过一个日期 +func (uo *uoPrototype) getTweakByTime(in *model.Tweak) (result []*model.Tweak, err error) { + return nil, nil +} + +// 查询一些tweak,通过一个工号 +func (uo *uoPrototype) getTweakByID(in *model.Tweak) (result []*model.Tweak, err error) { + return nil, nil +} diff --git a/handler/unit/unit_entry.go b/handler/unit/unit_entry.go new file mode 100644 index 0000000..889d752 --- /dev/null +++ b/handler/unit/unit_entry.go @@ -0,0 +1,16 @@ +package handler + +import ( + "gorm.io/gorm" + "zsxyww.com/scheduler/database" +) + +// Unit Operations +type uoPrototype struct { + c *gorm.DB +} + +func init() { + uo := uoPrototype{c: db.Main} + _ = uo +} diff --git a/handler/utils.go b/handler/utils.go index c3d650e..b9081e9 100644 --- a/handler/utils.go +++ b/handler/utils.go @@ -3,6 +3,7 @@ package handler import ( "github.com/golang-module/carbon/v2" "zsxyww.com/scheduler/config" + "zsxyww.com/scheduler/model" ) // 输入一个时间,返回时间是第几周的第几天 @@ -12,3 +13,8 @@ func getWorkDay(in carbon.Carbon) (weekOffset int, dayOffset int) { _dayOffset := in.DayOfWeek() return int(_weekOffset), _dayOffset } + +// 输入成员工号,返回这个成员的信息 +func getMemberByID(in int) *model.Member { + return nil +} diff --git a/model/tweak.go b/model/tweak.go new file mode 100644 index 0000000..cc16e28 --- /dev/null +++ b/model/tweak.go @@ -0,0 +1,25 @@ +package model + +import ( + "gorm.io/gorm" + "time" +) + +// 这个结构体是供数据库使用的表结构,换班补班蹭班的记录都会以这种方式储存 +type Tweak struct { + gorm.Model + IssueID int //请求的编号,例如一个换班请求会产生两个记录,IssueID相同 + IssueTime time.Time //需要进行操作的时间 + Type int //操作类型,具体看下面的常量声明 + SubjectID int //工号 + Name string //名字 +} + +const ( + OP_SWITCH_ADD = 0 //换班加入值班表 + OP_SWITCH_SUB = 1 //换班移出值班表 + OP_VOLUNTEER = 2 //蹭班 + OP_REPAY = 3 //补班 + OP_ADMIN_ADD = 4 + OP_ADMIN_SUB = 5 +)