Java Code Examples for org.jeecg.common.api.vo.Result#setMessage()

The following examples show how to use org.jeecg.common.api.vo.Result#setMessage() . 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: SysUserController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 给指定部门添加对应的用户
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/editSysDepartWithUser", method = RequestMethod.POST)
public Result<String> editSysDepartWithUser(@RequestBody SysDepartUsersVO sysDepartUsersVO) {
    Result<String> result = new Result<String>();
    try {
        String sysDepId = sysDepartUsersVO.getDepId();
        for(String sysUserId:sysDepartUsersVO.getUserIdList()) {
            SysUserDepart sysUserDepart = new SysUserDepart(null,sysUserId,sysDepId);
            QueryWrapper<SysUserDepart> queryWrapper = new QueryWrapper<SysUserDepart>();
            queryWrapper.eq("dep_id", sysDepId).eq("user_id",sysUserId);
            SysUserDepart one = sysUserDepartService.getOne(queryWrapper);
            if(one==null){
                sysUserDepartService.save(sysUserDepart);
            }
        }
        result.setMessage("添加成功!");
        result.setSuccess(true);
        return result;
    }catch(Exception e) {
        log.error(e.getMessage(), e);
        result.setSuccess(false);
        result.setMessage("出错了: " + e.getMessage());
        return result;
    }
}
 
Example 2
Source File: SysUploadController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 上传
 * @param request
 */
@PostMapping(value = "/uploadMinio")
public Result<?> uploadMinio(HttpServletRequest request) {
    Result<?> result = new Result<>();
    String bizPath = request.getParameter("biz");
    if(oConvertUtils.isEmpty(bizPath)){
        bizPath = "";
    }
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象
    String orgName = file.getOriginalFilename();// 获取文件名
    orgName = CommonUtils.getFileName(orgName);
    String file_url =  MinioUtil.upload(file,bizPath);
    //保存文件信息
    OSSFile minioFile = new OSSFile();
    minioFile.setFileName(orgName);
    minioFile.setUrl(file_url);
    ossFileService.save(minioFile);
    result.setMessage(file_url);
    result.setSuccess(true);
    return result;
}
 
Example 3
Source File: SysCategoryController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
     * 加载一级节点/如果是同步 则所有数据
 */
@RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
public Result<List<TreeSelectModel>> loadTreeRoot(@RequestParam(name="async") Boolean async,@RequestParam(name="pcode") String pcode) {
	Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
	try {
		List<TreeSelectModel> ls = this.sysCategoryService.queryListByCode(pcode);
		if(!async) {
			loadAllCategoryChildren(ls);
		}
		result.setResult(ls);
		result.setSuccess(true);
	} catch (Exception e) {
		e.printStackTrace();
		result.setMessage(e.getMessage());
		result.setSuccess(false);
	}
	return result;
}
 
Example 4
Source File: SysAnnouncementSendController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * @功能:一键已读
 * @return
 */
@PutMapping(value = "/readAll")
public Result<SysAnnouncementSend> readAll() {
	Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
	LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
	String userId = sysUser.getId();
	LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda();
	updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG);
	updateWrapper.set(SysAnnouncementSend::getReadTime, new Date());
	updateWrapper.last("where user_id ='"+userId+"'");
	SysAnnouncementSend announcementSend = new SysAnnouncementSend();
	sysAnnouncementSendService.update(announcementSend, updateWrapper);
	result.setSuccess(true);
	result.setMessage("全部已读");
	return result;
}
 
Example 5
Source File: SysDepartController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 查询数据 查出我的部门,并以树结构数据格式响应给前端
 *
 * @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.getIdentity()) && user.getIdentity() == 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: SysUserController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 用户手机号验证
 */
@PostMapping("/phoneVerification")
public Result<String> phoneVerification(@RequestBody JSONObject jsonObject) {
	Result<String> result = new Result<String>();
	String phone = jsonObject.getString("phone");
	String smscode = jsonObject.getString("smscode");
	Object code = redisUtil.get(phone);
	if (!smscode.equals(code)) {
		result.setMessage("手机验证码错误");
		result.setSuccess(false);
		return result;
	}
	redisUtil.set(phone, smscode);
	result.setResult(smscode);
	result.setSuccess(true);
	return result;
}
 
