use of org.jeecg.common.api.vo.Result in project jeecg-boot by jeecgboot.
the class JwtUtil method responseError.
/**
* @param response
* @param code
* @param errorMsg
*/
public static void responseError(ServletResponse response, Integer code, String errorMsg) {
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
Result jsonResult = new Result(code, errorMsg);
OutputStream os = null;
try {
os = httpServletResponse.getOutputStream();
httpServletResponse.setCharacterEncoding("UTF-8");
httpServletResponse.setStatus(401);
os.write(new ObjectMapper().writeValueAsString(jsonResult).getBytes("UTF-8"));
os.flush();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.jeecg.common.api.vo.Result in project jeecg-boot by jeecgboot.
the class OSSFileController method queryById.
/**
* 通过id查询.
*/
@ResponseBody
@GetMapping("/queryById")
public Result<OSSFile> queryById(@RequestParam(name = "id") String id) {
Result<OSSFile> result = new Result<>();
OSSFile file = ossFileService.getById(id);
if (file == null) {
result.error500("未找到对应实体");
} else {
result.setResult(file);
result.setSuccess(true);
}
return result;
}
use of org.jeecg.common.api.vo.Result in project jeecg-boot by jeecgboot.
the class OSSFileController method upload.
@ResponseBody
@PostMapping("/upload")
public // @RequiresRoles("admin")
Result upload(@RequestParam("file") MultipartFile multipartFile) {
Result result = new Result();
try {
ossFileService.upload(multipartFile);
result.success("上传成功!");
} catch (Exception ex) {
log.info(ex.getMessage(), ex);
result.error500("上传失败");
}
return result;
}
use of org.jeecg.common.api.vo.Result in project jeecg-boot by jeecgboot.
the class OSSFileController method delete.
@ResponseBody
@DeleteMapping("/delete")
public Result delete(@RequestParam(name = "id") String id) {
Result result = new Result();
OSSFile file = ossFileService.getById(id);
if (file == null) {
result.error500("未找到对应实体");
} else {
boolean ok = ossFileService.delete(file);
if (ok) {
result.success("删除成功!");
}
}
return result;
}
use of org.jeecg.common.api.vo.Result in project jeecg-boot by jeecgboot.
the class TestSocketController method sendUser.
@PostMapping("/sendUser")
public Result<String> sendUser(@RequestBody JSONObject jsonObject) {
Result<String> result = new Result<String>();
String userId = jsonObject.getString("userId");
String message = jsonObject.getString("message");
JSONObject obj = new JSONObject();
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_USER);
obj.put(WebsocketConst.MSG_USER_ID, userId);
obj.put(WebsocketConst.MSG_ID, "M0001");
obj.put(WebsocketConst.MSG_TXT, message);
webSocket.sendMessage(userId, obj.toJSONString());
result.setResult("单发");
return result;
}
Aggregations