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

The following examples show how to use org.jeecg.common.api.vo.Result#ok() . 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: SysDepartRoleController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 查询数据规则数据
 */
@GetMapping(value = "/datarule/{permissionId}/{departId}/{roleId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId,@PathVariable("roleId") String roleId) {
//查询已授权的部门规则
	List<SysPermissionDataRule> list = sysDepartPermissionService.getPermRuleListByDeptIdAndPermId(departId,permissionId);
 if(list==null || list.size()==0) {
	 return Result.error("未找到权限配置信息");
 }else {
	 Map<String,Object> map = new HashMap<>();
	 map.put("datarule", list);
	 LambdaQueryWrapper<SysDepartRolePermission> query = new LambdaQueryWrapper<SysDepartRolePermission>()
			 .eq(SysDepartRolePermission::getPermissionId, permissionId)
			 .eq(SysDepartRolePermission::getRoleId,roleId);
	 SysDepartRolePermission sysRolePermission = sysDepartRolePermissionService.getOne(query);
	 if(sysRolePermission==null) {
		 //return Result.error("未找到角色菜单配置信息");
	 }else {
		 String drChecked = sysRolePermission.getDataRuleIds();
		 if(oConvertUtils.isNotEmpty(drChecked)) {
			 map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
		 }
	 }
	 return Result.ok(map);
	 //TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
 }
}
 
Example 2
Source File: SysDepartRoleController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 保存数据规则至角色菜单关联表
 */
@PostMapping(value = "/datarule")
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
 try {
	 String permissionId = jsonObject.getString("permissionId");
	 String roleId = jsonObject.getString("roleId");
	 String dataRuleIds = jsonObject.getString("dataRuleIds");
	 log.info("保存数据规则>>"+"菜单ID:"+permissionId+"角色ID:"+ roleId+"数据权限ID:"+dataRuleIds);
	 LambdaQueryWrapper<SysDepartRolePermission> query = new LambdaQueryWrapper<SysDepartRolePermission>()
			 .eq(SysDepartRolePermission::getPermissionId, permissionId)
			 .eq(SysDepartRolePermission::getRoleId,roleId);
	 SysDepartRolePermission sysRolePermission = sysDepartRolePermissionService.getOne(query);
	 if(sysRolePermission==null) {
		 return Result.error("请先保存角色菜单权限!");
	 }else {
		 sysRolePermission.setDataRuleIds(dataRuleIds);
		 this.sysDepartRolePermissionService.updateById(sysRolePermission);
	 }
 } catch (Exception e) {
	 log.error("SysRoleController.saveDatarule()发生异常:" + e.getMessage(),e);
	 return Result.error("保存失败");
 }
 return Result.ok("保存成功!");
}
 
Example 3
Source File: SysRoleController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 查询数据规则数据
 */
@GetMapping(value = "/datarule/{permissionId}/{roleId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("roleId") String roleId) {
	List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
	if(list==null || list.size()==0) {
		return Result.error("未找到权限配置信息");
	}else {
		Map<String,Object> map = new HashMap<>();
		map.put("datarule", list);
		LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
				.eq(SysRolePermission::getPermissionId, permissionId)
				.isNotNull(SysRolePermission::getDataRuleIds)
				.eq(SysRolePermission::getRoleId,roleId);
		SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
		if(sysRolePermission==null) {
			//return Result.error("未找到角色菜单配置信息");
		}else {
			String drChecked = sysRolePermission.getDataRuleIds();
			if(oConvertUtils.isNotEmpty(drChecked)) {
				map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
			}
		}
		return Result.ok(map);
		//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
	}
}
 
Example 4
Source File: SysDepartRoleController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 通过id删除
 *
 * @param id
 * @return
 */
@AutoLog(value = "部门角色-通过id删除")
@ApiOperation(value="部门角色-通过id删除", notes="部门角色-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
	sysDepartRoleService.removeById(id);
	return Result.ok("删除成功!");
}
 
