@Id ListActionV2 @Description list user action. @Tags user @Security ApiKeyAuth @Success 200 {object} models.ListActionRespV2 @Router /v2/user/list_action [get]
(c echo.Context)
| 360 | // @Success 200 {object} models.ListActionRespV2 |
| 361 | // @Router /v2/user/list_action [get] |
| 362 | func ListActionV2(c echo.Context) error { |
| 363 | logger := handler.NewLogger().Named("ListActionV2") |
| 364 | |
| 365 | user, err := getCurrentUser(c) |
| 366 | if err != nil { |
| 367 | return c.JSON(http.StatusInternalServerError, models.BuildBaseResp(err)) |
| 368 | } |
| 369 | storeManager, err := common.NewStoreManager([]string{handler.ConsulAddr}, logger) |
| 370 | if err != nil { |
| 371 | return c.JSON(http.StatusInternalServerError, models.BuildBaseResp(fmt.Errorf("consul_addr=%v; connect to consul failed: %v", handler.ConsulAddr, err))) |
| 372 | } |
| 373 | role, exists, err := storeManager.GetRole(user.Tenant, user.Role) |
| 374 | if nil != err { |
| 375 | return c.JSON(http.StatusInternalServerError, models.BuildBaseResp(fmt.Errorf("consul_addr=%v ; get role failed: %v", handler.ConsulAddr, err))) |
| 376 | } |
| 377 | if !exists { |
| 378 | return c.JSON(http.StatusInternalServerError, models.BuildBaseResp(fmt.Errorf("current user does not belong to any role"))) |
| 379 | } |
| 380 | authority := make([]models.MenuItem, 0) |
| 381 | err = json.Unmarshal([]byte(role.Authority), &authority) |
| 382 | if nil != err { |
| 383 | return c.JSON(http.StatusInternalServerError, models.BuildBaseResp(err)) |
| 384 | } |
| 385 | return c.JSON(http.StatusOK, &models.ListActionRespV2{ |
| 386 | Authority: authority, |
| 387 | BaseResp: models.BuildBaseResp(nil), |
| 388 | }) |
| 389 | } |
| 390 | |
| 391 | func checkUserAccess(logger g.LoggerType, c echo.Context, operationUser string) (bool, error) { |
| 392 | storeManager, err := common.NewStoreManager([]string{handler.ConsulAddr}, logger) |
nothing calls this directly
no test coverage detected