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

The following examples show how to use org.jeecg.common.api.vo.Result#success() . 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: SysPositionController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 编辑
 *
 * @param sysPosition
 * @return
 */
@AutoLog(value = "职务表-编辑")
@ApiOperation(value = "职务表-编辑", notes = "职务表-编辑")
@PutMapping(value = "/edit")
public Result<SysPosition> edit(@RequestBody SysPosition sysPosition) {
    Result<SysPosition> result = new Result<SysPosition>();
    SysPosition sysPositionEntity = sysPositionService.getById(sysPosition.getId());
    if (sysPositionEntity == null) {
        result.error500("未找到对应实体");
    } else {
        boolean ok = sysPositionService.updateById(sysPosition);
        //TODO 返回false说明什么?
        if (ok) {
            result.success("修改成功!");
        }
    }

    return result;
}
 
Example 2
Source File: SysPermissionController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
  * 批量删除菜单
 * @param ids
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
public Result<SysPermission> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
	Result<SysPermission> result = new Result<>();
	try {
           String[] arr = ids.split(",");
		for (String id : arr) {
			if (oConvertUtils.isNotEmpty(id)) {
				sysPermissionService.deletePermission(id);
			}
		}
		result.success("删除成功!");
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		result.error500("删除成功!");
	}
	return result;
}
 
Example 3
Source File: JoaDemoController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
  *  编辑
 * @param joaDemo
 * @return
 */
@PutMapping(value = "/edit")
public Result<JoaDemo> edit(@RequestBody JoaDemo joaDemo) {
	Result<JoaDemo> result = new Result<JoaDemo>();
	JoaDemo joaDemoEntity = joaDemoService.getById(joaDemo.getId());
	if(joaDemoEntity==null) {
		result.error500("未找到对应实体");
	}else {
		boolean ok = joaDemoService.updateById(joaDemo);
		//TODO 返回false说明什么?
		if(ok) {
			result.success("修改成功!");
		}
	}
	
	return result;
}
 
Example 4
Source File: SysUserAgentController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
  *  编辑
 * @param sysUserAgent
 * @return
 */
@PutMapping(value = "/edit")
public Result<SysUserAgent> edit(@RequestBody SysUserAgent sysUserAgent) {
	Result<SysUserAgent> result = new Result<SysUserAgent>();
	SysUserAgent sysUserAgentEntity = sysUserAgentService.getById(sysUserAgent.getId());
	if(sysUserAgentEntity==null) {
		result.error500("未找到对应实体");
	}else {
		boolean ok = sysUserAgentService.updateById(sysUserAgent);
		//TODO 返回false说明什么?
		if(ok) {
			result.success("代理人设置成功!");
		}
	}
	
	return result;
}
 
Example 5
Source File: SysPermissionController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 保存角色授权
 * 
 * @return
 */