Example 5
Source File: SysFillRuleController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 分页列表查询
 *
 * @param sysFillRule
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@AutoLog(value = "填值规则-分页列表查询")
@ApiOperation(value = "填值规则-分页列表查询", notes = "填值规则-分页列表查询")
@GetMapping(value = "/list")
public Result<?> queryPageList(SysFillRule sysFillRule,
                               @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                               @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                               HttpServletRequest req) {
    QueryWrapper<SysFillRule> queryWrapper = QueryGenerator.initQueryWrapper(sysFillRule, req.getParameterMap());
    Page<SysFillRule> page = new Page<>(pageNo, pageSize);
    IPage<SysFillRule> pageList = sysFillRuleService.page(page, queryWrapper);
    return Result.ok(pageList);
}
 
Example 6
Source File: JeecgDemoController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 【数据权限示例 - 编程】mybatisPlus java类方式加载权限
 *
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@GetMapping(value = "/mpList")
@PermissionData(pageComponent = "jeecg/JeecgDemoList")
public Result<?> loadMpPermissonList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                     HttpServletRequest req) {
    QueryWrapper<JeecgDemo> queryWrapper = new QueryWrapper<JeecgDemo>();
    //编程方式,给queryWrapper装载数据权限规则
    QueryGenerator.installAuthMplus(queryWrapper, JeecgDemo.class);
    Page<JeecgDemo> page = new Page<JeecgDemo>(pageNo, pageSize);
    IPage<JeecgDemo> pageList = jeecgDemoService.page(page, queryWrapper);
    return Result.ok(pageList);
}
 
Example 7
Source File: SysFillRuleController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 通过id删除
 *
 * @param id
 * @return
 */
@AutoLog(value = "填值规则-通过id删除")
@ApiOperation(value = "填值规则-通过id删除", notes = "填值规则-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
    sysFillRuleService.removeById(id);
    return Result.ok("删除成功!");
}
 
Example 8
Source File: SysCheckRuleController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 批量删除
 *
 * @param ids
 * @return
 */
@AutoLog(value = "编码校验规则-批量删除")
@ApiOperation(value = "编码校验规则-批量删除", notes = "编码校验规则-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
    this.sysCheckRuleService.removeByIds(Arrays.asList(ids.split(",")));
    return Result.ok("批量删除成功!");
}
 
Example 9
Source File: SysMessageController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 编辑
 * 
 * @param sysMessage
 * @return
 */
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody SysMessage sysMessage) {	
	sysMessageService.updateById(sysMessage);
       return Result.ok("修改成功!");

}
 
Example 10
Source File: QuartzJobController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 添加定时任务
 * 
 * @param quartzJob
 * @return
 */
@RequiresRoles("admin")
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result<?> add(@RequestBody QuartzJob quartzJob) {
	List<QuartzJob> list = quartzJobService.findByJobClassName(quartzJob.getJobClassName());
	if (list != null && list.size() > 0) {
		return Result.error("该定时任务类名已存在");
	}
	quartzJobService.saveAndScheduleJob(quartzJob);
	return Result.ok("创建定时任务成功");
}
 
Example 11
Source File: SysUserServiceImpl.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@Override
@CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true)
public Result<?> changePassword(SysUser sysUser) {
    String salt = oConvertUtils.randomGen(8);
    sysUser.setSalt(salt);
    String password = sysUser.getPassword();
    String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(), password, salt);
    sysUser.setPassword(passwordEncode);
    this.userMapper.updateById(sysUser);
    return Result.ok("密码修改成功!");
}
 
Example 12
Source File: SysMessageController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 编辑
 * 
 * @param sysMessage
 * @return
 */
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody SysMessage sysMessage) {	
	sysMessageService.updateById(sysMessage);
       return Result.ok("修改成功!");

}
 
Example 13
Source File: SysPositionController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 通过id删除
 *
 * @param id
 * @return
 */
@AutoLog(value = "职务表-通过id删除")
@ApiOperation(value = "职务表-通过id删除", notes = "职务表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
    try {
        sysPositionService.removeById(id);
    } catch (Exception e) {
        log.error("删除失败", e.getMessage());
        return Result.error("删除失败!");
    }
    return Result.ok("删除成功!");
}
 
Example 14
Source File: SysPermissionController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 查询子菜单
 *
 * @param parentIds 父ID(多个采用半角逗号分割)
 * @return 返回 key-value 的 Map
 */
