org.springframework.web.bind.annotation.ResponseBody Java Examples

The following examples show how to use org.springframework.web.bind.annotation.ResponseBody. 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: CommonController.java    From ruoyiplus with MIT License 6 votes vote down vote up
/**
 * 通用上传请求
 */
@PostMapping("/common/upload")
@ResponseBody
public AjaxResult uploadFile(MultipartFile file) throws Exception
{
    try
    {
        // 上传文件路径
        String filePath = Global.getUploadPath();
        // 上传并返回新文件名称
        String fileName = FileUploadUtils.upload(filePath, file);
        String url = serverConfig.getUrl() + UPLOAD_PATH + fileName;
        AjaxResult ajax = AjaxResult.success();
        ajax.put("fileName", fileName);
        ajax.put("url", url);
        return ajax;
    }
    catch (Exception e)
    {
        return AjaxResult.error(e.getMessage());
    }
}
 
Example #2
Source File: WeixinNewstemplateController.java    From jeewx-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 保存信息
 * @return
 */
@RequestMapping(value = "/doAdd",method ={RequestMethod.GET, RequestMethod.POST})
@ResponseBody
public AjaxJson doAdd(@ModelAttribute WeixinNewstemplate weixinNewstemplate){
	AjaxJson j = new AjaxJson();
	try {
		//update-begin--Author:zhangweijian  Date: 20180807 for:新增默认未上传
		//'0':未上传;'1':上传中;'2':上传成功;'3':上传失败
		weixinNewstemplate.setUploadType("0");
		//update-end--Author:zhangweijian  Date: 20180807 for:新增默认未上传
		weixinNewstemplate.setTemplateType(WeixinMsgTypeEnum.wx_msg_type_news.getCode());
		weixinNewstemplate.setCreateTime(new Date());
		weixinNewstemplateService.doAdd(weixinNewstemplate);
		j.setMsg("保存成功");
	} catch (Exception e) {
		log.error(e.getMessage());
		j.setSuccess(false);
		j.setMsg("保存失败");
	}
	return j;
}
 
Example #3
Source File: AdminController.java    From qconfig with MIT License 6 votes vote down vote up
@RequestMapping("/batchCopyFile")
@ResponseBody
public Object batchCopyFile(@RequestBody JsonNode rootNode, @RequestParam String fileType) {
    Preconditions.checkArgument("common".equals(fileType) || "reference".equals(fileType) || "inherit".equals(fileType), "fileType无效");
    JsonNode groupsArrayNode = rootNode.get("groups");
    Preconditions.checkArgument(groupsArrayNode.isArray(), "groups字段必须是array");
    Iterator<JsonNode> it = groupsArrayNode.iterator();
    Map<String, Map<String, String>> allGroupResult = Maps.newHashMap();
    while (it.hasNext()) {
        JsonNode groupNode = it.next();
        String group = groupNode.get("group").asText();
        String srcProfile = groupNode.get("srcProfile").asText();
        String destProfile = groupNode.get("destProfile").asText();
        createSubEnv(group, destProfile);
        Map<String, String> groupResult = batchCopyWithPublish(group, srcProfile, destProfile, fileType);
        allGroupResult.put(group + "/" + srcProfile, groupResult);
    }
    return allGroupResult;
}
 
Example #4
Source File: InterfaceController.java    From ATest with GNU General Public License v3.0 6 votes vote down vote up
@RequestMapping(value = "/toUpdateInterface", method = RequestMethod.POST)
@ResponseBody
public Boolean toUpdateInterface(Integer interfaceId, String name, String api, Integer environmentId,
		String description) {
	if (null != name && !"".equals(name) && null != api && !"".equals(api) && null != environmentId
			&& null != interfaceId) {
		Interface interfaceObject = new Interface();
		interfaceObject.setId(interfaceId);
		interfaceObject.setName(name);
		interfaceObject.setApi(api);
		interfaceObject.setDescription(description);
		interfaceObject.setEnvironmentId(environmentId);
		return interfaceService.UpdateInterface(interfaceObject);
	}
	return false;
}
 