Example 7
Source File: SysUserController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 给指定部门添加对应的用户
 */
@RequestMapping(value = "/editSysDepartWithUser", method = RequestMethod.POST)
public Result<String> editSysDepartWithUser(@RequestBody SysDepartUsersVO sysDepartUsersVO) {
    Result<String> result = new Result<String>();
    try {
        String sysDepId = sysDepartUsersVO.getDepId();
        for(String sysUserId:sysDepartUsersVO.getUserIdList()) {
            SysUserDepart sysUserDepart = new SysUserDepart(null,sysUserId,sysDepId);
            QueryWrapper<SysUserDepart> queryWrapper = new QueryWrapper<SysUserDepart>();
            queryWrapper.eq("dep_id", sysDepId).eq("user_id",sysUserId);
            SysUserDepart one = sysUserDepartService.getOne(queryWrapper);
            if(one==null){
                sysUserDepartService.save(sysUserDepart);
            }
        }
        result.setMessage("添加成功!");
        result.setSuccess(true);
        return result;
    }catch(Exception e) {
        log.error(e.getMessage(), e);
        result.setSuccess(false);
        result.setMessage("出错了: " + e.getMessage());
        return result;
    }
}
 
Example 8
Source File: SysUserController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 查询指定用户和部门关联的数据
 *
 * @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 9
Source File: SysUserController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
*  校验用户账号是否唯一<br>
*  可以校验其他 需要检验什么就传什么。。。
  *
  * @param sysUser
  * @return
  */
 @RequestMapping(value = "/checkOnlyUser", method = RequestMethod.GET)
 public Result<Boolean> checkOnlyUser(SysUser sysUser) {
     Result<Boolean> result = new Result<>();
     //如果此参数为false则程序发生异常
     result.setResult(true);
     try {
         //通过传入信息查询新的用户信息
         SysUser user = sysUserService.getOne(new QueryWrapper<SysUser>(sysUser));
         if (user != null) {
             result.setSuccess(false);
             result.setMessage("用户账号已存在");
             return result;
         }

     } catch (Exception e) {
         result.setSuccess(false);
         result.setMessage(e.getMessage());
         return result;
     }
     result.setSuccess(true);
     return result;
 }
 
Example 10
Source File: ImportExcelUtil.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
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 11
Source File: SysUploadController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 上传
 * @param request
 */
@PostMapping(value = "/uploadMinio")
public Result<?> uploadMinio(HttpServletRequest request) {
    Result<?> result = new Result<>();
    String bizPath = request.getParameter("biz");
    if(oConvertUtils.isEmpty(bizPath)){
        bizPath = "";
    }
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象
    String orgName = file.getOriginalFilename();// 获取文件名
    orgName = CommonUtils.getFileName(orgName);
    String file_url =  MinioUtil.upload(file,bizPath);
    //保存文件信息
    OSSFile minioFile = new OSSFile();
    minioFile.setFileName(orgName);
    minioFile.setUrl(file_url);
    ossFileService.save(minioFile);
    result.setMessage(file_url);
    result.setSuccess(true);
    return result;
}
 
Example 12
Source File: SysRoleController.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
  * 校验角色编码唯一
 */
@RequestMapping(value = "/checkRoleCode", method = RequestMethod.GET)
public Result<Boolean> checkUsername(String id,String roleCode) {
	Result<Boolean> result = new Result<>();
	result.setResult(true);//如果此参数为false则程序发生异常
	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;
}
 
Example 13
Source File: SysCategoryController.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 分类字典树控件 加载节点
 * @param pid
 * @param pcode
 * @param condition
 * @return
 */
@RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
public Result<List<TreeSelectModel>> loadDict(@RequestParam(name="pid",required = false) String pid,@RequestParam(name="pcode",required = false) String pcode, @RequestParam(name="condition",required = false) String condition) {
 Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
 //pid如果传值了 就忽略pcode的作用
 if(oConvertUtils.isEmpty(pid)){
 	if(oConvertUtils.isEmpty(pcode)){
		result.setSuccess(false);
		result.setMessage("加载分类字典树参数有误.[null]!");
		return result;
	}else{
 		if(sysCategoryService.ROOT_PID_VALUE.equals(pcode)){
			pid = sysCategoryService.ROOT_PID_VALUE;
		}else{
			pid = this.sysCategoryService.queryIdByCode(pcode);
		}
		if(oConvertUtils.isEmpty(pid)){
			result.setSuccess(false);
			result.setMessage("加载分类字典树参数有误.[code]!");
			return result;
		}
	}
 }
 Map<String, String> query = null;
 if(oConvertUtils.isNotEmpty(condition)) {
	 query = JSON.parseObject(condition, Map.class);
 }
 List<TreeSelectModel> ls = sysCategoryService.queryListByPid(pid,query);
 result.setSuccess(true);
 result.setResult(ls);
 return result;
}
 
Example 14
Source File: SysCategoryController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
         * 加载节点的子数据
    */
   @RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET)
public Result<List<TreeSelectModel>> loadTreeChildren(@RequestParam(name="pid") String pid) {
	Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
	try {
		List<TreeSelectModel> ls = this.sysCategoryService.queryListByPid(pid);
		result.setResult(ls);
		result.setSuccess(true);
	} catch (Exception e) {
		e.printStackTrace();
		result.setMessage(e.getMessage());
		result.setSuccess(false);
	}
	return result;
}
 
Example 15
Source File: TeachingWorkController.java    From teaching with Apache License 2.0 5 votes vote down vote up
@AutoLog("发送作业给其他用户")
@ApiOperation(value = "发送作业给其他用户", notes = "发送作业给其他用户")
@PostMapping("/sendWork")
public Result<TeachingWork> sendWork(@RequestBody StudentWorkSendVO studentWorkSendVO){
 Result<TeachingWork> result = new Result<>();
 int count = teachingWorkService.sendWork(studentWorkSendVO);
 result.setSuccess(true);
 result.setMessage(String.format("发送成功,共%d个用户", count));
 return result;
}
 
Example 16
Source File: LoginController.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 手机号登录接口
 * 
 * @param jsonObject
 * @return
 */
@ApiOperation("手机号登录接口")
@PostMapping("/phoneLogin")
public Result<JSONObject> phoneLogin(@RequestBody JSONObject jsonObject) {
	Result<JSONObject> result = new Result<JSONObject>();
	String phone = jsonObject.getString("mobile");
	
	//校验用户有效性
	SysUser sysUser = sysUserService.getUserByPhone(phone);
	result = sysUserService.checkUserIsEffective(sysUser);
	if(!result.isSuccess()) {
		return result;
	}
	
	String smscode = jsonObject.getString("captcha");
	Object code = redisUtil.get(phone);
	if (!smscode.equals(code)) {
		result.setMessage("手机验证码错误");
		return result;
	}
	//用户信息
	userInfo(sysUser, result);
	//添加日志
	sysBaseAPI.addLog("用户名: " + sysUser.getUsername() + ",登录成功!", CommonConstant.LOG_TYPE_1, null);

	return result;
}
 
Example 17
Source File: SysRoleController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
  * 校验角色编码唯一
 */
@RequestMapping(value = "/checkRoleCode", method = RequestMethod.GET)
public Result<Boolean> checkUsername(String id,String roleCode) {
	Result<Boolean> result = new Result<>();
	result.setResult(true);//如果此参数为false则程序发生异常
	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;
}
 
Example 18
Source File: LoginController.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 手机号登录接口
 * 
 * @param jsonObject
 * @return
 */
@ApiOperation("手机号登录接口")
@PostMapping("/phoneLogin")
public Result<JSONObject> phoneLogin(@RequestBody JSONObject jsonObject) {
	Result<JSONObject> result = new Result<JSONObject>();
	String phone = jsonObject.getString("mobile");
	
	//校验用户有效性
	SysUser sysUser = sysUserService.getUserByPhone(phone);
	result = sysUserService.checkUserIsEffective(sysUser);
	if(!result.isSuccess()) {
		return result;
	}
	
	String smscode = jsonObject.getString("captcha");
	Object code = redisUtil.get(phone);
	if (!smscode.equals(code)) {
		result.setMessage("手机验证码错误");
		return result;
	}
	//用户信息
	userInfo(sysUser, result);
	//添加日志
	sysBaseAPI.addLog("用户名: " + sysUser.getUsername() + ",登录成功!", CommonConstant.LOG_TYPE_1, null);

	return result;
}
 