@GetMapping("/getSystemSubmenuBatch")
public Result getSystemSubmenuBatch(@RequestParam("parentIds") String parentIds) {
	try {
		LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>();
		List<String> parentIdList = Arrays.asList(parentIds.split(","));
		query.in(SysPermission::getParentId, parentIdList);
		query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
		query.orderByAsc(SysPermission::getSortNo);
		List<SysPermission> list = sysPermissionService.list(query);
		Map<String, List<SysPermissionTree>> listMap = new HashMap<>();
		for (SysPermission item : list) {
			String pid = item.getParentId();
			if (parentIdList.contains(pid)) {
				List<SysPermissionTree> mapList = listMap.get(pid);
				if (mapList == null) {
					mapList = new ArrayList<>();
				}
				mapList.add(new SysPermissionTree(item));
				listMap.put(pid, mapList);
			}
		}
		return Result.ok(listMap);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		return Result.error("批量查询子菜单失败:" + e.getMessage());
	}
}
 
Example 15
Source File: TeachingCourseUnitController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 分页列表查询
 *
 * @param teachingCourseUnit
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@AutoLog(value = "课程单元-分页列表查询")
@ApiOperation(value="课程单元-分页列表查询", notes="课程单元-分页列表查询")
@GetMapping(value = "/list")
@PermissionData
public Result<?> queryPageList(CourseUnitModel teachingCourseUnit,
							   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
							   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
							   HttpServletRequest req) {
	QueryWrapper<CourseUnitModel> queryWrapper = QueryGenerator.initQueryWrapper(teachingCourseUnit, req.getParameterMap());
	Page<CourseUnitModel> page = new Page<CourseUnitModel>(pageNo, pageSize);
	IPage<CourseUnitModel> pageList = teachingCourseUnitService.getCourseUnitList(page, queryWrapper);
	return Result.ok(pageList);
}
 
Example 16
Source File: JeecgDemoController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 批量删除
 *
 * @param ids
 * @return
 */
@DeleteMapping(value = "/deleteBatch")
@ApiOperation(value = "批量删除DEMO", notes = "批量删除DEMO")
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
    this.jeecgDemoService.removeByIds(Arrays.asList(ids.split(",")));
    return Result.ok("批量删除成功!");
}
 
Example 17
Source File: SysMessageTemplateController.java    From jeecg-boot with Apache License 2.0 3 votes vote down vote up
/**
 * 分页列表查询
 * 
 * @param sysMessageTemplate
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@GetMapping(value = "/list")
public Result<?> queryPageList(SysMessageTemplate sysMessageTemplate, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
		@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
	QueryWrapper<SysMessageTemplate> queryWrapper = QueryGenerator.initQueryWrapper(sysMessageTemplate, req.getParameterMap());
	Page<SysMessageTemplate> page = new Page<SysMessageTemplate>(pageNo, pageSize);
	IPage<SysMessageTemplate> pageList = sysMessageTemplateService.page(page, queryWrapper);
       return Result.ok(pageList);
}
 
Example 18
Source File: JeecgOrderTabMainController.java    From teaching with Apache License 2.0 2 votes vote down vote up
/**
 * 添加
 *
 * @param jeecgOrderCustomer
 * @return
 */
@PostMapping(value = "/addCustomer")
public Result<?> addCustomer(@RequestBody JeecgOrderCustomer jeecgOrderCustomer) {
    jeecgOrderCustomerService.save(jeecgOrderCustomer);
    return Result.ok("添加成功!");
}
 
Example 19
Source File: JeecgOrderTabMainController.java    From jeecg-cloud with Apache License 2.0 2 votes vote down vote up
/**
 * 添加
 *
 * @param jeecgOrderTicket
 * @return
 */
@PostMapping(value = "/addTicket")
public Result<?> addTicket(@RequestBody JeecgOrderTicket jeecgOrderTicket) {
    jeecgOrderTicketService.save(jeecgOrderTicket);
    return Result.ok("添加成功!");
}
 
Example 20
Source File: JeecgOrderMainController.java    From jeecg-boot with Apache License 2.0 2 votes vote down vote up
/**
 * 通过id查询
 *
 * @param id
 * @return
 */
@GetMapping(value = "/queryOrderCustomerListByMainId")
public Result<?> queryOrderCustomerListByMainId(@RequestParam(name = "id", required = true) String id) {
    List<JeecgOrderCustomer> jeecgOrderCustomerList = jeecgOrderCustomerService.selectCustomersByMainId(id);
    return Result.ok(jeecgOrderCustomerList);
}