Search in sources :

Example 1 with SysRole

use of org.jeecg.modules.system.entity.SysRole in project jeecg-boot by jeecgboot.

the class SysRoleController method edit.

/**
 *  编辑
 * @param role
 * @return
 */
// @RequiresRoles({"admin"})
@RequestMapping(value = "/edit", method = { RequestMethod.PUT, RequestMethod.POST })
public Result<SysRole> edit(@RequestBody SysRole role) {
    Result<SysRole> result = new Result<SysRole>();
    SysRole sysrole = sysRoleService.getById(role.getId());
    if (sysrole == null) {
        result.error500("未找到对应实体");
    } else {
        role.setUpdateTime(new Date());
        boolean ok = sysRoleService.updateById(role);
        // TODO 返回false说明什么?
        if (ok) {
            result.success("修改成功!");
        }
    }
    return result;
}
Also used : SysRole(org.jeecg.modules.system.entity.SysRole) Date(java.util.Date) Result(org.jeecg.common.api.vo.Result) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with SysRole

use of org.jeecg.modules.system.entity.SysRole in project jeecg-boot by jeecgboot.

the class SysRoleController method exportXls.

/**
 * 导出excel
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysRole sysRole, HttpServletRequest request) {
    // Step.1 组装查询条件
    QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(sysRole, request.getParameterMap());
    // Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysRole> pageList = sysRoleService.list(queryWrapper);
    // 导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "角色列表");
    mv.addObject(NormalExcelConstants.CLASS, SysRole.class);
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("角色列表数据", "导出人:" + user.getRealname(), "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
Also used : ExportParams(org.jeecgframework.poi.excel.entity.ExportParams) JeecgEntityExcelView(org.jeecgframework.poi.excel.view.JeecgEntityExcelView) SysRole(org.jeecg.modules.system.entity.SysRole) ModelAndView(org.springframework.web.servlet.ModelAndView) LoginUser(org.jeecg.common.system.vo.LoginUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with SysRole

use of org.jeecg.modules.system.entity.SysRole in project jeecg-boot by jeecgboot.

the class SysRoleController method checkUsername.

/**
 * 校验角色编码唯一
 */
@RequestMapping(value = "/checkRoleCode", method = RequestMethod.GET)
public Result<Boolean> checkUsername(String id, String roleCode) {
    Result<Boolean> result = new Result<>();
    // 如果此参数为false则程序发生异常
    result.setResult(true);
    log.info("--验证角色编码是否唯一---id:" + id + "--roleCode:" + roleCode);
    try {
        SysRole role = null;
        if (oConvertUtils.isNotEmpty(id)) {
            role = sysRoleService.getById(id);
        }
        SysRole newRole = sysRoleService.getOne(new QueryWrapper<SysRole>().lambda().eq(SysRole::getRoleCode, roleCode));
        if (newRole != null) {
            // 如果根据传入的roleCode查询到信息了,那么就需要做校验了。
            if (role == null) {
                // role为空=>新增模式=>只要roleCode存在则返回false
                result.setSuccess(false);
                result.setMessage("角色编码已存在");
                return result;
            } else if (!id.equals(newRole.getId())) {
                // 否则=>编辑模式=>判断两者ID是否一致-
                result.setSuccess(false);
                result.setMessage("角色编码已存在");
                return result;
            }
        }
    } catch (Exception e) {
        result.setSuccess(false);
        result.setResult(false);
        result.setMessage(e.getMessage());
        return result;
    }
    result.setSuccess(true);
    return result;
}
Also used : SysRole(org.jeecg.modules.system.entity.SysRole) IOException(java.io.IOException) Result(org.jeecg.common.api.vo.Result) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with SysRole

use of org.jeecg.modules.system.entity.SysRole in project kms by mahonelau.

the class SysThirdAccountServiceImpl method saveThirdUser.

public String saveThirdUser(SysUser sysUser) {
    // 保存用户
    String userid = UUIDGenerator.generate();
    sysUser.setId(userid);
    sysUserMapper.insert(sysUser);
    // 获取第三方角色
    SysRole sysRole = sysRoleMapper.selectOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleCode, "third_role"));
    // 保存用户角色
    SysUserRole userRole = new SysUserRole();
    userRole.setRoleId(sysRole.getId());
    userRole.setUserId(userid);
    sysUserRoleMapper.insert(userRole);
    return userid;
}
Also used : SysRole(org.jeecg.modules.system.entity.SysRole) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) SysUserRole(org.jeecg.modules.system.entity.SysUserRole)

Example 5 with SysRole

use of org.jeecg.modules.system.entity.SysRole in project kms by mahonelau.

the class SysRoleController method checkUsername.

/**
 * 校验角色编码唯一
 */
@RequestMapping(value = "/checkRoleCode", method = RequestMethod.GET)
public Result<Boolean> checkUsername(String id, String roleCode) {
    Result<Boolean> result = new Result<>();
    // 如果此参数为false则程序发生异常
    result.setResult(true);
    log.info("--验证角色编码是否唯一---id:" + id + "--roleCode:" + roleCode);
    try {
        SysRole role = null;
        if (oConvertUtils.isNotEmpty(id)) {
            role = sysRoleService.getById(id);
        }
        SysRole newRole = sysRoleService.getOne(new QueryWrapper<SysRole>().lambda().eq(SysRole::getRoleCode, roleCode));
        if (newRole != null) {
            // 如果根据传入的roleCode查询到信息了,那么就需要做校验了。
            if (role == null) {
                // role为空=>新增模式=>只要roleCode存在则返回false
                result.setSuccess(false);
                result.setMessage("角色编码已存在");
                return result;
            } else if (!id.equals(newRole.getId())) {
                // 否则=>编辑模式=>判断两者ID是否一致-
                result.setSuccess(false);
                result.setMessage("角色编码已存在");
                return result;
            }
        }
    } catch (Exception e) {
        result.setSuccess(false);
        result.setResult(false);
        result.setMessage(e.getMessage());
        return result;
    }
    result.setSuccess(true);
    return result;
}
Also used : SysRole(org.jeecg.modules.system.entity.SysRole) IOException(java.io.IOException) Result(org.jeecg.common.api.vo.Result) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SysRole (org.jeecg.modules.system.entity.SysRole)20 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)15 Result (org.jeecg.common.api.vo.Result)14 IOException (java.io.IOException)6 Date (java.util.Date)6 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)5 LoginUser (org.jeecg.common.system.vo.LoginUser)3 SysUserRole (org.jeecg.modules.system.entity.SysUserRole)3 ExportParams (org.jeecgframework.poi.excel.entity.ExportParams)3 JeecgEntityExcelView (org.jeecgframework.poi.excel.view.JeecgEntityExcelView)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 JSONObject (com.alibaba.fastjson.JSONObject)2 ApiOperation (io.swagger.annotations.ApiOperation)2 EncryptedString (org.jeecg.common.util.encryption.EncryptedString)2 SysDepart (org.jeecg.modules.system.entity.SysDepart)2 SysUser (org.jeecg.modules.system.entity.SysUser)2 HttpHeaders (org.springframework.http.HttpHeaders)2