Example #5
Source File: ShopManagerController.java    From Project with Apache License 2.0 6 votes vote down vote up
/**
 *  获取店铺信息
 * @return
 */
@RequestMapping(value = "/getShopInitInfo", method = RequestMethod.GET)
@ResponseBody
public Map<String,Object> getShopInitInfo(){
    Map<String, Object> modelMap = new HashMap<>();
    // 需要两个 List 分别接收 shopCategory 和 area 的信息
    List<ShopCategory> shopCategoryList =  new ArrayList<>();
    List<Area> areaList = new ArrayList<>();

    try{
        shopCategoryList = shopCategoryService.getShopCategoryList(new ShopCategory());
        areaList = areaService.getAreaList();
        modelMap.put("shopCategoryList", shopCategoryList);
        modelMap.put("areaList", areaList);
        modelMap.put("success", true);
    }catch (Exception e){
        modelMap.put("success", false);
        modelMap.put("errMsg", e.getMessage());
    }
    return modelMap;
}
 
Example #6
Source File: BasicController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class)
@ResponseBody
ErrorResponse handleError(HttpServletRequest req, Exception ex) {
    logger.error("", ex);

    Message msg = MsgPicker.getMsg();
    Throwable cause = ex;
    while (cause != null) {
        if (cause.getClass().getPackage().getName().startsWith("org.apache.hadoop.hbase")) {
            return new ErrorResponse(req.getRequestURL().toString(), new InternalErrorException(
                    String.format(Locale.ROOT, msg.getHBASE_FAIL(), ex.getMessage()), ex));
        }
        cause = cause.getCause();
    }

    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #7
Source File: ConsoleUserController.java    From console with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
@RequestMapping("/deleteConsoleUserByUserids")
@ResponseBody
public int deleteConsoleUserByUserids(HttpServletRequest request) {
    long startTime = System.currentTimeMillis();
    int nRows = 0;
    String _sUserIds = request.getParameter("userIds");
    String type = request.getParameter("type");
    if (!StringUtils.isNull(_sUserIds)) {
        nRows = consoleUserService.deleteConsoleUserUserIds(_sUserIds);
        boolean flag = false; // define opear result
        if (nRows != 0)
            flag = true;
    }

    return nRows;
}
 
Example #8
Source File: CommonController.java    From supplierShop with MIT License 6 votes vote down vote up
/**
 * 通用上传请求
 */
@PostMapping("/common/upload")
@ResponseBody
public AjaxResult uploadFile(MultipartFile file) throws Exception
{
    try
    {
        // 上传文件路径
        String filePath = Global.getUploadPath();
        // 上传并返回新文件名称
        String fileName = FileUploadUtils.upload(filePath, file);
        String url = serverConfig.getUrl() + fileName;
        AjaxResult ajax = AjaxResult.success();
        ajax.put("fileName", fileName);
        ajax.put("url", url);
        return ajax;
    }
    catch (Exception e)
    {
        return AjaxResult.error(e.getMessage());
    }
}
 
Example #9
Source File: MenuController.java    From WebStack-Guns with MIT License 6 votes vote down vote up
/**
 * 删除菜单
 */
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/remove")
@BussinessLog(value = "删除菜单", key = "menuId", dict = MenuDict.class)
@ResponseBody
public ResponseData remove(@RequestParam Long menuId) {
    if (ToolUtil.isEmpty(menuId)) {
        throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
    }

    //缓存菜单的名称
    LogObjectHolder.me().set(ConstantFactory.me().getMenuName(menuId));

    this.menuService.delMenuContainSubMenus(menuId);
    return SUCCESS_TIP;
}
 
Example #10
Source File: UserController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/{userName:.+}", method = { RequestMethod.DELETE }, produces = { "application/json" })
@ResponseBody
public EnvelopeResponse delete(@PathVariable("userName") String userName) throws IOException {

    checkProfileEditAllowed();

    if (StringUtils.equals(getPrincipal(), userName)) {
        throw new ForbiddenException("...");
    }

    //delete user's project ACL
    accessService.revokeProjectPermission(userName, MetadataConstants.TYPE_USER);

    //delete user's table/row/column ACL
    //        ACLOperationUtil.delLowLevelACL(userName, MetadataConstants.TYPE_USER);

    checkUserName(userName);
    userService.deleteUser(userName);
    return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, userName, "");
}
 
