修改同步接口

master
xiaoCJ 1 day ago
parent 91f52865b4
commit 63e3519187

@ -128,11 +128,15 @@ public class SysLoginController {
map.put("token", token);
SysUser sysUser = sysUserMapper.selectUserByUserName(String.valueOf(map.get("username")));
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String tokenWbdsj = loginService.login(sysUser.getUserName(), "123456", "1",
String.valueOf(UUID.randomUUID()));
ajax.put(Constants.TOKEN, tokenWbdsj);
// String tokenWbdsj = loginService.login(sysUser.getUserName(), "123456", "1",
// String.valueOf(UUID.randomUUID()));
// ajax.put(Constants.TOKEN, tokenWbdsj);
ajax.put("token", token);
ajax.put("roleId", loginResult.getRoleId());
//班级名称为空, 是老师账号
if (sysUser.getStuClass() != null) {
ajax.put("deptId", sysUser.getDeptId()); //班级ID
@ -143,8 +147,8 @@ public class SysLoginController {
ajax.put("schoolId", sysUser.getDeptId()); //老师账号的deptId就是存的学校ID
}
ajax.put("UserId", sysUser.getUserId());
ajax.put("name", loginResult.getName());
ajax.put("username", loginResult.getUsername());
return ajax;
}
}
@ -200,7 +204,9 @@ public class SysLoginController {
public String checkOrCreateForexSimulationUser(@RequestBody List<ZYUserInfo> zyUserInfoList) {
List<SysUser> users = new ArrayList<>();
List<SysUserRole> userRoleList = new ArrayList<>();
List<SysDept> sysDeptList = new ArrayList<>();
// 使用 Map 去重
Map<Long, SysDept> sysDeptMap = new HashMap<>();
for (int i = 0; i < zyUserInfoList.size(); i++) {
ZYUserInfo zyUserInfo = zyUserInfoList.get(i);
Integer zyUserId = zyUserInfo.getUserId();
@ -269,7 +275,7 @@ public class SysLoginController {
newSysDept.setUpdateBy(new Date().toString());
newSysDept.setStatus("0");
newSysDept.setDelFlag("0");
sysDeptList.add(newSysDept);
sysDeptMap.put(newSysDept.getDeptId(), newSysDept); // 使用 Map 去重
//添加一条班级数据
SysDept newSysDeptByClass = new SysDept();
@ -282,7 +288,7 @@ public class SysLoginController {
newSysDeptByClass.setUpdateBy(new Date().toString());
newSysDeptByClass.setStatus("0");
newSysDeptByClass.setDelFlag("0");
sysDeptList.add(newSysDeptByClass);
sysDeptMap.put(newSysDeptByClass.getDeptId(), newSysDeptByClass); // 使用 Map 去重
} else { // 学校存在 判断班级是否存在
SysDept sysDeptByClass = sysDeptMapper.selectDeptById(Long.valueOf(classId));
@ -301,13 +307,15 @@ public class SysLoginController {
newSysDeptByClass.setUpdateBy(new Date().toString());
newSysDeptByClass.setStatus("0");
newSysDeptByClass.setDelFlag("0");
sysDeptList.add(newSysDeptByClass);
sysDeptMap.put(newSysDeptByClass.getDeptId(), newSysDeptByClass); // 使用 Map 去重
}
}
}
if (users.isEmpty()) {
return "账号已全部存在";
}
// 将 Map 转换为 List
List<SysDept> sysDeptList = new ArrayList<>(sysDeptMap.values());
sysUserMapper.batchInsertUserInfo(users);
sysUserRoleMapper.batchUserRole(userRoleList);
sysDeptMapper.batchInsertUserInfo(sysDeptList);

Loading…
Cancel
Save