Search in sources :

Example 6 with AjaxResult

use of com.ruoyi.common.core.web.domain.AjaxResult in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class SysProfileController method profile.

/**
 * 个人信息
 */
@GetMapping
public AjaxResult profile() {
    String username = SecurityUtils.getUsername();
    SysUser user = userService.selectUserByUserName(username);
    AjaxResult ajax = AjaxResult.success(user);
    ajax.put("roleGroup", userService.selectUserRoleGroup(username));
    ajax.put("postGroup", userService.selectUserPostGroup(username));
    return ajax;
}
Also used : AjaxResult(com.ruoyi.common.core.web.domain.AjaxResult) SysUser(com.ruoyi.system.api.domain.SysUser) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 7 with AjaxResult

use of com.ruoyi.common.core.web.domain.AjaxResult in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class SysUserController method authRole.

/**
 * 根据用户编号获取授权角色
 */
@RequiresPermissions("system:user:query")
@GetMapping("/authRole/{userId}")
public AjaxResult authRole(@PathVariable("userId") Long userId) {
    AjaxResult ajax = AjaxResult.success();
    SysUser user = userService.selectUserById(userId);
    List<SysRole> roles = roleService.selectRolesByUserId(userId);
    ajax.put("user", user);
    ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
    return ajax;
}
Also used : R(com.ruoyi.common.core.domain.R) PathVariable(org.springframework.web.bind.annotation.PathVariable) Log(com.ruoyi.common.log.annotation.Log) SysRole(com.ruoyi.system.api.domain.SysRole) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ArrayUtils(org.apache.commons.lang3.ArrayUtils) InnerAuth(com.ruoyi.common.security.annotation.InnerAuth) TableDataInfo(com.ruoyi.common.core.web.page.TableDataInfo) RequiresPermissions(com.ruoyi.common.security.annotation.RequiresPermissions) RequestBody(org.springframework.web.bind.annotation.RequestBody) ISysConfigService(com.ruoyi.system.service.ISysConfigService) BaseController(com.ruoyi.common.core.web.controller.BaseController) PutMapping(org.springframework.web.bind.annotation.PutMapping) ISysRoleService(com.ruoyi.system.service.ISysRoleService) GetMapping(org.springframework.web.bind.annotation.GetMapping) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) BusinessType(com.ruoyi.common.log.enums.BusinessType) LoginUser(com.ruoyi.system.api.model.LoginUser) ISysPermissionService(com.ruoyi.system.service.ISysPermissionService) PostMapping(org.springframework.web.bind.annotation.PostMapping) Validated(org.springframework.validation.annotation.Validated) HttpServletResponse(javax.servlet.http.HttpServletResponse) Set(java.util.Set) IOException(java.io.IOException) AjaxResult(com.ruoyi.common.core.web.domain.AjaxResult) StringUtils(com.ruoyi.common.core.utils.StringUtils) SysUser(com.ruoyi.system.api.domain.SysUser) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) List(java.util.List) ISysUserService(com.ruoyi.system.service.ISysUserService) MultipartFile(org.springframework.web.multipart.MultipartFile) UserConstants(com.ruoyi.common.core.constant.UserConstants) ExcelUtil(com.ruoyi.common.core.utils.poi.ExcelUtil) ISysPostService(com.ruoyi.system.service.ISysPostService) SecurityUtils(com.ruoyi.common.security.utils.SecurityUtils) AjaxResult(com.ruoyi.common.core.web.domain.AjaxResult) SysUser(com.ruoyi.system.api.domain.SysUser) SysRole(com.ruoyi.system.api.domain.SysRole) RequiresPermissions(com.ruoyi.common.security.annotation.RequiresPermissions) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 8 with AjaxResult

use of com.ruoyi.common.core.web.domain.AjaxResult in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class SysDeptController method roleDeptTreeselect.

/**
 * 加载对应角色部门列表树
 */
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
    List<SysDept> depts = deptService.selectDeptList(new SysDept());
    AjaxResult ajax = AjaxResult.success();
    ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
    ajax.put("depts", deptService.buildDeptTreeSelect(depts));
    return ajax;
}
Also used : AjaxResult(com.ruoyi.common.core.web.domain.AjaxResult) SysDept(com.ruoyi.system.api.domain.SysDept) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 9 with AjaxResult