Example 19
Source File: SysUserController.java    From teaching with Apache License 2.0 4 votes vote down vote up
/**
 * 用户注册接口
 * 
 * @param jsonObject
 * @param user
 * @return
 */
@PostMapping("/register")
public Result<JSONObject> userRegister(@RequestBody JSONObject jsonObject, SysUser user) {
	Result<JSONObject> result = new Result<JSONObject>();
	String phone = jsonObject.getString("phone");
	String smscode = jsonObject.getString("smscode");
	Object code = redisUtil.get(phone);
	String username = jsonObject.getString("username");
	//未设置用户名,则用手机号作为用户名
	if(oConvertUtils.isEmpty(username)){
           username = phone;
       }
       //未设置密码,则随机生成一个密码
	String password = jsonObject.getString("password");
	if(oConvertUtils.isEmpty(password)){
           password = RandomUtil.randomString(8);
       }
	String email = jsonObject.getString("email");
	SysUser sysUser1 = sysUserService.getUserByName(username);
	if (sysUser1 != null) {
		result.setMessage("用户名已注册");
		result.setSuccess(false);
		return result;
	}
	SysUser sysUser2 = sysUserService.getUserByPhone(phone);
	if (sysUser2 != null) {
		result.setMessage("该手机号已注册");
		result.setSuccess(false);
		return result;
	}

	if(oConvertUtils.isNotEmpty(email)){
           SysUser sysUser3 = sysUserService.getUserByEmail(email);
           if (sysUser3 != null) {
               result.setMessage("邮箱已被注册");
               result.setSuccess(false);
               return result;
           }
       }

	if (!smscode.equals(code)) {
		result.setMessage("手机验证码错误");
		result.setSuccess(false);
		return result;
	}

	try {
		user.setCreateTime(new Date());// 设置创建时间
		String salt = oConvertUtils.randomGen(8);
		String passwordEncode = PasswordUtil.encrypt(username, password, salt);
		user.setSalt(salt);
		user.setUsername(username);
		user.setRealname(username);
		user.setPassword(passwordEncode);
		user.setEmail(email);
		user.setPhone(phone);
		user.setStatus(1);
		user.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
		user.setActivitiSync(CommonConstant.ACT_SYNC_1);
		sysUserService.addUserWithRole(user,"ee8626f80f7c2619917b6236f3a7f02b");//默认临时角色 test
		result.success("注册成功");
	} catch (Exception e) {
		result.error500("注册失败");
	}
	return result;
}
 
Example 20
Source File: SysUserController.java    From jeecg-boot with Apache License 2.0 4 votes vote down vote up
/**
 * 用户更改密码
 */
@GetMapping("/passwordChange")
public Result<SysUser> passwordChange(@RequestParam(name="username")String username,
									  @RequestParam(name="password")String password,
		                              @RequestParam(name="smscode")String smscode,
		                              @RequestParam(name="phone") String phone) {
       Result<SysUser> result = new Result<SysUser>();
       if(oConvertUtils.isEmpty(username) || oConvertUtils.isEmpty(password) || oConvertUtils.isEmpty(smscode)  || oConvertUtils.isEmpty(phone) ) {
           result.setMessage("重置密码失败!");
           result.setSuccess(false);
           return result;
       }

       SysUser sysUser=new SysUser();
       Object object= redisUtil.get(phone);
       if(null==object) {
       	result.setMessage("短信验证码失效!");
           result.setSuccess(false);
           return result;
       }
       if(!smscode.equals(object)) {
       	result.setMessage("短信验证码不匹配!");
           result.setSuccess(false);
           return result;
       }
       sysUser = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername,username).eq(SysUser::getPhone,phone));
       if (sysUser == null) {
           result.setMessage("未找到用户!");
           result.setSuccess(false);
           return result;
       } else {
           String salt = oConvertUtils.randomGen(8);
           sysUser.setSalt(salt);
           String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(), password, salt);
           sysUser.setPassword(passwordEncode);
           this.sysUserService.updateById(sysUser);
           result.setSuccess(true);
           result.setMessage("密码重置完成!");
           return result;
       }
   }