@RequestMapping(value = "/saveRolePermission", method = RequestMethod.POST)
@RequiresRoles({ "admin" })
public Result<String> saveRolePermission(@RequestBody JSONObject json) {
	long start = System.currentTimeMillis();
	Result<String> result = new Result<>();
	try {
		String roleId = json.getString("roleId");
		String permissionIds = json.getString("permissionIds");
		String lastPermissionIds = json.getString("lastpermissionIds");
		this.sysRolePermissionService.saveRolePermission(roleId, permissionIds, lastPermissionIds);
		result.success("保存成功!");
		log.info("======角色授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
	} catch (Exception e) {
		result.error500("授权失败!");
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example 6
Source File: SysRoleController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
  *  编辑
 * @param role
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
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;
}
 
Example 7
Source File: SysAnnouncementSendController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
  *   通过id删除
 * @param id
 * @return
 */
@DeleteMapping(value = "/delete")
public Result<SysAnnouncementSend> delete(@RequestParam(name="id",required=true) String id) {
	Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
	SysAnnouncementSend sysAnnouncementSend = sysAnnouncementSendService.getById(id);
	if(sysAnnouncementSend==null) {
		result.error500("未找到对应实体");
	}else {
		boolean ok = sysAnnouncementSendService.removeById(id);
		if(ok) {
			result.success("删除成功!");
		}
	}
	
	return result;
}
 
Example 8
Source File: SysUserController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 *   删除指定角色的用户关系
 * @param
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteUserRole", method = RequestMethod.DELETE)
public Result<SysUserRole> deleteUserRole(@RequestParam(name="roleId") String roleId,
                                                @RequestParam(name="userId",required=true) String userId
) {
    Result<SysUserRole> result = new Result<SysUserRole>();
    try {
        QueryWrapper<SysUserRole> queryWrapper = new QueryWrapper<SysUserRole>();
        queryWrapper.eq("role_id", roleId).eq("user_id",userId);
        sysUserRoleService.remove(queryWrapper);
        result.success("删除成功!");
    }catch(Exception e) {
        log.error(e.getMessage(), e);
        result.error500("删除失败!");
    }
    return result;
}
 
Example 9
Source File: SysCategoryController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
  *   通过id删除
 * @param id
 * @return
 */
@DeleteMapping(value = "/delete")
public Result<SysCategory> delete(@RequestParam(name="id",required=true) String id) {
	Result<SysCategory> result = new Result<SysCategory>();
	SysCategory sysCategory = sysCategoryService.getById(id);
	if(sysCategory==null) {
		result.error500("未找到对应实体");
	}else {
		boolean ok = sysCategoryService.removeById(id);
		if(ok) {
			result.success("删除成功!");
		}
	}
	
	return result;
}
 
Example 10
Source File: SysMessageTemplateController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 发送消息
 */
@PostMapping(value = "/sendMsg")
public Result<SysMessageTemplate> sendMessage(@RequestBody MsgParams msgParams) {
	Result<SysMessageTemplate> result = new Result<SysMessageTemplate>();
	Map<String, String> map = null;
	try {
		map = (Map<String, String>) JSON.parse(msgParams.getTestData());
	} catch (Exception e) {
		result.error500("解析Json出错!");
		return result;
	}
	boolean is_sendSuccess = pushMsgUtil.sendMessage(msgParams.getMsgType(), msgParams.getTemplateCode(), map, msgParams.getReceiver());
	if (is_sendSuccess) {
		result.success("发送消息任务添加成功!");
	} else {
		result.error500("发送消息任务添加失败!");
	}
	return result;
}
 
Example 11
Source File: SysDictItemController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * @功能:删除字典数据
 * @param id
 * @return
 */
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
@CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true)
public Result<SysDictItem> delete(@RequestParam(name="id",required=true) String id) {
	Result<SysDictItem> result = new Result<SysDictItem>();
	SysDictItem joinSystem = sysDictItemService.getById(id);
	if(joinSystem==null) {
		result.error500("未找到对应实体");
	}else {
		boolean ok = sysDictItemService.removeById(id);
		if(ok) {
			result.success("删除成功!");
		}
	}
	return result;
}
 
Example 12
Source File: SysUserAgentController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
  *   通过id删除
 * @param id
 * @return
 */
@DeleteMapping(value = "/delete")
public Result<SysUserAgent> delete(@RequestParam(name="id",required=true) String id) {
	Result<SysUserAgent> result = new Result<SysUserAgent>();
	SysUserAgent sysUserAgent = sysUserAgentService.getById(id);
	if(sysUserAgent==null) {
		result.error500("未找到对应实体");
	}else {
		boolean ok = sysUserAgentService.removeById(id);
		if(ok) {
			result.success("删除成功!");
		}
	}
	
	return result;
}
 
Example 13
Source File: LoginController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 获取访问量
 * @return
 */
@GetMapping("loginfo")
public Result<JSONObject> loginfo() {
	Result<JSONObject> result = new Result<JSONObject>();
	JSONObject obj = new JSONObject();
	//update-begin--Author:zhangweijian  Date:20190428 for:传入开始时间,结束时间参数
	// 获取一天的开始和结束时间
	Calendar calendar = new GregorianCalendar();
	calendar.set(Calendar.HOUR_OF_DAY, 0);
	calendar.set(Calendar.MINUTE, 0);
	calendar.set(Calendar.SECOND, 0);
	calendar.set(Calendar.MILLISECOND, 0);
	Date dayStart = calendar.getTime();
	calendar.add(Calendar.DATE, 1);
	Date dayEnd = calendar.getTime();
	// 获取系统访问记录
	Long totalVisitCount = logService.findTotalVisitCount();
	obj.put("totalVisitCount", totalVisitCount);
	Long todayVisitCount = logService.findTodayVisitCount(dayStart,dayEnd);
	obj.put("todayVisitCount", todayVisitCount);
	Long todayIp = logService.findTodayIp(dayStart,dayEnd);
	//update-end--Author:zhangweijian  Date:20190428 for:传入开始时间,结束时间参数
	obj.put("todayIp", todayIp);
	result.setResult(obj);
	result.success("登录成功");
	return result;
}
 
Example 14
Source File: SysDictItemController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * @功能:批量删除字典数据
 * @param ids
 * @return
 */
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
@CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true)
public Result<SysDictItem> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
	Result<SysDictItem> result = new Result<SysDictItem>();
	if(ids==null || "".equals(ids.trim())) {
		result.error500("参数不识别!");
	}else {
		this.sysDictItemService.removeByIds(Arrays.asList(ids.split(",")));
		result.success("删除成功!");
	}
	return result;
}
 
