use of com.ruoyi.common.core.domain.AjaxResult in project hocassian-media-matrix by hokaso.
the class SysProfileController method profile.
/**
* 个人信息
*/
@GetMapping
public AjaxResult profile() {
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
SysUser user = loginUser.getUser();
AjaxResult ajax = AjaxResult.success(user);
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
return ajax;
}
use of com.ruoyi.common.core.domain.AjaxResult in project Rental-Information-Platform by who1sBruce.
the class WebIndexController method thirdRegister.
/**
* 手机注册/登录
*/
@PostMapping("/thirdRegister")
@ResponseBody
public AjaxResult thirdRegister(HttpServletRequest request, @RequestBody SysUser user) {
String msg = "登录成功";
if (StringUtils.isEmpty(user.getLoginName()) || StringUtils.isEmpty(user.getCaptcha())) {
msg = "用户名/验证码不能为空";
return error(msg);
}
// 首先验证验证码是否正确
if (redisUtil.get(user.getLoginName()) == null || !redisUtil.get(user.getLoginName()).equals(user.getCaptcha())) {
msg = "验证码过期/错误";
return error(msg);
}
// 验证码正确则判断是否为新用户
SysUser sysUser = userService.selectUserByLoginName(user.getLoginName());
// 不是新用户,创建用户
if (sysUser == null) {
sysUser = new SysUser();
sysUser.setPcode(user.getPcode());
sysUser.setLoginName(user.getLoginName());
sysUser.setUserName(user.getLoginName());
sysUser.setPassword(user.getLoginName());
sysUser.setPhonenumber(user.getLoginName());
sysUser.setSalt(ShiroUtils.randomSalt());
sysUser.setPassword(passwordService.encryptPassword(sysUser.getLoginName(), sysUser.getPassword(), sysUser.getSalt()));
webIndexService.registerSave(sysUser);
}
// 获取token
String jwtToken = JwtUtils.createToken(sysUser.getLoginName(), sysUser.getPassword());
sysUser.setJwtToken(jwtToken);
AjaxResult ajaxResult = new AjaxResult(AjaxResult.Type.SUCCESS, msg, sysUser);
return ajaxResult;
}
use of com.ruoyi.common.core.domain.AjaxResult in project Rental-Information-Platform by who1sBruce.
the class WebIndexController method appSysFlowInfo.
/**
* @Description: 保存流量信息
* @author: zy
* @Return: 返回uv标识
*/
@PostMapping("/appSysFlowInfo")
@ResponseBody
public AjaxResult appSysFlowInfo(HttpServletRequest request, @RequestBody SysFlowLog sysFlowLog) {
String msg = "流量累积中";
// 定义pv.uv.ip标识,如果redis中存在,则加1,否则初始1
String pvFlow = "pvFlow:" + DateUtils.getDate();
String uvFlow = "uvFlow:" + DateUtils.getDate();
String ipFlow = "ipFlow:" + DateUtils.getDate();
// pvFlow进行累计操作
Long pvFlowNum = 1L;
if (StringUtils.isNull(redisUtil.get(pvFlow))) {
redisUtil.set(pvFlow, pvFlowNum, Constants.SYS_FLOW_TIME);
} else {
redisUtil.set(pvFlow, redisUtil.incr(pvFlow, 1), Constants.SYS_FLOW_TIME);
}
// uvFlow进行cookie去重
HashSet uvSet = new HashSet<>();
if (StringUtils.isNotNull(redisUtil.get(uvFlow))) {
uvSet = ((HashSet) redisUtil.get(uvFlow));
}
String uvCode = sysFlowLog.getUvCode();
if (StringUtils.isEmpty(uvCode)) {
uvCode = CodeUtil.getCode();
}
uvSet.add(uvCode);
redisUtil.set(uvFlow, uvSet, Constants.SYS_FLOW_TIME);
// ipFlow进行ip去重
String ipAddr = IpUtils.getIpAddr(request);
HashSet ipSet = new HashSet<>();
// 判断IP键是否存在
if (StringUtils.isNotNull(redisUtil.get(ipFlow))) {
ipSet = ((HashSet) redisUtil.get(ipFlow));
}
ipSet.add(ipAddr);
redisUtil.set(ipFlow, ipSet, Constants.SYS_FLOW_TIME);
AjaxResult ajaxResult = new AjaxResult(AjaxResult.Type.SUCCESS, msg, uvCode);
return ajaxResult;
}
use of com.ruoyi.common.core.domain.AjaxResult in project Rental-Information-Platform by who1sBruce.
the class UserFormModel method collection.
/**
* 获取数据集合
*/
@GetMapping("/collection")
@ResponseBody
public AjaxResult collection() {
String[] array = { "ruoyi 1", "ruoyi 2", "ruoyi 3", "ruoyi 4", "ruoyi 5" };
AjaxResult ajax = new AjaxResult();
ajax.put("value", array);
return ajax;
}
use of com.ruoyi.common.core.domain.AjaxResult in project Rental-Information-Platform by who1sBruce.
the class UserFormModel method userModel.
/**
* 获取用户数据
*/
@GetMapping("/userModel")
@ResponseBody
public AjaxResult userModel() {
AjaxResult ajax = new AjaxResult();
ajax.put("code", 200);
ajax.put("value", users);
return ajax;
}
Aggregations