Search in sources :

Example 26 with AjaxResult

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;
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) SysUser(com.ruoyi.common.core.domain.entity.SysUser) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 27 with AjaxResult

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;
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) SysUser(com.ruoyi.system.domain.SysUser)

Example 28 with 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;
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) HashSet(java.util.HashSet)

Example 29 with 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;
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 30 with AjaxResult

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;
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

AjaxResult (com.ruoyi.common.core.domain.AjaxResult)55 GetMapping (org.springframework.web.bind.annotation.GetMapping)25 PostMapping (org.springframework.web.bind.annotation.PostMapping)16 SysUser (com.ruoyi.common.core.domain.entity.SysUser)12 LoginUser (com.ruoyi.common.core.domain.model.LoginUser)10 Log (com.ruoyi.common.annotation.Log)8 StringUtils (com.ruoyi.common.utils.StringUtils)7 List (java.util.List)7 Autowired (org.springframework.beans.factory.annotation.Autowired)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 RestController (org.springframework.web.bind.annotation.RestController)7 MultipartFile (org.springframework.web.multipart.MultipartFile)7 SysUser (com.ruoyi.system.domain.SysUser)6 UserConstants (com.ruoyi.common.constant.UserConstants)5 BaseController (com.ruoyi.common.core.controller.BaseController)5 SysRole (com.ruoyi.common.core.domain.entity.SysRole)5 TableDataInfo (com.ruoyi.common.core.page.TableDataInfo)5 BusinessType (com.ruoyi.common.enums.BusinessType)5 SecurityUtils (com.ruoyi.common.utils.SecurityUtils)5