Skip to content

Commit

Permalink
Merge pull request #10 from SJTU-jCourse/feat/userpoint
Browse files Browse the repository at this point in the history
feat: first version of user point system.
  • Loading branch information
dujiajun authored Nov 12, 2024
2 parents a27e995 + 2fa6769 commit 2f27115
Show file tree
Hide file tree
Showing 31 changed files with 1,215 additions and 121 deletions.
4 changes: 4 additions & 0 deletions cmd/import_from_jwc/import_from_jwc.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func readRawCSV(filename string) [][]string {
func main() {
initDB()
data := readRawCSV(fmt.Sprintf("./data/%s.csv", Semester))
// 课程号,课程名称,学时,合上教师,任课教师,开课院系,课程安排,教学班名称,选课人数,学分,教室,授课语言,是否通识课,通识课归属模块,年级

// init
queryAllBaseCourse()
Expand Down Expand Up @@ -174,6 +175,9 @@ func queryAllBaseCourse() {

func parseMainTeacherFromLine(line []string) po.TeacherPO {
teacherInfo := strings.Split(line[4], "|")
if len(teacherInfo) <= 1 {
return po.TeacherPO{}
}
teacher := po.TeacherPO{
Name: teacherInfo[1],
Code: teacherInfo[0],
Expand Down
11 changes: 9 additions & 2 deletions cmd/load/trainingplan/extend_training_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"os"
"strconv"

"gorm.io/gorm/clause"

"github.com/joho/godotenv"

"jcourse_go/dal"
Expand Down Expand Up @@ -44,7 +46,9 @@ func main() {
MajorCode: tp.Code,
MajorClass: tp.MajorClass,
}
result := db.Model(po.TrainingPlanPO{}).Create(&tp_po)
result := db.Model(po.TrainingPlanPO{}).
Clauses(clause.OnConflict{DoNothing: true}).
Create(&tp_po)
if result.Error != nil {
log.Fatalf("In create training plan %#v:%#v", tp, result.Error)
}
Expand All @@ -65,7 +69,10 @@ func main() {
SuggestSemester: c.SuggestSemester,
// Department: c.Department,
}
cresult = db.Model(po.TrainingPlanCoursePO{}).Create(&tpc_po)
// 已有记录则跳过
cresult = db.Model(po.TrainingPlanCoursePO{}).
Clauses(clause.OnConflict{DoNothing: true}).
Create(&tpc_po)
if cresult.Error != nil {
if !errors.Is(cresult.Error, gorm.ErrRecordNotFound) {
log.Fatalf("In bind course %#v totraining plan %#v:%#v", c, tp, cresult.Error)
Expand Down
6 changes: 6 additions & 0 deletions constant/userpoint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package constant

const (
HandleFeeRateKey = "point_handling_fee_rate"
DefaultHandleFeeRate = 0.01
)
6 changes: 4 additions & 2 deletions dal/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ func GetRedisDSN() string {
port := util.GetRedisPort()
return fmt.Sprintf("%s:%s", host, port)
}

func GetRedisPassWord() string {
return util.GetRedisPassword()
}
func InitRedisClient() {
rdb = redis.NewClient(&redis.Options{
Addr: GetRedisDSN(),
Password: "",
Password: GetRedisPassWord(),
DB: 0,
})
}
Expand Down
66 changes: 34 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module jcourse_go

go 1.22.0
go 1.23

toolchain go1.22.6
toolchain go1.23.0

require (
github.com/SJTU-jCourse/password_hasher v0.0.0-20240731144855-1f64f055ff5c
github.com/bytedance/sonic v1.12.1
github.com/bytedance/sonic v1.12.3
github.com/gin-gonic/contrib v0.0.0-20240508051311-c1c6bf0061b0
github.com/gin-gonic/gin v1.10.0
github.com/glebarez/sqlite v1.11.0
Expand All @@ -18,74 +18,76 @@ require (
github.com/joho/godotenv v1.5.1
github.com/lib/pq v1.10.9
github.com/mozillazg/go-pinyin v0.20.0
github.com/redis/go-redis/v9 v9.5.3
github.com/pkg/errors v0.9.1
github.com/redis/go-redis/v9 v9.7.0
github.com/stretchr/testify v1.9.0
github.com/tmc/langchaingo v0.1.12
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gorm.io/driver/postgres v1.5.9
gorm.io/gorm v1.25.10
gorm.io/gorm v1.25.12
)

require (
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
github.com/bytedance/sonic/loader v0.2.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dlclark/regexp2 v1.10.0 // indirect
github.com/dlclark/regexp2 v1.11.4 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/glebarez/go-sqlite v1.21.2 // indirect
github.com/glebarez/go-sqlite v1.22.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/go-playground/validator/v10 v10.22.1 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/gomodule/redigo v2.0.0+incompatible // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/context v1.1.2 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/gorilla/sessions v1.3.0 // indirect
github.com/gorilla/sessions v1.4.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.5.5 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pgvector/pgvector-go v0.1.1 // indirect
github.com/pkoukk/tiktoken-go v0.1.6 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pgvector/pgvector-go v0.2.2 // indirect
github.com/pkoukk/tiktoken-go v0.1.7 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/vcaesar/cedar v0.20.2 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/arch v0.11.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.25.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/libc v1.22.5 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/sqlite v1.23.1 // indirect
modernc.org/libc v1.61.0 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/sqlite v1.33.1 // indirect
)

// 本地调试修改
Expand Down
Loading

0 comments on commit 2f27115

Please sign in to comment.