diff --git a/pom.xml b/pom.xml
index 885b084..b21b79f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
com.imyeyu.timiserverapi
TimiServerAPI
- 1.0.12
+ 1.0.13
jar
TimiServerAPI
imyeyu.com API
diff --git a/src/main/java/com/imyeyu/api/modules/common/entity/Tag.java b/src/main/java/com/imyeyu/api/modules/common/entity/Tag.java
index 32b3af3..db960b7 100644
--- a/src/main/java/com/imyeyu/api/modules/common/entity/Tag.java
+++ b/src/main/java/com/imyeyu/api/modules/common/entity/Tag.java
@@ -14,6 +14,21 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
public class Tag extends UUIDEntity {
+ ///
+ ///
+ /// @author 夜雨
+ /// @since 2026-08-12 16:49
+ public enum OwnerType {
+
+ GAO_STORE
+ }
+
+ /// 归属类型
+ protected OwnerType ownerType;
+
+ /// 归属 ID
+ protected String ownerId;
+
/// 名称多语言 ID
protected String nameLangId;
diff --git a/src/main/java/com/imyeyu/api/modules/common/mapper/TagMapper.java b/src/main/java/com/imyeyu/api/modules/common/mapper/TagMapper.java
index f8e79b5..c0a15e2 100644
--- a/src/main/java/com/imyeyu/api/modules/common/mapper/TagMapper.java
+++ b/src/main/java/com/imyeyu/api/modules/common/mapper/TagMapper.java
@@ -2,6 +2,7 @@ package com.imyeyu.api.modules.common.mapper;
import com.imyeyu.api.modules.common.entity.Tag;
import com.imyeyu.spring.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
@@ -13,4 +14,6 @@ import java.util.List;
public interface TagMapper extends BaseMapper {
List selectByIdList(Collection idList);
+
+ Tag selectByOwnerAndZhCN(@Param("ownerType") Tag.OwnerType ownerType, @Param("ownerId") String ownerId, @Param("zhCN") String zhCN);
}
diff --git a/src/main/java/com/imyeyu/api/modules/common/service/implement/TagServiceImplement.java b/src/main/java/com/imyeyu/api/modules/common/service/implement/TagServiceImplement.java
index 304d1b7..2387a57 100644
--- a/src/main/java/com/imyeyu/api/modules/common/service/implement/TagServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/common/service/implement/TagServiceImplement.java
@@ -40,6 +40,9 @@ public class TagServiceImplement extends AbstractEntityService impl
public void create(Tag tag) {
TimiException.required(tag, "not found tag");
TimiException.required(tag.getZhCN(), "not found tag.zhCN");
+ TimiException.required(tag.getOwnerType(), "not found ownerType");
+ TimiException.required(tag.getOwnerId(), "not found ownerId");
+ checkZhCNUniqueInOwner(tag, null);
tag.setNameLangId(multilingualService.create(tag.getZhCN()));
super.create(tag);
}
@@ -48,12 +51,15 @@ public class TagServiceImplement extends AbstractEntityService impl
public void update(Tag tag) {
TimiException.required(tag, "not found tag");
TimiException.required(tag.getId(), "not found tag.id");
+ Tag dbTag = get(tag.getId());
+ TimiException.required(dbTag, "not found tag");
+ tag.setOwnerType(dbTag.getOwnerType());
+ tag.setOwnerId(dbTag.getOwnerId());
if (tag.getZhCN() != null) {
if (tag.getNameLangId() == null) {
- Tag dbTag = get(tag.getId());
- TimiException.required(dbTag, "not found tag");
tag.setNameLangId(dbTag.getNameLangId());
}
+ checkZhCNUniqueInOwner(tag, tag.getId());
tag.setNameLangId(multilingualService.createIfDifferent(tag.getNameLangId(), tag.getZhCN()));
}
super.update(tag);
@@ -97,4 +103,9 @@ public class TagServiceImplement extends AbstractEntityService impl
example.setBizId(bizId);
return applyMapper.selectAllByExample(example);
}
+
+ private void checkZhCNUniqueInOwner(Tag tag, String allowedId) {
+ Tag existed = mapper.selectByOwnerAndZhCN(tag.getOwnerType(), tag.getOwnerId(), tag.getZhCN());
+ TimiException.requiredTrue(existed == null || existed.getId().equals(allowedId), "该标签名称已存在");
+ }
}
diff --git a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoCustomerController.java b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoCustomerController.java
index e36ffbc..26f399a 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoCustomerController.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoCustomerController.java
@@ -12,6 +12,7 @@ import com.imyeyu.api.modules.gao.service.GaoCustomerService;
import com.imyeyu.api.modules.gao.service.GaoStoreService;
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
+import com.imyeyu.api.modules.gao.vo.GaoCustomerPage;
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStateReq;
import com.imyeyu.api.modules.user.service.RoleChecker;
import com.imyeyu.api.modules.user.service.UserLoginService;
@@ -60,8 +61,8 @@ public class GaoCustomerController {
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
@PostMapping("/list")
@JsonView(ResponseView.Public.class)
- public PageResult list(@RequestBody Page page) {
- PageResult result = service.page(page);
+ public PageResult list(@RequestBody GaoCustomerPage page) {
+ PageResult result = service.pageByQuery(page);
List idList = result.getList().stream().map(GaoCustomer::getId).distinct().toList();
Map> attachmentMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, idList);
diff --git a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoTagController.java b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoTagController.java
new file mode 100644
index 0000000..c3568ad
--- /dev/null
+++ b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoTagController.java
@@ -0,0 +1,139 @@
+package com.imyeyu.api.modules.gao.controller;
+
+import com.fasterxml.jackson.annotation.JsonView;
+import com.imyeyu.api.annotation.RequireCorePermission;
+import com.imyeyu.api.bean.CorePermissionCode;
+import com.imyeyu.api.bean.ModuleCode;
+import com.imyeyu.api.modules.common.entity.Tag;
+import com.imyeyu.api.modules.common.entity.TagApply;
+import com.imyeyu.api.modules.common.service.TagService;
+import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
+import com.imyeyu.api.modules.gao.service.GaoStoreService;
+import com.imyeyu.api.modules.user.service.RoleChecker;
+import com.imyeyu.java.TimiJava;
+import com.imyeyu.java.bean.timi.TimiException;
+import com.imyeyu.spring.annotation.AOPLog;
+import com.imyeyu.spring.annotation.RequestRateLimit;
+import com.imyeyu.spring.bean.Page;
+import com.imyeyu.spring.bean.PageResult;
+import com.imyeyu.spring.util.ResponseView;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/// GAO 标签接口
+///
+/// @author Codex
+/// @since 2026-08-13
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/gao/tag")
+public class GaoTagController {
+
+ private final TagService service;
+ private final RoleChecker roleChecker;
+ private final GaoStoreService storeService;
+
+ /// 查询标签列表
+ ///
+ /// @param page 分页参数
+ /// @return 标签分页
+ @JsonView(ResponseView.Public.class)
+ @RequestRateLimit
+ @RequireCorePermission(CorePermissionCode.TAG_READ)
+ @PostMapping("/list")
+ public PageResult list(@RequestBody Page page) {
+ TimiException.required(page, "未找到分页参数");
+ page.setEqualsExample(TimiJava.defaultIfNull(page.getEqualsExample(), new Tag()));
+ page.getEqualsExample().setOwnerType(Tag.OwnerType.GAO_STORE);
+ if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
+ page.getEqualsExample().setOwnerId(storeService.getBelongIdByRequiredLoginUserId());
+ }
+ return service.page(page);
+ }
+
+ /// 查询标签详情
+ ///
+ /// @param id 标签 ID
+ /// @return 标签详情
+ @JsonView(ResponseView.Public.class)
+ @RequestRateLimit
+ @RequireCorePermission(CorePermissionCode.TAG_READ)
+ @PostMapping("/detail")
+ public Tag detail(@RequestParam String id) {
+ return service.get(id);
+ }
+
+ /// 创建标签
+ ///
+ /// @param tag 标签
+ /// @return 标签
+ @AOPLog
+ @JsonView(ResponseView.Public.class)
+ @RequestRateLimit
+ @RequireCorePermission(CorePermissionCode.TAG_CREATE)
+ @PostMapping("/create")
+ public Tag create(@RequestBody Tag tag) {
+ tag.setOwnerType(Tag.OwnerType.GAO_STORE);
+ if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
+ tag.setOwnerId(storeService.getBelongIdByRequiredLoginUserId());
+ }
+ service.create(tag);
+ return tag;
+ }
+
+ /// 更新标签
+ ///
+ /// @param tag 标签
+ @AOPLog
+ @RequestRateLimit
+ @RequireCorePermission(CorePermissionCode.TAG_UPDATE)
+ @PostMapping("/update")
+ public void update(@RequestBody Tag tag) {
+ Tag dbTag = service.get(tag.getId());
+ tag.setOwnerType(dbTag.getOwnerType());
+ tag.setOwnerId(dbTag.getOwnerId());
+ service.update(tag);
+ }
+
+ /// 删除标签
+ ///
+ /// @param id 标签 ID
+ @AOPLog
+ @RequestRateLimit
+ @RequireCorePermission(CorePermissionCode.TAG_DELETE)
+ @PostMapping("/delete")
+ public void delete(@RequestParam String id) {
+ service.delete(id);
+ }
+
+ /// 按业务查询标签
+ ///
+ /// @param bizType 业务类型
+ /// @param bizId 业务 ID
+ /// @return 标签列表
+ @JsonView(ResponseView.Public.class)
+ @RequestRateLimit
+ @RequireCorePermission(CorePermissionCode.TAG_READ)
+ @GetMapping("/list/biz/id")
+ public List listByBizType(@RequestParam TagApply.BizType bizType, @RequestParam String bizId) {
+ return service.listByBizType(bizType, bizId);
+ }
+
+ /// 差分保存业务标签
+ ///
+ /// @param apply 标签请求
+ @AOPLog
+ @RequestRateLimit
+ @RequireCorePermission(CorePermissionCode.TAG_APPLY)
+ @PostMapping("/apply")
+ public void apply(@RequestBody TagApply apply) {
+ service.apply(apply.getBizType(), apply.getBizId(), apply.getTagIdList());
+ }
+}
diff --git a/src/main/java/com/imyeyu/api/modules/gao/mapper/GaoCustomerMapper.java b/src/main/java/com/imyeyu/api/modules/gao/mapper/GaoCustomerMapper.java
index cde3fac..22824b9 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/mapper/GaoCustomerMapper.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/mapper/GaoCustomerMapper.java
@@ -3,6 +3,7 @@ package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
+import com.imyeyu.api.modules.gao.vo.GaoCustomerPage;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
@@ -35,4 +36,16 @@ public interface GaoCustomerMapper extends BaseMapper {
///
/// @return 性别统计列表
List stateGender(@Param("storeId") String storeId);
+
+ /// 查询客户总数
+ ///
+ /// @param page 查询条件
+ /// @return 客户总数
+ long countByQuery(GaoCustomerPage page);
+
+ /// 分页查询客户
+ ///
+ /// @param page 查询条件
+ /// @return 客户列表
+ List selectByQuery(GaoCustomerPage page);
}
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/GaoCustomerService.java b/src/main/java/com/imyeyu/api/modules/gao/service/GaoCustomerService.java
index 2c15d7a..7e9c9b2 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/GaoCustomerService.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/GaoCustomerService.java
@@ -3,8 +3,10 @@ package com.imyeyu.api.modules.gao.service;
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
+import com.imyeyu.api.modules.gao.vo.GaoCustomerPage;
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStateReq;
import com.imyeyu.spring.bean.Page;
+import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.service.BaseService;
import java.io.IOException;
@@ -19,6 +21,12 @@ import java.util.stream.Collectors;
/// @since 2026-07-27 14:12
public interface GaoCustomerService extends BaseService {
+ /// 按查询条件分页查询客户
+ ///
+ /// @param page 查询条件
+ /// @return 客户分页
+ PageResult pageByQuery(GaoCustomerPage page);
+
void updateWithAttachment(GaoCustomer customer);
/// 按编码查询客户
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoCustomerServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoCustomerServiceImplement.java
index 8b258ee..30a2289 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoCustomerServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoCustomerServiceImplement.java
@@ -10,6 +10,7 @@ import com.imyeyu.api.modules.gao.service.GaoCustomerService;
import com.imyeyu.api.modules.gao.util.CustomerXSSFBuilder;
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
+import com.imyeyu.api.modules.gao.vo.GaoCustomerPage;
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStateReq;
import com.imyeyu.api.modules.system.entity.Logger;
import com.imyeyu.api.modules.system.service.LoggerService;
@@ -18,6 +19,7 @@ import com.imyeyu.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiCode;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.bean.Page;
+import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.mapper.BaseMapper;
import com.imyeyu.spring.service.AbstractEntityService;
import lombok.RequiredArgsConstructor;
@@ -65,6 +67,15 @@ public class GaoCustomerServiceImplement extends AbstractEntityService pageByQuery(GaoCustomerPage page) {
+ TimiException.required(page, "not found page");
+ PageResult result = new PageResult<>();
+ result.setTotal(mapper.countByQuery(page));
+ result.setList(mapper.selectByQuery(page));
+ return result;
+ }
+
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void create(GaoCustomer customer) {
diff --git a/src/main/java/com/imyeyu/api/modules/gao/vo/GaoCustomerPage.java b/src/main/java/com/imyeyu/api/modules/gao/vo/GaoCustomerPage.java
new file mode 100644
index 0000000..bedfe0e
--- /dev/null
+++ b/src/main/java/com/imyeyu/api/modules/gao/vo/GaoCustomerPage.java
@@ -0,0 +1,25 @@
+package com.imyeyu.api.modules.gao.vo;
+
+import com.imyeyu.java.bean.BasePage;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/// GAO 客户分页查询请求
+///
+/// @author Codex
+/// @since 2026-08-13
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class GaoCustomerPage extends BasePage {
+
+ /// 门店 ID
+ private String storeId;
+
+ /// 关键字,匹配编码、姓名、电话
+ private String keyword;
+
+ /// 标签 ID 列表,客户必须同时拥有列表内全部标签
+ private List tagIdList;
+}
diff --git a/src/main/java/com/imyeyu/api/modules/system/controller/FileController.java b/src/main/java/com/imyeyu/api/modules/system/controller/FileController.java
index 4111308..a6da743 100644
--- a/src/main/java/com/imyeyu/api/modules/system/controller/FileController.java
+++ b/src/main/java/com/imyeyu/api/modules/system/controller/FileController.java
@@ -143,7 +143,7 @@ public class FileController implements TimiJava, OS.FileSystem {
public void read(HttpServletRequest req, HttpServletResponse resp) {
try {
String path = req.getServletPath().substring("/system/file/read".length());
- path = "E:\\IDEAProject\\TimiServerAPI\\data\\file" + path;
+ path = "/root/bin/data/mnt" + path;
if (TimiJava.isEmpty(path)) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
diff --git a/src/main/resources/db/migration/timiserver/V31__add_tag_owner_scope.sql b/src/main/resources/db/migration/timiserver/V31__add_tag_owner_scope.sql
new file mode 100644
index 0000000..aa38003
--- /dev/null
+++ b/src/main/resources/db/migration/timiserver/V31__add_tag_owner_scope.sql
@@ -0,0 +1,18 @@
+-- 历史标签统一归入迁移时创建的默认门店。
+SET @gao_default_store_id = '00000000-0000-0000-0000-000000000001';
+
+ALTER TABLE `tag`
+ ADD COLUMN `owner_type` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '归属类型' AFTER `id`,
+ ADD COLUMN `owner_id` VARCHAR(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '归属门店 ID' AFTER `owner_type`;
+
+UPDATE `tag`
+SET
+ `owner_type` = 'GAO_STORE',
+ `owner_id` = @gao_default_store_id
+WHERE `owner_type` IS NULL
+ OR `owner_id` IS NULL;
+
+ALTER TABLE `tag`
+ MODIFY COLUMN `owner_type` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '归属类型',
+ MODIFY COLUMN `owner_id` VARCHAR(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '归属门店 ID',
+ ADD KEY `idx_tag_owner` (`owner_type`, `owner_id`, `deleted_at`);
diff --git a/src/main/resources/mapper/timi-server/common/TagMapper.xml b/src/main/resources/mapper/timi-server/common/TagMapper.xml
index 0b8518a..60dc131 100644
--- a/src/main/resources/mapper/timi-server/common/TagMapper.xml
+++ b/src/main/resources/mapper/timi-server/common/TagMapper.xml
@@ -18,4 +18,18 @@
AND `deleted_at` IS NULL
+
diff --git a/src/main/resources/mapper/timi-server/gao/GaoCustomerMapper.xml b/src/main/resources/mapper/timi-server/gao/GaoCustomerMapper.xml
index ae69942..4352626 100644
--- a/src/main/resources/mapper/timi-server/gao/GaoCustomerMapper.xml
+++ b/src/main/resources/mapper/timi-server/gao/GaoCustomerMapper.xml
@@ -19,6 +19,52 @@
AND `deleted_at` IS NULL
+
+ `c`.`deleted_at` IS NULL
+
+ AND `c`.`store_id` = #{storeId}
+
+
+ AND (
+ `c`.`code` LIKE CONCAT('%', #{keyword}, '%')
+ OR `c`.`name` LIKE CONCAT('%', #{keyword}, '%')
+ OR `c`.`telephone` LIKE CONCAT('%', #{keyword}, '%')
+ )
+
+
+
+ AND `c`.`id` IN (
+ SELECT `ta`.`biz_id`
+ FROM `tag_apply` `ta`
+ WHERE
+ `ta`.`biz_type` = 'GAO_CUSTOMER'
+ AND `ta`.`tag_id` IN
+
+ #{tagId}
+
+ AND `ta`.`deleted_at` IS NULL
+ GROUP BY `ta`.`biz_id`
+ HAVING COUNT(DISTINCT `ta`.`tag_id`) = #{tagCount}
+ )
+
+
+
+
+
+
+