feat(新增): 多语言类型CURD,多语言CURD待完成

This commit is contained in:
bunny 2024-09-29 16:51:50 +08:00
parent ddb98b922b
commit 0472efb607
42 changed files with 780 additions and 62 deletions

View File

@ -1,4 +1,4 @@
package cn.bunny.dto.email;
package cn.bunny.dao.dto.email;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;

View File

@ -1,4 +1,4 @@
package cn.bunny.dto.email;
package cn.bunny.dao.dto.email;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;

View File

@ -0,0 +1,22 @@
package cn.bunny.dao.dto.i18n;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "I18nDto对象", title = "多语言分页查询", description = "多语言分页查询")
public class I18nDto {
@Schema(name = "keyName", title = "多语言key")
private Integer keyName;
@Schema(name = "translation", title = "多语言翻译名称")
private String translation;
}

View File

@ -0,0 +1,29 @@
package cn.bunny.dao.dto.i18n;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "I18nTypeAddDto对象", title = "多语言类型添加", description = "多语言类型添加内容")
public class I18nTypeAddDto {
@Schema(name = "typeName", title = "多语言类型(比如zh,en)")
@NotBlank(message = "多语言类型不能为空")
private String typeName;
@Schema(name = "summary", title = "名称解释(比如中文,英文)")
@NotBlank(message = "名称解释不能为空")
private String summary;
@Schema(name = "isDefault", title = "是否为默认")
private Boolean isDefault = false;
}

View File

@ -0,0 +1,32 @@
package cn.bunny.dao.dto.i18n;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "I18nTypeUpdateDto对象", title = "多语言类型更新", description = "多语言类型更新内容")
public class I18nTypeUpdateDto {
@Schema(name = "id", title = "主键")
@NotBlank(message = "id不能为空")
private Long id;
@Schema(name = "typeName", title = "多语言类型(比如zh,en)")
@NotBlank(message = "多语言类型不能为空")
private String typeName;
@Schema(name = "summary", title = "名称解释(比如中文,英文)")
@NotBlank(message = "名称解释不能为空")
private String summary;
@Schema(name = "isDefault", title = "是否为默认")
private Boolean isDefault = false;
}

View File

@ -0,0 +1,19 @@
package cn.bunny.dao.dto.menuIcon;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "MenuIconDto对象", title = "系统菜单图标分页查询对象", description = "系统菜单图标分页查询对象")
public class MenuIconDto {
@Schema(name = "iconName", title = "icon 名称")
private String iconName;
}

View File

@ -2,8 +2,7 @@ package cn.bunny.dao.entity.i18n;
import cn.bunny.dao.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@ -20,16 +19,16 @@ import lombok.experimental.Accessors;
@Setter
@Accessors(chain = true)
@TableName("sys_i18n")
@ApiModel(value = "I18n对象", description = "多语言表")
@Schema(name = "I18n对象", title = "多语言表", description = "多语言表")
public class I18n extends BaseEntity {
@ApiModelProperty("多语言key")
private Integer keyName;
@Schema(name = "keyName", title = "多语言key")
private String keyName;
@ApiModelProperty("多语言翻译名称")
@Schema(name = "translation", title = "多语言翻译名称")
private String translation;
@ApiModelProperty("多语言类型id")
@Schema(name = "typeId", title = "多语言类型id")
private Long typeId;
}

View File

@ -2,8 +2,7 @@ package cn.bunny.dao.entity.i18n;
import cn.bunny.dao.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@ -20,13 +19,16 @@ import lombok.experimental.Accessors;
@Setter
@Accessors(chain = true)
@TableName("sys_i18n_type")
@ApiModel(value = "I18nType对象", description = "多语言类型表")
@Schema(name = "I18nType对象", title = "多语言类型表", description = "多语言类型表")
public class I18nType extends BaseEntity {
@ApiModelProperty("多语言类型(比如zh,en)")
@Schema(name = "typeName", title = "多语言类型(比如zh,en)")
private String typeName;
@ApiModelProperty("名称解释(比如中文,英文)")
@Schema(name = "summary", title = "名称解释(比如中文,英文)")
private String summary;
@Schema(name = "isDefault", title = "是否为默认")
private Boolean isDefault;
}

View File

