Java Code Examples for org.jeecg.common.api.vo.Result#setCode()
The following examples show how to use
org.jeecg.common.api.vo.Result#setCode() .
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: ThirdLoginController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @RequestMapping(value = "/getLoginUser/{token}", method = RequestMethod.GET) @ResponseBody public Result<JSONObject> getLoginUser(@PathVariable("token") String token) throws Exception { Result<JSONObject> result = new Result<JSONObject>(); String username = JwtUtil.getUsername(token); //1. 校验用户是否有效 SysUser sysUser = sysUserService.getUserByName(username); result = sysUserService.checkUserIsEffective(sysUser); if(!result.isSuccess()) { return result; } JSONObject obj = new JSONObject(); //用户登录信息 obj.put("userInfo", sysUser); //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 2
Source File: ImportExcelUtil.java From jeecg-cloud with Apache License 2.0 | 6 votes |
public static Result<?> imporReturnRes(int errorLines,int successLines,List<String> errorMessage) throws IOException { if (errorLines == 0) { return Result.ok("共" + successLines + "行数据全部导入成功!"); } else { JSONObject result = new JSONObject(5); int totalCount = successLines + errorLines; result.put("totalCount", totalCount); result.put("errorCount", errorLines); result.put("successCount", successLines); result.put("msg", "总上传行数:" + totalCount + ",已导入行数:" + successLines + ",错误行数:" + errorLines); String fileUrl = PmsUtil.saveErrorTxtByList(errorMessage, "userImportExcelErrorLog"); int lastIndex = fileUrl.lastIndexOf(File.separator); String fileName = fileUrl.substring(lastIndex + 1); result.put("fileUrl", "/sys/common/static/" + fileUrl); result.put("fileName", fileName); Result res = Result.ok(result); res.setCode(201); res.setMessage("文件导入成功,但有错误。"); return res; } }
Example 3
Source File: ImportExcelUtil.java From jeecg-boot with Apache License 2.0 | 6 votes |
public static Result<?> imporReturnRes(int errorLines,int successLines,List<String> errorMessage) throws IOException { if (errorLines == 0) { return Result.ok("共" + successLines + "行数据全部导入成功!"); } else { JSONObject result = new JSONObject(5); int totalCount = successLines + errorLines; result.put("totalCount", totalCount); result.put("errorCount", errorLines); result.put("successCount", successLines); result.put("msg", "总上传行数:" + totalCount + ",已导入行数:" + successLines + ",错误行数:" + errorLines); String fileUrl = PmsUtil.saveErrorTxtByList(errorMessage, "userImportExcelErrorLog"); int lastIndex = fileUrl.lastIndexOf(File.separator); String fileName = fileUrl.substring(lastIndex + 1); result.put("fileUrl", "/sys/common/static/" + fileUrl); result.put("fileName", fileName); Result res = Result.ok(result); res.setCode(201); res.setMessage("文件导入成功,但有错误。"); return res; } }
Example 4
Source File: ThirdLoginController.java From jeecg-boot with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @RequestMapping(value = "/getLoginUser/{token}", method = RequestMethod.GET) @ResponseBody public Result<JSONObject> getLoginUser(@PathVariable("token") String token) throws Exception { Result<JSONObject> result = new Result<JSONObject>(); String username = JwtUtil.getUsername(token); //1. 校验用户是否有效 SysUser sysUser = sysUserService.getUserByName(username); result = sysUserService.checkUserIsEffective(sysUser); if(!result.isSuccess()) { return result; } JSONObject obj = new JSONObject(); //用户登录信息 obj.put("userInfo", sysUser); //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 5
Source File: QiniuController.java From teaching with Apache License 2.0 | 5 votes |
@AutoLog("获取七牛上传Token") @ApiOperation(value = "获取七牛上传Token", notes = "获取七牛上传token") @RequestMapping("/getToken") public Result getQiniuToken(){ Result result = new Result(); result.setCode(200); Auth auth = Auth.create(QiniuConfig.key, QiniuConfig.secret); result.setResult(auth.uploadToken(QiniuConfig.bucket, null, QiniuConfig.expires, null)); return result; }
Example 6
Source File: QiniuController.java From teaching with Apache License 2.0 | 5 votes |
@AutoLog("获取七牛上传Token") @ApiOperation(value = "获取七牛覆盖Token", notes = "获取七牛覆盖token") @RequestMapping("/getTokenByKey") public Result getQiniuTokenByKey(@RequestParam String key){ Result result = new Result(); result.setCode(200); Auth auth = Auth.create(QiniuConfig.key, QiniuConfig.secret); result.setResult(auth.uploadToken(QiniuConfig.bucket, key, QiniuConfig.expires, null)); return result; }
Example 7
Source File: LoginController.java From jeecg-cloud 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 8
Source File: LoginController.java From jeecg-boot-with-activiti with MIT License | 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 9
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 10
Source File: LoginController.java From jeecg-boot 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; }