mirror of
https://github.com/ZSCNetSupportDept/scheduler.git
synced 2025-10-28 20:45:05 +08:00
搭建好了一个框架,准备实现数据库相关功能
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
ListenPort: 25005
|
ListenPort: 25005
|
||||||
DB:
|
DB:
|
||||||
Type: "SQLite"
|
Type: "SQLite"
|
||||||
Path: "" # not need if use SQLite
|
Path: "./scheduler.db" # not need if use SQLite
|
||||||
Port: "" # not need if use SQLite
|
Port: "" # not need if use SQLite
|
||||||
User: "" # not need if use SQLite
|
User: "" # not need if use SQLite
|
||||||
Password: "" # not need if use SQLite
|
Password: "" # not need if use SQLite
|
||||||
|
|||||||
30
handler/unit/tweaks.go
Normal file
30
handler/unit/tweaks.go
Normal file
@@ -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
|
||||||
|
}
|
||||||
16
handler/unit/unit_entry.go
Normal file
16
handler/unit/unit_entry.go
Normal file
@@ -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
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"github.com/golang-module/carbon/v2"
|
"github.com/golang-module/carbon/v2"
|
||||||
"zsxyww.com/scheduler/config"
|
"zsxyww.com/scheduler/config"
|
||||||
|
"zsxyww.com/scheduler/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 输入一个时间,返回时间是第几周的第几天
|
// 输入一个时间,返回时间是第几周的第几天
|
||||||
@@ -12,3 +13,8 @@ func getWorkDay(in carbon.Carbon) (weekOffset int, dayOffset int) {
|
|||||||
_dayOffset := in.DayOfWeek()
|
_dayOffset := in.DayOfWeek()
|
||||||
return int(_weekOffset), _dayOffset
|
return int(_weekOffset), _dayOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 输入成员工号,返回这个成员的信息
|
||||||
|
func getMemberByID(in int) *model.Member {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
25
model/tweak.go
Normal file
25
model/tweak.go
Normal file
@@ -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
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user