Search in sources :

Example 1 with I18nDataCreateDTO

use of com.hccake.ballcat.i18n.model.dto.I18nDataCreateDTO in project ballcat by ballcat-projects.

the class I18nDataController method save.

/**
 * 新增国际化信息
 * @param i18nDataCreateDTO 国际化信息
 * @return R 通用返回体
 */
@CreateOperationLogging(msg = "新增国际化信息")
@PostMapping
@PreAuthorize("@per.hasPermission('i18n:i18n-data:add')")
@Operation(summary = "新增国际化信息", description = "新增国际化信息")
public R<Void> save(@Valid @RequestBody I18nDataCreateDTO i18nDataCreateDTO) {
    // 转换为实体类列表
    List<I18nData> list = new ArrayList<>();
    List<I18nDataCreateDTO.LanguageText> languageTexts = i18nDataCreateDTO.getLanguageTexts();
    for (I18nDataCreateDTO.LanguageText languageText : languageTexts) {
        I18nData i18nData = new I18nData();
        i18nData.setCode(i18nDataCreateDTO.getCode());
        i18nData.setRemarks(i18nDataCreateDTO.getRemarks());
        i18nData.setLanguageTag(languageText.getLanguageTag());
        i18nData.setMessage(languageText.getMessage());
        list.add(i18nData);
    }
    return i18nDataService.saveBatch(list) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "新增国际化信息失败");
}
Also used : ArrayList(java.util.ArrayList) I18nData(com.hccake.ballcat.i18n.model.entity.I18nData) I18nDataCreateDTO(com.hccake.ballcat.i18n.model.dto.I18nDataCreateDTO) CreateOperationLogging(com.hccake.ballcat.common.log.operation.annotation.CreateOperationLogging) Operation(io.swagger.v3.oas.annotations.Operation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

CreateOperationLogging (com.hccake.ballcat.common.log.operation.annotation.CreateOperationLogging)1 I18nDataCreateDTO (com.hccake.ballcat.i18n.model.dto.I18nDataCreateDTO)1 I18nData (com.hccake.ballcat.i18n.model.entity.I18nData)1 Operation (io.swagger.v3.oas.annotations.Operation)1 ArrayList (java.util.ArrayList)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1