refactor: update exception constants to follow new naming convention

- Update old ErrorStatus, ErrorType, and Service/Endpoint constants to new naming convention
- Fix incorrect TypeSpecific usage in JWT middleware
- Add missing event specific error definitions to specific.yaml
- Regenerate exception constants

Co-authored-by: Gemini <gemini@google.com>
This commit is contained in:
2026-01-21 14:31:03 +08:00
parent b1c78dce28
commit 14f50ecdb2
12 changed files with 236 additions and 229 deletions

View File

@@ -15,10 +15,10 @@ func Checkin(c *gin.Context) {
userIdOrig, ok := c.Get("user_id")
if !ok {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusUser).
SetService(exception.EventService).
SetEndpoint(exception.EventCheckinEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusUser).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceCheckin).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorMissingUserId).
Build()
utils.HttpResponse(c, 403, errorCode)
@@ -27,10 +27,10 @@ func Checkin(c *gin.Context) {
userId, err := uuid.Parse(userIdOrig.(string))
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer).
SetService(exception.EventService).
SetEndpoint(exception.EventCheckinEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusServer).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceCheckin).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorUuidParseFailed).
Build()
utils.HttpResponse(c, 500, errorCode)
@@ -40,10 +40,10 @@ func Checkin(c *gin.Context) {
eventIdOrig, ok := c.GetQuery("event_id")
if !ok {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.EventService).
SetEndpoint(exception.EventCheckinEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusClient).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceCheckin).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput).
Build()
utils.HttpResponse(c, 400, errorCode)
@@ -54,10 +54,10 @@ func Checkin(c *gin.Context) {
eventId, err := uuid.Parse(eventIdOrig)
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer).
SetService(exception.EventService).
SetEndpoint(exception.EventCheckinEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusServer).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceCheckin).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorUuidParseFailed).
Build()
utils.HttpResponse(c, 500, errorCode)
@@ -67,10 +67,10 @@ func Checkin(c *gin.Context) {
code, err := data.GenCheckinCode(eventId)
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer).
SetService(exception.EventService).
SetEndpoint(exception.EventCheckinEndpoint).
SetType(exception.ErrorTypeSpecific).
SetStatus(exception.StatusServer).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceCheckin).
SetType(exception.TypeSpecific).
SetOriginal(exception.EventCheckinGenCodeFailed).
Build()
utils.HttpResponse(c, 500, errorCode)
@@ -93,10 +93,10 @@ func CheckinSubmit(c *gin.Context) {
err := attendanceData.VerifyCheckinCode(req.ChekinCode)
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.EventService).
SetEndpoint(exception.EventCheckinSubmitEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusClient).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceCheckinSubmit).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput).
Build()
utils.HttpResponse(c, 400, errorCode)
@@ -110,10 +110,10 @@ func CheckinQuery(c *gin.Context) {
userIdOrig, ok := c.Get("user_id")
if !ok {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusUser).
SetService(exception.EventService).
SetEndpoint(exception.EventCheckinQueryEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusUser).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceCheckinQuery).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorMissingUserId).
Build()
utils.HttpResponse(c, 400, errorCode)
@@ -122,10 +122,10 @@ func CheckinQuery(c *gin.Context) {
userId, err := uuid.Parse(userIdOrig.(string))
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer).
SetService(exception.EventService).
SetEndpoint(exception.EventCheckinQueryEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusServer).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceCheckinQuery).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorUuidParseFailed).
Build()
utils.HttpResponse(c, 500, errorCode)
@@ -135,10 +135,10 @@ func CheckinQuery(c *gin.Context) {
eventIdOrig, ok := c.GetQuery("event_id")
if !ok {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.EventService).
SetEndpoint(exception.EventCheckinQueryEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusClient).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceCheckinQuery).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput).
Build()
utils.HttpResponse(c, 400, errorCode)
@@ -147,10 +147,10 @@ func CheckinQuery(c *gin.Context) {
eventId, err := uuid.Parse(eventIdOrig)
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.EventService).
SetEndpoint(exception.EventCheckinQueryEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusClient).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceCheckinQuery).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput).
Build()
utils.HttpResponse(c, 400, errorCode)
@@ -162,20 +162,20 @@ func CheckinQuery(c *gin.Context) {
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer).
SetService(exception.EventService).
SetEndpoint(exception.EventCheckinQueryEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusServer).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceCheckinQuery).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorDatabase).
Build()
utils.HttpResponse(c, 500, errorCode)
return
} else if attendance == nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.EventService).
SetEndpoint(exception.EventCheckinQueryEndpoint).
SetType(exception.ErrorTypeSpecific).
SetStatus(exception.StatusClient).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceCheckinQuery).
SetType(exception.TypeSpecific).
SetOriginal(exception.EventCheckinQueryRecordNotFound).
Build()
utils.HttpResponse(c, 404, errorCode)

View File

@@ -15,10 +15,10 @@ func Info(c *gin.Context) {
eventIdOrig, ok := c.GetQuery("event_id")
if !ok {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.EventService).
SetEndpoint(exception.EventInfoEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusClient).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceInfo).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput).
Build()
utils.HttpResponse(c, 400, errorCode)
@@ -29,10 +29,10 @@ func Info(c *gin.Context) {
eventId, err := uuid.Parse(eventIdOrig)
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer).
SetService(exception.EventService).
SetEndpoint(exception.EventInfoEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusServer).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceInfo).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorUuidParseFailed).
Build()
utils.HttpResponse(c, 500, errorCode)
@@ -42,10 +42,10 @@ func Info(c *gin.Context) {
event, err := eventData.GetEventById(eventId)
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.EventService).
SetEndpoint(exception.EventInfoEndpoint).
SetType(exception.ErrorTypeSpecific).
SetStatus(exception.StatusClient).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceInfo).
SetType(exception.TypeSpecific).
SetOriginal(exception.EventInfoNotFound).
Build()
utils.HttpResponse(c, 404, errorCode)