Example #11
Source File: UserManageController.java    From openzaly with Apache License 2.0 6 votes vote down vote up
@RequestMapping(method = RequestMethod.POST, value = "delUser")
@ResponseBody
public String deleteUser(HttpServletRequest request, @RequestBody byte[] bodyParam) {
	try {
		PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam);
		String siteUserId = getRequestSiteUserId(pluginPackage);

		if (isManager(siteUserId)) {
			Map<String, String> reqMap = getRequestDataMap(pluginPackage);
			String delUserID = reqMap.get("siteUserId");
			if (userService.delUser(delUserID)) {
				return SUCCESS;
			}
		} else {
			return NO_PERMISSION;
		}
	} catch (Exception e) {
		logger.error("del User error", e);
	}
	return ERROR;
}
 
Example #12
Source File: InterfaceCaseController.java    From ATest with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 执行接口用例并返回断言结果
 */
@RequestMapping(value = "/toRequestInterfaceCase", method = RequestMethod.POST)
@ResponseBody
public AssertResult toRequestInterfaceCase(Integer interfaceCaseId, Integer mockId) {
	if (null != interfaceCaseId) {
		Request request = new Request();
		request = interfaceCaseService.QueryRequestByTestCaseId(interfaceCaseId);
		Map<String, String> bindMap = new HashMap<String, String>();
		if (null != mockId) {
			Mock mock = mockService.QueryMockById(mockId);
			if (null != mock) {
				bindMap.putAll(mock.getBindVariableMocks());
			}
		}
		DoRequest doRequest = new DoRequest(0, request, bindMap);
		ResponseContent responseContent = new ResponseContent();
		responseContent = doRequest.toRequest();
		doRequest.toUpdateVariables(responseContent);
		return doRequest.toAssert(responseContent);
	}
	return null;
}
 
Example #13
Source File: WebAopLog.java    From Jpom with MIT License 6 votes vote down vote up
@Before("webLog()")
public void doBefore(JoinPoint joinPoint) {
    if (aopLogInterface != null) {
        aopLogInterface.before(joinPoint);
    }
    // 接收到请求,记录请求内容
    IS_LOG.set(ExtConfigBean.getInstance().isConsoleLogReqResponse());
    Signature signature = joinPoint.getSignature();
    if (signature instanceof MethodSignature) {
        MethodSignature methodSignature = (MethodSignature) signature;
        ResponseBody responseBody = methodSignature.getMethod().getAnnotation(ResponseBody.class);
        if (responseBody == null) {
            RestController restController = joinPoint.getTarget().getClass().getAnnotation(RestController.class);
            if (restController == null) {
                IS_LOG.set(false);
            }
        }
    }
}
 
Example #14
Source File: VersionLockController.java    From qconfig with MIT License 6 votes vote down vote up
@RequestMapping(value = "/unlock", method = RequestMethod.POST)
@ResponseBody
public Object upload(@RequestBody ClientFileVersionRequest clientFileVersion) {
    String ip = clientFileVersion.getIp().trim();
    logger.info("unlock consumer version, {}", clientFileVersion);
    Preconditions.checkArgument(!Strings.isNullOrEmpty(ip), "ip不能为空");
    ConfigMeta configMeta = transform(clientFileVersion);
    checkLegalMeta(configMeta);
    try {
        fixedConsumerVersionService.deleteConsumerVersion(configMeta, ip);
    } catch (Exception e) {
        logger.error("unlock consumer version error", e);
        return new JsonV2<>(-1, "取消锁定失败,请联系管理员!", null);
    }
    return new JsonV2<>(0, "取消锁定成功", null);
}
 
Example #15
Source File: EmpUserController.java    From frpMgr with MIT License 6 votes vote down vote up
/**
 * 停用用户
 * @param empUser
 * @return
 */
