mirror of https://github.com/halo-dev/halo
🎨 remove ResponseStatusEnum.java and be instead of HttpStatus
parent
135719607e
commit
c573c747fb
|
@ -341,9 +341,7 @@ public final class Logger implements org.slf4j.Logger {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void warn(Marker marker, String
|
||||
|
||||
format, Object... arguments) {
|
||||
public void warn(Marker marker, String format, Object... arguments) {
|
||||
if (isWarnEnabled(marker)) {
|
||||
proxy.warn(marker, format, arguments);
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
package cc.ryanc.halo.model.enums;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 请求响应enum
|
||||
* </pre>
|
||||
*
|
||||
* @author : RYAN0UP
|
||||
* @date : 2018/7/1
|
||||
*/
|
||||
public enum ResponseStatusEnum {
|
||||
|
||||
/**
|
||||
* 请求成功
|
||||
*/
|
||||
SUCCESS(200, "OK"),
|
||||
|
||||
/**
|
||||
* 资源为空
|
||||
*/
|
||||
EMPTY(204, "No Content"),
|
||||
|
||||
/**
|
||||
* 服务器内部错误
|
||||
*/
|
||||
ERROR(500, "Internal Server Error"),
|
||||
|
||||
/**
|
||||
* 未找到资源
|
||||
*/
|
||||
NOTFOUND(404, "Not Found");
|
||||
|
||||
private Integer code;
|
||||
private String msg;
|
||||
|
||||
ResponseStatusEnum(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
}
|
|
@ -81,6 +81,7 @@ public class BaseRepositoryImpl<DOMAIN, ID> extends SimpleJpaRepository<DOMAIN,
|
|||
this.entityInformation = entityInformation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
||||
Path<?> path = root.get(this.entityInformation.getIdAttribute());
|
||||
this.parameter = cb.parameter(Iterable.class);
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -78,6 +79,7 @@ public class AdminController extends BaseController {
|
|||
* 请求后台页面
|
||||
*
|
||||
* @param model model
|
||||
*
|
||||
* @return 模板路径admin/admin_index
|
||||
*/
|
||||
@GetMapping(value = {"", "/index"})
|
||||
|
@ -117,6 +119,7 @@ public class AdminController extends BaseController {
|
|||
* 处理跳转到登录页的请求
|
||||
*
|
||||
* @param session session
|
||||
*
|
||||
* @return 模板路径admin/admin_login
|
||||
*/
|
||||
@GetMapping(value = "/login")
|
||||
|
@ -135,6 +138,7 @@ public class AdminController extends BaseController {
|
|||
* @param loginName 登录名:邮箱/用户名
|
||||
* @param loginPwd loginPwd 密码
|
||||
* @param session session session
|
||||
*
|
||||
* @return JsonResult JsonResult
|
||||
*/
|
||||
@PostMapping(value = "/getLogin")
|
||||
|
@ -186,6 +190,7 @@ public class AdminController extends BaseController {
|
|||
* 退出登录 销毁session
|
||||
*
|
||||
* @param session session
|
||||
*
|
||||
* @return 重定向到/admin/login
|
||||
*/
|
||||
@GetMapping(value = "/logOut")
|
||||
|
@ -201,6 +206,7 @@ public class AdminController extends BaseController {
|
|||
* 查看所有日志
|
||||
*
|
||||
* @param model model model
|
||||
*
|
||||
* @return 模板路径admin/widget/_logs-all
|
||||
*/
|
||||
@GetMapping(value = "/logs")
|
||||
|
@ -244,10 +250,9 @@ public class AdminController extends BaseController {
|
|||
@ResponseBody
|
||||
public JsonResult getToken() {
|
||||
final String token = (System.currentTimeMillis() + new Random().nextInt(999999999)) + "";
|
||||
return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), ResponseStatusEnum.SUCCESS.getMsg(), SecureUtil.md5(token));
|
||||
return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), HttpStatus.OK.getReasonPhrase(), SecureUtil.md5(token));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小工具
|
||||
*
|
||||
|
@ -273,6 +278,7 @@ public class AdminController extends BaseController {
|
|||
*
|
||||
* @param file file
|
||||
* @param request request
|
||||
*
|
||||
* @return JsonResult
|
||||
*/
|
||||
@PostMapping(value = "/tools/markdownImport")
|
||||
|
|
|
@ -2,9 +2,9 @@ package cc.ryanc.halo.web.controller.api;
|
|||
|
||||
import cc.ryanc.halo.model.dto.Archive;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -75,9 +75,9 @@ public class ApiArchivesController {
|
|||
public JsonResult archivesYear() {
|
||||
final List<Archive> archives = postService.findPostGroupByYear();
|
||||
if (!CollectionUtils.isEmpty(archives)) {
|
||||
return new JsonResult(ResponseStatusEnum.SUCCESS.getCode(), ResponseStatusEnum.SUCCESS.getMsg(), archives);
|
||||
return new JsonResult(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), archives);
|
||||
} else {
|
||||
return new JsonResult(ResponseStatusEnum.EMPTY.getCode(), ResponseStatusEnum.EMPTY.getMsg());
|
||||
return new JsonResult(HttpStatus.NO_CONTENT.value(), HttpStatus.NO_CONTENT.getReasonPhrase());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,7 @@ public class ApiArchivesController {
|
|||
|
||||
/**
|
||||
* @return JsonResult
|
||||
*
|
||||
* @Author Aquan
|
||||
* @Description 返回所有文章
|
||||
* @Date 2019.1.4 11:06
|
||||
|
|
|
@ -3,7 +3,10 @@ package cc.ryanc.halo.web.controller.api;
|
|||
import cc.ryanc.halo.model.domain.Category;
|
||||
import cc.ryanc.halo.service.CategoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -70,6 +73,7 @@ public class ApiCategoryController {
|
|||
* </p>
|
||||
*
|
||||
* @param cateUrl 分类路径
|
||||
*
|
||||
* @return JsonResult
|
||||
*/
|
||||
@GetMapping(value = "/{cateUrl}")
|
||||
|
|
|
@ -51,6 +51,7 @@ public class ApiCommentController {
|
|||
* @param comment comment
|
||||
* @param postId postId
|
||||
* @param request request
|
||||
*
|
||||
* @return JsonResult
|
||||
*/
|
||||
@PostMapping(value = "/save")
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package cc.ryanc.halo.web.controller.api;
|
||||
|
||||
import cc.ryanc.halo.model.domain.Gallery;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
|
||||
import cc.ryanc.halo.service.GalleryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
|
@ -81,6 +81,7 @@ public class ApiGalleryController {
|
|||
* </p>
|
||||
*
|
||||
* @param id id
|
||||
*
|
||||
* @return JsonResult
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package cc.ryanc.halo.web.controller.api;
|
||||
|
||||
import cc.ryanc.halo.model.domain.Link;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
|
||||
import cc.ryanc.halo.service.LinkService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package cc.ryanc.halo.web.controller.api;
|
||||
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
|
||||
import cc.ryanc.halo.service.OptionsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -75,6 +76,7 @@ public class ApiOptionController {
|
|||
* </p>
|
||||
*
|
||||
* @param optionName 设置选项名称
|
||||
*
|
||||
* @return JsonResult
|
||||
*/
|
||||
@GetMapping(value = "/one")
|
||||
|
|
|
@ -2,12 +2,13 @@ package cc.ryanc.halo.web.controller.api;
|
|||
|
||||
import cc.ryanc.halo.exception.NotFoundException;
|
||||
import cc.ryanc.halo.model.domain.Post;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.PostTypeEnum;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
|
@ -58,6 +59,7 @@ public class ApiPageController {
|
|||
* </p>
|
||||
*
|
||||
* @param postId postId
|
||||
*
|
||||
* @return JsonResult
|
||||
*/
|
||||
@GetMapping(value = "/{postId}")
|
||||
|
|
|
@ -6,7 +6,6 @@ import cc.ryanc.halo.model.dto.JsonResult;
|
|||
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
||||
import cc.ryanc.halo.model.enums.PostStatusEnum;
|
||||
import cc.ryanc.halo.model.enums.PostTypeEnum;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
|
||||
import cc.ryanc.halo.service.PostService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -15,7 +14,11 @@ import org.springframework.data.domain.PageRequest;
|
|||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cc.ryanc.halo.model.dto.HaloConst.OPTIONS;
|
||||
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||
|
@ -98,6 +101,7 @@ public class ApiPostController {
|
|||
* </p>
|
||||
*
|
||||
* @param page 页码
|
||||
*
|
||||
* @return JsonResult
|
||||
*/
|
||||
@GetMapping(value = "/page/{page}")
|
||||
|
@ -109,9 +113,9 @@ public class ApiPostController {
|
|||
final Pageable pageable = PageRequest.of(page - 1, size, sort);
|
||||
final Page<Post> posts = postService.findPostByStatus(PostStatusEnum.PUBLISHED.getCode(), PostTypeEnum.POST_TYPE_POST.getDesc(), pageable);
|
||||
if (null == posts) {
|
||||
return new JsonResult(ResponseStatusEnum.EMPTY.getCode(), ResponseStatusEnum.EMPTY.getMsg());
|
||||
return new JsonResult(HttpStatus.NO_CONTENT.value(), HttpStatus.NO_CONTENT.getReasonPhrase());
|
||||
}
|
||||
return new JsonResult(ResponseStatusEnum.SUCCESS.getCode(), ResponseStatusEnum.SUCCESS.getMsg(), posts);
|
||||
return new JsonResult(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), posts);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,6 +152,7 @@ public class ApiPostController {
|
|||
* </p>
|
||||
*
|
||||
* @param postId 文章编号
|
||||
*
|
||||
* @return JsonResult
|
||||
*/
|
||||
@GetMapping(value = "/{postId}")
|
||||
|
|
|
@ -3,10 +3,13 @@ package cc.ryanc.halo.web.controller.api;
|
|||
import cc.ryanc.halo.exception.NotFoundException;
|
||||
import cc.ryanc.halo.model.domain.Tag;
|
||||
import cc.ryanc.halo.model.dto.JsonResult;
|
||||
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
|
||||
import cc.ryanc.halo.service.TagService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -51,9 +54,9 @@ public class ApiTagController {
|
|||
public JsonResult tags() {
|
||||
final List<Tag> tags = tagService.listAll();
|
||||
if (null != tags && tags.size() > 0) {
|
||||
return new JsonResult(ResponseStatusEnum.SUCCESS.getCode(), ResponseStatusEnum.SUCCESS.getMsg(), tags);
|
||||
return new JsonResult(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), tags);
|
||||
} else {
|
||||
return new JsonResult(ResponseStatusEnum.EMPTY.getCode(), ResponseStatusEnum.EMPTY.getMsg());
|
||||
return new JsonResult(HttpStatus.NO_CONTENT.value(), HttpStatus.NO_CONTENT.getReasonPhrase());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,6 +79,7 @@ public class ApiTagController {
|
|||
* </p>
|
||||
*
|
||||
* @param tagUrl tagUrl
|
||||
*
|
||||
* @return JsonResult
|
||||
*/
|
||||
@GetMapping(value = "/{tagUrl}")
|
||||
|
|
Loading…
Reference in New Issue