123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package admin_user
- 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"
- )
- // DeleteAdminUser
- // @summary 删除
- // @Description 删除管理员
- // @Tags User 用户管理
- // @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/user/{userID} [delete]
- func (svc *ApiAdminUser) DeleteAdminUser(c *gin.Context) {
- UserId, err := strconv.ParseInt(c.Param("userID"), 10, 64)
- if err != nil || UserId <= 0 {
- c.JSON(http.StatusBadRequest, gin.H{"error": common.ErrorMessage[common.InvalidUserID]})
- return
- }
- ctx, _ := utils.CreateContextWithToken(c, "authorizationservice", "AdminUserService.DeleteAdminUser")
- _, err = svc.Service.DeleteAdminUser(ctx, &pb.DeleteAdminUserRequest{
- UserId: UserId,
- })
- if err != nil {
- code, mgs := response.MicroErrorRequest(err)
- c.JSON(code, response.ErrorResponse(code, mgs))
- return
- }
- c.JSON(http.StatusOK, response.SuccessResponse(nil))
- }
|