2024-09-28 20:34:13 +08:00
|
|
|
package cn.bunny.services.controller;
|
|
|
|
|
2024-09-29 23:46:44 +08:00
|
|
|
import cn.bunny.dao.dto.i18n.I18nAddDto;
|
2024-09-29 16:51:50 +08:00
|
|
|
import cn.bunny.dao.dto.i18n.I18nDto;
|
2024-09-29 23:46:44 +08:00
|
|
|
import cn.bunny.dao.dto.i18n.I18nUpdateDto;
|
2024-10-01 22:23:00 +08:00
|
|
|
import cn.bunny.dao.entity.i18n.I18n;
|
2024-09-29 16:51:50 +08:00
|
|
|
import cn.bunny.dao.pojo.result.PageResult;
|
|
|
|
import cn.bunny.dao.pojo.result.Result;
|
|
|
|
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
|
|
|
import cn.bunny.dao.vo.i18n.I18nVo;
|
|
|
|
import cn.bunny.services.service.I18nService;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import jakarta.validation.Valid;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2024-09-28 20:34:13 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* <p>
|
2024-10-16 16:57:03 +08:00
|
|
|
* 多语言 前端控制器
|
2024-09-28 20:34:13 +08:00
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @author Bunny
|
|
|
|
* @since 2024-09-28
|
|
|
|
*/
|
2024-09-29 16:51:50 +08:00
|
|
|
@Tag(name = "多语言", description = "多语言相关接口")
|
2024-09-28 20:34:13 +08:00
|
|
|
@RestController
|
2024-09-29 16:51:50 +08:00
|
|
|
@RequestMapping("admin/i18n")
|
2024-09-28 20:34:13 +08:00
|
|
|
public class I18nController {
|
|
|
|
|
2024-09-29 16:51:50 +08:00
|
|
|
@Autowired
|
|
|
|
private I18nService i18nService;
|
|
|
|
|
|
|
|
@Operation(summary = "获取多语言内容", description = "获取多语言内容")
|
|
|
|
@GetMapping("getI18n")
|
2024-09-29 23:46:44 +08:00
|
|
|
public Mono<Result<Map<String, Object>>> getI18n() {
|
|
|
|
Map<String, Object> vo = i18nService.getI18n();
|
2024-09-29 16:51:50 +08:00
|
|
|
return Mono.just(Result.success(vo));
|
|
|
|
}
|
|
|
|
|
2024-10-16 16:57:03 +08:00
|
|
|
@Operation(summary = "获取管理多语言列", description = "获取管理多语言列")
|
2024-09-29 16:51:50 +08:00
|
|
|
@GetMapping("getI18nList/{page}/{limit}")
|
|
|
|
public Mono<Result<PageResult<I18nVo>>> getI18nList(
|
|
|
|
@Parameter(name = "page", description = "当前页", required = true)
|
|
|
|
@PathVariable("page") Integer page,
|
|
|
|
@Parameter(name = "limit", description = "每页记录数", required = true)
|
|
|
|
@PathVariable("limit") Integer limit,
|
|
|
|
I18nDto dto) {
|
2024-10-01 22:23:00 +08:00
|
|
|
Page<I18n> pageParams = new Page<>(page, limit);
|
2024-09-29 16:51:50 +08:00
|
|
|
PageResult<I18nVo> vo = i18nService.getI18nList(pageParams, dto);
|
|
|
|
return Mono.just(Result.success(vo));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Operation(summary = "添加多语言", description = "添加多语言")
|
|
|
|
@PostMapping("addI18n")
|
2024-09-29 23:46:44 +08:00
|
|
|
public Mono<Result<String>> addI18n(@Valid @RequestBody I18nAddDto dto) {
|
2024-09-29 16:51:50 +08:00
|
|
|
i18nService.addI18n(dto);
|
|
|
|
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Operation(summary = "更新多语言", description = "更新多语言")
|
2024-09-29 23:46:44 +08:00
|
|
|
@PutMapping("updateI18n")
|
|
|
|
public Mono<Result<String>> updateI18n(@Valid @RequestBody I18nUpdateDto dto) {
|
2024-09-29 16:51:50 +08:00
|
|
|
i18nService.updateI18n(dto);
|
|
|
|
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
|
|
|
}
|
|
|
|
|
2024-10-10 10:32:38 +08:00
|
|
|
@Operation(summary = "删除多语言", description = "删除多语言")
|
2024-09-29 23:46:44 +08:00
|
|
|
@DeleteMapping("deleteI18n")
|
2024-09-29 16:51:50 +08:00
|
|
|
public Mono<Result<String>> deleteI18n(@RequestBody List<Long> ids) {
|
|
|
|
i18nService.deleteI18n(ids);
|
|
|
|
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
|
|
|
}
|
2024-09-28 20:34:13 +08:00
|
|
|
}
|