Example 15
Source File: SysPermissionController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
  * 删除菜单
 * @param id
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
public Result<SysPermission> delete(@RequestParam(name = "id", required = true) String id) {
	Result<SysPermission> result = new Result<>();
	try {
		sysPermissionService.deletePermission(id);
		result.success("删除成功!");
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		result.error500(e.getMessage());
	}
	return result;
}
 
Example 16
Source File: SysDepartController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 批量删除 根据前端请求的多个ID,对数据库执行删除相关部门数据的操作
 * 
 * @param ids
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
public Result<SysDepart> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {

	Result<SysDepart> result = new Result<SysDepart>();
	if (ids == null || "".equals(ids.trim())) {
		result.error500("参数不识别!");
	} else {
		this.sysDepartService.deleteBatchWithChildren(Arrays.asList(ids.split(",")));
		result.success("删除成功!");
	}
	return result;
}
 
Example 17
Source File: SysAnnouncementSendController.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
  *  批量删除
 * @param ids
 * @return
 */
@DeleteMapping(value = "/deleteBatch")
public Result<SysAnnouncementSend> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
	Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
	if(ids==null || "".equals(ids.trim())) {
		result.error500("参数不识别!");
	}else {
		this.sysAnnouncementSendService.removeByIds(Arrays.asList(ids.split(",")));
		result.success("删除成功!");
	}
	return result;
}
 
Example 18
Source File: JoaDemoController.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
  *   添加
 * @param joaDemo
 * @return
 */
@PostMapping(value = "/add")
public Result<JoaDemo> add(@RequestBody JoaDemo joaDemo) {
	Result<JoaDemo> result = new Result<JoaDemo>();
	try {
		joaDemoService.save(joaDemo);
		result.success("添加成功!");
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		result.error500("操作失败");
	}
	return result;
}
 
Example 19
Source File: SysPermissionController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 查询菜单权限数据
 * 
 * @param sysPermissionDataRule
 * @return
 */
@RequestMapping(value = "/queryPermissionRule", method = RequestMethod.GET)
public Result<List<SysPermissionDataRule>> queryPermissionRule(SysPermissionDataRule sysPermissionDataRule) {
	Result<List<SysPermissionDataRule>> result = new Result<>();
	try {
		List<SysPermissionDataRule> permRuleList = sysPermissionDataRuleService.queryPermissionRule(sysPermissionDataRule);
		result.setResult(permRuleList);
		result.success("查询成功!");
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		result.error500("操作失败");
	}
	return result;
}
 
Example 20
Source File: CasClientController.java    From jeecg-boot-with-activiti with MIT License 4 votes vote down vote up
@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);
}