package admin_role import ( "github.com/gin-gonic/gin" "net/http" "sghgogs.com/micro/auth-client/response" "sghgogs.com/micro/auth-client/utils" pb "sghgogs.com/micro/auth-service/proto" "sghgogs.com/micro/common" "strconv" ) // DeleteAdminRole // @summary 删除 // @Description 删除角色 // @Tags Role 角色管理 // @Accept json // @Produce json // @Param Authorization header string true "Bearer 用户令牌" // @Param id path int true "角色ID" // @Success 200 {object} response.ApiResponse "成功" // @Failure 400 {object} response.ApiResponse "请求错误" // @Failure 500 {object} response.ApiResponse "内部错误" // @Router /v1/api/admin/role/{roleID} [delete] func (svc *ApiAdminRole) DeleteAdminRole(c *gin.Context) { RoleID, err := strconv.ParseInt(c.Param("roleID"), 10, 64) if err != nil || RoleID <= 0 { c.JSON(http.StatusBadRequest, response.ErrorResponse(http.StatusBadRequest, common.ErrorMessage[common.InvalidRoleID])) return } ctx, _ := utils.CreateContextWithToken(c, "authorizationservice", "AdminRoleService.DeleteAdminRole") _, err = svc.Service.DeleteAdminRole(ctx, &pb.DeleteAdminRoleRequest{ Id: RoleID, }) if err != nil { code, mgs := response.MicroErrorRequest(err) c.JSON(code, response.ErrorResponse(code, mgs)) return } c.JSON(http.StatusOK, response.SuccessResponse(nil)) }