Java Code Examples for org.jeecg.common.api.vo.Result#setResult()
The following examples show how to use
org.jeecg.common.api.vo.Result#setResult() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SysCategoryController.java From teaching with Apache License 2.0 | 6 votes |
/** * 加载单个数据 用于回显 */ @RequestMapping(value = "/loadOne", method = RequestMethod.GET) public Result<SysCategory> loadOne(@RequestParam(name="field") String field,@RequestParam(name="val") String val) { Result<SysCategory> result = new Result<SysCategory>(); try { QueryWrapper<SysCategory> query = new QueryWrapper<SysCategory>(); query.eq(field, val); List<SysCategory> ls = this.sysCategoryService.list(query); if(ls==null || ls.size()==0) { result.setMessage("查询无果"); result.setSuccess(false); }else if(ls.size()>1) { result.setMessage("查询数据异常,["+field+"]存在多个值:"+val); result.setSuccess(false); }else { result.setSuccess(true); result.setResult(ls.get(0)); } } catch (Exception e) { e.printStackTrace(); result.setMessage(e.getMessage()); result.setSuccess(false); } return result; }
Example 2
Source File: SysUserController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 查询指定用户和部门关联的数据 * * @param userId * @return */ @RequestMapping(value = "/userDepartList", method = RequestMethod.GET) public Result<List<DepartIdModel>> getUserDepartsList(@RequestParam(name = "userId", required = true) String userId) { Result<List<DepartIdModel>> result = new Result<>(); try { List<DepartIdModel> depIdModelList = this.sysUserDepartService.queryDepartIdsOfUser(userId); if (depIdModelList != null && depIdModelList.size() > 0) { result.setSuccess(true); result.setMessage("查找成功"); result.setResult(depIdModelList); } else { result.setSuccess(false); result.setMessage("查找失败"); } return result; } catch (Exception e) { log.error(e.getMessage(), e); result.setSuccess(false); result.setMessage("查找过程中出现了异常: " + e.getMessage()); return result; } }
Example 3
Source File: LoginController.java From teaching with Apache License 2.0 | 6 votes |
/** * 后台生成图形验证码 * @param response * @param key */ @ApiOperation("获取验证码2") @GetMapping(value = "/randomImage/{key}") public Result<String> randomImage(HttpServletResponse response,@PathVariable String key){ Result<String> res = new Result<String>(); try { String code = RandomUtil.randomString(BASE_CHECK_CODES,4); String lowerCaseCode = code.toLowerCase(); String realKey = MD5Util.MD5Encode(lowerCaseCode+key, "utf-8"); redisUtil.set(realKey, lowerCaseCode, 60); String base64 = RandImageUtil.generate(code); res.setSuccess(true); res.setResult(base64); } catch (Exception e) { res.error500("获取验证码出错"+e.getMessage()); e.printStackTrace(); } return res; }
Example 4
Source File: SysPositionController.java From teaching with Apache License 2.0 | 6 votes |
/** * 分页列表查询 * * @param sysPosition * @param pageNo * @param pageSize * @param req * @return */ @AutoLog(value = "职务表-分页列表查询") @ApiOperation(value = "职务表-分页列表查询", notes = "职务表-分页列表查询") @GetMapping(value = "/list") public Result<IPage<SysPosition>> queryPageList(SysPosition sysPosition, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { Result<IPage<SysPosition>> result = new Result<IPage<SysPosition>>(); QueryWrapper<SysPosition> queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, req.getParameterMap()); Page<SysPosition> page = new Page<SysPosition>(pageNo, pageSize); IPage<SysPosition> pageList = sysPositionService.page(page, queryWrapper); result.setSuccess(true); result.setResult(pageList); return result; }
Example 5
Source File: SysDepartController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 查询数据 查出我的部门,并以树结构数据格式响应给前端 * * @return */ @RequestMapping(value = "/queryMyDeptTreeList", method = RequestMethod.GET) public Result<List<SysDepartTreeModel>> queryMyDeptTreeList() { Result<List<SysDepartTreeModel>> result = new Result<>(); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); try { if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals( CommonConstant.USER_IDENTITY_2 )){ List<SysDepartTreeModel> list = sysDepartService.queryMyDeptTreeList(user.getDepartIds()); result.setResult(list); result.setMessage(CommonConstant.USER_IDENTITY_2.toString()); result.setSuccess(true); }else{ result.setMessage(CommonConstant.USER_IDENTITY_1.toString()); result.setSuccess(true); } } catch (Exception e) { log.error(e.getMessage(),e); } return result; }
Example 6
Source File: SysAnnouncementSendController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * @功能:获取我的消息 * @return */ @GetMapping(value = "/getMyAnnouncementSend") public Result<IPage<AnnouncementSendModel>> getMyAnnouncementSend(AnnouncementSendModel announcementSendModel, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) { Result<IPage<AnnouncementSendModel>> result = new Result<IPage<AnnouncementSendModel>>(); LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); announcementSendModel.setUserId(userId); announcementSendModel.setPageNo((pageNo-1)*pageSize); announcementSendModel.setPageSize(pageSize); Page<AnnouncementSendModel> pageList = new Page<AnnouncementSendModel>(pageNo,pageSize); pageList = sysAnnouncementSendService.getMyAnnouncementSendPage(pageList, announcementSendModel); result.setResult(pageList); result.setSuccess(true); return result; }
Example 7
Source File: SysDictController.java From jeecg-boot with Apache License 2.0 | 5 votes |
/** * 【APP接口】根据字典配置查询表字典数据 * @param query * @param pageNo * @param pageSize * @return */ @GetMapping("/queryTableData") public Result<List<DictModel>> queryTableData(DictQuery query, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, @RequestParam(value = "sign",required = false) String sign,HttpServletRequest request){ Result<List<DictModel>> res = new Result<List<DictModel>>(); // SQL注入漏洞 sign签名校验 String dictCode = query.getTable()+","+query.getText()+","+query.getCode(); List<DictModel> ls = this.sysDictService.queryDictTablePageList(query,pageSize,pageNo); res.setResult(ls); res.setSuccess(true); return res; }
Example 8
Source File: SysDepartRoleController.java From teaching with Apache License 2.0 | 5 votes |
/** * 获取部门下角色 * @param departId * @return */ @RequestMapping(value = "/getDeptRoleList", method = RequestMethod.GET) public Result<List<SysDepartRole>> getDeptRoleList(@RequestParam(value = "departId") String departId){ Result<List<SysDepartRole>> result = new Result<>(); List<SysDepartRole> deptRoleList = sysDepartRoleService.list(new QueryWrapper<SysDepartRole>().eq("depart_id",departId)); result.setSuccess(true); result.setResult(deptRoleList); return result; }
Example 9
Source File: SysUserController.java From jeecg-boot-with-activiti with MIT License | 5 votes |
@RequestMapping(value = "/userRoleList", method = RequestMethod.GET) public Result<IPage<SysUser>> userRoleList(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) { Result<IPage<SysUser>> result = new Result<IPage<SysUser>>(); Page<SysUser> page = new Page<SysUser>(pageNo, pageSize); String roleId = req.getParameter("roleId"); String username = req.getParameter("username"); IPage<SysUser> pageList = sysUserService.getUserByRoleId(page,roleId,username); result.setSuccess(true); result.setResult(pageList); return result; }
Example 10
Source File: SysRoleController.java From teaching with Apache License 2.0 | 5 votes |
/** * 分页列表查询 * @param role * @param pageNo * @param pageSize * @param req * @return */ @RequestMapping(value = "/list", method = RequestMethod.GET) public Result<IPage<SysRole>> queryPageList(SysRole role, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) { Result<IPage<SysRole>> result = new Result<IPage<SysRole>>(); QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(role, req.getParameterMap()); Page<SysRole> page = new Page<SysRole>(pageNo, pageSize); IPage<SysRole> pageList = sysRoleService.page(page, queryWrapper); result.setSuccess(true); result.setResult(pageList); return result; }
Example 11
Source File: LoginController.java From jeecg-boot-with-activiti with MIT License | 5 votes |
/** * 获取加密字符串 * @return */ @GetMapping(value = "/getEncryptedString") public Result<Map<String,String>> getEncryptedString(){ Result<Map<String,String>> result = new Result<Map<String,String>>(); Map<String,String> map = new HashMap<String,String>(); map.put("key", EncryptedString.key); map.put("iv",EncryptedString.iv); result.setResult(map); return result; }
Example 12
Source File: SysAnnouncementController.java From teaching with Apache License 2.0 | 5 votes |
/** * @功能:补充用户数据,并返回系统消息 * @param id * @return */ @RequestMapping(value = "/listByUser", method = RequestMethod.GET) public Result<Map<String,Object>> listByUser() { Result<Map<String,Object>> result = new Result<Map<String,Object>>(); LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); // 1.将系统消息补充到用户通告阅读标记表中 Collection<String> anntIds = sysAnnouncementSendService.queryByUserId(userId); LambdaQueryWrapper<SysAnnouncement> querySaWrapper = new LambdaQueryWrapper<SysAnnouncement>(); querySaWrapper.eq(SysAnnouncement::getMsgType,CommonConstant.MSG_TYPE_ALL); // 全部人员 querySaWrapper.eq(SysAnnouncement::getDelFlag,CommonConstant.DEL_FLAG_0.toString()); // 未删除 querySaWrapper.eq(SysAnnouncement::getSendStatus, CommonConstant.HAS_SEND); //已发布 querySaWrapper.ge(SysAnnouncement::getEndTime, sysUser.getCreateTime()); //新注册用户不看结束通知 if(anntIds!=null&&anntIds.size()>0) { querySaWrapper.notIn(SysAnnouncement::getId, anntIds); } List<SysAnnouncement> announcements = sysAnnouncementService.list(querySaWrapper); if(announcements.size()>0) { for(int i=0;i<announcements.size();i++) { SysAnnouncementSend announcementSend = new SysAnnouncementSend(); announcementSend.setAnntId(announcements.get(i).getId()); announcementSend.setUserId(userId); announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG); sysAnnouncementSendService.save(announcementSend); } } // 2.查询用户未读的系统消息 Page<SysAnnouncement> anntMsgList = new Page<SysAnnouncement>(0,5); anntMsgList = sysAnnouncementService.querySysCementPageByUserId(anntMsgList,userId,"1");//通知公告消息 Page<SysAnnouncement> sysMsgList = new Page<SysAnnouncement>(0,5); sysMsgList = sysAnnouncementService.querySysCementPageByUserId(sysMsgList,userId,"2");//系统消息 Map<String,Object> sysMsgMap = new HashMap<String, Object>(); sysMsgMap.put("sysMsgList", sysMsgList.getRecords()); sysMsgMap.put("sysMsgTotal", sysMsgList.getTotal()); sysMsgMap.put("anntMsgList", anntMsgList.getRecords()); sysMsgMap.put("anntMsgTotal", anntMsgList.getTotal()); result.setSuccess(true); result.setResult(sysMsgMap); return result; }
Example 13
Source File: SysAnnouncementController.java From jeecg-cloud with Apache License 2.0 | 5 votes |
/** * 分页列表查询 * @param sysAnnouncement * @param pageNo * @param pageSize * @param req * @return */ @RequestMapping(value = "/list", method = RequestMethod.GET) public Result<IPage<SysAnnouncement>> queryPageList(SysAnnouncement sysAnnouncement, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) { Result<IPage<SysAnnouncement>> result = new Result<IPage<SysAnnouncement>>(); sysAnnouncement.setDelFlag(CommonConstant.DEL_FLAG_0.toString()); QueryWrapper<SysAnnouncement> queryWrapper = new QueryWrapper<SysAnnouncement>(sysAnnouncement); Page<SysAnnouncement> page = new Page<SysAnnouncement>(pageNo,pageSize); //排序逻辑 处理 String column = req.getParameter("column"); String order = req.getParameter("order"); if(oConvertUtils.isNotEmpty(column) && oConvertUtils.isNotEmpty(order)) { if("asc".equals(order)) { queryWrapper.orderByAsc(oConvertUtils.camelToUnderline(column)); }else { queryWrapper.orderByDesc(oConvertUtils.camelToUnderline(column)); } } IPage<SysAnnouncement> pageList = sysAnnouncementService.page(page, queryWrapper); log.info("查询当前页:"+pageList.getCurrent()); log.info("查询当前页数量:"+pageList.getSize()); log.info("查询结果数量:"+pageList.getRecords().size()); log.info("数据总数:"+pageList.getTotal()); result.setSuccess(true); result.setResult(pageList); return result; }
Example 14
Source File: SysRoleController.java From jeecg-boot-with-activiti with MIT License | 5 votes |
/** * 分页列表查询 * @param role * @param pageNo * @param pageSize * @param req * @return */ @RequestMapping(value = "/list", method = RequestMethod.GET) public Result<IPage<SysRole>> queryPageList(SysRole role, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) { Result<IPage<SysRole>> result = new Result<IPage<SysRole>>(); QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(role, req.getParameterMap()); Page<SysRole> page = new Page<SysRole>(pageNo, pageSize); IPage<SysRole> pageList = sysRoleService.page(page, queryWrapper); result.setSuccess(true); result.setResult(pageList); return result; }
Example 15
Source File: SysAnnouncementController.java From jeecg-boot with Apache License 2.0 | 5 votes |
/** * 通过id查询 * @param id * @return */ @RequestMapping(value = "/queryById", method = RequestMethod.GET) public Result<SysAnnouncement> queryById(@RequestParam(name="id",required=true) String id) { Result<SysAnnouncement> result = new Result<SysAnnouncement>(); SysAnnouncement sysAnnouncement = sysAnnouncementService.getById(id); if(sysAnnouncement==null) { result.error500("未找到对应实体"); }else { result.setResult(sysAnnouncement); result.setSuccess(true); } return result; }
Example 16
Source File: SysUserController.java From jeecg-boot with Apache License 2.0 | 5 votes |
@RequestMapping(value = "/queryById", method = RequestMethod.GET) public Result<SysUser> queryById(@RequestParam(name = "id", required = true) String id) { Result<SysUser> result = new Result<SysUser>(); SysUser sysUser = sysUserService.getById(id); if (sysUser == null) { result.error500("未找到对应实体"); } else { result.setResult(sysUser); result.setSuccess(true); } return result; }
Example 17
Source File: LoginController.java From teaching with Apache License 2.0 | 4 votes |
/** * app登录 * @param sysLoginModel * @return * @throws Exception */ @RequestMapping(value = "/mLogin", method = RequestMethod.POST) public Result<JSONObject> mLogin(@RequestBody SysLoginModel sysLoginModel) throws Exception { Result<JSONObject> result = new Result<JSONObject>(); String username = sysLoginModel.getUsername(); String password = sysLoginModel.getPassword(); //1. 校验用户是否有效 SysUser sysUser = sysUserService.getUserByName(username); result = sysUserService.checkUserIsEffective(sysUser); if(!result.isSuccess()) { return result; } //2. 校验用户名或密码是否正确 String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt()); String syspassword = sysUser.getPassword(); if (!syspassword.equals(userpassword)) { result.error500("用户名或密码错误"); return result; } String orgCode = sysUser.getOrgCode(); if(oConvertUtils.isEmpty(orgCode)) { //如果当前用户无选择部门 查看部门关联信息 List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId()); if (departs == null || departs.size() == 0) { result.error500("用户暂未归属部门,不可登录!"); return result; } orgCode = departs.get(0).getOrgCode(); sysUser.setOrgCode(orgCode); this.sysUserService.updateUserDepart(username, orgCode); } JSONObject obj = new JSONObject(); //用户登录信息 obj.put("userInfo", sysUser); // 生成token String token = JwtUtil.sign(username, syspassword); // 设置超时时间 redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token); redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000); //token 信息 obj.put("token", token); result.setResult(obj); result.setSuccess(true); result.setCode(200); sysBaseAPI.addLog("用户名: " + username + ",登录成功[移动端]!", CommonConstant.LOG_TYPE_1, null); return result; }
Example 18
Source File: CasClientController.java From jeecg-cloud with Apache License 2.0 | 4 votes |
@GetMapping("/validateLogin") public Object validateLogin(@RequestParam(name="ticket") String ticket, @RequestParam(name="service") String service, HttpServletRequest request, HttpServletResponse response) throws Exception { Result<JSONObject> result = new Result<JSONObject>(); log.info("Rest api login."); try { String validateUrl = prefixUrl+"/p3/serviceValidate"; String res = CASServiceUtil.getSTValidate(validateUrl, ticket, service); log.info("res."+res); final String error = XmlUtils.getTextForElement(res, "authenticationFailure"); if(StringUtils.isNotEmpty(error)) { throw new Exception(error); } final String principal = XmlUtils.getTextForElement(res, "user"); if (StringUtils.isEmpty(principal)) { throw new Exception("No principal was found in the response from the CAS server."); } log.info("-------token----username---"+principal); //1. 校验用户是否有效 SysUser sysUser = sysUserService.getUserByName(principal); result = sysUserService.checkUserIsEffective(sysUser); if(!result.isSuccess()) { return result; } String token = JwtUtil.sign(sysUser.getUsername(), sysUser.getPassword()); // 设置超时时间 redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token); redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000); //获取用户部门信息 JSONObject obj = new JSONObject(); List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId()); obj.put("departs", departs); if (departs == null || departs.size() == 0) { obj.put("multi_depart", 0); } else if (departs.size() == 1) { sysUserService.updateUserDepart(principal, departs.get(0).getOrgCode()); obj.put("multi_depart", 1); } else { obj.put("multi_depart", 2); } obj.put("token", token); obj.put("userInfo", sysUser); result.setResult(obj); result.success("登录成功"); } catch (Exception e) { //e.printStackTrace(); result.error500(e.getMessage()); } return new HttpEntity<>(result); }
Example 19
Source File: SysDictController.java From jeecg-cloud with Apache License 2.0 | 4 votes |
/** * 获取字典数据 * @param dictCode 字典code * @param dictCode 表名,文本字段,code字段 | 举例:sys_user,realname,id * @return */ @RequestMapping(value = "/getDictItems/{dictCode}", method = RequestMethod.GET) public Result<List<DictModel>> getDictItems(@PathVariable String dictCode, @RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) { log.info(" dictCode : "+ dictCode); Result<List<DictModel>> result = new Result<List<DictModel>>(); List<DictModel> ls = null; try { if(dictCode.indexOf(",")!=-1) { //关联表字典(举例:sys_user,realname,id) String[] params = dictCode.split(","); if(params.length<3) { result.error500("字典Code格式不正确!"); return result; } //SQL注入校验(只限制非法串改数据库) final String[] sqlInjCheck = {params[0],params[1],params[2]}; SqlInjectionUtil.filterContent(sqlInjCheck); if(params.length==4) { //SQL注入校验(查询条件SQL 特殊check,此方法仅供此处使用) SqlInjectionUtil.specialFilterContent(params[3]); ls = sysDictService.queryTableDictItemsByCodeAndFilter(params[0],params[1],params[2],params[3]); }else if (params.length==3) { ls = sysDictService.queryTableDictItemsByCode(params[0],params[1],params[2]); }else{ result.error500("字典Code格式不正确!"); return result; } }else { //字典表 ls = sysDictService.queryDictItemsByCode(dictCode); } result.setSuccess(true); result.setResult(ls); log.info(result.toString()); } catch (Exception e) { log.error(e.getMessage(),e); result.error500("操作失败"); return result; } return result; }
Example 20
Source File: SysDictController.java From jeecg-boot with Apache License 2.0 | 4 votes |
/** * 获取字典数据 * @param dictCode 字典code * @param dictCode 表名,文本字段,code字段 | 举例:sys_user,realname,id * @return */ @RequestMapping(value = "/getDictItems/{dictCode}", method = RequestMethod.GET) public Result<List<DictModel>> getDictItems(@PathVariable String dictCode, @RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) { log.info(" dictCode : "+ dictCode); Result<List<DictModel>> result = new Result<List<DictModel>>(); List<DictModel> ls = null; try { if(dictCode.indexOf(",")!=-1) { //关联表字典(举例:sys_user,realname,id) String[] params = dictCode.split(","); if(params.length<3) { result.error500("字典Code格式不正确!"); return result; } //SQL注入校验(只限制非法串改数据库) final String[] sqlInjCheck = {params[0],params[1],params[2]}; SqlInjectionUtil.filterContent(sqlInjCheck); if(params.length==4) { //SQL注入校验(查询条件SQL 特殊check,此方法仅供此处使用) SqlInjectionUtil.specialFilterContent(params[3]); ls = sysDictService.queryTableDictItemsByCodeAndFilter(params[0],params[1],params[2],params[3]); }else if (params.length==3) { ls = sysDictService.queryTableDictItemsByCode(params[0],params[1],params[2]); }else{ result.error500("字典Code格式不正确!"); return result; } }else { //字典表 ls = sysDictService.queryDictItemsByCode(dictCode); } result.setSuccess(true); result.setResult(ls); log.info(result.toString()); } catch (Exception e) { log.error(e.getMessage(),e); result.error500("操作失败"); return result; } return result; }