Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:添加查询修改接口 #1041

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin/niuniu/draw.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

type drawUserRanking struct {
name string
user *userInfo
user *UserInfo
}

type drawer []drawUserRanking
Expand Down
2 changes: 1 addition & 1 deletion plugin/niuniu/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func init() {
}
// 获取初始长度
length := db.randLength()
u := userInfo{
u := UserInfo{
UID: uid,
Length: length,
}
Expand Down
49 changes: 30 additions & 19 deletions plugin/niuniu/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
sync.RWMutex
}

type userInfo struct {
type UserInfo struct {

Check failure on line 27 in plugin/niuniu/model.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported type UserInfo should have comment or be unexported (revive)
UID int64
Length float64
UserCount int
Expand All @@ -39,7 +39,7 @@
Buff5 int // 暂定
}

type users []*userInfo
type users []*UserInfo

var (
db = &model{}
Expand All @@ -54,8 +54,19 @@
})
)

// GetNiuNiuInfo ...
func GetNiuNiuInfo(gid, uid int64) (*UserInfo, error) {
niu, err := db.findNiuNiu(gid, uid)
return &niu, err
}

// InsertNiuNiuInfo ...
func InsertNiuNiuInfo(u *UserInfo, gid int64) error {
return db.insertNiuNiu(u, gid)
}

// useWeiGe 使用道具伟哥
func (u *userInfo) useWeiGe() (string, float64) {
func (u *UserInfo) useWeiGe() (string, float64) {
niuniu := u.Length
reduce := math.Abs(hitGlue(niuniu))
niuniu += reduce
Expand All @@ -67,7 +78,7 @@
}

// usePhilter 使用道具媚药
func (u *userInfo) usePhilter() (string, float64) {
func (u *UserInfo) usePhilter() (string, float64) {
niuniu := u.Length
reduce := math.Abs(hitGlue(niuniu))
niuniu -= reduce
Expand All @@ -79,7 +90,7 @@
}

// useArtifact 使用道具击剑神器
func (u *userInfo) useArtifact(adduserniuniu float64) (string, float64, float64) {
func (u *UserInfo) useArtifact(adduserniuniu float64) (string, float64, float64) {
myLength := u.Length
difference := myLength - adduserniuniu
var (
Expand All @@ -101,7 +112,7 @@
}

// useShenJi 使用道具击剑神稽
func (u *userInfo) useShenJi(adduserniuniu float64) (string, float64, float64) {
func (u *UserInfo) useShenJi(adduserniuniu float64) (string, float64, float64) {
myLength := u.Length
difference := myLength - adduserniuniu
var (
Expand Down Expand Up @@ -132,10 +143,10 @@
return r, myLength, adduserniuniu + 0.7*change
}

func (u *userInfo) processNiuNiuAction(t string, props string) (string, error) {
func (u *UserInfo) processNiuNiuAction(t string, props string) (string, error) {
var (
messages string
info userInfo
info UserInfo
err error
f float64
)
Expand Down Expand Up @@ -173,7 +184,7 @@
return messages, err
}

func (u *userInfo) createUserInfoByProps(props string) error {
func (u *UserInfo) createUserInfoByProps(props string) error {
var (
err error
)
Expand Down Expand Up @@ -210,12 +221,12 @@

// 接收值依次是 被jj用户的信息 记录gid和uid的字符串 道具名称
// 返回值依次是 要发送的消息 错误信息
func (u *userInfo) processJJuAction(adduserniuniu *userInfo, t string, props string) (string, error) {
func (u *UserInfo) processJJuAction(adduserniuniu *UserInfo, t string, props string) (string, error) {
var (
fencingResult string
f float64
f1 float64
info userInfo
info UserInfo
err error
)
v, ok := prop.Load(t)
Expand Down Expand Up @@ -253,7 +264,7 @@
return fencingResult, err
}

func (u *userInfo) purchaseItem(n int) (int, error) {
func (u *UserInfo) purchaseItem(n int) (int, error) {
var (
money int
err error
Expand Down Expand Up @@ -295,7 +306,7 @@
}

func (m users) positive() users {
var m1 []*userInfo
var m1 []*UserInfo
for _, i2 := range m {
if i2.Length > 0 {
m1 = append(m1, i2)
Expand All @@ -305,7 +316,7 @@
}

func (m users) negative() users {
var m1 []*userInfo
var m1 []*UserInfo
for _, i2 := range m {
if i2.Length <= 0 {
m1 = append(m1, i2)
Expand Down Expand Up @@ -343,20 +354,20 @@
func (db *model) createGIDTable(gid int64) error {
db.Lock()
defer db.Unlock()
return db.sql.Create(strconv.FormatInt(gid, 10), &userInfo{})
return db.sql.Create(strconv.FormatInt(gid, 10), &UserInfo{})
}

// findNiuNiu 返回一个用户的牛牛信息
func (db *model) findNiuNiu(gid, uid int64) (userInfo, error) {
func (db *model) findNiuNiu(gid, uid int64) (UserInfo, error) {
db.RLock()
defer db.RUnlock()
u := userInfo{}
u := UserInfo{}
err := db.sql.Find(strconv.FormatInt(gid, 10), &u, "where UID = "+strconv.FormatInt(uid, 10))
return u, err
}

// insertNiuNiu 更新一个用户的牛牛信息
func (db *model) insertNiuNiu(u *userInfo, gid int64) error {
func (db *model) insertNiuNiu(u *UserInfo, gid int64) error {
db.Lock()
defer db.Unlock()
return db.sql.Insert(strconv.FormatInt(gid, 10), u)
Expand All @@ -371,6 +382,6 @@
func (db *model) readAllTable(gid int64) (users, error) {
db.Lock()
defer db.Unlock()
a, err := sql.FindAll[userInfo](&db.sql, strconv.FormatInt(gid, 10), "where UserCount = 0")
a, err := sql.FindAll[UserInfo](&db.sql, strconv.FormatInt(gid, 10), "where UserCount = 0")
return a, err
}
Loading