use of com.ruoyi.common.core.web.domain.AjaxResult in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class ValidateCodeServiceImpl method createCaptcha.

/**
 * 生成验证码
 */
@Override
public AjaxResult createCaptcha() throws IOException, CaptchaException {
    AjaxResult ajax = AjaxResult.success();
    boolean captchaOnOff = captchaProperties.getEnabled();
    ajax.put("captchaOnOff", captchaOnOff);
    if (!captchaOnOff) {
        return ajax;
    }
    // 保存验证码信息
    String uuid = IdUtils.simpleUUID();
    String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
    String capStr = null, code = null;
    BufferedImage image = null;
    String captchaType = captchaProperties.getType();
    // 生成验证码
    if ("math".equals(captchaType)) {
        String capText = captchaProducerMath.createText();
        capStr = capText.substring(0, capText.lastIndexOf("@"));
        code = capText.substring(capText.lastIndexOf("@") + 1);
        image = captchaProducerMath.createImage(capStr);
    } else if ("char".equals(captchaType)) {
        capStr = code = captchaProducer.createText();
        image = captchaProducer.createImage(capStr);
    }
    redisService.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
    // 转换流信息写出
    FastByteArrayOutputStream os = new FastByteArrayOutputStream();
    try {
        ImageIO.write(image, "jpg", os);
    } catch (IOException e) {
        return AjaxResult.error(e.getMessage());
    }
    ajax.put("uuid", uuid);
    ajax.put("img", Base64.encode(os.toByteArray()));
    return ajax;
}
Also used : AjaxResult(com.ruoyi.common.core.web.domain.AjaxResult) FastByteArrayOutputStream(org.springframework.util.FastByteArrayOutputStream) IOException(java.io.IOException) BufferedImage(java.awt.image.BufferedImage)

Example 10 with AjaxResult

use of com.ruoyi.common.core.web.domain.AjaxResult in project RuoYi-Cloud by yangzongzhuan.

the class SysDeptController method roleDeptTreeselect.

/**
 * 加载对应角色部门列表树
 */
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
    List<SysDept> depts = deptService.selectDeptList(new SysDept());
    AjaxResult ajax = AjaxResult.success();
    ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
    ajax.put("depts", deptService.buildDeptTreeSelect(depts));
    return ajax;
}
Also used : AjaxResult(com.ruoyi.common.core.web.domain.AjaxResult) SysDept(com.ruoyi.system.api.domain.SysDept) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

AjaxResult (com.ruoyi.common.core.web.domain.AjaxResult)16 GetMapping (org.springframework.web.bind.annotation.GetMapping)12 Log (com.ruoyi.common.log.annotation.Log)6 SysUser (com.ruoyi.system.api.domain.SysUser)6 LoginUser (com.ruoyi.system.api.model.LoginUser)6 IOException (java.io.IOException)6 PostMapping (org.springframework.web.bind.annotation.PostMapping)6 UserConstants (com.ruoyi.common.core.constant.UserConstants)4 R (com.ruoyi.common.core.domain.R)4 StringUtils (com.ruoyi.common.core.utils.StringUtils)4 ExcelUtil (com.ruoyi.common.core.utils.poi.ExcelUtil)4 BaseController (com.ruoyi.common.core.web.controller.BaseController)4 TableDataInfo (com.ruoyi.common.core.web.page.TableDataInfo)4 BusinessType (com.ruoyi.common.log.enums.BusinessType)4 InnerAuth (com.ruoyi.common.security.annotation.InnerAuth)4 RequiresPermissions (com.ruoyi.common.security.annotation.RequiresPermissions)4 SecurityUtils (com.ruoyi.common.security.utils.SecurityUtils)4 SysRole (com.ruoyi.system.api.domain.SysRole)4 ISysConfigService (com.ruoyi.system.service.ISysConfigService)4 ISysPermissionService (com.ruoyi.system.service.ISysPermissionService)4