Merge branch 'master' of https://gitee.com/youlaiorg/youlai-boot
This commit is contained in:
@@ -61,7 +61,7 @@ public class RateLimiterFilter extends OncePerRequestFilter {
|
||||
|
||||
/**
|
||||
* IP限流过滤器
|
||||
* 默认情况下:限制同一个IP在一分钟内只能访问10次,可以通过修改系统配置进行调整
|
||||
* 默认情况下:限制同一个IP在一秒内只能访问10次,可以通过修改系统配置进行调整
|
||||
*
|
||||
* @param request 请求体
|
||||
* @param response 响应体
|
||||
|
||||
@@ -73,8 +73,8 @@ public enum FormTypeEnum implements IBaseEnum<Integer> {
|
||||
|
||||
|
||||
@JsonCreator
|
||||
public static QueryTypeEnum fromValue(Integer value) {
|
||||
for (QueryTypeEnum type : QueryTypeEnum.values()) {
|
||||
public static FormTypeEnum fromValue(Integer value) {
|
||||
for (FormTypeEnum type : FormTypeEnum.values()) {
|
||||
if (type.getValue().equals(value)) {
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -169,14 +169,18 @@ public class CodegenServiceImpl implements CodegenService {
|
||||
path = (codegenProperties.getBackendAppName()
|
||||
+ File.separator
|
||||
+ "src" + File.separator + "main" + File.separator + "resources"
|
||||
+ File.separator + moduleName
|
||||
+ File.separator + subPackageName
|
||||
);
|
||||
} else if ("API".equals(templateName)) {
|
||||
// path = "src/api/system";
|
||||
path = (codegenProperties.getFrontendAppName()
|
||||
+ File.separator
|
||||
+ "src" + File.separator + subPackageName
|
||||
+ File.separator + "src"
|
||||
+ File.separator + subPackageName
|
||||
+ File.separator + moduleName
|
||||
);
|
||||
} else if ("VIEW".equals(templateName)) {
|
||||
// path = "src/views/system/user";
|
||||
path = (codegenProperties.getFrontendAppName()
|
||||
+ File.separator + "src"
|
||||
+ File.separator + subPackageName
|
||||
@@ -241,8 +245,6 @@ public class CodegenServiceImpl implements CodegenService {
|
||||
hasRequiredField = true;
|
||||
}
|
||||
fieldConfig.setTsType(JavaTypeEnum.getTsTypeByJavaType(fieldConfig.getFieldType()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
bindMap.put("hasLocalDateTime", hasLocalDateTime);
|
||||
|
||||
@@ -80,7 +80,7 @@ public class GenConfigServiceImpl extends ServiceImpl<GenConfigMapper, GenConfig
|
||||
|
||||
String tableComment = tableMetadata.getTableComment();
|
||||
if (StrUtil.isNotBlank(tableComment)) {
|
||||
genConfig.setBusinessName(tableComment.replace("表", ""));
|
||||
genConfig.setBusinessName(tableComment.replace("表", "").trim());
|
||||
}
|
||||
// 实体类名 = 表名去掉前缀后转驼峰,前缀默认为下划线分割的第一个元素
|
||||
String entityName = StrUtil.toCamelCase(StrUtil.removePrefix(tableName, tableName.split("_")[0]));
|
||||
@@ -132,7 +132,7 @@ public class GenConfigServiceImpl extends ServiceImpl<GenConfigMapper, GenConfig
|
||||
genFieldConfigs.add(fieldConfig);
|
||||
}
|
||||
}
|
||||
//对genFieldConfigs按照fieldSort排序
|
||||
// 对 genFieldConfigs 按照 fieldSort 排序
|
||||
genFieldConfigs = genFieldConfigs.stream().sorted(Comparator.comparing(GenFieldConfig::getFieldSort)).toList();
|
||||
GenConfigForm genConfigForm = codegenConverter.toGenConfigForm(genConfig, genFieldConfigs);
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
|
||||
/**
|
||||
* 系统配置前端控制层
|
||||
*
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.youlai.boot.system.model.vo.DictPageVO;
|
||||
import com.youlai.boot.common.annotation.RepeatSubmit;
|
||||
import com.youlai.boot.system.model.form.DictForm;
|
||||
import com.youlai.boot.common.annotation.Log;
|
||||
import com.youlai.boot.system.model.vo.DictVO;
|
||||
import com.youlai.boot.system.service.DictService;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -47,8 +48,8 @@ public class DictController {
|
||||
|
||||
@Operation(summary = "字典列表")
|
||||
@GetMapping("/list")
|
||||
public Result<List<Option<String>>> getDictList() {
|
||||
List<Option<String>> list = dictService.getDictList();
|
||||
public Result<List<DictVO>> getAllDictWithData() {
|
||||
List<DictVO> list = dictService.getAllDictWithData();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,6 @@ import org.mapstruct.Mappings;
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface UserConverter {
|
||||
|
||||
@Mappings({
|
||||
@Mapping(target = "genderLabel", expression = "java(com.youlai.boot.common.base.IBaseEnum.getLabelByValue(bo.getGender(), com.youlai.boot.system.enums.GenderEnum.class))")
|
||||
})
|
||||
UserPageVO toPageVo(UserBO bo);
|
||||
|
||||
Page<UserPageVO> toPageVo(Page<UserBO> bo);
|
||||
|
||||
28
src/main/java/com/youlai/boot/system/enums/DictCodeEnum.java
Normal file
28
src/main/java/com/youlai/boot/system/enums/DictCodeEnum.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.youlai.boot.system.enums;
|
||||
|
||||
import com.youlai.boot.common.base.IBaseEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 字典编码枚举
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2024/10/30
|
||||
*/
|
||||
@Getter
|
||||
public enum DictCodeEnum implements IBaseEnum<String> {
|
||||
|
||||
GENDER("gender", "性别"),
|
||||
NOTICE_TYPE("notice_type", "通知类型"),
|
||||
NOTICE_LEVEL("notice_level", "通知级别");
|
||||
|
||||
private final String value;
|
||||
|
||||
private final String label;
|
||||
|
||||
DictCodeEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.youlai.boot.system.enums;
|
||||
|
||||
import com.youlai.boot.common.base.IBaseEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 性别枚举
|
||||
*
|
||||
* @author haoxr
|
||||
* @since 2022/10/14
|
||||
*/
|
||||
@Getter
|
||||
@Schema(enumAsRef = true)
|
||||
public enum GenderEnum implements IBaseEnum<Integer> {
|
||||
|
||||
MALE(1, "男"),
|
||||
FEMALE (2, "女");
|
||||
|
||||
private final Integer value;
|
||||
|
||||
private final String label;
|
||||
|
||||
GenderEnum(Integer value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import lombok.Getter;
|
||||
* 通告发布状态枚举
|
||||
*
|
||||
* @author haoxr
|
||||
* @since 2022/10/14
|
||||
* @since 2024/10/14
|
||||
*/
|
||||
@Getter
|
||||
@Schema(enumAsRef = true)
|
||||
|
||||
@@ -8,20 +8,14 @@ import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.youlai.boot.common.base.BaseAnalysisEventListener;
|
||||
import com.youlai.boot.system.enums.GenderEnum;
|
||||
import com.youlai.boot.system.model.entity.Dept;
|
||||
import com.youlai.boot.system.model.entity.Role;
|
||||
import com.youlai.boot.system.model.entity.User;
|
||||
import com.youlai.boot.system.model.entity.UserRole;
|
||||
import com.youlai.boot.system.enums.DictCodeEnum;
|
||||
import com.youlai.boot.system.model.entity.*;
|
||||
import com.youlai.boot.common.base.IBaseEnum;
|
||||
import com.youlai.boot.common.constant.SystemConstants;
|
||||
import com.youlai.boot.common.enums.StatusEnum;
|
||||
import com.youlai.boot.system.converter.UserConverter;
|
||||
import com.youlai.boot.system.model.dto.UserImportDTO;
|
||||
import com.youlai.boot.system.service.DeptService;
|
||||
import com.youlai.boot.system.service.RoleService;
|
||||
import com.youlai.boot.system.service.UserRoleService;
|
||||
import com.youlai.boot.system.service.UserService;
|
||||
import com.youlai.boot.system.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
@@ -55,6 +49,7 @@ public class UserImportListener extends BaseAnalysisEventListener<UserImportDTO>
|
||||
private final RoleService roleService;
|
||||
private final UserRoleService userRoleService;
|
||||
private final DeptService deptService;
|
||||
private final DictDataService dictDataService;
|
||||
|
||||
public UserImportListener() {
|
||||
this.userService = SpringUtil.getBean(UserService.class);
|
||||
@@ -62,6 +57,7 @@ public class UserImportListener extends BaseAnalysisEventListener<UserImportDTO>
|
||||
this.roleService = SpringUtil.getBean(RoleService.class);
|
||||
this.userRoleService = SpringUtil.getBean(UserRoleService.class);
|
||||
this.deptService = SpringUtil.getBean(DeptService.class);
|
||||
this.dictDataService = SpringUtil.getBean(DictDataService.class);
|
||||
this.userConverter = SpringUtil.getBean(UserConverter.class);
|
||||
}
|
||||
|
||||
@@ -107,11 +103,18 @@ public class UserImportListener extends BaseAnalysisEventListener<UserImportDTO>
|
||||
// 校验通过,持久化至数据库
|
||||
User entity = userConverter.toEntity(userImportDTO);
|
||||
entity.setPassword(passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD)); // 默认密码
|
||||
// 性别逆向解析
|
||||
// 性别逆向翻译 根据字典标签得到字典值
|
||||
String genderLabel = userImportDTO.getGenderLabel();
|
||||
if (StrUtil.isNotBlank(genderLabel)) {
|
||||
Integer genderValue = (Integer) IBaseEnum.getValueByLabel(genderLabel, GenderEnum.class);
|
||||
entity.setGender(genderValue);
|
||||
DictData dictData = dictDataService.getOne(new LambdaQueryWrapper<DictData>()
|
||||
.eq(DictData::getDictCode, DictCodeEnum.GENDER.getValue())
|
||||
.eq(DictData::getLabel, genderLabel)
|
||||
.last("limit 1")
|
||||
);
|
||||
if (dictData != null) {
|
||||
Integer genderValue = Integer.parseInt(dictData.getValue());
|
||||
entity.setGender(genderValue);
|
||||
}
|
||||
}
|
||||
// 角色解析
|
||||
String roleCodes = userImportDTO.getRoleCodes();
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.boot.common.model.Option;
|
||||
import com.youlai.boot.system.model.entity.DictData;
|
||||
import com.youlai.boot.system.model.query.DictDataPageQuery;
|
||||
import com.youlai.boot.system.model.query.DictPageQuery;
|
||||
import com.youlai.boot.system.model.vo.DictDataPageVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
@@ -2,11 +2,15 @@ package com.youlai.boot.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.boot.common.model.Option;
|
||||
import com.youlai.boot.system.model.entity.Dict;
|
||||
import com.youlai.boot.system.model.query.DictPageQuery;
|
||||
import com.youlai.boot.system.model.vo.DictPageVO;
|
||||
import com.youlai.boot.system.model.vo.DictVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典 访问层
|
||||
*
|
||||
@@ -24,6 +28,13 @@ public interface DictMapper extends BaseMapper<Dict> {
|
||||
* @return
|
||||
*/
|
||||
Page<DictPageVO> getDictPage(Page<DictPageVO> page, DictPageQuery queryParams);
|
||||
|
||||
/**
|
||||
* 获取所有字典和字典数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DictVO> getAllDictWithData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import lombok.EqualsAndHashCode;
|
||||
* @since 2024-07-29 11:17:26
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "系统配置")
|
||||
@TableName("sys_config")
|
||||
public class Config extends BaseEntity {
|
||||
@@ -51,7 +51,6 @@ public class Config extends BaseEntity {
|
||||
/**
|
||||
* 逻辑删除标识(0-未删除 1-已删除)
|
||||
*/
|
||||
@TableLogic(value = "0", delval = "1")
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
||||
@@ -58,9 +58,8 @@ public class Dept extends BaseEntity {
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 逻辑删除标识(0-未删除 1-已删除)
|
||||
* 是否删除(0-否 1-是)
|
||||
*/
|
||||
@TableLogic(value = "0", delval = "1")
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
@@ -11,9 +11,9 @@ import lombok.EqualsAndHashCode;
|
||||
* @author haoxr
|
||||
* @since 2022/12/17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_dict")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class Dict extends BaseEntity {
|
||||
|
||||
/**
|
||||
@@ -37,4 +37,9 @@ public class Dict extends BaseEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 逻辑删除标识(0-未删除 1-已删除)
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
@@ -3,18 +3,18 @@ package com.youlai.boot.system.model.entity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.youlai.boot.common.base.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 字典数据表
|
||||
* 字典数据实体对象
|
||||
*
|
||||
* @author haoxr
|
||||
* @since 2022/12/17
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_dict_data")
|
||||
@Data
|
||||
public class DictData extends BaseEntity {
|
||||
|
||||
@@ -79,9 +79,9 @@ public class Notice extends BaseEntity {
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 逻辑删除标识(0-未删除 1-已删除)
|
||||
*/
|
||||
@TableLogic(value = "0", delval = "1")
|
||||
private Integer isDeleted;
|
||||
}
|
||||
|
||||
@@ -50,4 +50,9 @@ public class Role extends BaseEntity {
|
||||
* 更新人 ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 是否删除(0-否 1-是)
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
}
|
||||
@@ -67,4 +67,9 @@ public class User extends BaseEntity {
|
||||
* 更新人 ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 是否删除(0-否 1-是)
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.youlai.system.model.form;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.time.LocalDateTime;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 用户公告状态表单对象
|
||||
*
|
||||
* @author youlaitech
|
||||
* @since 2024-08-28 16:56
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "用户公告状态表单对象")
|
||||
public class NoticeStatusForm implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description ="字典数据分页查询对象")
|
||||
public class DictDataPageQuery extends BasePageQuery {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description ="字典数据项分页查询对象")
|
||||
public class DictPageQuery extends BasePageQuery {
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
* @since 2024-08-27 10:31
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description ="通知公告查询对象")
|
||||
public class NoticePageQuery extends BasePageQuery {
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.youlai.boot.system.model.query;
|
||||
|
||||
import com.youlai.boot.common.base.BasePageQuery;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户公告状态分页查询对象
|
||||
*
|
||||
* @author youlaitech
|
||||
* @since 2024-08-28 16:56
|
||||
*/
|
||||
@Schema(description ="用户公告状态查询对象")
|
||||
@Getter
|
||||
@Setter
|
||||
public class NoticeStatusQuery extends BasePageQuery {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "公共通知id")
|
||||
private Long noticeId;
|
||||
|
||||
@Schema(description = "用户id")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "读取状态,0未读,1已读取")
|
||||
private Long readStatus;
|
||||
|
||||
@Schema(description = "用户阅读时间")
|
||||
private List<String> readTime;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.youlai.boot.system.model.query;
|
||||
|
||||
import com.youlai.boot.common.base.BasePageQuery;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 权限分页查询对象
|
||||
*
|
||||
* @author haoxr
|
||||
* @since 2022/1/14 22:22
|
||||
*/
|
||||
@Data
|
||||
@Schema
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PermPageQuery extends BasePageQuery {
|
||||
|
||||
@Schema(description="权限名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description="菜单ID")
|
||||
private Long menuId;
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
* @since 2022/1/14
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description ="用户分页查询对象")
|
||||
public class UserPageQuery extends BasePageQuery {
|
||||
|
||||
|
||||
46
src/main/java/com/youlai/boot/system/model/vo/DictVO.java
Normal file
46
src/main/java/com/youlai/boot/system/model/vo/DictVO.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package com.youlai.boot.system.model.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 字典数据项分页VO
|
||||
*
|
||||
* @author Ray
|
||||
* @since 0.0.1
|
||||
*/
|
||||
@Schema(description = "字典数据分页对象")
|
||||
@Getter
|
||||
@Setter
|
||||
public class DictVO {
|
||||
|
||||
@Schema(description = "字典名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "字典编码")
|
||||
private String dictCode;
|
||||
|
||||
@Schema(description = "字典数据集合")
|
||||
private List<DictData> dictDataList;
|
||||
|
||||
@Schema(description = "字典数据")
|
||||
@Getter
|
||||
@Setter
|
||||
public static class DictData {
|
||||
|
||||
@Schema(description = "字典数据值")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "字典数据标签")
|
||||
private String label;
|
||||
|
||||
@Schema(description = "标签类型")
|
||||
private String tagType;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class UserPageVO {
|
||||
private String mobile;
|
||||
|
||||
@Schema(description="性别")
|
||||
private String genderLabel;
|
||||
private Integer gender;
|
||||
|
||||
@Schema(description="用户头像地址")
|
||||
private String avatar;
|
||||
|
||||
@@ -7,11 +7,12 @@ import com.youlai.boot.system.model.entity.Dict;
|
||||
import com.youlai.boot.system.model.form.DictForm;
|
||||
import com.youlai.boot.system.model.query.DictPageQuery;
|
||||
import com.youlai.boot.system.model.vo.DictPageVO;
|
||||
import com.youlai.boot.system.model.vo.DictVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据字典业务接口
|
||||
* 字典业务接口
|
||||
*
|
||||
* @author haoxr
|
||||
* @since 2022/10/12
|
||||
@@ -48,7 +49,7 @@ public interface DictService extends IService<Dict> {
|
||||
/**
|
||||
* 修改字典
|
||||
*
|
||||
* @param id
|
||||
* @param id 字典ID
|
||||
* @param dictForm 字典表单
|
||||
* @return
|
||||
*/
|
||||
@@ -63,19 +64,10 @@ public interface DictService extends IService<Dict> {
|
||||
void deleteDictByIds(String idsStr);
|
||||
|
||||
|
||||
/**
|
||||
* 获取字典的数据项
|
||||
*
|
||||
* @param code 字典编码
|
||||
* @return
|
||||
*/
|
||||
List<Option<Long>> listDictItemsByCode(String code);
|
||||
|
||||
|
||||
/**
|
||||
* 获取字典列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Option<String>> getDictList();
|
||||
List<DictVO> getAllDictWithData();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.youlai.boot.system.model.form.DictForm;
|
||||
import com.youlai.boot.system.model.query.DictPageQuery;
|
||||
import com.youlai.boot.system.model.vo.DictPageVO;
|
||||
import com.youlai.boot.common.model.Option;
|
||||
import com.youlai.boot.system.model.vo.DictVO;
|
||||
import com.youlai.boot.system.service.DictDataService;
|
||||
import com.youlai.boot.system.service.DictService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -145,44 +146,11 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典的数据项
|
||||
*
|
||||
* @param code 字典编码
|
||||
* 获取所有字典和字典数据
|
||||
*/
|
||||
@Override
|
||||
public List<Option<Long>> listDictItemsByCode(String code) {
|
||||
// 根据字典编码获取字典ID
|
||||
Dict dict = this.getOne(new LambdaQueryWrapper<Dict>()
|
||||
.eq(Dict::getDictCode, code)
|
||||
.select(Dict::getId)
|
||||
.last("limit 1")
|
||||
);
|
||||
// 如果字典不存在,则返回空集合
|
||||
if (dict == null) {
|
||||
return CollectionUtil.newArrayList();
|
||||
}
|
||||
|
||||
// 获取字典项
|
||||
List<DictData> dictData = dictDataService.list(
|
||||
new LambdaQueryWrapper<DictData>()
|
||||
.eq(DictData::getDictCode, dict.getDictCode())
|
||||
);
|
||||
|
||||
// 转换为 Option
|
||||
return dictDataConverter.toOption(dictData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典列表
|
||||
*/
|
||||
@Override
|
||||
public List<Option<String>> getDictList() {
|
||||
return this.list(new LambdaQueryWrapper<Dict>()
|
||||
.eq(Dict::getStatus, 1)
|
||||
.select(Dict::getName, Dict::getDictCode)
|
||||
).stream()
|
||||
.map(dict -> new Option<>(dict.getDictCode(), dict.getName()))
|
||||
.toList();
|
||||
public List<DictVO> getAllDictWithData() {
|
||||
return this.baseMapper.getAllDictWithData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +61,8 @@ mybatis-plus:
|
||||
db-config:
|
||||
# 主键ID类型
|
||||
id-type: none
|
||||
# 逻辑删除字段名称
|
||||
logic-delete-field: is_deleted
|
||||
# 逻辑删除全局属性名(驼峰和下划线都支持)
|
||||
logic-delete-field: isDeleted
|
||||
# 逻辑删除-删除值
|
||||
logic-delete-value: 1
|
||||
# 逻辑删除-未删除值
|
||||
|
||||
@@ -46,7 +46,7 @@ mybatis-plus:
|
||||
# 主键ID类型
|
||||
id-type: none
|
||||
# 逻辑删除字段名称
|
||||
logic-delete-field: is_deleted
|
||||
logic-delete-field: isDeleted
|
||||
# 逻辑删除-删除值
|
||||
logic-delete-value: 1
|
||||
# 逻辑删除-未删除值
|
||||
|
||||
@@ -3,6 +3,8 @@ spring:
|
||||
name: youlai-boot
|
||||
profiles:
|
||||
active: dev
|
||||
project:
|
||||
version: @project.version@
|
||||
|
||||
# 代码生成器配置
|
||||
codegen:
|
||||
|
||||
@@ -7,7 +7,7 @@ ${AnsiColor.BRIGHT_BLUE}
|
||||
|_|\___/ \__,_| |______\__,_|_|
|
||||
|
||||
${AnsiColor.BRIGHT_GREEN}
|
||||
YouLai Boot Version: 2.8.1
|
||||
YouLai Boot Version: ${project.version}
|
||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
||||
有来官网: https://www.youlai.tech/
|
||||
版权所属: 有来开源组织
|
||||
|
||||
@@ -30,14 +30,16 @@
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} -%5level ---[%15.15thread] %-40.40logger{39} : %msg%n%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志记录器的滚动策略,按大小和时间记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!-- 滚动后的日志文件命名模式 -->
|
||||
<fileNamePattern>${LOG_HOME}/%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<!--日志文档保留天数-->
|
||||
<!-- 单个日志文件的最大大小 -->
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
<!-- 最大保留30天的日志 -->
|
||||
<maxHistory>30</maxHistory>
|
||||
<!-- 总日志文件大小不超过3GB -->
|
||||
<totalSizeCap>1GB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
<!-- 临界值过滤器,输出大于INFO级别日志 -->
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
@@ -59,4 +61,4 @@
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
</springProfile>
|
||||
</configuration>
|
||||
</configuration>
|
||||
|
||||
@@ -35,12 +35,26 @@
|
||||
value,
|
||||
label
|
||||
FROM
|
||||
sys_dict_data
|
||||
sys_dict_data
|
||||
<where>
|
||||
dict_code = #{dictCode}
|
||||
</where>
|
||||
ORDER BY
|
||||
sort ASC
|
||||
sort ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据字典编码获取字典数据列表 -->
|
||||
<select id="getDictDataList" resultType="com.youlai.boot.system.model.vo.DictVO$DictData">
|
||||
SELECT
|
||||
value,
|
||||
label,
|
||||
tag_type
|
||||
FROM
|
||||
sys_dict_data
|
||||
WHERE
|
||||
status = 1 AND dict_code = #{dictCode}
|
||||
ORDER BY
|
||||
sort ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -25,4 +25,26 @@
|
||||
ORDER BY
|
||||
t1.create_time DESC
|
||||
</select>
|
||||
|
||||
<resultMap id="DictWithDataMap" type="com.youlai.boot.system.model.vo.DictVO">
|
||||
<result column="name" property="name"/>
|
||||
<result column="dict_code" property="dictCode"/>
|
||||
<collection property="dictDataList"
|
||||
column="{dictCode=dict_code}"
|
||||
select="com.youlai.boot.system.mapper.DictDataMapper.getDictDataList">
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<!-- 获取所有字典和字典数据 -->
|
||||
<select id="getAllDictWithData" resultMap="DictWithDataMap">
|
||||
SELECT
|
||||
t1.name,
|
||||
t1.dict_code
|
||||
FROM
|
||||
sys_dict t1
|
||||
WHERE
|
||||
t1.is_deleted = 0 AND t1.status = 1
|
||||
ORDER BY
|
||||
t1.create_time DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -2,36 +2,36 @@ import request from "@/utils/request";
|
||||
|
||||
const ${entityName.toUpperCase()}_BASE_URL = "/api/v1/${lowerFirstEntityName}s";
|
||||
|
||||
class ${entityName}API {
|
||||
const ${entityName}API = {
|
||||
/** 获取${businessName}分页数据 */
|
||||
static getPage(queryParams?: ${entityName}PageQuery) {
|
||||
getPage(queryParams?: ${entityName}PageQuery) {
|
||||
return request<any, PageResult<${entityName}PageVO[]>>({
|
||||
url: `${${entityName.toUpperCase()}_BASE_URL}/page`,
|
||||
method: "get",
|
||||
params: queryParams,
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 获取${businessName}表单数据
|
||||
*
|
||||
* @param id ${entityName}ID
|
||||
* @returns ${entityName}表单数据
|
||||
*/
|
||||
static getFormData(id: number) {
|
||||
getFormData(id: number) {
|
||||
return request<any, ${entityName}Form>({
|
||||
url: `${${entityName.toUpperCase()}_BASE_URL}/${id}/form`,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/** 添加${businessName}*/
|
||||
static add(data: ${entityName}Form) {
|
||||
add(data: ${entityName}Form) {
|
||||
return request({
|
||||
url: `${${entityName.toUpperCase()}_BASE_URL}`,
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新${businessName}
|
||||
@@ -39,20 +39,20 @@ class ${entityName}API {
|
||||
* @param id ${entityName}ID
|
||||
* @param data ${entityName}表单数据
|
||||
*/
|
||||
static update(id: number, data: ${entityName}Form) {
|
||||
update(id: number, data: ${entityName}Form) {
|
||||
return request({
|
||||
url: `${${entityName.toUpperCase()}_BASE_URL}/${id}`,
|
||||
method: "put",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 批量删除${businessName},多个以英文逗号(,)分割
|
||||
*
|
||||
* @param ids ${businessName}ID字符串,多个以英文逗号(,)分割
|
||||
*/
|
||||
static deleteByIds(ids: string) {
|
||||
deleteByIds(ids: string) {
|
||||
return request({
|
||||
url: `${${entityName.toUpperCase()}_BASE_URL}/${ids}`,
|
||||
method: "delete",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
/>
|
||||
#elseif($fieldConfig.formType == "SELECT")
|
||||
#if($fieldConfig.dictType != "")
|
||||
<dictionary v-model="queryParams.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
||||
<dict v-model="queryParams.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
||||
#else
|
||||
<el-select v-model="queryParams.$fieldConfig.fieldName" placeholder="请选择$fieldConfig.fieldComment">
|
||||
<el-option :key="1" :value="1" label="选项一"/>
|
||||
@@ -187,7 +187,7 @@
|
||||
/>
|
||||
#elseif($fieldConfig.formType == "SELECT")
|
||||
#if($fieldConfig.dictType != "")
|
||||
<dictionary v-model="formData.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
||||
<dict v-model="formData.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
||||
#else
|
||||
<el-select v-model="formData.$fieldConfig.fieldName" placeholder="请选择$fieldConfig.fieldComment">
|
||||
<el-option :value="0" label="选项一"/>
|
||||
@@ -256,7 +256,7 @@
|
||||
inheritAttrs: false,
|
||||
});
|
||||
|
||||
import ${entityName}API, { ${entityName}PageVO, ${entityName}Form, ${entityName}PageQuery } from "@/api/${kebabCaseEntityName}";
|
||||
import ${entityName}API, { ${entityName}PageVO, ${entityName}Form, ${entityName}PageQuery } from "@/api/${moduleName}/${kebabCaseEntityName}";
|
||||
|
||||
const queryFormRef = ref(ElForm);
|
||||
const dataFormRef = ref(ElForm);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SystemCodeGenerator {
|
||||
.injectionConfig(consumer -> {
|
||||
List<CustomFile> customFiles = new ArrayList<>();
|
||||
customFiles.add(new CustomFile.Builder().fileName("VO.java").templatePath("/templates/vo.java.vm").packageName("model.vo").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("VO.java").templatePath("/templates/dto.java.vm").packageName("model.dto").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("DTO.java").templatePath("/templates/dto.java.vm").packageName("model.dto").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("BO.java").templatePath("/templates/bo.java.vm").packageName("model.bo").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("PageQuery.java").templatePath("/templates/query.java.vm").packageName("model.query").build());
|
||||
customFiles.add(new CustomFile.Builder().fileName("PageVO.java").templatePath("/templates/pageVO.java.vm").packageName("model.vo").build());
|
||||
|
||||
Reference in New Issue
Block a user