```
feat(logic): 实现角色行走位置更新与账号加载功能 - 在 walk.go 中优化 Walk 方法,手动赋值替换 copier.Copy 提高可控性 - 在 main.go 中新增 loadAccounts 函数用于从 csv 文件加载账号并注册 - 新增 strings 包引用以支持文件内容按行分割 - 注释掉调试用的 fmt 打印语句,保留逻辑结构便于后续启用 - 在 base_sys_user.go 中增加 GetEamil 方法
This commit is contained in:
@@ -4,13 +4,15 @@ import (
|
|||||||
"blazing/common/socket/errorcode"
|
"blazing/common/socket/errorcode"
|
||||||
"blazing/logic/service/maps"
|
"blazing/logic/service/maps"
|
||||||
"blazing/logic/service/player"
|
"blazing/logic/service/player"
|
||||||
|
|
||||||
"github.com/jinzhu/copier"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h Controller) Walk(data *maps.WalkInInfo, c *player.Player) (result *maps.WalkOutInfo, err errorcode.ErrorCode) {
|
func (h Controller) Walk(data *maps.WalkInInfo, c *player.Player) (result *maps.WalkOutInfo, err errorcode.ErrorCode) {
|
||||||
result = &maps.WalkOutInfo{}
|
result = &maps.WalkOutInfo{
|
||||||
copier.Copy(result, data)
|
Flag: data.Flag,
|
||||||
|
Point: data.Point,
|
||||||
|
Reserve2: data.Reverse2,
|
||||||
|
}
|
||||||
|
|
||||||
result.UserID = data.Head.UserID
|
result.UserID = data.Head.UserID
|
||||||
c.Info.Pos = data.Point
|
c.Info.Pos = data.Point
|
||||||
//glog.Debug(context.Background(), err1)
|
//glog.Debug(context.Background(), err1)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
||||||
"github.com/gogf/gf/v2/os/gproc"
|
"github.com/gogf/gf/v2/os/gproc"
|
||||||
@@ -15,6 +16,8 @@ import (
|
|||||||
"blazing/cool"
|
"blazing/cool"
|
||||||
|
|
||||||
//"blazing/o/service"
|
//"blazing/o/service"
|
||||||
|
"blazing/modules/base/service"
|
||||||
|
blservice "blazing/modules/blazing/service"
|
||||||
"net/http"
|
"net/http"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
|
|
||||||
@@ -41,7 +44,7 @@ func signalHandlerForMain(sig os.Signal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
//loadAccounts()
|
||||||
if cool.IsRedisMode {
|
if cool.IsRedisMode {
|
||||||
go cool.ListenFunc(gctx.New())
|
go cool.ListenFunc(gctx.New())
|
||||||
}
|
}
|
||||||
@@ -60,3 +63,22 @@ func main() {
|
|||||||
|
|
||||||
gproc.Listen()
|
gproc.Listen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func loadAccounts() {
|
||||||
|
t1, _ := os.Getwd()
|
||||||
|
data, err := os.ReadFile(t1 + "/b.csv")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
lines := strings.Split(string(data), "\n")
|
||||||
|
for _, line := range lines {
|
||||||
|
line = strings.TrimSpace(line)
|
||||||
|
if line == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
t := service.NewBaseSysUserService().GetEamil(line)
|
||||||
|
|
||||||
|
blservice.NewUserService(uint32(t.ID)).Reg(t.Username, 0)
|
||||||
|
}
|
||||||
|
//fmt.Printf("加载 %d 个账号\n", len(accounts))
|
||||||
|
}
|
||||||
|
|||||||
@@ -44,6 +44,12 @@ func (s *BaseSysUserService) GetPerson(userId uint) (res *model.BaseSysUser) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
func (s *BaseSysUserService) GetEamil(userId string) (res *model.BaseSysUser) {
|
||||||
|
m := cool.DBM(s.Model)
|
||||||
|
m.Where("email", userId).FieldsEx("password").Scan(&res)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
func (s *BaseSysUserService) ModifyBefore(ctx context.Context, method string, param g.MapStrAny) (err error) {
|
func (s *BaseSysUserService) ModifyBefore(ctx context.Context, method string, param g.MapStrAny) (err error) {
|
||||||
if method == "Delete" {
|
if method == "Delete" {
|
||||||
// 禁止删除超级管理员
|
// 禁止删除超级管理员
|
||||||
|
|||||||
Reference in New Issue
Block a user