Commit c4ba745fcb176104958bc6a0855961ca3e92c526

Authored by zichun
1 parent c46d7175

fix(user): always clear permissions on update — null permissionCategoryIds now c…

…lears all (REQ-USR-002)
backend/src/main/java/com/xly/erp/module/usr/service/impl/UserServiceImpl.java
@@ -191,21 +191,19 @@ public class UserServiceImpl implements UserService { @@ -191,21 +191,19 @@ public class UserServiceImpl implements UserService {
191 throw new BizException(40020, "用户号或用户名已存在"); 191 throw new BizException(40020, "用户号或用户名已存在");
192 } 192 }
193 193
194 - if (ids != null) {  
195 - userPermissionMapper.deleteByUserId(id);  
196 - if (!ids.isEmpty()) {  
197 - String createdBy = SecurityContextHelper.currentUserNo();  
198 - LocalDateTime now = LocalDateTime.now();  
199 - for (Integer cid : ids) {  
200 - UserPermission rel = new UserPermission();  
201 - rel.setSBrandsId(tenant.getBrandsId());  
202 - rel.setSSubsidiaryId(tenant.getSubsidiaryId());  
203 - rel.setTCreateDate(now);  
204 - rel.setIUserId(id);  
205 - rel.setICategoryId(cid);  
206 - rel.setSCreatedBy(createdBy);  
207 - userPermissionMapper.insert(rel);  
208 - } 194 + userPermissionMapper.deleteByUserId(id);
  195 + if (ids != null && !ids.isEmpty()) {
  196 + String createdBy = SecurityContextHelper.currentUserNo();
  197 + LocalDateTime now = LocalDateTime.now();
  198 + for (Integer cid : ids) {
  199 + UserPermission rel = new UserPermission();
  200 + rel.setSBrandsId(tenant.getBrandsId());
  201 + rel.setSSubsidiaryId(tenant.getSubsidiaryId());
  202 + rel.setTCreateDate(now);
  203 + rel.setIUserId(id);
  204 + rel.setICategoryId(cid);
  205 + rel.setSCreatedBy(createdBy);
  206 + userPermissionMapper.insert(rel);
209 } 207 }
210 } 208 }
211 return id; 209 return id;