diff --git a/pom.xml b/pom.xml
index a77ebe1..75960a9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -173,7 +173,7 @@
com.imyeyu.spring
timi-spring
- 0.0.18
+ 0.0.19
com.imyeyu.network
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 d237a78..21a7452 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
@@ -1,6 +1,7 @@
package com.imyeyu.api.modules.gao.controller;
import com.fasterxml.jackson.annotation.JsonView;
+import com.imyeyu.api.bean.ModuleCode;
import com.imyeyu.api.bean.RoleMatchMode;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.service.AttachmentService;
@@ -10,9 +11,12 @@ import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
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.GaoCustomerTrendStateReq;
+import com.imyeyu.api.modules.user.service.RoleChecker;
+import com.imyeyu.api.modules.user.service.UserLoginService;
import com.imyeyu.api.modules.user.service.UserService;
import com.imyeyu.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiException;
@@ -42,14 +46,17 @@ import java.util.Map;
/// @author 夜雨
/// @since 2026-07-27 14:12
@RestController
-@RequireGaoRole(value = {GaoRoleCode.STORE_MANAGER, GaoRoleCode.EMPLOYEE}, mode = RoleMatchMode.ANY)
+@RequireGaoRole(value = {GaoRoleCode.GLOBAL_MANAGER, GaoRoleCode.STORE_MANAGER, GaoRoleCode.EMPLOYEE}, mode = RoleMatchMode.ANY)
@RequiredArgsConstructor
@RequestMapping("/gao/customer")
public class GaoCustomerController {
private final UserService userService;
+ private final RoleChecker roleChecker;
private final AttachmentService attachmentService;
private final GaoCustomerService service;
+ private final GaoStoreService gaoStoreService;
+ private final UserLoginService userLoginService;
@AOPLog
@RequestRateLimit
@@ -92,6 +99,9 @@ public class GaoCustomerController {
@PostMapping("/create")
@JsonView(ResponseView.Public.class)
public String create(@RequestBody GaoCustomer customer) {
+ if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
+ customer.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
+ }
service.create(customer);
return customer.getId();
}
@@ -101,6 +111,9 @@ public class GaoCustomerController {
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE)
@PostMapping("/update")
public void update(@RequestBody GaoCustomer customer) {
+ if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
+ customer.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
+ }
service.updateWithAttachment(customer);
}
diff --git a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoEventController.java b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoEventController.java
index 08a19d2..cdd4456 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoEventController.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoEventController.java
@@ -1,5 +1,6 @@
package com.imyeyu.api.modules.gao.controller;
+import com.imyeyu.api.bean.ModuleCode;
import com.imyeyu.api.bean.RoleMatchMode;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.annotation.RequireGaoRole;
@@ -7,6 +8,9 @@ import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
import com.imyeyu.api.modules.gao.entity.GaoEvent;
import com.imyeyu.api.modules.gao.service.GaoEventService;
+import com.imyeyu.api.modules.gao.service.GaoStoreService;
+import com.imyeyu.api.modules.user.service.RoleChecker;
+import com.imyeyu.api.modules.user.service.UserLoginService;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.Page;
@@ -26,12 +30,15 @@ import java.util.Map;
/// @author 夜雨
/// @since 2026-07-27 14:13
@RestController
-@RequireGaoRole(value = {GaoRoleCode.STORE_MANAGER, GaoRoleCode.EMPLOYEE}, mode = RoleMatchMode.ANY)
+@RequireGaoRole(value = {GaoRoleCode.GLOBAL_MANAGER, GaoRoleCode.STORE_MANAGER, GaoRoleCode.EMPLOYEE}, mode = RoleMatchMode.ANY)
@RequiredArgsConstructor
@RequestMapping("/gao/event")
public class GaoEventController {
private final GaoEventService service;
+ private final RoleChecker roleChecker;
+ private final GaoStoreService gaoStoreService;
+ private final UserLoginService userLoginService;
@AOPLog
@RequestRateLimit
@@ -65,16 +72,22 @@ public class GaoEventController {
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.EVENT_CREATE)
@PostMapping("/create")
- public void create(@RequestBody GaoEvent registrationEvent) {
- service.create(registrationEvent);
+ public void create(@RequestBody GaoEvent event) {
+ if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
+ event.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
+ }
+ service.create(event);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.EVENT_UPDATE)
@PostMapping("/update")
- public void update(@RequestBody GaoEvent registrationEvent) {
- service.update(registrationEvent);
+ public void update(@RequestBody GaoEvent event) {
+ if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
+ event.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
+ }
+ service.update(event);
}
@AOPLog
diff --git a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoEventRecordController.java b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoEventRecordController.java
index 427c534..571ff8e 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoEventRecordController.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoEventRecordController.java
@@ -1,6 +1,7 @@
package com.imyeyu.api.modules.gao.controller;
import com.fasterxml.jackson.annotation.JsonView;
+import com.imyeyu.api.bean.ModuleCode;
import com.imyeyu.api.bean.RoleMatchMode;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.service.AttachmentService;
@@ -14,10 +15,14 @@ import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
import com.imyeyu.api.modules.gao.service.GaoEventRecordService;
import com.imyeyu.api.modules.gao.service.GaoEventService;
+import com.imyeyu.api.modules.gao.service.GaoStoreService;
import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordPage;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordRankPage;
+import com.imyeyu.api.modules.user.service.RoleChecker;
+import com.imyeyu.api.modules.user.service.UserLoginService;
import com.imyeyu.api.modules.user.service.UserService;
+import com.imyeyu.java.TimiJava;
import com.imyeyu.network.Network;
import com.imyeyu.spring.TimiSpring;
import com.imyeyu.spring.annotation.AOPLog;
@@ -43,16 +48,19 @@ import java.util.Map;
/// @author 夜雨
/// @since 2026-07-27 14:11
@RestController
-@RequireGaoRole(value = {GaoRoleCode.STORE_MANAGER, GaoRoleCode.EMPLOYEE}, mode = RoleMatchMode.ANY)
+@RequireGaoRole(value = {GaoRoleCode.GLOBAL_MANAGER, GaoRoleCode.STORE_MANAGER, GaoRoleCode.EMPLOYEE}, mode = RoleMatchMode.ANY)
@RequiredArgsConstructor
@RequestMapping("/gao/event/record")
public class GaoEventRecordController {
private final UserService userService;
+ private final RoleChecker roleChecker;
private final GaoEventService eventService;
private final AttachmentService attachmentService;
private final GaoCustomerService customerService;
+ private final GaoStoreService gaoStoreService;
private final GaoEventRecordService service;
+ private final UserLoginService userLoginService;
@AOPLog
@RequestRateLimit
@@ -92,22 +100,40 @@ public class GaoEventRecordController {
@AOPLog
@RequestRateLimit
+ @RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_CREATE)
@PostMapping("/create")
public void create(@RequestBody GaoEventRecord record) {
+ if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
+ record.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
+ }
service.create(record);
}
@AOPLog
@RequestRateLimit
+ @RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_CREATE)
@PostMapping("/create/batch")
public void createBatch(@RequestBody List recordList) {
+ if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
+ String storeId = gaoStoreService.getBelongIdByRequiredLoginUserId();
+ for (GaoEventRecord record : recordList) {
+ record.setStoreId(storeId);
+ }
+ }
service.createBatch(recordList);
}
@AOPLog
@RequestRateLimit
+ @RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_CREATE)
@PostMapping("/create/customer")
public void createWithCustomer(@RequestBody GaoCustomer customer) {
+ if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
+ String storeId = gaoStoreService.getBelongIdByRequiredLoginUserId();
+ for (GaoEventRecord record : TimiJava.safeIterable(customer.getEventRecordList())) {
+ record.setStoreId(storeId);
+ }
+ }
service.createWithCustomer(customer);
}
@@ -116,6 +142,9 @@ public class GaoEventRecordController {
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_UPDATE)
@PostMapping("/update")
public void update(@RequestBody GaoEventRecord record) {
+ if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
+ record.setStoreId(gaoStoreService.getBelongIdByRequiredLoginUserId());
+ }
service.update(record);
}
diff --git a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoStoreController.java b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoStoreController.java
index 008bc8b..05ddbb9 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoStoreController.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoStoreController.java
@@ -1,5 +1,6 @@
package com.imyeyu.api.modules.gao.controller;
+import com.imyeyu.api.bean.RoleMatchMode;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.annotation.RequireGaoRole;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
@@ -7,7 +8,6 @@ import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
import com.imyeyu.api.modules.gao.entity.GaoStore;
import com.imyeyu.api.modules.gao.service.GaoStoreService;
import com.imyeyu.api.modules.user.service.UserLoginService;
-import com.imyeyu.api.bean.RoleMatchMode;
import com.imyeyu.network.Network;
import com.imyeyu.spring.TimiSpring;
import com.imyeyu.spring.annotation.AOPLog;
@@ -105,8 +105,8 @@ public class GaoStoreController {
@AOPLog
@RequestRateLimit
@RequireGaoRole(value = {GaoRoleCode.GLOBAL_MANAGER, GaoRoleCode.STORE_MANAGER, GaoRoleCode.EMPLOYEE}, mode = RoleMatchMode.ANY)
- @PostMapping("/detail/user")
- public GaoStore getByLoginUser() {
+ @PostMapping("/user")
+ public GaoStore getLoginStore() {
return service.getByUserId(userLoginService.getRequireLoginUserId());
}
}
diff --git a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoUserController.java b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoUserController.java
index dbc0e8b..13f26b8 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoUserController.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoUserController.java
@@ -39,9 +39,9 @@ import java.util.Map;
/// @author 夜雨
/// @since 2026-07-30 14:15
@RestController
+@RequireGaoRole(GaoRoleCode.STORE_MANAGER)
@RequiredArgsConstructor
@RequestMapping("/gao/user")
-@RequireGaoRole(GaoRoleCode.STORE_MANAGER)
public class GaoUserController {
private final UserService userService;
@@ -99,6 +99,9 @@ public class GaoUserController {
@PostMapping("/create")
@JsonView(ResponseView.Public.class)
public GaoUser create(@RequestBody GaoUser gaoUser) {
+ if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
+ gaoUser.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
+ }
service.create(gaoUser);
return service.get(gaoUser.getId());
}
diff --git a/src/main/java/com/imyeyu/api/modules/gao/mapper/GaoUserMapper.java b/src/main/java/com/imyeyu/api/modules/gao/mapper/GaoUserMapper.java
index 157595a..dc94f6e 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/mapper/GaoUserMapper.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/mapper/GaoUserMapper.java
@@ -2,8 +2,6 @@ package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoUser;
import com.imyeyu.spring.mapper.BaseMapper;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
///
/// GAO 用户 Mapper
@@ -11,10 +9,4 @@ import org.apache.ibatis.annotations.Select;
/// @author Codex
/// @since 2026-07-30
public interface GaoUserMapper extends BaseMapper {
-
- @Select("SELECT * FROM `gao_user` WHERE `user_id` = #{userId} AND `deleted_at` IS NULL LIMIT 1")
- GaoUser selectByUserId(@Param("userId") String userId);
-
- @Select("SELECT * FROM `gao_user` WHERE `store_id` = #{storeId} AND `user_id` = #{userId} AND `deleted_at` IS NULL LIMIT 1")
- GaoUser selectByStoreIdAndUserId(@Param("storeId") String storeId, @Param("userId") String userId);
}
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/GaoStoreService.java b/src/main/java/com/imyeyu/api/modules/gao/service/GaoStoreService.java
index 3529698..43f4fe0 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/GaoStoreService.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/GaoStoreService.java
@@ -20,6 +20,8 @@ public interface GaoStoreService extends BaseService {
/// @return 门店
GaoStore getByUserId(String userId);
+ String getBelongIdByRequiredLoginUserId();
+
/// 导出门店列表
///
/// @param page 分页查询条件
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoEventRecordServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoEventRecordServiceImplement.java
index e3af9a0..1e3e670 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoEventRecordServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoEventRecordServiceImplement.java
@@ -91,7 +91,10 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService customerIdList = TimiJava.defaultIfEmpty(record.getCustomerIdList(), List.of(record.getCustomerId()));
+ List customerIdList = record.getCustomerIdList();
+ if (TimiJava.isEmpty(customerIdList)) {
+ customerIdList = List.of(record.getCustomerId());
+ }
TimiException.required(customerIdList, "not found customerId or empty customerIdList");
GaoEventRecord firstRecord = null;
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoEventServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoEventServiceImplement.java
index cac18ba..47a7e7a 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoEventServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoEventServiceImplement.java
@@ -66,13 +66,8 @@ public class GaoEventServiceImplement extends AbstractEntityService roleCodeList) {
List dbRoleRelationList = roleRelationMapper.selectAllByEventIdList(List.of(eventId));
Set roleCodeSet = TimiJava.defaultIfEmpty(roleCodeList, List.of()).stream().filter(TimiJava::isNotEmpty).collect(Collectors.toSet());
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoStoreServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoStoreServiceImplement.java
index ca70e60..4c52c6f 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoStoreServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoStoreServiceImplement.java
@@ -8,6 +8,7 @@ import com.imyeyu.api.modules.gao.service.GaoStoreService;
import com.imyeyu.api.modules.gao.util.StoreXSSFBuilder;
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.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiCode;
import com.imyeyu.java.bean.timi.TimiException;
@@ -39,6 +40,7 @@ public class GaoStoreServiceImplement extends AbstractEntityService page) throws IOException {
page.setIndex(0);
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoUserServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoUserServiceImplement.java
index a77d6e2..66891e4 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoUserServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoUserServiceImplement.java
@@ -9,7 +9,6 @@ import com.imyeyu.api.modules.gao.service.GaoStoreService;
import com.imyeyu.api.modules.gao.service.GaoUserService;
import com.imyeyu.api.modules.system.entity.Logger;
import com.imyeyu.api.modules.system.service.LoggerService;
-import com.imyeyu.api.modules.user.service.RoleService;
import com.imyeyu.api.modules.user.service.UserService;
import com.imyeyu.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiCode;
@@ -33,7 +32,6 @@ public class GaoUserServiceImplement extends AbstractEntityService