fix: harden auth flows and align api contracts

This commit is contained in:
Your Name
2026-05-30 21:29:24 +08:00
parent 7ad65a0138
commit a332917142
50 changed files with 23594 additions and 723 deletions

View File

@@ -28,7 +28,7 @@ func NewRoleHandler(roleService *service.RoleService) *RoleHandler {
// @Produce json
// @Security BearerAuth
// @Param request body service.CreateRoleRequest true "角色信息"
// @Success 201 {object} Response{data=domain.Role} "角色创建成功"
// @Success 201 {object} Response{data=SwaggerRole} "角色创建成功"
// @Failure 400 {object} Response "请求参数错误"
// @Failure 403 {object} Response "无权限"
// @Router /api/v1/roles [post]
@@ -90,7 +90,7 @@ func (h *RoleHandler) ListRoles(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "角色ID"
// @Success 200 {object} Response{data=domain.Role} "角色信息"
// @Success 200 {object} Response{data=SwaggerRole} "角色信息"
// @Failure 404 {object} Response "角色不存在"
// @Router /api/v1/roles/{id} [get]
func (h *RoleHandler) GetRole(c *gin.Context) {
@@ -122,7 +122,7 @@ func (h *RoleHandler) GetRole(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "角色ID"
// @Param request body service.UpdateRoleRequest true "更新信息"
// @Success 200 {object} Response{data=domain.Role} "更新成功"
// @Success 200 {object} Response{data=SwaggerRole} "更新成功"
// @Failure 400 {object} Response "请求参数错误"
// @Failure 403 {object} Response "无权限"
// @Failure 404 {object} Response "角色不存在"
@@ -242,7 +242,7 @@ func (h *RoleHandler) UpdateRoleStatus(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "角色ID"
// @Success 200 {object} Response{data=[]domain.Permission} "权限列表"
// @Success 200 {object} Response{data=[]SwaggerPermission} "权限列表"
// @Failure 404 {object} Response "角色不存在"
// @Router /api/v1/roles/{id}/permissions [get]
func (h *RoleHandler) GetRolePermissions(c *gin.Context) {
@@ -278,7 +278,7 @@ func (h *RoleHandler) GetRolePermissions(c *gin.Context) {
// @Failure 400 {object} Response "请求参数错误"
// @Failure 403 {object} Response "无权限"
// @Failure 404 {object} Response "角色不存在"
// @Router /api/v1/roles/{id}/permissions [post]
// @Router /api/v1/roles/{id}/permissions [put]
func (h *RoleHandler) AssignPermissions(c *gin.Context) {
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
if err != nil {