use of org.maxkey.entity.UserInfo in project MaxKey by dromara.
the class SafeController method setting.
@ResponseBody
@RequestMapping(value = "/setting")
public Message setting(HttpServletRequest request, HttpServletResponse response, @RequestParam("authnType") String authnType, @RequestParam("mobile") String mobile, @RequestParam("mobileVerify") String mobileVerify, @RequestParam("email") String email, @RequestParam("emailVerify") String emailVerify, @RequestParam("theme") String theme) {
UserInfo userInfo = WebContext.getUserInfo();
userInfo.setAuthnType(Integer.parseInt(authnType));
userInfoService.updateAuthnType(userInfo);
userInfo.setMobile(mobile);
userInfoService.updateMobile(userInfo);
userInfo.setEmail(email);
userInfo.setTheme(theme);
WebContext.setCookie(response, null, WebConstants.THEME_COOKIE_NAME, theme, ConstsTimeInterval.ONE_WEEK);
userInfoService.updateEmail(userInfo);
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS), MessageType.success);
}
use of org.maxkey.entity.UserInfo in project MaxKey by dromara.
the class SafeController method changeAppLoginPasswod.
@ResponseBody
@RequestMapping(value = "/changeAppLoginPasswod")
public Message changeAppLoginPasswod(@RequestParam("oldPassword") String oldPassword, @RequestParam("newPassword") String newPassword, @RequestParam("confirmPassword") String confirmPassword) {
UserInfo userInfo = WebContext.getUserInfo();
_logger.debug("App Login Password : " + userInfo.getAppLoginPassword());
_logger.debug("App Login new Password : " + PasswordReciprocal.getInstance().encode(newPassword));
if (newPassword.equals(confirmPassword)) {
if (StringUtils.isEmpty(userInfo.getAppLoginPassword()) || userInfo.getAppLoginPassword().equals(PasswordReciprocal.getInstance().encode(oldPassword))) {
userInfo.setAppLoginPassword(PasswordReciprocal.getInstance().encode(newPassword));
boolean change = userInfoService.updateAppLoginPassword(userInfo);
_logger.debug("" + change);
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS), MessageType.prompt);
}
}
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_ERROR), MessageType.error);
}
use of org.maxkey.entity.UserInfo in project MaxKey by dromara.
the class UserInfoController method importing.
@RequestMapping(value = "/import")
public ModelAndView importing(@ModelAttribute("excelImportFile") ExcelImport excelImportFile) {
if (excelImportFile.isExcelNotEmpty()) {
try {
List<UserInfo> userInfoList = Lists.newArrayList();
Workbook workbook = excelImportFile.biuldWorkbook();
int recordCount = 0;
int sheetSize = workbook.getNumberOfSheets();
for (int i = 0; i < sheetSize; i++) {
// 遍历sheet页
Sheet sheet = workbook.getSheetAt(i);
int rowSize = sheet.getLastRowNum() + 1;
for (int j = 1; j < rowSize; j++) {
// 遍历行
Row row = sheet.getRow(j);
if (row == null || j < 3) {
// 略过空行和前3行
continue;
} else {
// 其他行是数据行
UserInfo userInfo = buildUserFromSheetRow(row);
userInfoList.add(userInfo);
recordCount++;
_logger.debug("record {} user {} account {}", recordCount, userInfo.getDisplayName(), userInfo.getUsername());
}
}
}
// 数据去重
if (!CollectionUtils.isEmpty(userInfoList)) {
userInfoList = userInfoList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getUsername()))), ArrayList::new));
if (userInfoService.insertBatch(userInfoList)) {
new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS), null, MessageType.success, OperateType.add, MessageScope.DB);
} else {
new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR), MessageType.error);
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
excelImportFile.closeWorkbook();
}
} else {
new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR), MessageType.error);
}
return new ModelAndView("/userinfo/usersImport");
}
use of org.maxkey.entity.UserInfo in project MaxKey by dromara.
the class UserInfoController method forwardChangeUserinfoStatus.
@RequestMapping(value = { "/forwardChangeUserinfoStatus/{id}" })
public ModelAndView forwardChangeUserinfoStatus(@PathVariable("id") String id) {
ModelAndView modelAndView = new ModelAndView("/userinfo/changeUserinfoStatus");
UserInfo userInfo = userInfoService.get(id);
modelAndView.addObject("model", userInfo);
return modelAndView;
}
use of org.maxkey.entity.UserInfo in project MaxKey by dromara.
the class UserInfoController method getUserInfo.
/**
* 查询用户,根据id
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value = "/getUsers/{id}")
public UserInfo getUserInfo(@PathVariable("id") String id) {
_logger.debug(id);
UserInfo userInfo = userInfoService.get(id);
if (userInfo != null && userInfo.getDecipherable() != null) {
try {
userInfo.setPassword(PasswordReciprocal.getInstance().decoder(userInfo.getDecipherable()));
} catch (Exception e) {
}
userInfo.setDecipherable(userInfo.getPassword());
}
return userInfo;
}
Aggregations