@RequiresPermissions("sys:empUser:updateStatus")
@ResponseBody
@RequestMapping(value = "disable")
public String disable(EmpUser empUser) {
	if (User.isSuperAdmin(empUser.getUserCode())) {
		return renderResult(Global.FALSE, "非法操作,不能够操作此用户!");
	}
	if (!EmpUser.USER_TYPE_EMPLOYEE.equals(empUser.getUserType())){
		return renderResult(Global.FALSE, "非法操作,不能够操作此用户!");
	}
	if (empUser.getCurrentUser().getUserCode().equals(empUser.getUserCode())) {
		return renderResult(Global.FALSE, text("停用用户失败,不允许停用当前用户"));
	}
	empUser.setStatus(User.STATUS_DISABLE);
	userService.updateStatus(empUser);
	return renderResult(Global.TRUE, text("停用用户''{0}''成功", empUser.getUserName()));
}
 
Example #16
Source File: UploadFileController.java    From erp-framework with MIT License 6 votes vote down vote up
/**
 * 检验分片是否未上传或者未完成
 * result.header.status=0是已上传完整,否则为1
 *
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/checkChunk", produces = "application/json; charset=utf-8")
@ResponseBody
public ResultBean checkChunk(HttpServletRequest request, HttpServletResponse response) throws Exception {
    //检查当前分块是否上传成功
    String fileMd5 = request.getParameter("fileMd5");
    String chunk = request.getParameter("chunk");
    String chunkSize = request.getParameter("chunkSize");
    String dir = TEMP_PATH + File.separator + fileMd5;
    String partName = fileMd5 + CHUNK_NAME_SPLIT + chunk + CHUNK_NAME_SPLIT;
    String suffix = ".part";
    File checkFile = new File(dir + File.separator + partName + suffix);
    //检查文件是否存在,且大小是否一致
    if (checkFile.exists() && checkFile.length() == Integer.parseInt(chunkSize)) {
        //上传过
        return new ResultBean("上传过");
    } else {
        //没有上传过
        return new ResultBean();
    }
}
 
Example #17
Source File: ErrorPageController.java    From My-Blog with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = ERROR_PATH)
@ResponseBody
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
    Map<String, Object> body = getErrorAttributes(request, getTraceParameter(request));
    HttpStatus status = getStatus(request);
    return new ResponseEntity<Map<String, Object>>(body, status);
}
 
Example #18
Source File: BlockTxDetailInfoController.java    From WeBASE-Collect-Bee with Apache License 2.0 5 votes vote down vote up
@ResponseBody
@RequestMapping("/time/get")
@ApiOperation(value = "based on time range", httpMethod = "POST")
public CommonResponse getBlockTxDetailInfoByTimeRange(@RequestBody @Valid TimeRangeQueryReq req,
        BindingResult result) {
    if (result.hasErrors()) {
        return ResponseUtils.validateError(result);
    }

    return blockTxDetailInfoManager.getPageListByTimeRange(req);
}
 
Example #19
Source File: SysOperlogController.java    From supplierShop with MIT License 5 votes vote down vote up
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
@RequiresPermissions("monitor:operlog:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysOperLog operLog)
{
    List<SysOperLog> list = operLogService.selectOperLogList(operLog);
    ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
    return util.exportExcel(list, "操作日志");
}
 
Example #20
Source File: JwkSetEndpoint.java    From authmore-framework with Apache License 2.0 5 votes vote down vote up
@GetMapping("/auth/jwk")
@ResponseBody
public Map<String, Object> getKey(Principal principal) {
    RSAPublicKey publicKey = (RSAPublicKey) this.keyPair.getPublic();
    RSAKey key = new RSAKey.Builder(publicKey).build();
    return new JWKSet(key).toJSONObject();
}
 
Example #21
Source File: AgentController.java    From runscore with Apache License 2.0 5 votes vote down vote up
@PostMapping("/agentOpenAnAccount")
@ResponseBody
public Result agentOpenAnAccount(@RequestBody AgentOpenAnAccountParam param) {
	UserAccountDetails user = (UserAccountDetails) SecurityContextHolder.getContext().getAuthentication()
			.getPrincipal();
	param.setInviterId(user.getUserAccountId());
	agentService.agentOpenAnAccount(param);
	return Result.success();
}
 
Example #22
Source File: ExceptionControllerAdvice.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
/**
 * 拦截绑定参数异常
 *
 * @param e
 * @return
 */
