use of com.ruoyi.common.core.domain.AjaxResult in project Rental-Information-Platform by who1sBruce.
the class WebIndexController method ajaxThridLogin.
/**
* 密码登录 Json参数
*/
@PostMapping("/thirdLogin")
@ResponseBody
public AjaxResult ajaxThridLogin(HttpServletRequest request, @RequestBody SysUser user) {
String msg = "用户不存在/密码错误";
// 判断是不是手机号码
if (!user.getLoginName().matches(UserConstants.MOBILE_PHONE_NUMBER_PATTERN) || StringUtils.isEmpty(user.getPassword())) {
return error(msg);
}
UsernamePasswordToken token = new UsernamePasswordToken(user.getLoginName(), user.getPassword());
Subject subject = SecurityUtils.getSubject();
try {
subject.login(token);
SysUser sysUser = ShiroUtils.getSysUser();
// 获取token
String jwtToken = JwtUtils.createToken(sysUser.getLoginName(), sysUser.getPassword());
sysUser.setJwtToken(jwtToken);
AjaxResult ajaxResult = new AjaxResult(AjaxResult.Type.SUCCESS, "登录成功", sysUser);
return ajaxResult;
} catch (AuthenticationException e) {
if (com.ruoyi.common.utils.StringUtils.isNotEmpty(e.getMessage())) {
msg = e.getMessage();
}
return error(msg);
}
}
use of com.ruoyi.common.core.domain.AjaxResult in project Rental-Information-Platform by who1sBruce.
the class WebProfileController method update.
/**
* 修改用户
*/
@PostMapping("/update")
@ResponseBody
public AjaxResult update(SysUser user) {
SysUser currentUser = userService.selectUserByLoginName(user.getLoginName());
if (StringUtils.isNotNull(currentUser)) {
currentUser.setUserName(user.getUserName());
currentUser.setEmail(user.getEmail());
currentUser.setSex(user.getSex());
if (StringUtils.isEmpty(currentUser.getCode())) {
currentUser.setCode(user.getCode());
}
currentUser.setAddress(user.getAddress());
if (userService.updateUserInfo(currentUser) > 0) {
AjaxResult ajaxResult = new AjaxResult(AjaxResult.Type.SUCCESS, "登录成功", currentUser);
return ajaxResult;
}
}
return error();
}
use of com.ruoyi.common.core.domain.AjaxResult in project Rental-Information-Platform by who1sBruce.
the class WebProfileController method resetPwd.
@PostMapping("/resetPwd")
@ResponseBody
public AjaxResult resetPwd(String loginName, String oldPassword, String newPassword) {
SysUser user = userService.selectUserByLoginName(loginName);
if (StringUtils.isNotEmpty(newPassword) && passwordService.matches(user, oldPassword)) {
user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
if (userService.resetUserPwd(user) > 0) {
// 获取token
String jwtToken = JwtUtils.createToken(user.getLoginName(), user.getPassword());
user.setJwtToken(jwtToken);
AjaxResult ajaxResult = new AjaxResult(AjaxResult.Type.SUCCESS, "修改密码成功", user);
return ajaxResult;
}
return error();
} else {
return error("修改密码失败,旧密码错误");
}
}
use of com.ruoyi.common.core.domain.AjaxResult in project Rental-Information-Platform by who1sBruce.
the class ApiHouseController method findVillageList.
/**
* @Description: 获取小區信息
* @date: 0714
* @Return: AjaxResult
*/
@GetMapping("/findVillageList")
@ResponseBody
public AjaxResult findVillageList(HouseVillage houseVillage) {
startPage();
String msg = "小區列表";
List<HouseVillage> list = houseVillageService.selectHouseVillageList(houseVillage);
AjaxResult ajaxResult = new AjaxResult(AjaxResult.Type.SUCCESS, msg, list);
return ajaxResult;
}
use of com.ruoyi.common.core.domain.AjaxResult in project Rental-Information-Platform by who1sBruce.
the class ApiHouseController method findHouseList.
/**
* @Description: 获取房源信息
* @date: 0714
* @Return: AjaxResult
*/
@GetMapping("/findHouseList")
@ResponseBody
public AjaxResult findHouseList(HouseRoom houseRoom) {
startPage();
String msg = "房源列表";
List<HouseRoom> list = houseRoomService.selectHouseRoomList(houseRoom);
AjaxResult ajaxResult = new AjaxResult(AjaxResult.Type.SUCCESS, msg, list);
return ajaxResult;
}
Aggregations