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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations