feat(service): 添加键盘人设国际化配置
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.yolo.keyboard.controller.admin.character;
|
||||
|
||||
import com.yolo.keyboard.dal.dataobject.character.CharacterI18nDO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -100,5 +101,56 @@ public class KeyboardCharacterController {
|
||||
ExcelUtils.write(response, "键盘人设.xls", "数据", KeyboardCharacterRespVO.class,
|
||||
BeanUtils.toBean(list, KeyboardCharacterRespVO.class));
|
||||
}
|
||||
// ==================== 子表(键盘人设国际化内容) ====================
|
||||
|
||||
@GetMapping("/character-i18n/page")
|
||||
@Operation(summary = "获得键盘人设国际化内容分页")
|
||||
@Parameter(name = "characterId", description = "角色主表id")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:character:query')")
|
||||
public CommonResult<PageResult<CharacterI18nDO>> getCharacterI18nPage(PageParam pageReqVO,
|
||||
@RequestParam("characterId") Long characterId) {
|
||||
return success(characterService.getCharacterI18nPage(pageReqVO, characterId));
|
||||
}
|
||||
|
||||
@PostMapping("/character-i18n/create")
|
||||
@Operation(summary = "创建键盘人设国际化内容")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:character:create')")
|
||||
public CommonResult<Long> createCharacterI18n(@Valid @RequestBody CharacterI18nDO characterI18n) {
|
||||
return success(characterService.createCharacterI18n(characterI18n));
|
||||
}
|
||||
|
||||
@PutMapping("/character-i18n/update")
|
||||
@Operation(summary = "更新键盘人设国际化内容")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:character:update')")
|
||||
public CommonResult<Boolean> updateCharacterI18n(@Valid @RequestBody CharacterI18nDO characterI18n) {
|
||||
characterService.updateCharacterI18n(characterI18n);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/character-i18n/delete")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@Operation(summary = "删除键盘人设国际化内容")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:character:delete')")
|
||||
public CommonResult<Boolean> deleteCharacterI18n(@RequestParam("id") Long id) {
|
||||
characterService.deleteCharacterI18n(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/character-i18n/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除键盘人设国际化内容")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:character:delete')")
|
||||
public CommonResult<Boolean> deleteCharacterI18nList(@RequestParam("ids") List<Long> ids) {
|
||||
characterService.deleteCharacterI18nListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/character-i18n/get")
|
||||
@Operation(summary = "获得键盘人设国际化内容")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:character:query')")
|
||||
public CommonResult<CharacterI18nDO> getCharacterI18n(@RequestParam("id") Long id) {
|
||||
return success(characterService.getCharacterI18n(id));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,12 +13,6 @@ import static com.yolo.keyboard.framework.common.util.date.DateUtils.FORMAT_YEAR
|
||||
@Data
|
||||
public class KeyboardCharacterPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "标题", example = "王五")
|
||||
private String characterName;
|
||||
|
||||
@Schema(description = "背景描述")
|
||||
private String characterBackground;
|
||||
|
||||
@Schema(description = "角色头像", example = "https://www.iocoder.cn")
|
||||
private String avatarUrl;
|
||||
|
||||
|
||||
@@ -16,14 +16,6 @@ public class KeyboardCharacterRespVO {
|
||||
@ExcelProperty("主键 Id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "标题", example = "王五")
|
||||
@ExcelProperty("标题")
|
||||
private String characterName;
|
||||
|
||||
@Schema(description = "背景描述")
|
||||
@ExcelProperty("背景描述")
|
||||
private String characterBackground;
|
||||
|
||||
@Schema(description = "角色头像", example = "https://www.iocoder.cn")
|
||||
@ExcelProperty("角色头像")
|
||||
private String avatarUrl;
|
||||
|
||||
@@ -14,12 +14,6 @@ public class KeyboardCharacterSaveReqVO {
|
||||
@Schema(description = "主键 Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "7592")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "标题", example = "王五")
|
||||
private String characterName;
|
||||
|
||||
@Schema(description = "背景描述")
|
||||
private String characterBackground;
|
||||
|
||||
@Schema(description = "角色头像", example = "https://www.iocoder.cn")
|
||||
private String avatarUrl;
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.yolo.keyboard.dal.dataobject.character;
|
||||
|
||||
import com.yolo.keyboard.framework.tenant.core.aop.TenantIgnore;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.yolo.keyboard.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 键盘人设国际化内容 DO
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@TableName("keyboard_character_i18n")
|
||||
@KeySequence("keyboard_character_i18n_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TenantIgnore
|
||||
public class CharacterI18nDO {
|
||||
|
||||
/**
|
||||
* 主键 Id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 角色主表id
|
||||
*/
|
||||
private Long characterId;
|
||||
/**
|
||||
* 语言标识,如 zh-CN/en-US/ja-JP
|
||||
*/
|
||||
private String locale;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String characterName;
|
||||
/**
|
||||
* 背景描述
|
||||
*/
|
||||
private String characterBackground;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createdAt;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
}
|
||||
@@ -28,14 +28,6 @@ public class KeyboardCharacterDO {
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String characterName;
|
||||
/**
|
||||
* 背景描述
|
||||
*/
|
||||
private String characterBackground;
|
||||
/**
|
||||
* 角色头像
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.yolo.keyboard.dal.mysql.character;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.yolo.keyboard.dal.dataobject.character.CharacterI18nDO;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageParam;
|
||||
import com.yolo.keyboard.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.yolo.keyboard.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 键盘人设国际化内容 Mapper
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@Mapper
|
||||
public interface CharacterI18nMapper extends BaseMapperX<CharacterI18nDO> {
|
||||
|
||||
default PageResult<CharacterI18nDO> selectPage(PageParam reqVO, Long characterId) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CharacterI18nDO>()
|
||||
.eq(CharacterI18nDO::getCharacterId, characterId)
|
||||
.orderByDesc(CharacterI18nDO::getId));
|
||||
}
|
||||
|
||||
default int deleteByCharacterId(Long characterId) {
|
||||
return delete(CharacterI18nDO::getCharacterId, characterId);
|
||||
}
|
||||
|
||||
default int deleteByCharacterIds(List<Long> characterIds) {
|
||||
return deleteBatch(CharacterI18nDO::getCharacterId, characterIds);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,8 +19,6 @@ public interface KeyboardCharacterMapper extends BaseMapperX<KeyboardCharacterDO
|
||||
|
||||
default PageResult<KeyboardCharacterDO> selectPage(KeyboardCharacterPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<KeyboardCharacterDO>()
|
||||
.likeIfPresent(KeyboardCharacterDO::getCharacterName, reqVO.getCharacterName())
|
||||
.eqIfPresent(KeyboardCharacterDO::getCharacterBackground, reqVO.getCharacterBackground())
|
||||
.eqIfPresent(KeyboardCharacterDO::getAvatarUrl, reqVO.getAvatarUrl())
|
||||
.eqIfPresent(KeyboardCharacterDO::getDownload, reqVO.getDownload())
|
||||
.eqIfPresent(KeyboardCharacterDO::getTag, reqVO.getTag())
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.yolo.keyboard.service.character;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.yolo.keyboard.dal.dataobject.character.CharacterI18nDO;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageParam;
|
||||
import jakarta.validation.*;
|
||||
import com.yolo.keyboard.controller.admin.character.vo.*;
|
||||
import com.yolo.keyboard.dal.dataobject.character.KeyboardCharacterDO;
|
||||
@@ -57,5 +60,51 @@ public interface KeyboardCharacterService {
|
||||
* @return 键盘人设分页
|
||||
*/
|
||||
PageResult<KeyboardCharacterDO> getCharacterPage(KeyboardCharacterPageReqVO pageReqVO);
|
||||
// ==================== 子表(键盘人设国际化内容) ====================
|
||||
|
||||
/**
|
||||
* 获得键盘人设国际化内容分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param characterId 角色主表id
|
||||
* @return 键盘人设国际化内容分页
|
||||
*/
|
||||
PageResult<CharacterI18nDO> getCharacterI18nPage(PageParam pageReqVO, Long characterId);
|
||||
|
||||
/**
|
||||
* 创建键盘人设国际化内容
|
||||
*
|
||||
* @param characterI18n 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createCharacterI18n(@Valid CharacterI18nDO characterI18n);
|
||||
|
||||
/**
|
||||
* 更新键盘人设国际化内容
|
||||
*
|
||||
* @param characterI18n 更新信息
|
||||
*/
|
||||
void updateCharacterI18n(@Valid CharacterI18nDO characterI18n);
|
||||
|
||||
/**
|
||||
* 删除键盘人设国际化内容
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteCharacterI18n(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除键盘人设国际化内容
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteCharacterI18nListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得键盘人设国际化内容
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 键盘人设国际化内容
|
||||
*/
|
||||
CharacterI18nDO getCharacterI18n(Long id);
|
||||
}
|
||||
@@ -4,7 +4,10 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.yolo.keyboard.controller.admin.character.vo.*;
|
||||
import com.yolo.keyboard.dal.dataobject.character.CharacterI18nDO;
|
||||
import com.yolo.keyboard.dal.dataobject.character.KeyboardCharacterDO;
|
||||
import com.yolo.keyboard.dal.mysql.character.CharacterI18nMapper;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageParam;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||
import com.yolo.keyboard.framework.common.util.object.BeanUtils;
|
||||
import com.yolo.keyboard.dal.mysql.character.KeyboardCharacterMapper;
|
||||
@@ -14,6 +17,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import static com.yolo.keyboard.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.yolo.keyboard.module.infra.enums.ErrorCodeConstants.CHARACTER_I18N_NOT_EXISTS;
|
||||
import static com.yolo.keyboard.module.infra.enums.ErrorCodeConstants.CHARACTER_NOT_EXISTS;
|
||||
|
||||
|
||||
@@ -29,6 +33,9 @@ public class KeyboardCharacterServiceImpl implements KeyboardCharacterService {
|
||||
private static final String CHARACTER_CACHE_KEY_PREFIX = "character:";
|
||||
private static final long CHARACTER_CACHE_TTL_MINUTES = 5L;
|
||||
|
||||
@Resource
|
||||
private CharacterI18nMapper characterI18nMapper;
|
||||
|
||||
@Resource
|
||||
private KeyboardCharacterMapper characterMapper;
|
||||
|
||||
@@ -80,6 +87,59 @@ public class KeyboardCharacterServiceImpl implements KeyboardCharacterService {
|
||||
deleteCharacterCaches(ids);
|
||||
}
|
||||
|
||||
// ==================== 子表(键盘人设国际化内容) ====================
|
||||
|
||||
@Override
|
||||
public PageResult<CharacterI18nDO> getCharacterI18nPage(PageParam pageReqVO, Long characterId) {
|
||||
return characterI18nMapper.selectPage(pageReqVO, characterId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createCharacterI18n(CharacterI18nDO characterI18n) {
|
||||
characterI18nMapper.insert(characterI18n);
|
||||
return characterI18n.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCharacterI18n(CharacterI18nDO characterI18n) {
|
||||
// 校验存在
|
||||
validateCharacterI18nExists(characterI18n.getId());
|
||||
// 更新
|
||||
characterI18nMapper.updateById(characterI18n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCharacterI18n(Long id) {
|
||||
// 删除
|
||||
characterI18nMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCharacterI18nListByIds(List<Long> ids) {
|
||||
// 删除
|
||||
characterI18nMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharacterI18nDO getCharacterI18n(Long id) {
|
||||
return characterI18nMapper.selectById(id);
|
||||
}
|
||||
|
||||
private void validateCharacterI18nExists(Long id) {
|
||||
if (characterI18nMapper.selectById(id) == null) {
|
||||
throw exception(CHARACTER_I18N_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteCharacterI18nByCharacterId(Long characterId) {
|
||||
characterI18nMapper.deleteByCharacterId(characterId);
|
||||
}
|
||||
|
||||
private void deleteCharacterI18nByCharacterIds(List<Long> characterIds) {
|
||||
characterI18nMapper.deleteByCharacterIds(characterIds);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void validateCharacterExists(Long id) {
|
||||
if (characterMapper.selectById(id) == null) {
|
||||
|
||||
Reference in New Issue
Block a user