Merge branch 'master' of https://gitee.com/youlaiorg/youlai-boot
This commit is contained in:
@@ -65,7 +65,7 @@
|
||||
`update_by` bigint DEFAULT NULL COMMENT '修改人ID',
|
||||
`is_deleted` tinyint DEFAULT '0' COMMENT '是否删除(1-删除,0-未删除)',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `uk_code` (`dict_code`) USING BTREE
|
||||
KEY `idx_dict_code` (`dict_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='字典表';
|
||||
-- ----------------------------
|
||||
-- Records of sys_dict
|
||||
|
||||
@@ -61,7 +61,7 @@ public class RateLimiterFilter extends OncePerRequestFilter {
|
||||
|
||||
/**
|
||||
* IP限流过滤器
|
||||
* 默认情况下:限制同一个IP在一分钟内只能访问10次,可以通过修改系统配置进行调整
|
||||
* 默认情况下:限制同一个IP在一秒内只能访问10次,可以通过修改系统配置进行调整
|
||||
*
|
||||
* @param request 请求体
|
||||
* @param response 响应体
|
||||
|
||||
@@ -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]));
|
||||
|
||||
@@ -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,12 +103,19 @@ 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);
|
||||
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();
|
||||
List<Long> roleIds = null;
|
||||
|
||||
@@ -35,6 +35,7 @@ public interface DictMapper extends BaseMapper<Dict> {
|
||||
* @return 字典列表
|
||||
*/
|
||||
List<DictVO> getAllDictWithData();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class UserPageVO {
|
||||
private String mobile;
|
||||
|
||||
@Schema(description="性别")
|
||||
private String genderLabel;
|
||||
private Integer gender;
|
||||
|
||||
@Schema(description="用户头像地址")
|
||||
private String avatar;
|
||||
|
||||
@@ -70,6 +70,7 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
||||
long count = this.count(new LambdaQueryWrapper<Dict>()
|
||||
.eq(Dict::getDictCode, dictCode)
|
||||
);
|
||||
|
||||
Assert.isTrue(count == 0, "字典编码已存在");
|
||||
|
||||
return this.save(entity);
|
||||
|
||||
@@ -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/
|
||||
版权所属: 有来开源组织
|
||||
|
||||
@@ -53,6 +53,12 @@
|
||||
AND u.create_time <= #{endDate}
|
||||
</if>
|
||||
</if>
|
||||
<if test="queryParams.roleIds != null and queryParams.roleIds.size() > 0">
|
||||
AND sur.role_id IN
|
||||
<foreach item="roleId" collection="queryParams.roleIds" open="(" separator="," close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY
|
||||
u.id
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<div class="search-container">
|
||||
<div class="search-bar">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInQuery == 1)
|
||||
@@ -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="选项一"/>
|
||||
@@ -93,8 +93,8 @@
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<el-card shadow="never" class="table-container">
|
||||
<template #header>
|
||||
<el-card shadow="never">
|
||||
<div class="mb-10px">
|
||||
<el-button
|
||||
v-hasPerm="['${moduleName}:${lowerFirstEntityName}:add']"
|
||||
type="success"
|
||||
@@ -112,7 +112,7 @@
|
||||
<template #icon><Delete /></template>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
ref="dataTableRef"
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user