Commit caeb23a3dcc94d99565b7a4ab4bf0da0b586036a
Merge remote-tracking branch 'origin/feature/codegen-front' into feature/codegen-front
Showing
12 changed files
with
92 additions
and
9 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/validation/ValidationUtils.java
| @@ -16,7 +16,7 @@ import java.util.regex.Pattern; | @@ -16,7 +16,7 @@ import java.util.regex.Pattern; | ||
| 16 | */ | 16 | */ |
| 17 | public class ValidationUtils { | 17 | public class ValidationUtils { |
| 18 | 18 | ||
| 19 | - private static final Pattern PATTERN_MOBILE = Pattern.compile("^(?:(?:\\+|00)86)?1(?:(?:3[\\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\\d])|(?:9[189]))\d{8}$"); | 19 | + private static final Pattern PATTERN_MOBILE = Pattern.compile("^(?:(?:\\+|00)86)?1(?:(?:3[\\d])|(?:4[0,1,4-9])|(?:5[0-3,5-9])|(?:6[2,5-7])|(?:7[0-8])|(?:8[\\d])|(?:9[0-3,5-9]))\d{8}$"); |
| 20 | 20 | ||
| 21 | private static final Pattern PATTERN_URL = Pattern.compile("^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"); | 21 | private static final Pattern PATTERN_URL = Pattern.compile("^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"); |
| 22 | 22 |
yudao-framework/yudao-spring-boot-starter-biz-ip/src/main/java/cn/iocoder/yudao/framework/ip/core/utils/IPUtils.java
| @@ -51,7 +51,7 @@ public class IPUtils { | @@ -51,7 +51,7 @@ public class IPUtils { | ||
| 51 | */ | 51 | */ |
| 52 | @SneakyThrows | 52 | @SneakyThrows |
| 53 | public static Integer getAreaId(String ip) { | 53 | public static Integer getAreaId(String ip) { |
| 54 | - return Integer.parseInt(SEARCHER.search(ip)); | 54 | + return Integer.parseInt(SEARCHER.search(ip.trim())); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | /** | 57 | /** |
yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml
| @@ -52,8 +52,8 @@ | @@ -52,8 +52,8 @@ | ||
| 52 | 52 | ||
| 53 | <!-- Test 测试相关 --> | 53 | <!-- Test 测试相关 --> |
| 54 | <dependency> | 54 | <dependency> |
| 55 | - <groupId>org.springframework.boot</groupId> | ||
| 56 | - <artifactId>spring-boot-starter-test</artifactId> | 55 | + <groupId>cn.iocoder.boot</groupId> |
| 56 | + <artifactId>yudao-spring-boot-starter-test</artifactId> | ||
| 57 | <scope>test</scope> | 57 | <scope>test</scope> |
| 58 | </dependency> | 58 | </dependency> |
| 59 | 59 |
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/test/java/cn/iocoder/yudao/framework/tenant/core/job/TenantJobTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.tenant.core.job; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService; | ||
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; | ||
| 5 | +import com.google.common.collect.Lists; | ||
| 6 | +import org.junit.jupiter.api.Test; | ||
| 7 | +import org.mockito.Mock; | ||
| 8 | +import org.mockito.Mockito; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 验证 job 租户逻辑 | ||
| 16 | + * {@link TenantJobHandlerDecorator} | ||
| 17 | + * | ||
| 18 | + * @author gaibu | ||
| 19 | + */ | ||
| 20 | +public class TenantJobTest extends BaseMockitoUnitTest { | ||
| 21 | + | ||
| 22 | + @Mock | ||
| 23 | + TenantFrameworkService tenantFrameworkService; | ||
| 24 | + | ||
| 25 | + @Test | ||
| 26 | + public void test() throws Exception { | ||
| 27 | + // 准备测试租户 id | ||
| 28 | + List<Long> tenantIds = Lists.newArrayList(1L, 2L, 3L); | ||
| 29 | + // mock 数据 | ||
| 30 | + Mockito.doReturn(tenantIds).when(tenantFrameworkService).getTenantIds(); | ||
| 31 | + // 准备测试任务 | ||
| 32 | + TestJob testJob = new TestJob(); | ||
| 33 | + // 创建任务装饰器 | ||
| 34 | + TenantJobHandlerDecorator tenantJobHandlerDecorator = new TenantJobHandlerDecorator(tenantFrameworkService, testJob); | ||
| 35 | + | ||
| 36 | + // 执行任务 | ||
| 37 | + tenantJobHandlerDecorator.execute(null); | ||
| 38 | + | ||
| 39 | + // 断言返回值 | ||
| 40 | + assertEquals(testJob.getTenantIds(), tenantIds); | ||
| 41 | + } | ||
| 42 | +} |
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/test/java/cn/iocoder/yudao/framework/tenant/core/job/TestJob.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.tenant.core.job; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; | ||
| 5 | +import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; | ||
| 6 | +import org.springframework.stereotype.Component; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | +import java.util.concurrent.CopyOnWriteArrayList; | ||
| 10 | + | ||
| 11 | +@Component | ||
| 12 | +@TenantJob // 标记多租户 | ||
| 13 | +public class TestJob implements JobHandler { | ||
| 14 | + | ||
| 15 | + private final List<Long> tenantIds = new CopyOnWriteArrayList<>(); | ||
| 16 | + | ||
| 17 | + @Override | ||
| 18 | + public String execute(String param) throws Exception { | ||
| 19 | + tenantIds.add(TenantContextHolder.getTenantId()); | ||
| 20 | + return "success"; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public List<Long> getTenantIds() { | ||
| 24 | + CollUtil.sort(tenantIds, Long::compareTo); | ||
| 25 | + return tenantIds; | ||
| 26 | + } | ||
| 27 | +} |
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/SecurityProperties.java
| @@ -37,4 +37,8 @@ public class SecurityProperties { | @@ -37,4 +37,8 @@ public class SecurityProperties { | ||
| 37 | */ | 37 | */ |
| 38 | private List<String> permitAllUrls = Collections.emptyList(); | 38 | private List<String> permitAllUrls = Collections.emptyList(); |
| 39 | 39 | ||
| 40 | + /** | ||
| 41 | + * PasswordEncoder 加密复杂度,越高开销越大 | ||
| 42 | + */ | ||
| 43 | + private Integer passwordEncoderLength = 4; | ||
| 40 | } | 44 | } |
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
| @@ -69,7 +69,7 @@ public class YudaoSecurityAutoConfiguration { | @@ -69,7 +69,7 @@ public class YudaoSecurityAutoConfiguration { | ||
| 69 | */ | 69 | */ |
| 70 | @Bean | 70 | @Bean |
| 71 | public PasswordEncoder passwordEncoder() { | 71 | public PasswordEncoder passwordEncoder() { |
| 72 | - return new BCryptPasswordEncoder(); | 72 | + return new BCryptPasswordEncoder(securityProperties.getPasswordEncoderLength()); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | /** | 75 | /** |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java
| @@ -135,6 +135,8 @@ public interface BpmTaskConvert { | @@ -135,6 +135,8 @@ public interface BpmTaskConvert { | ||
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | @Mapping(source = "taskDefinitionKey", target = "definitionKey") | 137 | @Mapping(source = "taskDefinitionKey", target = "definitionKey") |
| 138 | + @Mapping(target = "createTime", expression = "java(bean.getCreateTime() == null ? null : LocalDateTime.ofInstant(bean.getCreateTime().toInstant(), ZoneId.systemDefault()))") | ||
| 139 | + @Mapping(target = "endTime", expression = "java(bean.getEndTime() == null ? null : LocalDateTime.ofInstant(bean.getEndTime().toInstant(), ZoneId.systemDefault()))") | ||
| 138 | BpmTaskRespVO convert3(HistoricTaskInstance bean); | 140 | BpmTaskRespVO convert3(HistoricTaskInstance bean); |
| 139 | 141 | ||
| 140 | BpmTaskRespVO.User convert3(AdminUserRespDTO bean); | 142 | BpmTaskRespVO.User convert3(AdminUserRespDTO bean); |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/codegen/CodegenTableDO.java
| @@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO; | @@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO; | ||
| 5 | import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum; | 5 | import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum; |
| 6 | import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum; | 6 | import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum; |
| 7 | import com.baomidou.mybatisplus.annotation.KeySequence; | 7 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 8 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 8 | import com.baomidou.mybatisplus.annotation.TableName; | 9 | import com.baomidou.mybatisplus.annotation.TableName; |
| 9 | import com.baomidou.mybatisplus.generator.config.po.TableInfo; | 10 | import com.baomidou.mybatisplus.generator.config.po.TableInfo; |
| 10 | import lombok.Data; | 11 | import lombok.Data; |
| @@ -26,6 +27,7 @@ public class CodegenTableDO extends BaseDO { | @@ -26,6 +27,7 @@ public class CodegenTableDO extends BaseDO { | ||
| 26 | /** | 27 | /** |
| 27 | * ID 编号 | 28 | * ID 编号 |
| 28 | */ | 29 | */ |
| 30 | + @TableId | ||
| 29 | private Long id; | 31 | private Long id; |
| 30 | 32 | ||
| 31 | /** | 33 | /** |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java
| @@ -22,7 +22,7 @@ public class TradeOrderBaseVO { | @@ -22,7 +22,7 @@ public class TradeOrderBaseVO { | ||
| 22 | private String no; | 22 | private String no; |
| 23 | 23 | ||
| 24 | @Schema(description = "下单时间", required = true) | 24 | @Schema(description = "下单时间", required = true) |
| 25 | - private Date createTime; | 25 | + private LocalDateTime createTime; |
| 26 | 26 | ||
| 27 | @Schema(description = "订单类型", required = true, example = "1") | 27 | @Schema(description = "订单类型", required = true, example = "1") |
| 28 | private Integer type; | 28 | private Integer type; |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/sms/SmsCodeDO.java
yudao-ui-admin/src/views/login.vue
| @@ -52,11 +52,12 @@ | @@ -52,11 +52,12 @@ | ||
| 52 | </el-form-item> | 52 | </el-form-item> |
| 53 | <el-form-item prop="mobileCode"> | 53 | <el-form-item prop="mobileCode"> |
| 54 | <el-input v-model="loginForm.mobileCode" type="text" auto-complete="off" placeholder="短信验证码" | 54 | <el-input v-model="loginForm.mobileCode" type="text" auto-complete="off" placeholder="短信验证码" |
| 55 | + class="sms-login-mobile-code-prefix" | ||
| 55 | @keyup.enter.native="handleLogin"> | 56 | @keyup.enter.native="handleLogin"> |
| 56 | - <template v-slot="icon"> | 57 | + <template> |
| 57 | <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon"/> | 58 | <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon"/> |
| 58 | </template> | 59 | </template> |
| 59 | - <template v-slot="append"> | 60 | + <template slot="append"> |
| 60 | <span v-if="mobileCodeTimer <= 0" class="getMobileCode" @click="getSmsCode" style="cursor: pointer;">获取验证码</span> | 61 | <span v-if="mobileCodeTimer <= 0" class="getMobileCode" @click="getSmsCode" style="cursor: pointer;">获取验证码</span> |
| 61 | <span v-if="mobileCodeTimer > 0" class="getMobileCode">{{ mobileCodeTimer }}秒后可重新获取</span> | 62 | <span v-if="mobileCodeTimer > 0" class="getMobileCode">{{ mobileCodeTimer }}秒后可重新获取</span> |
| 62 | </template> | 63 | </template> |
| @@ -335,4 +336,9 @@ export default { | @@ -335,4 +336,9 @@ export default { | ||
| 335 | text-decoration: underline red; | 336 | text-decoration: underline red; |
| 336 | color: red; | 337 | color: red; |
| 337 | } | 338 | } |
| 339 | +.sms-login-mobile-code-prefix { | ||
| 340 | + :deep(.el-input__prefix) { | ||
| 341 | + top: 22%; | ||
| 342 | + } | ||
| 343 | +} | ||
| 338 | </style> | 344 | </style> |