Compare commits
27
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a150f9e017 | ||
|
|
ecd2fa1c33 | ||
|
|
e3236d262d | ||
|
|
c8e2e16ba5 | ||
|
|
99b44faf09 | ||
|
|
b3e3cbf84b | ||
|
|
0aee11d824 | ||
|
|
fcf358a768 | ||
|
|
619369104c | ||
|
|
4f1408b9d0 | ||
|
|
029eea70cc | ||
|
|
22b1e65385 | ||
|
|
2170c48763 | ||
|
|
c2d1c48aae | ||
|
|
e14958c643 | ||
|
|
da288338cd | ||
|
|
ea430f2468 | ||
|
|
f76f79744a | ||
|
|
19daaff907 | ||
|
|
db94d8f932 | ||
|
|
53618fe362 | ||
|
|
523edffc4e | ||
|
|
c7ddb1a8b0 | ||
|
|
45c9fc814a | ||
|
|
407dc13ac4 | ||
|
|
0c06bf16c2 | ||
|
|
1db39e77d3 |
@@ -11,7 +11,7 @@
|
||||
|
||||
<groupId>com.imyeyu.timiserverapi</groupId>
|
||||
<artifactId>TimiServerAPI</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.18</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>TimiServerAPI</name>
|
||||
<description>imyeyu.com API</description>
|
||||
@@ -205,11 +205,6 @@
|
||||
<artifactId>timi-utils</artifactId>
|
||||
<version>0.0.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.majiajie</groupId>
|
||||
<artifactId>tinypinyin</artifactId>
|
||||
<version>2.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.imyeyu.font.icon</groupId>
|
||||
<artifactId>timi-icon-font</artifactId>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.imyeyu.java.bean.Language;
|
||||
import com.imyeyu.spring.annotation.table.Column;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -17,18 +15,6 @@ public class Multilingual extends UUIDEntity {
|
||||
|
||||
protected String zhCN;
|
||||
|
||||
@Column("zh_cn_pinyin_full")
|
||||
@JsonIgnore
|
||||
protected String zhCNPinyinFull;
|
||||
|
||||
@Column("zh_cn_pinyin_initial")
|
||||
@JsonIgnore
|
||||
protected String zhCNPinyinInitial;
|
||||
|
||||
@Column("zh_cn_pinyin_mixed")
|
||||
@JsonIgnore
|
||||
protected String zhCNPinyinMixed;
|
||||
|
||||
protected String zhTW;
|
||||
|
||||
protected String enUS;
|
||||
|
||||
-23
@@ -3,7 +3,6 @@ package com.imyeyu.api.modules.common.service.implement;
|
||||
import com.imyeyu.api.modules.common.entity.Multilingual;
|
||||
import com.imyeyu.api.modules.common.mapper.MultilingualMapper;
|
||||
import com.imyeyu.api.modules.common.service.MultilingualService;
|
||||
import com.imyeyu.api.util.PinyinUtil;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import com.imyeyu.spring.util.Redis;
|
||||
@@ -35,18 +34,6 @@ public class MultilingualServiceImplement extends AbstractEntityService<Multilin
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(Multilingual multilingual) {
|
||||
fillPinyin(multilingual);
|
||||
super.create(multilingual);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Multilingual multilingual) {
|
||||
fillPinyin(multilingual);
|
||||
super.update(multilingual);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multilingual get(String id) {
|
||||
Multilingual result = redisLanguage.get(getKey(id));
|
||||
@@ -94,14 +81,4 @@ public class MultilingualServiceImplement extends AbstractEntityService<Multilin
|
||||
private String getKey(String id) {
|
||||
return "%s%s".formatted(KEY_PREFIX, id);
|
||||
}
|
||||
|
||||
private void fillPinyin(Multilingual multilingual) {
|
||||
if (multilingual == null) {
|
||||
return;
|
||||
}
|
||||
String zhCN = multilingual.getZhCN();
|
||||
multilingual.setZhCNPinyinFull(PinyinUtil.full(zhCN));
|
||||
multilingual.setZhCNPinyinInitial(PinyinUtil.initial(zhCN));
|
||||
multilingual.setZhCNPinyinMixed(PinyinUtil.mixed(zhCN));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@ import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.entity.TagApply;
|
||||
import com.imyeyu.api.modules.user.bean.Gender;
|
||||
import com.imyeyu.api.modules.user.entity.User;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.spring.annotation.table.Column;
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import lombok.Data;
|
||||
@@ -61,18 +59,6 @@ public class GaoCustomer extends UUIDEntity {
|
||||
/// 姓名
|
||||
private String name;
|
||||
|
||||
@Column("zh_cn_pinyin_full")
|
||||
@JsonIgnore
|
||||
private String namePinyinFull;
|
||||
|
||||
@Column("zh_cn_pinyin_initial")
|
||||
@JsonIgnore
|
||||
private String namePinyinInitial;
|
||||
|
||||
@Column("zh_cn_pinyin_mixed")
|
||||
@JsonIgnore
|
||||
private String namePinyinMixed;
|
||||
|
||||
/// 性别
|
||||
private Gender gender;
|
||||
|
||||
|
||||
-10
@@ -21,7 +21,6 @@ import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStateReq;
|
||||
import com.imyeyu.api.modules.system.entity.Logger;
|
||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.api.util.PinyinUtil;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
@@ -92,7 +91,6 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
||||
public void create(GaoCustomer customer) {
|
||||
TimiException.required(customer.getName(), "not found customer.name");
|
||||
TimiException.required(customer.getStoreId(), "not found customer.storeId");
|
||||
fillPinyin(customer);
|
||||
|
||||
Logger logger = new Logger(Logger.Module.GAO, "GAO_CUSTOMER_CREATE");
|
||||
try {
|
||||
@@ -171,7 +169,6 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
||||
}
|
||||
}
|
||||
dbCustomer.setName(customer.getName());
|
||||
fillPinyin(dbCustomer);
|
||||
dbCustomer.setGender(customer.getGender());
|
||||
dbCustomer.setAge(customer.getAge());
|
||||
dbCustomer.setBirthdateCalendar(customer.getBirthdateCalendar());
|
||||
@@ -427,11 +424,4 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
||||
customer.setInvitedCount(customer.getInvitedCount() + delta);
|
||||
mapper.update(customer);
|
||||
}
|
||||
|
||||
private void fillPinyin(GaoCustomer customer) {
|
||||
String name = customer.getName();
|
||||
customer.setNamePinyinFull(PinyinUtil.full(name));
|
||||
customer.setNamePinyinInitial(PinyinUtil.initial(name));
|
||||
customer.setNamePinyinMixed(PinyinUtil.mixed(name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.imyeyu.api.util;
|
||||
|
||||
import me.majiajie.tinypinyin.Pinyin;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/// 拼音搜索工具
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-21
|
||||
public final class PinyinUtil {
|
||||
|
||||
private PinyinUtil() {
|
||||
}
|
||||
|
||||
/// 转换为无声调全拼
|
||||
///
|
||||
/// @param value 原始文字
|
||||
/// @return 无声调全拼
|
||||
public static String full(String value) {
|
||||
return convert(value, false, false);
|
||||
}
|
||||
|
||||
/// 转换为拼音首字母
|
||||
///
|
||||
/// @param value 原始文字
|
||||
/// @return 拼音首字母
|
||||
public static String initial(String value) {
|
||||
return convert(value, true, false);
|
||||
}
|
||||
|
||||
/// 转换为首字全拼、后续字首字母的混合拼音
|
||||
///
|
||||
/// @param value 原始文字
|
||||
/// @return 混合拼音
|
||||
public static String mixed(String value) {
|
||||
return convert(value, false, true);
|
||||
}
|
||||
|
||||
private static String convert(String value, boolean initial, boolean mixed) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder result = new StringBuilder(value.length());
|
||||
boolean first = true;
|
||||
for (char character : value.toCharArray()) {
|
||||
if (Character.isWhitespace(character)) {
|
||||
continue;
|
||||
}
|
||||
String pinyin = Pinyin.toPinyin(character).toLowerCase(Locale.ROOT);
|
||||
if (pinyin.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (initial || (mixed && !first)) {
|
||||
result.append(pinyin.charAt(0));
|
||||
} else {
|
||||
result.append(pinyin);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package db.migration.timiserver;
|
||||
|
||||
import com.imyeyu.api.util.PinyinUtil;
|
||||
import org.flywaydb.core.api.migration.BaseJavaMigration;
|
||||
import org.flywaydb.core.api.migration.Context;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
/// 回填拼音搜索字段
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-21
|
||||
public class V37__backfill_pinyin_search extends BaseJavaMigration {
|
||||
|
||||
private static final int BATCH_SIZE = 500;
|
||||
|
||||
@Override
|
||||
public void migrate(Context context) throws Exception {
|
||||
backfillMultilingual(context.getConnection());
|
||||
backfillCustomer(context.getConnection());
|
||||
}
|
||||
|
||||
private void backfillMultilingual(Connection connection) throws Exception {
|
||||
try (PreparedStatement select = connection.prepareStatement("""
|
||||
SELECT `id`, `zh_cn`
|
||||
FROM `multilingual`
|
||||
WHERE `zh_cn` IS NOT NULL
|
||||
AND (`zh_cn_pinyin_full` IS NULL OR `zh_cn_pinyin_initial` IS NULL OR `zh_cn_pinyin_mixed` IS NULL)
|
||||
""");
|
||||
PreparedStatement update = connection.prepareStatement("""
|
||||
UPDATE `multilingual`
|
||||
SET `zh_cn_pinyin_full` = ?, `zh_cn_pinyin_initial` = ?, `zh_cn_pinyin_mixed` = ?
|
||||
WHERE `id` = ?
|
||||
""")) {
|
||||
try (ResultSet resultSet = select.executeQuery()) {
|
||||
int batchSize = 0;
|
||||
while (resultSet.next()) {
|
||||
addMultilingualBatch(update, resultSet.getString("id"), resultSet.getString("zh_cn"));
|
||||
batchSize++;
|
||||
if (batchSize >= BATCH_SIZE) {
|
||||
update.executeBatch();
|
||||
batchSize = 0;
|
||||
}
|
||||
}
|
||||
if (batchSize > 0) {
|
||||
update.executeBatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void backfillCustomer(Connection connection) throws Exception {
|
||||
try (PreparedStatement select = connection.prepareStatement("""
|
||||
SELECT `id`, `name`
|
||||
FROM `gao_customer`
|
||||
WHERE `name` IS NOT NULL
|
||||
AND (`name_pinyin_full` IS NULL OR `name_pinyin_initial` IS NULL OR `name_pinyin_mixed` IS NULL)
|
||||
""");
|
||||
PreparedStatement update = connection.prepareStatement("""
|
||||
UPDATE `gao_customer`
|
||||
SET `name_pinyin_full` = ?, `name_pinyin_initial` = ?, `name_pinyin_mixed` = ?
|
||||
WHERE `id` = ?
|
||||
""")) {
|
||||
try (ResultSet resultSet = select.executeQuery()) {
|
||||
int batchSize = 0;
|
||||
while (resultSet.next()) {
|
||||
addCustomerBatch(update, resultSet.getString("id"), resultSet.getString("name"));
|
||||
batchSize++;
|
||||
if (batchSize >= BATCH_SIZE) {
|
||||
update.executeBatch();
|
||||
batchSize = 0;
|
||||
}
|
||||
}
|
||||
if (batchSize > 0) {
|
||||
update.executeBatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addMultilingualBatch(PreparedStatement update, String id, String value) throws Exception {
|
||||
update.setString(1, PinyinUtil.full(value));
|
||||
update.setString(2, PinyinUtil.initial(value));
|
||||
update.setString(3, PinyinUtil.mixed(value));
|
||||
update.setString(4, id);
|
||||
update.addBatch();
|
||||
}
|
||||
|
||||
private void addCustomerBatch(PreparedStatement update, String id, String value) throws Exception {
|
||||
update.setString(1, PinyinUtil.full(value));
|
||||
update.setString(2, PinyinUtil.initial(value));
|
||||
update.setString(3, PinyinUtil.mixed(value));
|
||||
update.setString(4, id);
|
||||
update.addBatch();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
ALTER TABLE `multilingual`
|
||||
ADD COLUMN `zh_cn_pinyin_full` TEXT NULL COMMENT '简体中文全拼' AFTER `zh_cn`,
|
||||
ADD COLUMN `zh_cn_pinyin_initial` TEXT NULL COMMENT '简体中文拼音首字母' AFTER `zh_cn_pinyin_full`,
|
||||
ADD COLUMN `zh_cn_pinyin_mixed` TEXT NULL COMMENT '简体中文混合拼音' AFTER `zh_cn_pinyin_initial`,
|
||||
ADD KEY `idx_multilingual_zh_cn_pinyin_full` (`zh_cn_pinyin_full`(128)),
|
||||
ADD KEY `idx_multilingual_zh_cn_pinyin_initial` (`zh_cn_pinyin_initial`(128)),
|
||||
ADD KEY `idx_multilingual_zh_cn_pinyin_mixed` (`zh_cn_pinyin_mixed`(128));
|
||||
|
||||
ALTER TABLE `gao_customer`
|
||||
ADD COLUMN `name_pinyin_full` VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '姓名全拼' AFTER `name`,
|
||||
ADD COLUMN `name_pinyin_initial` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '姓名拼音首字母' AFTER `name_pinyin_full`,
|
||||
ADD COLUMN `name_pinyin_mixed` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '姓名混合拼音' AFTER `name_pinyin_initial`,
|
||||
ADD KEY `idx_gao_customer_store_name_pinyin_full` (`store_id`, `deleted_at`, `name_pinyin_full`(128)),
|
||||
ADD KEY `idx_gao_customer_store_name_pinyin_initial` (`store_id`, `deleted_at`, `name_pinyin_initial`),
|
||||
ADD KEY `idx_gao_customer_store_name_pinyin_mixed` (`store_id`, `deleted_at`, `name_pinyin_mixed`);
|
||||
@@ -32,9 +32,6 @@
|
||||
OR `m`.`ja_jp` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `m`.`de_de` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `m`.`ko_kr` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `m`.`zh_cn_pinyin_full` LIKE CONCAT(#{keyword}, '%')
|
||||
OR `m`.`zh_cn_pinyin_initial` LIKE CONCAT(#{keyword}, '%')
|
||||
OR `m`.`zh_cn_pinyin_mixed` LIKE CONCAT(#{keyword}, '%')
|
||||
)
|
||||
</if>
|
||||
AND `t`.`deleted_at` IS NULL
|
||||
|
||||
@@ -29,9 +29,6 @@
|
||||
`c`.`code` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `c`.`name` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `c`.`telephone` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `c`.`name_pinyin_full` LIKE CONCAT(#{keyword}, '%')
|
||||
OR `c`.`name_pinyin_initial` LIKE CONCAT(#{keyword}, '%')
|
||||
OR `c`.`name_pinyin_mixed` LIKE CONCAT(#{keyword}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="tagIdList != null and !tagIdList.isEmpty()">
|
||||
|
||||
Reference in New Issue
Block a user