|
@ -19,6 +19,7 @@ import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.ObjectUtils; |
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -69,6 +70,8 @@ public class PermissionServiceImpl implements PermissionService { |
|
|
if (ObjectUtils.isEmpty(admin.getMarket())) { |
|
|
if (ObjectUtils.isEmpty(admin.getMarket())) { |
|
|
throw new Exception("地区为空!"); |
|
|
throw new Exception("地区为空!"); |
|
|
} |
|
|
} |
|
|
|
|
|
if (admin.getMarket().contains("总部") && admin.getMarket().size() > 1) { |
|
|
|
|
|
throw new Exception("总部不可与其他地区共存");} |
|
|
if (ObjectUtils.isEmpty(admin.getPostiton())) { |
|
|
if (ObjectUtils.isEmpty(admin.getPostiton())) { |
|
|
throw new Exception("职位为空!"); |
|
|
throw new Exception("职位为空!"); |
|
|
} |
|
|
} |
|
@ -86,6 +89,9 @@ public class PermissionServiceImpl implements PermissionService { |
|
|
} else { |
|
|
} else { |
|
|
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
|
|
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
|
|
admin.setPassword(passwordEncoder.encode(("123456"))); |
|
|
admin.setPassword(passwordEncoder.encode(("123456"))); |
|
|
|
|
|
// 将地区列表转换为逗号分隔的字符串 |
|
|
|
|
|
String markets = String.join(",", admin.getMarket()); |
|
|
|
|
|
admin.setMarket(Collections.singletonList(markets)); |
|
|
permissionMapper.addPermission(admin); |
|
|
permissionMapper.addPermission(admin); |
|
|
AdminRole adminRole = new AdminRole(); |
|
|
AdminRole adminRole = new AdminRole(); |
|
|
adminRole.setAdminId(admin.getId()); |
|
|
adminRole.setAdminId(admin.getId()); |
|
|