|
|
@@ -3,15 +3,12 @@ package com.ffii.tsms.modules.user.service; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.util.LinkedHashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Locale; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import com.ffii.tsms.modules.common.service.AuditLogService; |
|
|
|
import org.apache.commons.lang3.LocaleUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@@ -41,8 +38,6 @@ import jakarta.persistence.Table; |
|
|
|
import com.ffii.core.utils.JsonUtils; |
|
|
|
import com.ffii.tsms.modules.common.SecurityUtils; |
|
|
|
|
|
|
|
import jakarta.mail.internet.InternetAddress; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class UserService extends AbstractBaseEntityService<User, Long, UserRepository> { |
|
|
|
private static final String USER_AUTH_SQL = "SELECT a.authority" |
|
|
@@ -91,9 +86,9 @@ public class UserService extends AbstractBaseEntityService<User, Long, UserRepos |
|
|
|
return userRepository.findByUsernameAndDeletedFalse(username); |
|
|
|
} |
|
|
|
|
|
|
|
public Map<String, Object> softDelete(User user) { |
|
|
|
public void softDelete(User user) { |
|
|
|
|
|
|
|
// =====GET OLD AUDIT LOG=====// |
|
|
|
// =====GET OLD AUDIT LOG=====// |
|
|
|
String tableName = user.getClass().getAnnotation(Table.class).name(); |
|
|
|
StringBuilder sql = new StringBuilder("SELECT * FROM " + tableName + " WHERE id = :id"); |
|
|
|
String oldValueJson = null; |
|
|
@@ -124,8 +119,6 @@ public class UserService extends AbstractBaseEntityService<User, Long, UserRepos |
|
|
|
newValueJson); |
|
|
|
// =====GET NEW AUDIT LOG=====// |
|
|
|
|
|
|
|
return Map.of( |
|
|
|
"id", user.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
// @Transactional(rollbackFor = Exception.class) |
|
|
@@ -148,7 +141,8 @@ public class UserService extends AbstractBaseEntityService<User, Long, UserRepos |
|
|
|
+ " u.email," |
|
|
|
+ " u.phone1," |
|
|
|
+ " u.phone2," |
|
|
|
+ " u.remarks " |
|
|
|
+ " u.remarks, " |
|
|
|
+ " ug.groupId " |
|
|
|
+ " FROM `user` u" |
|
|
|
+ " left join user_group ug on u.id = ug.userId" |
|
|
|
+ " where u.deleted = false"); |
|
|
@@ -201,7 +195,7 @@ public class UserService extends AbstractBaseEntityService<User, Long, UserRepos |
|
|
|
} |
|
|
|
|
|
|
|
private User saveOrUpdate(User instance, UpdateUserReq req) { |
|
|
|
|
|
|
|
|
|
|
|
if (instance.getId() == null){ |
|
|
|
req.setLocked(false); |
|
|
|
} |
|
|
@@ -263,7 +257,7 @@ public class UserService extends AbstractBaseEntityService<User, Long, UserRepos |
|
|
|
User instance = new User(); |
|
|
|
instance.setPassword(pwdHash); |
|
|
|
instance = saveOrUpdate(instance, req); |
|
|
|
|
|
|
|
|
|
|
|
// Locale locale = instance.getLocale() != null ? LocaleUtils.from(instance.getLocale()) : Locale.ENGLISH; |
|
|
|
// mailService.send( |
|
|
|
// MailRequest.builder() |
|
|
|