java——添加大量学生用户
程序员文章站
2022-03-09 23:19:27
...
@RequestMapping(value = "/add", method = RequestMethod.POST)
@RequiresPermissions("user:add")
public Result<?> add() {
try{
}catch(Exception e){
e.printStackTrace();
}
List<StStudent> stStudents=stStudentService.list();
for(StStudent ststudent:stStudents){
SysUser user=new SysUser();
user.setRealname(ststudent.getStName());
user.setUsername(ststudent.getStudentId());
user.setWorkNo(ststudent.getStudentId());
user.setSex(new Integer(ststudent.getSex()));
user.setCreateTime(new Date());//设置创建时间
String salt = oConvertUtils.randomGen(8);
user.setSalt(salt);
String passwordEncode = PasswordUtil.encrypt(user.getUsername(), "123456", salt);
user.setPassword(passwordEncode);
user.setDelFlag("0");
sysUserService.addUserWithRole(user, "1257603335870078978");
}
return Result.ok("添加成功!");
}
上一篇: 关于数据库mysql连接超时以及连接池超时的一些问题
下一篇: 多线程的安全性问题