This commit is contained in:
周源 2022-04-29 16:53:59 +08:00
parent 14db546118
commit 1ab3cdbd67
1 changed files with 60 additions and 60 deletions

View File

@ -46,7 +46,6 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
@ -208,66 +207,67 @@ public class ApiAuthController extends ApiBaseController {
}
}
// @PostMapping("reset")
// @ResponseBody
// @ApiOperation(value = "重新")
// public void sendPhoneCode() {
// List<User> list = userService.list();
// list.forEach(user->{
// user.setPassword(Ydool.password(user.getSalt(), "xsrd789"));
// });
// userService.updateBatchById(list);
// render(Ret.ok());
// }
/*@PostMapping("reset")
@ResponseBody
@ApiOperation(value = "重新")
public void sendPhoneCode() {
List<User> list = userService.list();
list.forEach(user->{
user.setPassword(Ydool.password(user.getSalt(), "xsrd789"));
});
userService.updateBatchById(list);
render(Ret.ok());
}*/
// @PostMapping("recover")
// @ResponseBody
// @ApiOperation(value = "恢复")
// public void recover() {
// //有一批老的机关用户,在变更多角色之前,user表里存了其机关身份,改了多角色之后,userType里没有把机关算进去,在他们加了代表角色之后
// //userType里多了代表角色,然后删代表角色的时候判断userType只有代表角色,以为没有别的角色,把user,role信息也给删了,导致登录不上去
// //-把userType也造出来,防止出现下次
// List<Office> officeList = officeService.list();
// officeList.forEach(office->{
// String userId = office.getUserId();
// User user = userService.getById(userId);
// if(user==null){
// user = new User();
// user.setId(userId);
// user.setSalt(RandomUtil.randomString(6));
// user.setPassword(Ydool.password(user.getSalt(), Global.getConfig(ConfigUtils.USER_INIT_PASSWORD)));
// user.setInitPwd(true);
// user.setStatus(1);
// user.setAccountType(office.getDuty());
//
// user.setLoginName(office.getPhone());
// user.setAccountType(office.getDuty());
// user.setUserName(office.getName());
// user.setPhone(office.getPhone());
// user.setStreetId(office.getStreet());
// userService.save(user);
//
// UserType userType = new UserType();
// userType.setUserId(user.getId());
// userType.setType(office.getDuty());
// userTypeService.saveOrUpdate(userType);
//
// if ("admin".equals(office.getDuty())) {
// Role role = roleService.getOne(new QueryWrapper<Role>().eq("code", "admin"));
// if (role != null) {
// userRoleService.save(new UserRole(office.getUserId(), role.getId()));
// }
// } else {
// //默认权限
// Role role = roleService.getOne(new QueryWrapper<Role>().eq("code", "default"));
// if (role != null) {
// userRoleService.save(new UserRole(office.getUserId(), role.getId()));
// }
// }
// }
// });
// render(Ret.ok());
// }
/* @PostMapping("recover")
@ResponseBody
@ApiOperation(value = "恢复")
public void recover() {
//有一批老的机关用户,在变更多角色之前,user表里仅存了其机关身份,而改了多角色之后,角色信息从user的单一表变成userType这个一对多表里,而代码只对新添加数据做了处理,老数据没处理
//导致userType中并没有他们的机关身份,而在他们加了代表角色之后
//userType里有了他们的代表角色
//然后在删代表角色的时候判断userType只有代表角色,以为没有别的角色,把user,userRole,userType信息全给删了,导致登录无法使用
List<Office> officeList = officeService.list();
officeList.forEach(office->{
String userId = office.getUserId();
User user = userService.getById(userId);
if(user==null){
user = new User();
user.setId(userId);
user.setSalt(RandomUtil.randomString(6));
user.setPassword(Ydool.password(user.getSalt(), Global.getConfig(ConfigUtils.USER_INIT_PASSWORD)));
user.setInitPwd(true);
user.setStatus(1);
user.setAccountType(office.getDuty());
user.setLoginName(office.getPhone());
user.setAccountType(office.getDuty());
user.setUserName(office.getName());
user.setPhone(office.getPhone());
user.setStreetId(office.getStreet());
userService.save(user);
UserType userType = new UserType();
userType.setUserId(user.getId());
userType.setType(office.getDuty());
userTypeService.saveOrUpdate(userType);
if ("admin".equals(office.getDuty())) {
Role role = roleService.getOne(new QueryWrapper<Role>().eq("code", "admin"));
if (role != null) {
userRoleService.save(new UserRole(office.getUserId(), role.getId()));
}
} else {
//默认权限
Role role = roleService.getOne(new QueryWrapper<Role>().eq("code", "default"));
if (role != null) {
userRoleService.save(new UserRole(office.getUserId(), role.getId()));
}
}
}
});
render(Ret.ok());
}*/
@PostMapping("sendCode/login")
@ResponseBody