refactor: 将端口和在线ID类型从uint16改为uint32
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed

This commit is contained in:
xinian
2026-03-02 18:34:20 +08:00
committed by cnb
parent ae06d18aa2
commit 47bc680889
12 changed files with 35 additions and 35 deletions

View File

@@ -34,9 +34,9 @@ type QuitSReq struct {
func (this *ServerController) Quit(ctx context.Context, req *QuitSReq) (res *cool.BaseRes, err error) {
res = &cool.BaseRes{}
serv := service.NewServerService().GetServerID(uint16(req.ID))
serv := service.NewServerService().GetServerID(req.ID)
aa, ok := cool.GetClient(serv.Port)
aa, ok := cool.GetClient(serv.OnlineID*100000 + serv.Port)
if ok && aa != nil { //如果已经存在且这个端口已经被存过
aa.QuitSelf(req.Code)
}

View File

@@ -29,7 +29,7 @@ func NewServerService() *ServerService {
var rr []g.MapStrAny
r, _ := gconv.Map(data)["list"].(gdb.Result)
for i := 0; i < len(r); i++ {
t, ok := cool.GetClient(gconv.Uint16(r[i].Map()["port"]))
t, ok := cool.GetClient(10000*gconv.Uint32(r[i].Map()["online_id"])+gconv.Uint32(r[i].Map()["port"]))
// tt.Friends = v.Friends
subm := r[i].GMap()
@@ -74,7 +74,7 @@ func (s *ServerService) GetPort(DepartmentID uint) gdb.List {
var res gdb.Result
m := cool.DBM(s.Model).Where("is_open", 1).Fields("ip", "port", "online_id", "is_vip", "name")
if DepartmentID != 1 {
res, _ = m.All()
} else {
@@ -107,7 +107,7 @@ func (s *ServerService) StartUPdate(OnlineID uint16, isinstall int) model.Server
return tttt
}
func (s *ServerService) SetServerID(OnlineID uint16, Port uint16) error {
func (s *ServerService) SetServerID(OnlineID uint32, Port uint32) error {
m := cool.DBM(s.Model).Where("online_id", OnlineID)
@@ -122,7 +122,7 @@ func (s *ServerService) SetServerID(OnlineID uint16, Port uint16) error {
return nil
}
func (s *ServerService) GetServerID(OnlineID uint16) model.ServerList {
func (s *ServerService) GetServerID(OnlineID uint32) model.ServerList {
var tttt model.ServerList
cool.DBM(s.Model).Where("online_id", OnlineID).Scan(&tttt)
@@ -131,7 +131,7 @@ func (s *ServerService) GetServerID(OnlineID uint16) model.ServerList {
}
// 保存版本号
func (s *ServerService) SetServerScreen(id uint16, name string) {
func (s *ServerService) SetServerScreen(id uint32, name string) {
cool.DBM(s.Model).Where("online_id", id).Data("old_screen", name).Update()