2025-06-20 17:13:51 +08:00
|
|
|
|
package admin
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"context"
|
2026-01-25 07:42:32 +08:00
|
|
|
|
"fmt"
|
|
|
|
|
|
"strings"
|
2025-06-20 17:13:51 +08:00
|
|
|
|
|
2025-06-20 22:03:38 +00:00
|
|
|
|
"blazing/cool"
|
|
|
|
|
|
|
2026-03-11 00:43:17 +08:00
|
|
|
|
"blazing/modules/base/model"
|
2025-06-20 22:03:38 +00:00
|
|
|
|
"blazing/modules/base/service"
|
|
|
|
|
|
|
2026-01-23 20:34:52 +00:00
|
|
|
|
config "blazing/modules/config/service"
|
2026-01-25 23:17:46 +08:00
|
|
|
|
dict "blazing/modules/dict/service"
|
2026-01-19 18:51:56 +08:00
|
|
|
|
blazing "blazing/modules/player/service"
|
2026-01-25 07:42:32 +08:00
|
|
|
|
playerservice "blazing/modules/player/service"
|
2025-07-17 05:20:30 +08:00
|
|
|
|
|
2026-02-08 02:11:46 +08:00
|
|
|
|
"github.com/deatil/go-cryptobin/cryptobin/crypto"
|
2026-01-23 20:34:52 +00:00
|
|
|
|
"github.com/gogf/gf/v2/database/gdb"
|
2025-06-20 17:13:51 +08:00
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
2026-02-23 00:54:47 +08:00
|
|
|
|
"github.com/gogf/gf/v2/os/gtime"
|
2025-06-20 17:13:51 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type BaseSysUserController struct {
|
|
|
|
|
|
*cool.Controller
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
|
var base_sys_user_controller = &BaseSysUserController{
|
|
|
|
|
|
&cool.Controller{
|
|
|
|
|
|
Prefix: "/admin/base/sys/user",
|
|
|
|
|
|
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page", "Move"},
|
|
|
|
|
|
Service: service.NewBaseSysUserService(),
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
// 注册路由
|
|
|
|
|
|
cool.RegisterController(base_sys_user_controller)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type UserMoveReq struct {
|
|
|
|
|
|
g.Meta `path:"/move" method:"GET"`
|
|
|
|
|
|
Authorization string `json:"Authorization" in:"header"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (c *BaseSysUserController) Move(ctx context.Context, req *UserMoveReq) (res *cool.BaseRes, err error) {
|
|
|
|
|
|
err = service.NewBaseSysUserService().Move(ctx)
|
|
|
|
|
|
res = cool.Ok(nil)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-07-17 05:20:30 +08:00
|
|
|
|
|
2026-03-11 00:43:17 +08:00
|
|
|
|
type ReqShopReq struct {
|
|
|
|
|
|
g.Meta `path:"/reqshop" method:"POST"`
|
|
|
|
|
|
Authorization string `json:"Authorization" in:"header"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (c *BaseSysUserController) ReqShop(ctx context.Context, req *ReqShopReq) (res *cool.BaseRes, err error) {
|
|
|
|
|
|
t := cool.GetAdmin(ctx)
|
|
|
|
|
|
|
|
|
|
|
|
if !playerservice.NewTaskService(uint32(t.UserId)).CanShop() {
|
|
|
|
|
|
return cool.Fail("不满足申请条件"), nil
|
|
|
|
|
|
}
|
|
|
|
|
|
cool.DBM(&model.BaseSysUserRole{}).Data("roleId", "27", "userId", t.UserId).Save()
|
|
|
|
|
|
res = cool.Ok(nil)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-25 07:42:32 +08:00
|
|
|
|
type SessionReq struct {
|
|
|
|
|
|
g.Meta `path:"/getSession" method:"GET"`
|
|
|
|
|
|
Authorization string `json:"Authorization" in:"header"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-22 22:40:32 +08:00
|
|
|
|
func (c *BaseSysUserController) GetSession(ctx context.Context, req *SessionReq) (res *SessionRes, err error) {
|
2025-07-17 05:20:30 +08:00
|
|
|
|
|
|
|
|
|
|
t := cool.GetAdmin(ctx)
|
|
|
|
|
|
if t == nil || t.UserId == 0 {
|
|
|
|
|
|
|
2025-08-22 22:40:32 +08:00
|
|
|
|
return &SessionRes{}, nil
|
2025-07-17 05:20:30 +08:00
|
|
|
|
}
|
2025-08-22 22:40:32 +08:00
|
|
|
|
|
|
|
|
|
|
res = &SessionRes{}
|
2026-02-23 21:50:57 +08:00
|
|
|
|
|
2025-12-06 23:59:00 +08:00
|
|
|
|
t1 := service.NewBaseSysUserService().GetPerson(uint32(t.UserId))
|
2025-08-22 22:40:32 +08:00
|
|
|
|
|
2026-01-25 07:42:32 +08:00
|
|
|
|
res.UserID = int(t1.ID)
|
2026-02-23 21:50:57 +08:00
|
|
|
|
playerinfo := blazing.NewUserService(uint32(t1.ID)).Info.Person(uint32(t1.ID))
|
|
|
|
|
|
if playerinfo != nil {
|
2026-01-25 07:42:32 +08:00
|
|
|
|
res.IsReg = 1
|
2026-02-23 00:54:47 +08:00
|
|
|
|
if t1.DepartmentID == 35 { ///抢先服玩家,3天没登录衰退
|
2026-03-10 20:51:48 +08:00
|
|
|
|
|
2026-02-23 21:50:57 +08:00
|
|
|
|
if playerinfo.UpdateTime.AddDate(0, 0, 3).Before(gtime.Now()) {
|
2026-02-23 00:54:47 +08:00
|
|
|
|
t1.DepartmentID = 1
|
|
|
|
|
|
service.NewBaseSysUserService().SetdepartmentId(uint32(t1.ID), 1)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-07-17 05:20:30 +08:00
|
|
|
|
}
|
2026-01-25 23:17:46 +08:00
|
|
|
|
res.PetID = dict.NewDictInfoService().GetShiny()
|
2026-02-23 00:54:47 +08:00
|
|
|
|
|
2026-02-13 06:02:32 +08:00
|
|
|
|
res.Server = config.NewServerService().GetPort(t1.DepartmentID)
|
|
|
|
|
|
|
2026-01-25 07:42:32 +08:00
|
|
|
|
// share.ShareManager.DeleteSession(t1)
|
2026-02-08 02:11:46 +08:00
|
|
|
|
cypten := crypto.
|
|
|
|
|
|
FromString(blazing.NewInfoService(uint32(t.UserId)).Gensession()).
|
|
|
|
|
|
SetKey("gfertf12dfertf12").
|
|
|
|
|
|
SetIv("gfertf12dfertf12").
|
|
|
|
|
|
Aes().
|
|
|
|
|
|
CBC().
|
|
|
|
|
|
PKCS7Padding().
|
|
|
|
|
|
Encrypt().
|
|
|
|
|
|
ToBase64String()
|
|
|
|
|
|
res.Session = cypten
|
2026-01-25 07:42:32 +08:00
|
|
|
|
|
2025-07-17 05:20:30 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-08-22 22:40:32 +08:00
|
|
|
|
|
|
|
|
|
|
type SessionRes struct {
|
2026-01-25 23:17:46 +08:00
|
|
|
|
IsReg int `json:"isreg"`
|
|
|
|
|
|
UserID int `json:"userid"`
|
|
|
|
|
|
Session string `json:"session"`
|
|
|
|
|
|
|
|
|
|
|
|
Server gdb.List `json:"server"`
|
|
|
|
|
|
PetID []int `json:"petid"`
|
2025-08-22 22:40:32 +08:00
|
|
|
|
}
|
2026-01-25 07:42:32 +08:00
|
|
|
|
|
|
|
|
|
|
type RegReq struct {
|
|
|
|
|
|
g.Meta `path:"/regrobot" method:"GET"`
|
|
|
|
|
|
Authorization string `json:"Authorization" in:"header"`
|
|
|
|
|
|
// 玩家昵称,@ArraySerialize注解
|
|
|
|
|
|
Nickname string `json:"nickname" ` // 固定长度16字节
|
|
|
|
|
|
// 机器人人物颜色 rgb,@UInt注解
|
|
|
|
|
|
Color uint32 `json:"color" ` // 4字节
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (c *BaseSysUserController) Regrobot(ctx context.Context, req *RegReq) (res *RegRes, err error) {
|
|
|
|
|
|
|
|
|
|
|
|
t := cool.GetAdmin(ctx)
|
|
|
|
|
|
|
|
|
|
|
|
res = &RegRes{}
|
|
|
|
|
|
|
|
|
|
|
|
t1 := service.NewBaseSysUserService().GetPerson(uint32(t.UserId))
|
|
|
|
|
|
|
|
|
|
|
|
ser := playerservice.NewUserService(uint32(t1.ID))
|
|
|
|
|
|
|
|
|
|
|
|
logininfo := ser.Info.Reg(cool.Filter.Replace(strings.Trim(req.Nickname, "\x00"), '*'), req.Color)
|
|
|
|
|
|
if logininfo != nil {
|
|
|
|
|
|
|
|
|
|
|
|
res.Session = blazing.NewInfoService(uint32(t.UserId)).Gensession()
|
|
|
|
|
|
cool.CacheManager.Set(context.TODO(), fmt.Sprintf("player:%d", uint32(t1.ID)), logininfo, 0)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type RegRes struct {
|
|
|
|
|
|
Session string `json:"session"`
|
|
|
|
|
|
}
|
2026-03-10 20:51:48 +08:00
|
|
|
|
|
|
|
|
|
|
type UserGoldAddReq struct {
|
|
|
|
|
|
g.Meta `path:"/goldadd" method:"GET"`
|
|
|
|
|
|
Authorization string `json:"Authorization" in:"header"`
|
|
|
|
|
|
|
|
|
|
|
|
UserID int `json:"userid"`
|
|
|
|
|
|
Gold float32 `json:"gold"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (c *BaseSysUserController) GoldAdd(ctx context.Context, req *UserGoldAddReq) (res *cool.BaseRes, err error) {
|
|
|
|
|
|
service.NewBaseSysUserService().UpdateGold(uint32(req.UserID), int64(req.Gold*100))
|
|
|
|
|
|
res = cool.Ok(nil)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-03-11 12:19:13 +08:00
|
|
|
|
|
|
|
|
|
|
type DuihuanGoldAddReq struct {
|
|
|
|
|
|
g.Meta `path:"/duihuan" method:"POST"`
|
|
|
|
|
|
Authorization string `json:"Authorization" in:"header"`
|
|
|
|
|
|
|
|
|
|
|
|
Gold float32 `json:"gold"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (c *BaseSysUserController) DuihuanGold(ctx context.Context, req *DuihuanGoldAddReq) (res *cool.BaseRes, err error) {
|
|
|
|
|
|
t := cool.GetAdmin(ctx)
|
|
|
|
|
|
|
|
|
|
|
|
if service.NewBaseSysUserService().GetGold(t.UserId) < int64(req.Gold*100) {
|
|
|
|
|
|
res = cool.Fail("余额不足")
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-03-11 12:50:33 +08:00
|
|
|
|
|
2026-03-19 17:18:32 +08:00
|
|
|
|
service.NewBaseSysUserService().DuihuanFreeGold(uint32(t.UserId), int64(req.Gold*100), int64(req.Gold*100))
|
2026-03-11 12:19:13 +08:00
|
|
|
|
res = cool.Ok(nil)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|