bug修改

This commit is contained in:
2025-08-22 13:47:52 +08:00
parent ff2996853a
commit 9ccfbb9f4a
12 changed files with 115 additions and 28 deletions

Binary file not shown.

View File

@@ -97,7 +97,7 @@ func InfoUser(ctx context.Context, c *app.RequestContext) {
} }
// CreateUser . // CreateUser .
// @router /v1/user/create/ [POST] // @router /v1/user/ [POST]
func CreateUser(ctx context.Context, c *app.RequestContext) { func CreateUser(ctx context.Context, c *app.RequestContext) {
var err error var err error
var req user.CreateUserRequest var req user.CreateUserRequest
@@ -113,13 +113,14 @@ func CreateUser(ctx context.Context, c *app.RequestContext) {
} }
if err = mysql.CreateUser([]*model.User{ if err = mysql.CreateUser([]*model.User{
{ {
UserID: strconv.FormatInt(userId, 10), UserID: strconv.FormatInt(userId, 10),
UserName: req.Name, UserName: req.Name,
Gender: req.Gender, Gender: req.Gender,
Age: uint8(req.Age), Age: uint8(req.Age),
Mobile: req.Mobile, Mobile: req.Mobile,
Area: uint8(req.Area), Area: uint8(req.Area),
UserPassword: req.UserPassword, UserPassword: req.UserPassword,
AvatarImageURL: req.AvatarImageURL,
}, },
}); err != nil { }); err != nil {
c.JSON(consts.StatusInternalServerError, &user.CreateUserResponse{Code: user.Code_DBErr, Msg: err.Error()}) c.JSON(consts.StatusInternalServerError, &user.CreateUserResponse{Code: user.Code_DBErr, Msg: err.Error()})

View File

@@ -1822,12 +1822,13 @@ func (p *UserInfoReq) String() string {
} }
type CreateUserRequest struct { type CreateUserRequest struct {
Name string `thrift:"name,1" form:"name" form:"name" json:"name" vd:"(len($) > 0 && len($) < 100)"` Name string `thrift:"name,1" form:"name" json:"name" vd:"(len($) > 0 && len($) < 100)"`
Gender Gender `thrift:"gender,2" form:"gender" json:"gender" vd:"($ == 1||$ == 2)"` Gender Gender `thrift:"gender,2" form:"gender" json:"gender" vd:"($ == 1||$ == 2)"`
Age int64 `thrift:"age,3" form:"age" json:"age" vd:"$>0"` Age int64 `thrift:"age,3" form:"age" json:"age"`
Mobile string `thrift:"mobile,4" form:"mobile" json:"mobile" vd:"(len($) > 0 && len($) < 12)"` Mobile string `thrift:"mobile,4" form:"mobile" form:"mobile" json:"mobile" vd:"(len($) > 0 && len($) < 12)"`
Area int64 `thrift:"area,5" form:"area" form:"area" json:"area" vd:"$>0"` Area int64 `thrift:"area,5" form:"area" json:"area" vd:"$>0"`
UserPassword string `thrift:"user_password,6" form:"user_password" form:"user_password" json:"user_password" vd:"(len($) > 0 && len($) < 15)"` UserPassword string `thrift:"user_password,6" form:"user_password" json:"user_password" vd:"(len($) > 0 && len($) < 15)"`
AvatarImageURL string `thrift:"avatar_image_url,7" form:"avatar_image_url" json:"avatar_image_url"`
} }
func NewCreateUserRequest() *CreateUserRequest { func NewCreateUserRequest() *CreateUserRequest {
@@ -1861,6 +1862,10 @@ func (p *CreateUserRequest) GetUserPassword() (v string) {
return p.UserPassword return p.UserPassword
} }
func (p *CreateUserRequest) GetAvatarImageURL() (v string) {
return p.AvatarImageURL
}
var fieldIDToName_CreateUserRequest = map[int16]string{ var fieldIDToName_CreateUserRequest = map[int16]string{
1: "name", 1: "name",
2: "gender", 2: "gender",
@@ -1868,6 +1873,7 @@ var fieldIDToName_CreateUserRequest = map[int16]string{
4: "mobile", 4: "mobile",
5: "area", 5: "area",
6: "user_password", 6: "user_password",
7: "avatar_image_url",
} }
func (p *CreateUserRequest) Read(iprot thrift.TProtocol) (err error) { func (p *CreateUserRequest) Read(iprot thrift.TProtocol) (err error) {
@@ -1936,6 +1942,14 @@ func (p *CreateUserRequest) Read(iprot thrift.TProtocol) (err error) {
} else if err = iprot.Skip(fieldTypeId); err != nil { } else if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError goto SkipFieldError
} }
case 7:
if fieldTypeId == thrift.STRING {
if err = p.ReadField7(iprot); err != nil {
goto ReadFieldError
}
} else if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError
}
default: default:
if err = iprot.Skip(fieldTypeId); err != nil { if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError goto SkipFieldError
@@ -2031,6 +2045,17 @@ func (p *CreateUserRequest) ReadField6(iprot thrift.TProtocol) error {
p.UserPassword = _field p.UserPassword = _field
return nil return nil
} }
func (p *CreateUserRequest) ReadField7(iprot thrift.TProtocol) error {
var _field string
if v, err := iprot.ReadString(); err != nil {
return err
} else {
_field = v
}
p.AvatarImageURL = _field
return nil
}
func (p *CreateUserRequest) Write(oprot thrift.TProtocol) (err error) { func (p *CreateUserRequest) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16 var fieldId int16
@@ -2062,6 +2087,10 @@ func (p *CreateUserRequest) Write(oprot thrift.TProtocol) (err error) {
fieldId = 6 fieldId = 6
goto WriteFieldError goto WriteFieldError
} }
if err = p.writeField7(oprot); err != nil {
fieldId = 7
goto WriteFieldError
}
} }
if err = oprot.WriteFieldStop(); err != nil { if err = oprot.WriteFieldStop(); err != nil {
goto WriteFieldStopError goto WriteFieldStopError
@@ -2176,6 +2205,22 @@ WriteFieldBeginError:
WriteFieldEndError: WriteFieldEndError:
return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err)
} }
func (p *CreateUserRequest) writeField7(oprot thrift.TProtocol) (err error) {
if err = oprot.WriteFieldBegin("avatar_image_url", thrift.STRING, 7); err != nil {
goto WriteFieldBeginError
}
if err := oprot.WriteString(p.AvatarImageURL); err != nil {
return err
}
if err = oprot.WriteFieldEnd(); err != nil {
goto WriteFieldEndError
}
return nil
WriteFieldBeginError:
return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err)
WriteFieldEndError:
return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err)
}
func (p *CreateUserRequest) String() string { func (p *CreateUserRequest) String() string {
if p == nil { if p == nil {

View File

@@ -62,10 +62,11 @@ struct UserInfoReq {
struct CreateUserRequest{ struct CreateUserRequest{
1: string name (api.body="name", api.form="name",api.vd="(len($) > 0 && len($) < 100)") 1: string name (api.body="name", api.form="name",api.vd="(len($) > 0 && len($) < 100)")
2: Gender gender (api.body="gender", api.form="gender",api.vd="($ == 1||$ == 2)") 2: Gender gender (api.body="gender", api.form="gender",api.vd="($ == 1||$ == 2)")
3: i64 age (api.body="age", api.form="age",api.vd="$>0") 3: i64 age (api.body="age", api.form="age")
4: string mobile (api.body="mobile", api.form="mobile",api.vd="(len($) > 0 && len($) < 12)") 4: string mobile (api.body="mobile", api.form="mobile",api.vd="(len($) > 0 && len($) < 12)")
5: i64 area (api.body="area", api.form="area",api.vd="$>0") 5: i64 area (api.body="area", api.form="area",api.vd="$>0")
6: string user_password (api.body="user_password", api.form="user_password",api.vd="(len($) > 0 && len($) < 15)") 6: string user_password (api.body="user_password", api.form="user_password",api.vd="(len($) > 0 && len($) < 15)")
7: string avatar_image_url (api.body="avatar_image_url", api.form="avatar_image_url")
} }
struct CreateUserResponse{ struct CreateUserResponse{

Binary file not shown.

View File

@@ -11,7 +11,7 @@ import (
) )
// AudioCall . // AudioCall .
// @router /audioCall [POST] // @router /v1/audio_call/ [POST]
func AudioCall(ctx context.Context, c *app.RequestContext) { func AudioCall(ctx context.Context, c *app.RequestContext) {
var err error var err error
var req audioAndVideoCalls.AudioCallReq var req audioAndVideoCalls.AudioCallReq

View File

@@ -11,7 +11,7 @@ import (
) )
// RoomList . // RoomList .
// @router /roomlist [GET] // @router /v1/roomlist/ [GET]
func RoomList(ctx context.Context, c *app.RequestContext) { func RoomList(ctx context.Context, c *app.RequestContext) {
var err error var err error
var req audioAndVideoCalls.RoomListReq var req audioAndVideoCalls.RoomListReq
@@ -31,7 +31,7 @@ func RoomList(ctx context.Context, c *app.RequestContext) {
} }
// RoomRemove . // RoomRemove .
// @router /room [DELETE] // @router /v1/room/ [DELETE]
func RoomRemove(ctx context.Context, c *app.RequestContext) { func RoomRemove(ctx context.Context, c *app.RequestContext) {
var err error var err error
var req audioAndVideoCalls.RemoveRoomReq var req audioAndVideoCalls.RemoveRoomReq

View File

@@ -12,7 +12,7 @@ import (
) )
// VideoCall . // VideoCall .
// @router /videoCall [POST] // @router /v1/video_call/ [POST]
func VideoCall(ctx context.Context, c *app.RequestContext) { func VideoCall(ctx context.Context, c *app.RequestContext) {
var err error var err error
var req audioAndVideoCalls.VideoCallReq var req audioAndVideoCalls.VideoCallReq

View File

@@ -17,8 +17,23 @@ import (
func Register(r *server.Hertz) { func Register(r *server.Hertz) {
root := r.Group("/", rootMw()...) root := r.Group("/", rootMw()...)
root.POST("/audioCall", append(_audiocallMw(), audioAndVideoCalls.AudioCall)...) {
root.DELETE("/room", append(_roomremoveMw(), audioAndVideoCalls.RoomRemove)...) _v1 := root.Group("/v1", _v1Mw()...)
root.GET("/roomlist", append(_roomlistMw(), audioAndVideoCalls.RoomList)...) {
root.POST("/videoCall", append(_videocallMw(), audioAndVideoCalls.VideoCall)...) _audio_call := _v1.Group("/audio_call", _audio_callMw()...)
_audio_call.POST("/", append(_audiocallMw(), audioAndVideoCalls.AudioCall)...)
}
{
_room := _v1.Group("/room", _roomMw()...)
_room.DELETE("/", append(_roomremoveMw(), audioAndVideoCalls.RoomRemove)...)
}
{
_roomlist := _v1.Group("/roomlist", _roomlistMw()...)
_roomlist.GET("/", append(_roomlist0Mw(), audioAndVideoCalls.RoomList)...)
}
{
_video_call := _v1.Group("/video_call", _video_callMw()...)
_video_call.POST("/", append(_videocallMw(), audioAndVideoCalls.VideoCall)...)
}
}
} }

View File

@@ -45,3 +45,28 @@ func _roomremoveMw() []app.HandlerFunc {
// your code... // your code...
return nil return nil
} }
func _v1Mw() []app.HandlerFunc {
// your code...
return nil
}
func _audio_callMw() []app.HandlerFunc {
// your code...
return nil
}
func _video_callMw() []app.HandlerFunc {
// your code...
return nil
}
func _roomMw() []app.HandlerFunc {
// your code...
return nil
}
func _roomlist0Mw() []app.HandlerFunc {
// your code...
return nil
}

View File

@@ -20,7 +20,7 @@ struct audioCallResp {
service AudioCallService { service AudioCallService {
audioCallResp audioCall(1: audioCallReq request) (api.post="/audioCall"); audioCallResp audioCall(1: audioCallReq request) (api.post="/v1/audio_call/");
} }
struct videoCallReq { struct videoCallReq {
@@ -34,7 +34,7 @@ struct videoCallResp {
} }
service VideoCallService { service VideoCallService {
videoCallResp videoCall(1: videoCallReq request) (api.post="/videoCall"); videoCallResp videoCall(1: videoCallReq request) (api.post="/v1/video_call/");
} }
@@ -56,6 +56,6 @@ struct RemoveRoomResp {
} }
service RoomService { service RoomService {
roomListResp RoomList(1: roomListReq request) (api.get="/roomlist"); roomListResp RoomList(1: roomListReq request) (api.get="/v1/roomlist/");
RemoveRoomResp RoomRemove(1: RemoveRoomReq request) (api.delete="/room"); RemoveRoomResp RoomRemove(1: RemoveRoomReq request) (api.delete="/v1/room/");
} }

Binary file not shown.