@ -0,0 +1,29 @@
package cn.bunny.dao.entity.i18n;
import cn.bunny.dao.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter
@Setter
@Accessors(chain = true)
@TableName("sys_i18n")
@Schema(name = "I18nWithI18nType对象", title = "多语言和多语言类型", description = "多语言和多语言类型内容")
public class I18nWithI18nType extends BaseEntity {
@Schema(name = "keyName", title = "多语言key")
private String keyName;
@Schema(name = "translation", title = "多语言翻译名称")
private String translation;
@Schema(name = "typeName", title = "多语言类型(比如zh,en)")
private String typeName;
@Schema(name = "summary", title = "名称解释(比如中文,英文)")
private String summary;
}

View File

@ -21,6 +21,7 @@ import lombok.experimental.Accessors;
@TableName("sys_email_template")
@Schema(name = "EmailTemplate对象", title = "邮件模板表", description = "邮件模板表")
public class EmailTemplate extends BaseEntity {
@Schema(name = "templateName", title = "模板名称")
private String templateName;
@ -35,4 +36,5 @@ public class EmailTemplate extends BaseEntity {
@Schema(name = "isDefault", title = "是否默认")
private Boolean isDefault;
}

View File

@ -13,6 +13,7 @@ import lombok.experimental.Accessors;
@TableName("sys_menu_icon")
@Schema(name = "MenuIcon对象", title = "系统菜单图标", description = "系统菜单图标")
public class MenuIcon extends BaseEntity {
@Schema(name = "iconName", title = "icon 名称")
private String iconName;

View File

@ -12,16 +12,18 @@ import lombok.Setter;
@TableName("sys_power")
@Schema(name = "Power对象", title = "权限", description = "权限")
public class Power extends BaseEntity {
@Schema(name = "parentId", title = "父级id")
private Long parentId;
@ApiModelProperty("权限编码")
@Schema(name = "parentId", title = "权限编码")
private String powerCode;
@ApiModelProperty("权限名称")
@Schema(name = "powerName", title = "权限名称")
private String powerName;
@ApiModelProperty("请求路径")
@Schema(name = "requestUrl", title = "请求路径")
private String requestUrl;
}

View File

@ -13,6 +13,7 @@ import lombok.experimental.Accessors;
@TableName("sys_role")
@Schema(name = "Role对象", title = "角色", description = "角色")
public class Role extends BaseEntity {
@Schema(name = "roleCode", title = "角色代码")
private String roleCode;

View File

@ -15,6 +15,7 @@ import lombok.experimental.Accessors;
@TableName("sys_role_power")
@Schema(name = "RolePower对象", title = "角色权限关系", description = "角色权限关系")
public class RolePower extends BaseEntity {
@Schema(name = "roleId", title = "角色id")
private String roleId;

View File

@ -2,8 +2,8 @@ package cn.bunny.dao.entity.system;
import cn.bunny.dao.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@ -20,55 +20,56 @@ import lombok.experimental.Accessors;
@Setter
@Accessors(chain = true)
@TableName("sys_router")
@ApiModel(value = "Router对象", description = "系统菜单表")
@Schema(name = "Router对象", title = "系统菜单表", description = "系统菜单表")
public class Router extends BaseEntity {
@ApiModelProperty("父级id")
@Schema(name = "parentId", title = "父级id")
private Long parentId;
@ApiModelProperty("在项目中路径")
@Schema(name = "path", title = "在项目中路径")
private String path;
@ApiModelProperty("组件位置")
@Schema(name = "component", title = "组件位置")
private String component;
@ApiModelProperty("frame路径")
@Schema(name = "frameSrc", title = "frame路径")
private String frameSrc;
@ApiModelProperty("重定向")
@Schema(name = "redirect", title = "重定向")
private String redirect;
@ApiModelProperty("路由名称")
@Schema(name = "routeName", title = "路由名称")
private String routeName;
@ApiModelProperty("路由title")
@Schema(name = "title", title = "路由title")
private String title;
@ApiModelProperty("菜单类型")
@Schema(name = "menuType", title = "菜单类型")
private Integer menuType;
@ApiModelProperty("图标")
@Schema(name = "icon", title = "图标")
private String icon;
@ApiModelProperty("进入动画")
@Schema(name = "enterTransition", title = "进入动画")
private String enterTransition;
@ApiModelProperty("退出动画")
@Schema(name = "leaveTransition", title = "退出动画")
private String leaveTransition;
@ApiModelProperty("等级")
@Schema(name = "routerRank", title = "等级")
private Integer routerRank;
@ApiModelProperty("是否隐藏标签")
@Schema(name = "hiddenTag", title = "是否隐藏标签")
private Boolean hiddenTag;
@ApiModelProperty("是否固定标签")
@Schema(name = "fixedTag", title = "是否固定标签")
private Boolean fixedTag;
@ApiModelProperty("是否显示父级")
@Schema(name = "showParent", title = "是否显示父级")
private Boolean showParent;
@ApiModelProperty("是否显示 返给前端为 showLink")
@Schema(name = "visible", title = "是否显示 返给前端为 showLink")
private Boolean visible;
}

View File

@ -13,6 +13,7 @@ import lombok.experimental.Accessors;
@TableName("sys_router_power")
@Schema(name = "RouterPower对象", title = "路由和权限关系表", description = "路由和权限关系表")
public class RouterPower extends BaseEntity {
@Schema(name = "routerId", title = "路由ID")
private Long routerId;

View File

@ -13,6 +13,7 @@ import lombok.experimental.Accessors;
@TableName("sys_router_role")
@Schema(name = "RouterRole对象", title = "路由角色关系", description = "路由角色关系")
public class RouterRole extends BaseEntity {
@Schema(name = "routerId", title = "路由ID")
private Long routerId;

View File

@ -2,8 +2,7 @@ package cn.bunny.dao.entity.system;
import cn.bunny.dao.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@ -20,37 +19,37 @@ import lombok.experimental.Accessors;
@Setter
@Accessors(chain = true)
@TableName("system_log")
@ApiModel(value = "SystemLog对象", description = "系统日志表")
@Schema(name = "SystemLog对象", title = "系统日志表", description = "系统日志表")
public class SystemLog extends BaseEntity {
@ApiModelProperty("所在类路径")
@Schema(name = "classPath", title = "所在类路径")
private String classPath;
@ApiModelProperty("执行方法名称")
@Schema(name = "methodName", title = "执行方法名称")
private String methodName;
@ApiModelProperty("入参内容")
@Schema(name = "args", title = "入参内容")
private String args;
@ApiModelProperty("返回参数")
@Schema(name = "result", title = "返回参数")
private String result;
@ApiModelProperty("报错堆栈")
@Schema(name = "errorStack", title = "报错堆栈")
private String errorStack;
@ApiModelProperty("报错")
@Schema(name = "errorMessage", title = "报错")
private String errorMessage;
@ApiModelProperty("邮箱")
@Schema(name = "email", title = "邮箱")
private String email;
@ApiModelProperty("用户名")
@Schema(name = "nickname", title = "用户名")
private String nickname;
@ApiModelProperty("当前用户token")
@Schema(name = "token", title = "当前用户token")
private String token;
@ApiModelProperty("当前用户IP地址")
@Schema(name = "ipAddress", title = "当前用户IP地址")
private String ipAddress;
}

View File

@ -13,9 +13,11 @@ import lombok.experimental.Accessors;
@TableName("sys_user_role")
@Schema(name = "UserRole对象", title = "用户角色关系", description = "用户角色关系")
public class UserRole extends BaseEntity {
@Schema(name = "userId", title = "用户id")
private String userId;
@Schema(name = "roleId", title = "角色id")
private String roleId;
}

View File

@ -1,5 +1,6 @@
package cn.bunny.dao.pojo.result;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -15,13 +16,19 @@ import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "PageResult 对象", title = "分页返回结果", description = "分页返回结果")
public class PageResult<T> implements Serializable {
// 当前页
@Schema(name = "pageNo", title = "当前页")
private Long pageNo;
// 每页记录数
@Schema(name = "pageSize", title = "每页记录数")
private Long pageSize;
// 总记录数
@Schema(name = "total", title = "总记录数")
private Long total;
// 当前页数据集合
@Schema(name = "list", title = "当前页数据集合")
private List<T> list;
}

View File

@ -0,0 +1,26 @@
package cn.bunny.dao.vo.i18n;
import cn.bunny.dao.vo.BaseVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "I18nVo对象", title = "多语言返回内容", description = "多语言返回内容")
public class I18nTypeVo extends BaseVo {
@Schema(name = "typeName", title = "多语言类型(比如zh,en)")
private String typeName;
@Schema(name = "summary", title = "名称解释(比如中文,英文)")
private String summary;
@Schema(name = "isDefault", title = "是否为默认")
private Boolean isDefault;
}

View File

@ -0,0 +1,27 @@
package cn.bunny.dao.vo.i18n;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "I18nVo对象", title = "多语言返回内容", description = "多语言返回内容")
public class I18nVo {
@Schema(name = "keyName", title = "多语言key")
private Integer keyName;
@Schema(name = "translation", title = "多语言翻译名称")
private String translation;
@Schema(name = "typeId", title = "多语言类型id")
private Long typeId;
}

View File

@ -0,0 +1,18 @@
package cn.bunny.dao.vo.menuIcon;
import cn.bunny.dao.vo.BaseVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "RouterControllerVo对象", title = "路由管理端返回对象", description = "路由管理端返回对象")
public class MenuIconVo extends BaseVo {
@Schema(name = "iconName", title = "icon 名称")
private String iconName;
}

View File

@ -1,7 +1,23 @@
package cn.bunny.services.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.bunny.dao.dto.i18n.I18nDto;
import cn.bunny.dao.entity.system.MenuIcon;
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;
/**
* <p>
@ -11,8 +27,52 @@ import org.springframework.web.bind.annotation.RestController;
* @author Bunny
* @since 2024-09-28
*/
@Tag(name = "多语言", description = "多语言相关接口")
@RestController
@RequestMapping("/i18n")
@RequestMapping("admin/i18n")
public class I18nController {
@Autowired
private I18nService i18nService;
@Operation(summary = "获取多语言内容", description = "获取多语言内容")
@GetMapping("getI18n")
public Mono<Result<Map<String, Map<String, String>>>> getI18n() {
Map<String, Map<String, String>> vo = i18nService.getI18n();
return Mono.just(Result.success(vo));
}
@Operation(summary = "获取管理多语言列表", description = "获取管理多语言列表")
@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) {
Page<MenuIcon> pageParams = new Page<>(page, limit);
PageResult<I18nVo> vo = i18nService.getI18nList(pageParams, dto);
return Mono.just(Result.success(vo));
}
@Operation(summary = "添加多语言", description = "添加多语言")
@PostMapping("addI18n")
public Mono<Result<String>> addI18n(@Valid @RequestBody I18nDto dto) {
i18nService.addI18n(dto);
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
}
@Operation(summary = "更新多语言", description = "更新多语言")
@PostMapping("updateI18n")
public Mono<Result<String>> updateI18n(@Valid @RequestBody I18nDto dto) {
i18nService.updateI18n(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}
@Operation(summary = "删除多语言类型", description = "删除多语言类型")
@PostMapping("deleteI18n")
public Mono<Result<String>> deleteI18n(@RequestBody List<Long> ids) {
i18nService.deleteI18n(ids);
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
}
}

View File

@ -1,7 +1,18 @@
package cn.bunny.services.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.bunny.dao.dto.i18n.I18nTypeAddDto;
import cn.bunny.dao.dto.i18n.I18nTypeUpdateDto;
import cn.bunny.dao.pojo.result.Result;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.dao.vo.i18n.I18nTypeVo;
import cn.bunny.services.service.I18nTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;
import java.util.List;
/**
* <p>
@ -11,8 +22,39 @@ import org.springframework.web.bind.annotation.RestController;
* @author Bunny
* @since 2024-09-28
*/
@Tag(name = "多语言类型", description = "多语言类型相关接口")
@RestController
@RequestMapping("/i18nType")
@RequestMapping("admin/i18nType")
public class I18nTypeController {
@Autowired
private I18nTypeService i18nTypeService;
@Operation(summary = "获取多语言类型", description = "获取多语言类型")
@GetMapping("getI18nTypeList")
public Mono<Result<List<I18nTypeVo>>> getI18nTypeList() {
List<I18nTypeVo> voList = i18nTypeService.getI18nTypeList();
return Mono.just(Result.success(voList));
}
@Operation(summary = "添加多语言类型", description = "添加多语言类型")
@PostMapping("addI18nType")
public Mono<Result<String>> addI18nType(@RequestBody I18nTypeAddDto dto) {
i18nTypeService.addI18nType(dto);
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
}
@Operation(summary = "更新多语言类型", description = "更新多语言类型")
@PostMapping("updateI18nType")
public Mono<Result<String>> updateI18nType(@RequestBody I18nTypeUpdateDto dto) {
i18nTypeService.updateI18nType(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}
@Operation(summary = "删除多语言类型", description = "删除多语言类型")
@PostMapping("deleteI18nType")
public Mono<Result<String>> deleteI18nType(@RequestBody List<Long> ids) {
i18nTypeService.deleteI18nType(ids);
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
}
}

View File

@ -1,8 +1,21 @@
package cn.bunny.services.controller;
import cn.bunny.dao.dto.menuIcon.MenuIconDto;
import cn.bunny.dao.entity.system.MenuIcon;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.Result;
import cn.bunny.dao.vo.menuIcon.MenuIconVo;
import cn.bunny.services.service.MenuIconService;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
/**
* <p>
@ -14,7 +27,22 @@ import org.springframework.web.bind.annotation.RestController;
*/
@Tag(name = "菜单Icon", description = "菜单Icon相关接口")
@RestController
@RequestMapping("/menuIcon")
@RequestMapping("admin/menuIcon")
public class MenuIconController {
@Autowired
private MenuIconService menuIconService;
@Operation(summary = "获取菜单Icon", description = "获取菜单Icon")
@GetMapping("getMenuIconList/{page}/{limit}")
public Mono<Result<PageResult<MenuIconVo>>> getMenuIconList(
@Parameter(name = "page", description = "当前页", required = true)
@PathVariable("page") Integer page,
@Parameter(name = "limit", description = "每页记录数", required = true)
@PathVariable("limit") Integer limit,
MenuIconDto dto) {
Page<MenuIcon> pageParams = new Page<>(page, limit);
PageResult<MenuIconVo> pageResult = menuIconService.getMenuIconList(pageParams, dto);
return Mono.just(Result.success(pageResult));
}
}

View File

@ -1,8 +1,16 @@
package cn.bunny.services.mapper;
import cn.bunny.dao.dto.i18n.I18nDto;
import cn.bunny.dao.entity.i18n.I18n;
import cn.bunny.dao.entity.i18n.I18nWithI18nType;
import cn.bunny.dao.entity.system.MenuIcon;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
@ -15,4 +23,19 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface I18nMapper extends BaseMapper<I18n> {
/**
* * 多语言和多语言类型
*
* @return 多语言和多语言类型列表
*/
List<I18nWithI18nType> selectListWithI18nType();
/**
* * 分页查询多语言内容
*
* @param pageParams 分页想去
* @param dto 路由查询表单
* @return 分页结果
*/
IPage<I18n> selectListByPage(@Param("page") Page<MenuIcon> pageParams, @Param("dto") I18nDto dto);
}

View File

@ -4,6 +4,8 @@ import cn.bunny.dao.entity.i18n.I18nType;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* <p>
* 多语言类型表 Mapper 接口
@ -15,4 +17,10 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface I18nTypeMapper extends BaseMapper<I18nType> {
/**
* 物理删除多语言类型
*
* @param ids 删除 id 列表
*/
void deleteBatchIdsWithPhysics(List<Long> ids);
}

View File

@ -1,8 +1,12 @@
package cn.bunny.services.mapper;
import cn.bunny.dao.dto.menuIcon.MenuIconDto;
import cn.bunny.dao.entity.system.MenuIcon;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* <p>
@ -15,4 +19,12 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MenuIconMapper extends BaseMapper<MenuIcon> {
/**
* 分页查询菜单图标
*
* @param pageParams 分页查询结果
* @param dto 系统菜单图标分页查询对象
* @return 分页查询结果返回内容
*/
IPage<MenuIcon> selectListByPage(@Param("page") Page<MenuIcon> pageParams, @Param("dto") MenuIconDto dto);
}

View File

@ -52,5 +52,5 @@ public interface RouterMapper extends BaseMapper<Router> {
*
* @param ids 删除id列表
*/
void deletedMenuByIds(List<Long> ids);
void deleteBatchIdsWithPhysics(List<Long> ids);
}

View File

@ -94,7 +94,7 @@ public class WebSecurityConfig {
String[] annotations = {
"/", "/ws/**",
"/*/*/noAuth/**", "/*/noAuth/**", "/noAuth/**",
"/media.ico", "/favicon.ico", "*.html",
"/media.ico", "/favicon.ico", "*.html", "/webjars/**",
"/swagger-resources/**", "/v3/**", "/swagger-ui/**"
};
return web -> web.ignoring().requestMatchers(annotations);

View File

@ -1,8 +1,16 @@
package cn.bunny.services.service;
import cn.bunny.dao.dto.i18n.I18nDto;
import cn.bunny.dao.entity.i18n.I18n;
import cn.bunny.dao.entity.system.MenuIcon;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.i18n.I18nVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* <p>
* 多语言表 服务类
@ -13,4 +21,38 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface I18nService extends IService<I18n> {
/**
* * 获取多语言内容
*
* @return 多语言返回内容
*/
Map<String, Map<String, String>> getI18n();
/**
* * 获取管理多语言列表
*
* @return 多语言返回列表
*/
PageResult<I18nVo> getI18nList(Page<MenuIcon> pageParams, I18nDto dto);
/**
* * 添加多语言
*
* @param dto 添加表单
*/
void addI18n(I18nDto dto);
/**
* * 更新多语言
*
* @param dto 更新表单
*/
void updateI18n(I18nDto dto);
/**
* * 删除多语言类型
*
* @param ids 删除id列表
*/
void deleteI18n(List<Long> ids);
}

View File

@ -1,8 +1,13 @@
package cn.bunny.services.service;
import cn.bunny.dao.dto.i18n.I18nTypeAddDto;
import cn.bunny.dao.dto.i18n.I18nTypeUpdateDto;
import cn.bunny.dao.entity.i18n.I18nType;
import cn.bunny.dao.vo.i18n.I18nTypeVo;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 多语言类型表 服务类
@ -13,4 +18,31 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface I18nTypeService extends IService<I18nType> {
/**
* 获取多语言类型
*
* @return 多语言类型列表
*/
List<I18nTypeVo> getI18nTypeList();
/**
* 添加多语言类型
*
* @param dto 多语言类型添加
*/
void addI18nType(I18nTypeAddDto dto);
/**
* 更新多语言类型
*
* @param dto 多语言类型更新
*/
void updateI18nType(I18nTypeUpdateDto dto);
/**
* 删除多语言类型
*
* @param ids 删除id列表
*/
void deleteI18nType(List<Long> ids);
}

View File

@ -1,6 +1,10 @@
package cn.bunny.services.service;
import cn.bunny.dao.dto.menuIcon.MenuIconDto;
import cn.bunny.dao.entity.system.MenuIcon;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.menuIcon.MenuIconVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
/**
@ -13,4 +17,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface MenuIconService extends IService<MenuIcon> {
/**
* * 获取菜单Icon
*
* @param pageParams 分页查询结果
* @param dto 系统菜单图标分页查询对象
* @return 分页查询结果返回内容
*/
PageResult<MenuIconVo> getMenuIconList(Page<MenuIcon> pageParams, MenuIconDto dto);
}

View File

@ -1,11 +1,23 @@
package cn.bunny.services.service.impl;
import cn.bunny.dao.dto.i18n.I18nDto;
import cn.bunny.dao.entity.i18n.I18n;
import cn.bunny.dao.entity.i18n.I18nWithI18nType;
import cn.bunny.dao.entity.system.MenuIcon;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.i18n.I18nVo;
import cn.bunny.services.mapper.I18nMapper;
import cn.bunny.services.service.I18nService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* <p>
* 多语言表 服务实现类
@ -17,4 +29,67 @@ import org.springframework.stereotype.Service;
@Service
public class I18nServiceImpl extends ServiceImpl<I18nMapper, I18n> implements I18nService {
/**
* * 获取多语言内容
*
* @return 多语言返回内容
*/
@Override
public Map<String, Map<String, String>> getI18n() {
List<I18nWithI18nType> i18nWithI18nTypes = baseMapper.selectListWithI18nType();
return i18nWithI18nTypes.stream()
.collect(Collectors.groupingBy(I18nWithI18nType::getTypeName, Collectors.toMap(I18nWithI18nType::getKeyName, I18nWithI18nType::getSummary)));
}
/**
* * 获取管理多语言列表
*
* @return 多语言返回列表
*/
@Override
public PageResult<I18nVo> getI18nList(Page<MenuIcon> pageParams, I18nDto dto) {
IPage<I18n> page = baseMapper.selectListByPage(pageParams, dto);
List<I18nVo> i18nVoList = page.getRecords().stream().map(i18n -> {
I18nVo i18nVo = new I18nVo();
BeanUtils.copyProperties(i18n, i18nVo);
return i18nVo;
}).toList();
return PageResult.<I18nVo>builder()
.list(i18nVoList)
.pageSize(page.getSize())
.pageNo(page.getCurrent())
.total(page.getTotal())
.build();
}
/**
* * 添加多语言
*
* @param dto 添加表单
*/
@Override
public void addI18n(I18nDto dto) {
}
/**
* * 更新多语言
*
* @param dto 更新表单
*/
@Override
public void updateI18n(I18nDto dto) {
}
/**
* * 删除多语言类型
*
* @param ids 删除id列表
*/
@Override
public void deleteI18n(List<Long> ids) {
}
}

View File

@ -1,10 +1,21 @@
package cn.bunny.services.service.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.dao.dto.i18n.I18nTypeAddDto;
import cn.bunny.dao.dto.i18n.I18nTypeUpdateDto;
import cn.bunny.dao.entity.i18n.I18nType;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.dao.vo.i18n.I18nTypeVo;
import cn.bunny.services.mapper.I18nTypeMapper;
import cn.bunny.services.service.I18nTypeService;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* <p>
@ -15,6 +26,82 @@ import org.springframework.stereotype.Service;
* @since 2024-09-28
*/
@Service
@Transactional
public class I18nTypeServiceImpl extends ServiceImpl<I18nTypeMapper, I18nType> implements I18nTypeService {
/**
* 获取多语言类型
*
* @return 多语言类型列表
*/
@Override
public List<I18nTypeVo> getI18nTypeList() {
return list().stream().map(i18nType -> {
I18nTypeVo i18nTypeVo = new I18nTypeVo();
BeanUtils.copyProperties(i18nType, i18nTypeVo);
return i18nTypeVo;
}).toList();
}
/**
* 添加多语言类型
*
* @param dto 多语言类型添加
*/
@Override
public void addI18nType(I18nTypeAddDto dto) {
String typeName = dto.getTypeName();
Boolean isDefault = dto.getIsDefault();
// 查询添加的数据是否之前添加过
List<I18nType> i18nTypeList = list(Wrappers.<I18nType>lambdaQuery().eq(I18nType::getTypeName, typeName));
if (!i18nTypeList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_EXIST);
// 如果是默认将其它内容设为false
if (isDefault) {
LambdaUpdateWrapper<I18nType> lambdaUpdateWrapper = Wrappers.<I18nType>update().lambda().set(I18nType::getIsDefault, false);
update(null, lambdaUpdateWrapper);
}
// 保存数据
I18nType i18nType = new I18nType();
BeanUtils.copyProperties(dto, i18nType);
save(i18nType);
}
/**
* 更新多语言类型
*
* @param dto 多语言类型更新
*/
@Override
public void updateI18nType(I18nTypeUpdateDto dto) {
Long id = dto.getId();
Boolean isDefault = dto.getIsDefault();
// 查询更新的内容是否存在
List<I18nType> i18nTypeList = list(Wrappers.<I18nType>lambdaQuery().eq(I18nType::getId, id));
if (i18nTypeList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
// 如果是默认将其它内容设为false
if (isDefault) {
LambdaUpdateWrapper<I18nType> lambdaUpdateWrapper = Wrappers.<I18nType>update().lambda().set(I18nType::getIsDefault, false);
update(null, lambdaUpdateWrapper);
}
// 更新内容
I18nType i18nType = new I18nType();
BeanUtils.copyProperties(dto, i18nType);
updateById(i18nType);
}
/**
* 删除多语言类型
*
* @param ids 删除id列表
*/
@Override
public void deleteI18nType(List<Long> ids) {
baseMapper.deleteBatchIdsWithPhysics(ids);
}
}

View File

@ -1,11 +1,19 @@
package cn.bunny.services.service.impl;
import cn.bunny.dao.dto.menuIcon.MenuIconDto;
import cn.bunny.dao.entity.system.MenuIcon;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.menuIcon.MenuIconVo;
import cn.bunny.services.mapper.MenuIconMapper;
import cn.bunny.services.service.MenuIconService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 系统菜单图标 服务实现类
@ -17,4 +25,29 @@ import org.springframework.stereotype.Service;
@Service
public class MenuIconServiceImpl extends ServiceImpl<MenuIconMapper, MenuIcon> implements MenuIconService {
/**
* * 获取菜单Icon
*
* @param pageParams 分页查询结果
* @param dto 系统菜单图标分页查询对象
* @return 分页查询结果返回内容
*/
@Override
public PageResult<MenuIconVo> getMenuIconList(Page<MenuIcon> pageParams, MenuIconDto dto) {
// 分页查询菜单图标
IPage<MenuIcon> page = baseMapper.selectListByPage(pageParams, dto);
List<MenuIconVo> voList = page.getRecords().stream().map(menuIcon -> {
MenuIconVo menuIconVo = new MenuIconVo();
BeanUtils.copyProperties(menuIcon, menuIconVo);
return menuIconVo;
}).toList();
return PageResult.<MenuIconVo>builder()
.list(voList)
.pageNo(page.getCurrent())
.pageSize(page.getSize())
.total(page.getTotal())
.build();
}
}

View File

@ -205,6 +205,6 @@ public class RouterServiceImpl extends ServiceImpl<RouterMapper, Router> impleme
List<Long> longList = list(Wrappers.<Router>lambdaQuery().in(Router::getParentId, ids)).stream().map(Router::getId).toList();
ids.addAll(longList);
baseMapper.deletedMenuByIds(ids);
baseMapper.deleteBatchIdsWithPhysics(ids);
}
}

View File

@ -20,4 +20,24 @@
id, key_name, translation, type_id, create_user, update_user, update_time, create_time, is_deleted
</sql>
<!-- 多语言和多语言类型 -->
<select id="selectListWithI18nType" resultType="cn.bunny.dao.entity.i18n.I18nWithI18nType">
select i18n.*, i18n_type.type_name
from sys_i18n i18n,
sys_i18n_type i18n_type
where i18n.type_id = i18n_type.id
</select>
<!-- 分页查询多语言内容 -->
<select id="selectListByPage" resultType="cn.bunny.dao.entity.i18n.I18n">
select *
from sys_i18n
<if test="dto.keyName != null and dto.keyName != ''">
key_name like CONCAT('%',#{dto.keyName},'%')
</if>
<if test="dto.translation != null and dto.translation != ''">
translation like CONCAT('%',#{dto.translation},'%')
</if>
</select>
</mapper>

View File

@ -12,11 +12,22 @@
<result column="update_time" property="updateTime"/>
<result column="create_time" property="createTime"/>
<result column="is_deleted" property="isDeleted"/>
<result column="is_default" property="isDefault"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, type_name, summary, create_user, update_user, update_time, create_time, is_deleted
id, type_name, summary, create_user, update_user, update_time, create_time, is_deleted,is_default
</sql>
<!-- 物理删除多语言类型 -->
<delete id="deleteBatchIdsWithPhysics">
delete
from sys_i18n_type
where id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -18,4 +18,16 @@
id, icon_name, create_user, update_user, create_time, update_time, is_deleted
</sql>
<!-- 分页查询菜单图标 -->
<select id="selectListByPage" resultType="cn.bunny.dao.entity.system.MenuIcon">
select *
from sys_menu_icon
<where>
<if test="dto.iconName != '' and dto.iconName != null">
icon_name like #{dto.iconName}
</if>
</where>
order by update_time
</select>
</mapper>

View File

@ -34,7 +34,7 @@
</sql>
<!-- 物理删除路由菜单 -->
<delete id="deletedMenuByIds">
<delete id="deleteBatchIdsWithPhysics">
delete
from sys_router
where id in