package com.red.circle.other.adapter.app.sys.properties;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 静态资源配置.
 *
 * @author pengliang on 2021/1/20
 * @eo.api-type http
 * @eo.groupName 系统服务.静态资源
 * @eo.path /sys/static-config
 */
@RestController
@RequestMapping(value = "/sys/static-config", produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class StaticConfigRestController extends BaseController {

  private final UserProfileGateway userProfileGateway;
  private final StaticResourcesProperties staticResourcesProperties;

  /**
   * 等级资源.
   *
   * @eo.name 等级资源.
   * @eo.url /level
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/level")
  public Map<String, UserLevelStyleProperties> getLevelStyle(AppExtCommand cmd) {
    userProfileGateway.removeCacheAll(cmd.requiredReqUserId());
    return staticResourcesProperties.getLevelStyle();
  }

}


