All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rexsheng.springboot.faster.system.locale.adapter.LocaleController Maven / Gradle / Ivy

The newest version!
package com.github.rexsheng.springboot.faster.system.locale.adapter;

import com.github.rexsheng.springboot.faster.common.domain.Result;
import com.github.rexsheng.springboot.faster.logging.RequestLog;
import com.github.rexsheng.springboot.faster.system.locale.application.LocaleService;
import com.github.rexsheng.springboot.faster.system.locale.application.dto.RefreshLocaleSourceRequest;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sys/locale")
@Tag(name = "LocaleController",description = "国际化管理")
@ConditionalOnProperty(prefix = "app.module.management",name = "controller",havingValue = "true",matchIfMissing = true)
@ConditionalOnClass(RedisTemplate.class)
public class LocaleController {

    @Autowired
    private LocaleService localeService;

    @PostMapping("/refresh")
    @PreAuthorize("hasAuthority(T(com.github.rexsheng.springboot.faster.common.constant.AuthCodeConstant).DICT_REFRESH)")
    @RequestLog("更新字典缓存")
    public Result refresh(){
        RefreshLocaleSourceRequest request=new RefreshLocaleSourceRequest();
        localeService.refreshLocaleSource(request);
        return Result.success();
    }

    @GetMapping
    @PreAuthorize("@ss.denyApi()")
    public Result getAll(){
        return Result.success(localeService.getActivedLocaleSource());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy