fix/status-review-sync-20260409 #1
@@ -23,7 +23,7 @@ func NewCustomFieldHandler(customFieldService *service.CustomFieldService) *Cust
|
||||
func (h *CustomFieldHandler) CreateField(c *gin.Context) {
|
||||
var req service.CreateFieldRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ func (h *CustomFieldHandler) CreateField(c *gin.Context) {
|
||||
func (h *CustomFieldHandler) UpdateField(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid field id"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": "invalid field id"})
|
||||
return
|
||||
}
|
||||
|
||||
var req service.UpdateFieldRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ func (h *CustomFieldHandler) UpdateField(c *gin.Context) {
|
||||
func (h *CustomFieldHandler) DeleteField(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid field id"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": "invalid field id"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func (h *CustomFieldHandler) DeleteField(c *gin.Context) {
|
||||
func (h *CustomFieldHandler) GetField(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid field id"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": "invalid field id"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ func (h *CustomFieldHandler) ListFields(c *gin.Context) {
|
||||
func (h *CustomFieldHandler) SetUserFieldValues(c *gin.Context) {
|
||||
userID, ok := getUserIDFromContext(c)
|
||||
if !ok {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "unauthorized"})
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"code": 401, "message": "unauthorized"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ func (h *CustomFieldHandler) SetUserFieldValues(c *gin.Context) {
|
||||
}
|
||||
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ func (h *CustomFieldHandler) SetUserFieldValues(c *gin.Context) {
|
||||
func (h *CustomFieldHandler) GetUserFieldValues(c *gin.Context) {
|
||||
userID, ok := getUserIDFromContext(c)
|
||||
if !ok {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "unauthorized"})
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"code": 401, "message": "unauthorized"})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func NewRoleHandler(roleService *service.RoleService) *RoleHandler {
|
||||
func (h *RoleHandler) CreateRole(c *gin.Context) {
|
||||
var req service.CreateRoleRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func (h *RoleHandler) CreateRole(c *gin.Context) {
|
||||
func (h *RoleHandler) ListRoles(c *gin.Context) {
|
||||
var req service.ListRoleRequest
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -54,11 +54,11 @@ func (h *RoleHandler) ListRoles(c *gin.Context) {
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": gin.H{
|
||||
"items": roles,
|
||||
"total": total,
|
||||
"total": total,
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func (h *RoleHandler) ListRoles(c *gin.Context) {
|
||||
func (h *RoleHandler) GetRole(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid role id"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": "invalid role id"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -86,13 +86,13 @@ func (h *RoleHandler) GetRole(c *gin.Context) {
|
||||
func (h *RoleHandler) UpdateRole(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid role id"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": "invalid role id"})
|
||||
return
|
||||
}
|
||||
|
||||
var req service.UpdateRoleRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ func (h *RoleHandler) UpdateRole(c *gin.Context) {
|
||||
func (h *RoleHandler) DeleteRole(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid role id"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": "invalid role id"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ func (h *RoleHandler) DeleteRole(c *gin.Context) {
|
||||
func (h *RoleHandler) UpdateRoleStatus(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid role id"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": "invalid role id"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func (h *RoleHandler) UpdateRoleStatus(c *gin.Context) {
|
||||
}
|
||||
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func (h *RoleHandler) UpdateRoleStatus(c *gin.Context) {
|
||||
case "disabled", "0":
|
||||
status = domain.RoleStatusDisabled
|
||||
default:
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid status"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": "invalid status"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ func (h *RoleHandler) UpdateRoleStatus(c *gin.Context) {
|
||||
func (h *RoleHandler) GetRolePermissions(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid role id"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": "invalid role id"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ func (h *RoleHandler) GetRolePermissions(c *gin.Context) {
|
||||
func (h *RoleHandler) AssignPermissions(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid role id"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": "invalid role id"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ func (h *RoleHandler) AssignPermissions(c *gin.Context) {
|
||||
}
|
||||
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user