Skip to content

Commit

Permalink
fix: 修正各类小错误
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed May 11, 2024
1 parent 2d22a1f commit 0551f5c
Show file tree
Hide file tree
Showing 9 changed files with 1,243 additions and 1,567 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dist = ./dist

# 生成 API 文件
api:
web restdoc -o=$(API)/restdoc.json $(ROOT)/cmfx
web restdoc -o=$(API)/restdoc.yaml $(ROOT)/cmfx

# 生成 go 的依赖内容
gen:
Expand Down
2 changes: 1 addition & 1 deletion cmfx/cmfx.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package cmfx

// # restdoc cmfx 文档
//
// @media application/json application/xml
// @media application/json application/xml application/cbor
// @version [Version]
// @tag admin 管理员端
// @tag rbac RBAC
Expand Down
2 changes: 1 addition & 1 deletion cmfx/modules/admin/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type modelInfo struct {
type respInfo struct {
m *Loader

XMLName struct{} `xml:"info" json:"-"`
XMLName struct{} `xml:"info" json:"-" cbor:"-"`

ID int64 `json:"id" xml:"id,attr" cbor:"id"`
Sex types.Sex `json:"sex" xml:"sex,attr" cbor:"sex"`
Expand Down
2 changes: 1 addition & 1 deletion cmfx/user/settings/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (obj Object[T]) Set(uid int64, o *T) error {

err = obj.s.db.DoTransaction(func(tx *orm.Tx) error {
for _, mod := range mods {
if _, err := tx.Update(mod, "value"); err != nil {
if _, _, err := tx.Save(mod, "value"); err != nil {
return errors.Join(err, tx.Rollback())
}
}
Expand Down
4 changes: 4 additions & 0 deletions cmfx/user/settings/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func TestObject(t *testing.T) {
a.NotError(err).NotNil(opt).
Equal(opt.F2, 2).
Length(obj.users, 1)
size, err := ss.db.Where("uid=?", 1).Select(true, &modelSetting{})
a.NotError(err).Zero(size) // 未存入数据库

// Object.Set

Expand All @@ -63,6 +65,8 @@ func TestObject(t *testing.T) {
a.NotError(err).NotNil(opt).
Equal(opt.F2, 1).
Length(obj.users, 1) // 主动写入了数据
size, err = ss.db.Where("uid=?", 1).Select(true, &modelSetting{})
a.NotError(err).Equal(size, 1) // 已入数据库
}

func TestGetFieldName(t *testing.T) {
Expand Down
Loading

0 comments on commit 0551f5c

Please sign in to comment.