|
|
@@ -9,6 +9,7 @@ import com.usoftchina.bi.core.utils.EncryUtil;
|
|
|
import com.usoftchina.bi.server.aspect.JwtTokenAspect;
|
|
|
import com.usoftchina.bi.server.dao.user.UserMapper;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.usoftchina.bi.server.model.po.MessageLog;
|
|
|
import com.usoftchina.bi.server.model.po.TokenData;
|
|
|
import com.usoftchina.bi.server.model.po.User;
|
|
|
import com.usoftchina.bi.server.model.po.UserGroup;
|
|
|
@@ -24,6 +25,7 @@ import org.springframework.util.StringUtils;
|
|
|
import java.io.IOException;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class UserService {
|
|
|
@@ -205,7 +207,9 @@ public class UserService {
|
|
|
添加用户到用户组
|
|
|
*/
|
|
|
public RepEntity setUserInto(UserGroupSetInfo userGroupSetInfo){
|
|
|
+ String username = BaseContextHolder.getUserName();
|
|
|
int userGroupId = userGroupSetInfo.getUserGroupId();
|
|
|
+ String groupName = userMapper.getUserGroup(userGroupId).getUserGroupName();
|
|
|
List<Integer> userList = userGroupSetInfo.getUserList();
|
|
|
Iterator isList = userList.iterator();
|
|
|
while (isList.hasNext()){
|
|
|
@@ -217,6 +221,8 @@ public class UserService {
|
|
|
userMapper.setUserInto(userId, userGroupId);
|
|
|
}
|
|
|
}
|
|
|
+ //记录LOG
|
|
|
+ userGroupLog(userList, username, groupName, "add");
|
|
|
return new RepEntity(RepCode.success);
|
|
|
}
|
|
|
|
|
|
@@ -234,11 +240,59 @@ public class UserService {
|
|
|
public RepEntity delUserInGroup(UserGroupSetInfo userGroupSetInfo){
|
|
|
List<Integer> list = userGroupSetInfo.getUserList();
|
|
|
int userGroupId = userGroupSetInfo.getUserGroupId();
|
|
|
+ String username = BaseContextHolder.getUserName();
|
|
|
+ String groupName = userMapper.getUserGroup(userGroupId).getUserGroupName();
|
|
|
Iterator isList = list.iterator();
|
|
|
while (isList.hasNext()){
|
|
|
int userId = (int) isList.next();
|
|
|
userMapper.delUserInGroup(userId, userGroupId);
|
|
|
}
|
|
|
+ //记录LOG
|
|
|
+ userGroupLog(list, username, groupName, "delete");
|
|
|
return new RepEntity(RepCode.success);
|
|
|
}
|
|
|
+
|
|
|
+ private void userGroupLog(List<Integer> userList, String username, String groupName, String type){
|
|
|
+ //记录LOG
|
|
|
+ List<String> userIdsList = userList.stream().map(x -> x + "").collect(Collectors.toList());
|
|
|
+ String userIds = String.join(",", userIdsList);
|
|
|
+ String userNames = userMapper.getUserByIds(userIds);
|
|
|
+ String[] userNameArray = userNames.split(",");
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ MessageLog messageLog = new MessageLog();
|
|
|
+ String content = "", result = "";
|
|
|
+ if (userNameArray.length > 10) {
|
|
|
+ for (int i = 0, len = userNameArray.length; i < len; i = i+10) {
|
|
|
+ for (int j = 0; j < 10; j++) {
|
|
|
+ sb.append(userNameArray[i+j] + ",");
|
|
|
+ }
|
|
|
+ String names = sb.substring(0, sb.length() - 1);
|
|
|
+ if ("add".equals(type)) {
|
|
|
+ content = "添加用户:" + names + " 到用户组" + groupName + "中";
|
|
|
+ result = "添加成功";
|
|
|
+ }else if ("delete".equals(type)){
|
|
|
+ content = "从用户组" + groupName + "删除用户:" + names;
|
|
|
+ result = "删除成功";
|
|
|
+ }
|
|
|
+ messageLog = new MessageLog(username, content,result, null, "用户管理", null);
|
|
|
+ messageLogService.customizeLog(messageLog);
|
|
|
+ sb.delete(0, sb.length());
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ for (int i = 0, len = userNameArray.length; i < len; i++) {
|
|
|
+ sb.append(userNameArray[i] + ",");
|
|
|
+ }
|
|
|
+ String names = sb.substring(0, sb.length() - 1);
|
|
|
+ if ("add".equals(type)) {
|
|
|
+ content = "添加用户:" + names + " 到用户组" + groupName + "中";
|
|
|
+ result = "添加成功";
|
|
|
+ }else if ("delete".equals(type)){
|
|
|
+ content = "从用户组" + groupName + "删除用户:" + names;
|
|
|
+ result = "删除成功";
|
|
|
+ }
|
|
|
+ messageLog = new MessageLog(username, content,result, null, "用户管理", null);
|
|
|
+ messageLogService.customizeLog(messageLog);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|