Search in sources :

Example 1 with Result

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();
    }
}
Also used : OutputStream(java.io.OutputStream) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Result(org.jeecg.common.api.vo.Result)

Example 2 with Result

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;
}
Also used : OSSFile(org.jeecg.modules.oss.entity.OSSFile) Result(org.jeecg.common.api.vo.Result)

Example 3 with 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;
}
Also used : Result(org.jeecg.common.api.vo.Result)

Example 4 with 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;
}
Also used : OSSFile(org.jeecg.modules.oss.entity.OSSFile) Result(org.jeecg.common.api.vo.Result)

Example 5 with 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;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Result(org.jeecg.common.api.vo.Result) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

Result (org.jeecg.common.api.vo.Result)261 JSONObject (com.alibaba.fastjson.JSONObject)96 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)50 LoginUser (org.jeecg.common.system.vo.LoginUser)38 SysUser (org.jeecg.modules.system.entity.SysUser)36 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)32 Date (java.util.Date)28 IOException (java.io.IOException)26 ApiOperation (io.swagger.annotations.ApiOperation)24 SysAnnouncement (org.jeecg.modules.system.entity.SysAnnouncement)24 EncryptedString (org.jeecg.common.util.encryption.EncryptedString)21 GetMapping (org.springframework.web.bind.annotation.GetMapping)21 SysAnnouncementSend (org.jeecg.modules.system.entity.SysAnnouncementSend)18 ArrayList (java.util.ArrayList)17 SysDepart (org.jeecg.modules.system.entity.SysDepart)17 CacheEvict (org.springframework.cache.annotation.CacheEvict)15 SysRole (org.jeecg.modules.system.entity.SysRole)14 IPage (com.baomidou.mybatisplus.core.metadata.IPage)13 SysCategory (org.jeecg.modules.system.entity.SysCategory)12 SysUserAgent (org.jeecg.modules.system.entity.SysUserAgent)12