Skip to content

Commit

Permalink
Merge pull request #15 from golang-acexy/develop
Browse files Browse the repository at this point in the history
调整部分代码命名
  • Loading branch information
acexy authored Jun 24, 2024
2 parents 385a452 + 73e5a16 commit d19e2d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ginmodule/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ func (r *Request) BindBodyJson(object any) error {
return r.ctx.ShouldBindJSON(object)
}

// MustBodyJson 将请求body数据绑定到json结构体中
// MustBindBodyJson 将请求body数据绑定到json结构体中
// 任何错误将触发Panic流程中断
func (r *Request) MustBodyJson(object any) {
func (r *Request) MustBindBodyJson(object any) {
err := r.BindBodyJson(object)
if err != nil {
panic(&internalPanic{
Expand Down
6 changes: 3 additions & 3 deletions ginmodule/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func RespRestStatusError(statusCode StatusCode, statusMessage ...StatusMessage)
}

// RespRestBizError 响应标准格式的Rest业务错误
func RespRestBizError(bizErrorCode BizErrorCode, bizErrorMessage BizErrorMessage) Response {
func RespRestBizError(bizErrorCode *BizErrorCode, bizErrorMessage *BizErrorMessage) Response {
dataRest := &RestRespStruct{
Status: &RestRespStatusStruct{
StatusCode: StatusCodeSuccess,
Expand Down Expand Up @@ -179,8 +179,8 @@ func (c *commonResp) ToResponse() Response {
return c
}

// RespStatusCode 设置响应状态码
func RespStatusCode(statusCode int) Response {
// RespHttpStatusCode 设置响应状态码
func RespHttpStatusCode(statusCode int) Response {
return &commonResp{ginFn: func(context *gin.Context) {
context.Status(statusCode)
}}
Expand Down
4 changes: 2 additions & 2 deletions ginmodule/status.go → ginmodule/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ type RestRespStatusStruct struct {
StatusMessage StatusMessage `json:"statusMessage"`

// 业务错误码 仅当StatusCode为200时进入业务错误判断
BizErrorCode BizErrorCode `json:"bizErrorCode"`
BizErrorMessage BizErrorMessage `json:"bizErrorMessage"`
BizErrorCode *BizErrorCode `json:"bizErrorCode"`
BizErrorMessage *BizErrorMessage `json:"bizErrorMessage"`

// 系统响应时间戳
Timestamp int64 `json:"timestamp"`
Expand Down

0 comments on commit d19e2d6

Please sign in to comment.