|
|
|
@@ -7,6 +7,7 @@ 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.StringUtils; |
|
|
|
@@ -184,6 +185,25 @@ public class UserService extends AbstractBaseEntityService<User, Long, UserRepos |
|
|
|
Map.of(Params.ID, id)); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public List<Map<String, Object>> listUserAuth(Map<String, Object> args) { |
|
|
|
|
|
|
|
StringBuilder sql = new StringBuilder("SELECT" |
|
|
|
+ " a.id, " |
|
|
|
+ " a.module," |
|
|
|
+ " a.authority," |
|
|
|
+ " a.name," |
|
|
|
+ " a.description, "); |
|
|
|
if (args.containsKey("userId")) |
|
|
|
sql.append(" EXISTS(SELECT 1 FROM user_authority ua WHERE a.id = ua.authId AND userId = :userId) AS v"); |
|
|
|
else |
|
|
|
sql.append(" 0 AS v"); |
|
|
|
sql.append(" FROM authority a" |
|
|
|
+ " ORDER BY a.module, a.name"); |
|
|
|
|
|
|
|
return jdbcDao.queryForList(sql.toString(), args); |
|
|
|
} |
|
|
|
|
|
|
|
public List<Integer> listUserGroupId(long id) { |
|
|
|
return jdbcDao.queryForInts( |
|
|
|
"SELECT" |
|
|
|
@@ -201,47 +221,28 @@ public class UserService extends AbstractBaseEntityService<User, Long, UserRepos |
|
|
|
} |
|
|
|
BeanUtils.copyProperties(req,instance); |
|
|
|
instance = save(instance); |
|
|
|
// long id = instance.getId(); |
|
|
|
|
|
|
|
// List<Map<String, Integer>> groupBatchInsertValues = req.getAddGroupIds().stream() |
|
|
|
// .map(groupId -> Map.of("userId", (int) id, "groupId", groupId)) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
// List<Map<String, Integer>> groupBatchDeleteValues = req.getRemoveGroupIds().stream() |
|
|
|
// .map(groupId -> Map.of("userId", (int) id, "groupId", groupId)) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
|
|
|
|
// if (!groupBatchInsertValues.isEmpty()) { |
|
|
|
// jdbcDao.batchUpdate( |
|
|
|
// "INSERT IGNORE INTO user_group (groupId,userId)" |
|
|
|
// + " VALUES (:groupId, :userId)", |
|
|
|
// groupBatchInsertValues); |
|
|
|
// } |
|
|
|
// if (!groupBatchDeleteValues.isEmpty()) { |
|
|
|
// jdbcDao.batchUpdate( |
|
|
|
// "DELETE FROM user_group" |
|
|
|
// + " WHERE groupId = :groupId AND userId = :userId", |
|
|
|
// groupBatchDeleteValues); |
|
|
|
// } |
|
|
|
|
|
|
|
// List<Map<String, Integer>> authBatchInsertValues = req.getAddAuthIds().stream() |
|
|
|
// .map(authId -> Map.of("userId", (int)id, "authId", authId)) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
// List<Map<String, Integer>> authBatchDeleteValues = req.getRemoveAuthIds().stream() |
|
|
|
// .map(authId -> Map.of("userId", (int)id, "authId", authId)) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
// if (!authBatchInsertValues.isEmpty()) { |
|
|
|
// jdbcDao.batchUpdate( |
|
|
|
// "INSERT IGNORE INTO user_authority (userId, authId)" |
|
|
|
// + " VALUES (:userId, :authId)", |
|
|
|
// authBatchInsertValues); |
|
|
|
// } |
|
|
|
|
|
|
|
// if (!authBatchDeleteValues.isEmpty()) { |
|
|
|
// jdbcDao.batchUpdate( |
|
|
|
// "DELETE FROM user_authority" |
|
|
|
// + " WHERE userId = :userId AND authId = :authId", |
|
|
|
// authBatchDeleteValues); |
|
|
|
// } |
|
|
|
long id = instance.getId(); |
|
|
|
|
|
|
|
List<Map<String, Integer>> authBatchInsertValues = req.getAddAuthIds().stream() |
|
|
|
.map(authId -> Map.of("userId", (int)id, "authId", authId)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
List<Map<String, Integer>> authBatchDeleteValues = req.getRemoveAuthIds().stream() |
|
|
|
.map(authId -> Map.of("userId", (int)id, "authId", authId)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
if (!authBatchInsertValues.isEmpty()) { |
|
|
|
jdbcDao.batchUpdate( |
|
|
|
"INSERT IGNORE INTO user_authority (userId, authId)" |
|
|
|
+ " VALUES (:userId, :authId)", |
|
|
|
authBatchInsertValues); |
|
|
|
} |
|
|
|
|
|
|
|
if (!authBatchDeleteValues.isEmpty()) { |
|
|
|
jdbcDao.batchUpdate( |
|
|
|
"DELETE FROM user_authority" |
|
|
|
+ " WHERE userId = :userId ", |
|
|
|
// + "AND authId = :authId", |
|
|
|
authBatchDeleteValues); |
|
|
|
} |
|
|
|
return instance; |
|
|
|
} |
|
|
|
|
|
|
|
|