From 417a3e427bf2b35b88f995717fb829436c07fb0d Mon Sep 17 00:00:00 2001 From: Colorful Date: Sun, 20 Nov 2022 21:56:13 +0800 Subject: [PATCH] Dev (#303) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refactor/replace deprecated usage (#236) * chore: 修正README锚点不跳转的问题 * fix:#190 * fix:#184 * chore(deps-dev): bump freemarker from 2.3.30 to 2.3.31 Bumps freemarker from 2.3.30 to 2.3.31. Signed-off-by: dependabot[bot] * chore(deps): bump lin-cms-spring-boot-starter Bumps [lin-cms-spring-boot-starter](https://github.com/TaleLin/lin-cms-java-core) from 0.2.0-RC2 to 0.2.0-RELEASE. - [Release notes](https://github.com/TaleLin/lin-cms-java-core/releases) - [Commits](https://github.com/TaleLin/lin-cms-java-core/commits) Signed-off-by: dependabot[bot] * Chore/upgrade version (#200) * chore: 修正README锚点不跳转的问题 * fix:#190 * fix:#184 * chore: 升级主工程以及核心库版本号 Co-authored-by: ToWeLong <1191430240@qq.com> * chore(deps): bump spring-boot-starter-parent from 2.4.3 to 2.5.0 Bumps [spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) from 2.4.3 to 2.5.0. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v2.4.3...v2.5.0) Signed-off-by: dependabot[bot] * Dev (#226) * chore(deps): bump spring-boot-starter-parent from 2.5.0 to 2.5.2 (#220) Bumps [spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) from 2.5.0 to 2.5.2. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v2.5.0...v2.5.2) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-parent dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * refactor: optimize ci action config * Update maven.yml * Update maven.yml * fix issue #131 * chore(deps): bump qiniu-java-sdk from 7.4.0 to 7.8.0 Bumps [qiniu-java-sdk](https://github.com/qiniu/java-sdk) from 7.4.0 to 7.8.0. - [Release notes](https://github.com/qiniu/java-sdk/releases) - [Changelog](https://github.com/qiniu/java-sdk/blob/master/CHANGELOG.md) - [Commits](https://github.com/qiniu/java-sdk/compare/v7.4.0...v7.8.0) --- updated-dependencies: - dependency-name: com.qiniu:qiniu-java-sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Chore/replace expired configurations (#222) * chore: 修正README锚点不跳转的问题 * fix:#190 * fix:#184 * chore: 替换过期的配置项 * test: 临时解决 CI 单元测试异常(原因未明) Co-authored-by: ToWeLong <1191430240@qq.com> Co-authored-by: 华钦 * Docs/upgrade readme (#225) * chore: 修正README锚点不跳转的问题 * fix:#190 * fix:#184 * docs: 更新 readme 中 springboot 版本号 Co-authored-by: ToWeLong <1191430240@qq.com> Co-authored-by: 华钦 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dengliming Co-authored-by: fuhao Co-authored-by: ToWeLong <1191430240@qq.com> Co-authored-by: 华钦 * refactor: 替换jackson已过期的配置引用 Co-authored-by: ToWeLong <1191430240@qq.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 华钦 Co-authored-by: dengliming Co-authored-by: fuhao * chore(pom.xml): 升级框架版本为0.2.1-RELEASE * fix #223 & test去除deprecated api等问题修复 * fix: #247 * fix: 反代后IP获取错误 * feat: 登录验证码 * fix: 无用字段 * fix: 不开启验证码时要求header的错误 * fix: sout clean * fix: aes192 to 256 * fix: 修复错误修改的配置 * fix: 增加aes配置校验,避免输入参数不合法 * fix: 部分情况下fileMap.size()不可靠&校验信息不需要${} * fix: 属性前缀 * fix: fix #264 配置文件中未配置字段时,spring不会调用set方法 * chore(application-dev.yml): 默认关闭验证码 * refactor: 数据库新增 is_deleted 字段,作为删除标识 Co-authored-by: ToWeLong <1191430240@qq.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 华钦 Co-authored-by: dengliming Co-authored-by: fuhao Co-authored-by: Gadfly --- .../configuration/LoginCaptchaProperties.java | 6 ++---- .../talelin/latticy/model/BaseModel.java | 5 ++++- .../latticy/module/file/AbstractUploader.java | 9 ++++++++- .../resources/ValidationMessages.properties | 2 +- src/main/resources/application-dev.yml | 2 +- src/main/resources/application.yml | 4 ++-- src/main/resources/code-message.properties | 2 +- src/main/resources/mapper/BookMapper.xml | 5 +++-- src/main/resources/mapper/FileMapper.xml | 5 +++-- src/main/resources/mapper/GroupMapper.xml | 14 +++++++------- src/main/resources/mapper/LogMapper.xml | 7 ++++--- .../resources/mapper/PermissionMapper.xml | 7 ++++--- src/main/resources/mapper/UserMapper.xml | 7 ++++--- src/main/resources/schema.sql | 19 +++++++++++++------ src/test/resources/h2-test.sql | 7 +++++++ 15 files changed, 64 insertions(+), 37 deletions(-) diff --git a/src/main/java/io/github/talelin/latticy/common/configuration/LoginCaptchaProperties.java b/src/main/java/io/github/talelin/latticy/common/configuration/LoginCaptchaProperties.java index d5a24b51..fb7c9a13 100644 --- a/src/main/java/io/github/talelin/latticy/common/configuration/LoginCaptchaProperties.java +++ b/src/main/java/io/github/talelin/latticy/common/configuration/LoginCaptchaProperties.java @@ -20,18 +20,17 @@ public class LoginCaptchaProperties { /** * aes 密钥 */ - private String secret; + private String secret = CaptchaUtil.getRandomString(32); /** * aes 偏移量 */ - private String iv; + private String iv = CaptchaUtil.getRandomString(16); /** * 启用验证码 */ private Boolean enabled = Boolean.FALSE; public void setSecret(String secret) { - this.secret = CaptchaUtil.getRandomString(32); if (StringUtils.hasText(secret)) { byte[] bytes = secret.getBytes(); if (bytes.length == 16 || bytes.length == 24 || bytes.length == 32) { @@ -43,7 +42,6 @@ public void setSecret(String secret) { } public void setIv(String iv) { - this.iv = CaptchaUtil.getRandomString(16); if (StringUtils.hasText(iv)) { byte[] bytes = iv.getBytes(); if (bytes.length == 16) { diff --git a/src/main/java/io/github/talelin/latticy/model/BaseModel.java b/src/main/java/io/github/talelin/latticy/model/BaseModel.java index 9b672be5..d92e147f 100644 --- a/src/main/java/io/github/talelin/latticy/model/BaseModel.java +++ b/src/main/java/io/github/talelin/latticy/model/BaseModel.java @@ -22,7 +22,10 @@ public class BaseModel { @JsonIgnore private Date updateTime; - @TableLogic @JsonIgnore private Date deleteTime; + + @TableLogic + @JsonIgnore + private Boolean isDeleted; } diff --git a/src/main/java/io/github/talelin/latticy/module/file/AbstractUploader.java b/src/main/java/io/github/talelin/latticy/module/file/AbstractUploader.java index f738b1bc..b0f3f5ab 100644 --- a/src/main/java/io/github/talelin/latticy/module/file/AbstractUploader.java +++ b/src/main/java/io/github/talelin/latticy/module/file/AbstractUploader.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; /** * 文件上传类的基类 @@ -128,7 +129,13 @@ protected void checkFileMap(MultiValueMap fileMap) { throw new NotFoundException(10026); } int nums = getFileProperties().getNums(); - if (fileMap.size() > nums) { + AtomicInteger sizes = new AtomicInteger(); + fileMap.keySet().forEach(key -> fileMap.get(key).forEach(file -> { + if (!file.isEmpty()) { + sizes.getAndIncrement(); + } + })); + if (sizes.get() > nums) { throw new FileTooManyException(10121); } } diff --git a/src/main/resources/ValidationMessages.properties b/src/main/resources/ValidationMessages.properties index b42f97c1..b209f4c8 100644 --- a/src/main/resources/ValidationMessages.properties +++ b/src/main/resources/ValidationMessages.properties @@ -1,7 +1,7 @@ # \u901A\u7528\u5F02\u5E38\u4FE1\u606F id.positive=id\u5FC5\u987B\u4E3A\u6B63\u6574\u6570 page.count.min=\u5206\u9875\u6570\u91CF\u5FC5\u987B\u4E3A\u6B63\u6574\u6570 -page.count.max=\u5206\u9875\u6570\u91CF\u5FC5\u987B\u5C0F\u4E8E${value} +page.count.max=\u5206\u9875\u6570\u91CF\u5FC5\u987B\u5C0F\u4E8E{value} page.number.min=\u5206\u9875\u9875\u7801\u5FC5\u987B\u4E3A\u6B63\u6574\u6570 # \u5206\u7EC4\u5F02\u5E38\u4FE1\u606F group.id.positive=\u5206\u7EC4id\u5FC5\u987B\u4E3A\u6B63\u6574\u6570 diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index e5ff737c..7fb07f12 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -20,7 +20,7 @@ auth: # 开启登录要求验证码 login-captcha: - enabled: true + enabled: false secret: "m49CPM5ak@MDXTzbbT_ZEyMM3KBsBn!h" # 开启http请求日志记录 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fe30c011..a8e7b89a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -25,8 +25,8 @@ mybatis-plus: banner: false db-config: # 逻辑删除(软删除) - logic-delete-value: NOW() - logic-not-delete-value: 'NULL' + logic-delete-value: 1 + logic-not-delete-value: 0 # mapper路径位置 mapper-locations: classpath:mapper/*.xml diff --git a/src/main/resources/code-message.properties b/src/main/resources/code-message.properties index daf33132..07b5c90a 100644 --- a/src/main/resources/code-message.properties +++ b/src/main/resources/code-message.properties @@ -55,7 +55,7 @@ code-message[10080]=\u8BF7\u6C42\u65B9\u6CD5\u4E0D\u5141\u8BB8 code-message[10100]=\u5237\u65B0\u4EE4\u724C\u83B7\u53D6\u5931\u8D25 code-message[10110]=\u6587\u4EF6\u4F53\u79EF\u8FC7\u5927 code-message[10120]=\u6587\u4EF6\u6570\u91CF\u8FC7\u591A -code-message[10121]=\u6587\u4EF6\u592A\u591A\uFF0C\u6587\u4EF6\u603B\u6570\u4E0D\u53EF\u8D85\u8FC7${file.nums} +code-message[10121]=\u6587\u4EF6\u592A\u591A\uFF0C\u6587\u4EF6\u603B\u6570\u4E0D\u53EF\u8D85\u8FC7${lin.file.nums} code-message[10130]=\u6587\u4EF6\u6269\u5C55\u540D\u4E0D\u7B26\u5408\u89C4\u8303 code-message[10140]=\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5 code-message[10150]=\u4E22\u5931\u53C2\u6570 diff --git a/src/main/resources/mapper/BookMapper.xml b/src/main/resources/mapper/BookMapper.xml index 3da0f20f..0105be61 100644 --- a/src/main/resources/mapper/BookMapper.xml +++ b/src/main/resources/mapper/BookMapper.xml @@ -11,6 +11,7 @@ + @@ -20,7 +21,7 @@ WHERE b.title LIKE #{q} AND - b.delete_time IS NULL + b.is_deleted = 0 \ No newline at end of file diff --git a/src/main/resources/mapper/FileMapper.xml b/src/main/resources/mapper/FileMapper.xml index d51e9075..a9f37324 100644 --- a/src/main/resources/mapper/FileMapper.xml +++ b/src/main/resources/mapper/FileMapper.xml @@ -14,6 +14,7 @@ + diff --git a/src/main/resources/mapper/GroupMapper.xml b/src/main/resources/mapper/GroupMapper.xml index 5f979713..904d9401 100644 --- a/src/main/resources/mapper/GroupMapper.xml +++ b/src/main/resources/mapper/GroupMapper.xml @@ -10,7 +10,7 @@ - + @@ -19,7 +19,7 @@ g.create_time,g.update_time,g.delete_time from lin_group AS g WHERE - g.delete_time IS NULL + g.is_deleted = 0 AND g.id IN ( @@ -28,7 +28,7 @@ LEFT JOIN lin_user_group as ug ON ug.user_id = u.id WHERE u.id = #{userId} - AND u.delete_time IS NULL + AND u.is_deleted = 0 ) @@ -36,7 +36,7 @@ SELECT g.id from lin_group AS g WHERE - g.delete_time IS NULL + g.is_deleted = 0 AND g.id IN ( @@ -45,12 +45,12 @@ LEFT JOIN lin_user_group as ug ON ug.user_id = u.id WHERE u.id = #{userId} - AND u.delete_time IS NULL + AND u.is_deleted = 0 ) diff --git a/src/main/resources/mapper/LogMapper.xml b/src/main/resources/mapper/LogMapper.xml index a7090228..69d58f74 100644 --- a/src/main/resources/mapper/LogMapper.xml +++ b/src/main/resources/mapper/LogMapper.xml @@ -15,11 +15,12 @@ + SELECT l.* FROM lin_log l - WHERE l.delete_time IS NULL + WHERE l.is_deleted = 0 AND l.username=#{name} @@ -47,7 +48,7 @@ diff --git a/src/main/resources/mapper/PermissionMapper.xml b/src/main/resources/mapper/PermissionMapper.xml index 4b12f5e8..4df0293d 100644 --- a/src/main/resources/mapper/PermissionMapper.xml +++ b/src/main/resources/mapper/PermissionMapper.xml @@ -11,6 +11,7 @@ + - SELECT COUNT(*) FROM lin_user as u WHERE u.username = #{username} AND u.delete_time IS NULL + SELECT COUNT(*) FROM lin_user as u WHERE u.username = #{username} AND u.is_deleted = 0 diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index ed9436d0..5100cd9e 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -17,6 +17,7 @@ CREATE TABLE lin_file create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id), UNIQUE KEY md5_del (md5, delete_time) ) ENGINE = InnoDB @@ -40,6 +41,7 @@ CREATE TABLE lin_log create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 @@ -57,7 +59,8 @@ CREATE TABLE lin_permission mount tinyint(1) NOT NULL DEFAULT 1 COMMENT '0:关闭 1:开启', create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - delete_time datetime(3) DEFAULT NULL, + delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 @@ -76,6 +79,7 @@ CREATE TABLE lin_group create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id), UNIQUE KEY name_del (name, delete_time) ) ENGINE = InnoDB @@ -111,6 +115,7 @@ CREATE TABLE lin_user create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id), UNIQUE KEY username_del (username, delete_time), UNIQUE KEY email_del (email, delete_time) @@ -120,11 +125,11 @@ CREATE TABLE lin_user -- ---------------------------- -- 用户授权信息表 -# id -# user_id -# identity_type 登录类型(手机号 邮箱 用户名)或第三方应用名称(微信 微博等) -# identifier 标识(手机号 邮箱 用户名或第三方应用的唯一标识) -# credential 密码凭证(站内的保存密码,站外的不保存或保存token) +-- id +-- user_id +-- identity_type 登录类型(手机号 邮箱 用户名)或第三方应用名称(微信 微博等) +-- identifier 标识(手机号 邮箱 用户名或第三方应用的唯一标识) +-- credential 密码凭证(站内的保存密码,站外的不保存或保存token) -- ---------------------------- DROP TABLE IF EXISTS lin_user_identity; CREATE TABLE lin_user_identity @@ -137,6 +142,7 @@ CREATE TABLE lin_user_identity create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 @@ -172,6 +178,7 @@ CREATE TABLE book create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 diff --git a/src/test/resources/h2-test.sql b/src/test/resources/h2-test.sql index d34ec581..1836c55b 100644 --- a/src/test/resources/h2-test.sql +++ b/src/test/resources/h2-test.sql @@ -9,6 +9,7 @@ CREATE TABLE book create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -26,6 +27,7 @@ CREATE TABLE lin_file create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id), UNIQUE KEY md5_del (md5, delete_time) ) ENGINE = InnoDB @@ -45,6 +47,7 @@ CREATE TABLE lin_log create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -62,6 +65,7 @@ CREATE TABLE lin_permission create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -79,6 +83,7 @@ CREATE TABLE lin_group create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id), UNIQUE KEY name_del (name, delete_time) ) ENGINE = InnoDB @@ -111,6 +116,7 @@ CREATE TABLE lin_user create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id), UNIQUE KEY username_del (username, delete_time), UNIQUE KEY email_del (email, delete_time) @@ -128,6 +134,7 @@ CREATE TABLE lin_user_identity create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, + is_deleted tinyint(1) DEFAULT 0, PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;