@ResponseBody
@ExceptionHandler(value = ServletRequestBindingException.class)
public MessageResult myErrorHandler(ServletRequestBindingException e) {
    e.printStackTrace();
    log.info(">>>拦截绑定参数异常>>",e);
    MessageResult result = MessageResult.error(3000, "参数绑定错误(如:必须参数没传递)!");
    return result;
}
 
Example #23
Source File: SysJobController.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 校验cron表达式是否有效
 */
@PostMapping("/checkCronExpressionIsValid")
@ResponseBody
public boolean checkCronExpressionIsValid(SysJob job)
{
    return jobService.checkCronExpressionIsValid(job.getCronExpression());
}
 
Example #24
Source File: ConfigController.java    From cymbal with Apache License 2.0 5 votes vote down vote up
/**
 * Update name of redis config.
 *
 * @param clusterId cluster id
 * @param configId config id
 * @param configName new config name
 */
@PatchMapping("/clusters/{clusterId}/configs/{configId}")
@PreAuthorize(value = "@clusterPermissionChecker.hasOperationPermissionForCluster(#clusterId, principal.username)")
@ResponseBody
public void updateConfigName(@PathVariable final String clusterId, @PathVariable final Integer configId,
        final @RequestBody String configName) {
    redisConfigProcessService.updateConfigName(configId, configName);
}
 
Example #25
Source File: OutGivingController.java    From Jpom with MIT License 5 votes vote down vote up
@RequestMapping(value = "save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@OptLog(UserOperateLogV1.OptType.SaveOutGiving)
@Feature(method = MethodFeature.EDIT)
public String save(String type, String id) throws IOException {
    if ("add".equalsIgnoreCase(type)) {
        if (!StringUtil.isGeneral(id, 2, 20)) {
            return JsonMessage.getString(401, "分发id 不能为空并且长度在2-20(英文字母 、数字和下划线)");
        }
        return addOutGiving(id);
    } else {
        return updateGiving(id);
    }
}
 
Example #26
Source File: SysDeptController.java    From ruoyiplus with MIT License 5 votes vote down vote up
@RequiresPermissions("system:dept:list")
@GetMapping("/list")
@ResponseBody
public List<SysDept> list(SysDept dept)
{
    List<SysDept> deptList = deptService.selectDeptList(dept);
    return deptList;
}
 
Example #27
Source File: BuildListController.java    From Jpom with MIT License 5 votes vote down vote up
@RequestMapping(value = "branchList.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public String branchList(
        @ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "仓库地址不正确")) String url,
        @ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "登录账号")) String userName,
        @ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "登录密码")) String userPwd) throws GitAPIException, IOException {
    List<String> list = GitUtil.getBranchList(url, userName, userPwd);
    return JsonMessage.getString(200, "ok", list);
}
 
Example #28
Source File: SysRoleController.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 角色状态修改
 */
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:role:edit")
@PostMapping("/changeStatus")
@ResponseBody
public AjaxResult changeStatus(SysRole role)
{
    return toAjax(roleService.changeStatus(role));
}
 
Example #29
Source File: SpringControllerCollectsTest.java    From code with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/getName.do"/*, params = { "method=ddddd" }*/)
@ResponseBody
public String getName(String name, String sex) {
	if ("男".equals(sex)) {
		throw new RuntimeException("该方法传女不传男");
	}
	return "hanmeme";
}
 
Example #30
Source File: DemoController.java    From code with Apache License 2.0 5 votes vote down vote up
/**
 * 发送消息到队列,一条消息只会被一个消费者接收,接收完后会从队列中删除
 *
 * @param message
 * @return
 */
@ResponseBody
@RequestMapping("sendToQueue")
public String sendToQueue(String message) {
    String result = "";
    try {
        queueSender.send(QUEUE_NAME, message);
        result = "suc";
    } catch (Exception e) {
        result = e.getCause().toString();
    }
    return result;
}