feat: 轮播图设置模块
This commit is contained in:
parent
d505a43122
commit
ae24df4741
@ -9,7 +9,6 @@ import com.jsl.oa.utils.ResultUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -70,8 +69,8 @@ public class InfoController {
|
||||
}
|
||||
|
||||
@PutMapping("/info/header-image/edit-setting")
|
||||
public BaseResponse infoEditSettingHeaderImage(@RequestBody @Validated CarouselVO carouselVO, @RequestParam Integer id, HttpServletRequest πrequest, @NotNull BindingResult bindingResult) {
|
||||
public BaseResponse infoEditSettingHeaderImage(@RequestParam Boolean showType, HttpServletRequest request) {
|
||||
log.info("请求接口[PUT]: /info/header-image/edit-setting");
|
||||
return null;
|
||||
return infoService.editSettingHeaderImage(request, showType);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.jsl.oa.exception;
|
||||
|
||||
import com.jsl.oa.utils.BaseResponse;
|
||||
import com.jsl.oa.utils.ErrorCode;
|
||||
import com.jsl.oa.utils.ResultUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -8,6 +9,7 @@ import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@ -17,21 +19,28 @@ public class ProcessException {
|
||||
|
||||
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.class)
|
||||
public ResponseEntity<BaseResponse> businessMethodNotAllowedException() {
|
||||
log.debug("请求方法错误");
|
||||
log.warn("请求方法错误");
|
||||
return ResultUtil.error("MethodNotAllowed", 405, "请求方法错误");
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = DuplicateKeyException.class)
|
||||
public ResponseEntity<BaseResponse> businessDuplicateKeyException(@NotNull DuplicateKeyException e) {
|
||||
log.debug(e.getMessage(), e);
|
||||
log.warn(e.getMessage(), e);
|
||||
return ResultUtil.error("DuplicateEntry", 400, "数据重复/外键约束");
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = HttpMessageNotReadableException.class)
|
||||
public ResponseEntity<BaseResponse> businessHttpMessageNotReadableException(HttpMessageNotReadableException e) {
|
||||
log.debug(e.getMessage(), e);
|
||||
log.warn(e.getMessage(), e);
|
||||
return ResultUtil.error("HttpMessageNotReadable", 400, "请求参数错误");
|
||||
}
|
||||
@ExceptionHandler(value = MissingServletRequestParameterException.class)
|
||||
public ResponseEntity<BaseResponse> businessMissingServletRequestParameterExceptionException(MissingServletRequestParameterException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return ResponseEntity
|
||||
.status(400)
|
||||
.body(ResultUtil.error(ErrorCode.PARAMETER_ERROR, e.getMessage()));
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
public ResponseEntity<BaseResponse> businessException(@NotNull Exception e) {
|
||||
|
@ -57,4 +57,14 @@ public interface InfoService {
|
||||
* @return {@link BaseResponse}
|
||||
*/
|
||||
BaseResponse delHeaderImage(HttpServletRequest request, Integer id);
|
||||
|
||||
/**
|
||||
* <h2>编辑轮播图设置</h2>
|
||||
* <hr/>
|
||||
* 编辑轮播图显示类型
|
||||
*
|
||||
* @param showType 显示类型(true:顺序,false:倒序)
|
||||
* @return {@link BaseResponse}
|
||||
*/
|
||||
BaseResponse editSettingHeaderImage(HttpServletRequest request, Boolean showType);
|
||||
}
|
||||
|
@ -121,4 +121,21 @@ public class InfoServiceImpl implements InfoService {
|
||||
return ResultUtil.error(ErrorCode.DATABASE_UPDATE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResponse editSettingHeaderImage(HttpServletRequest request, Boolean showType) {
|
||||
// 用户权限校验
|
||||
if (!Processing.checkUserIsAdmin(request, roleMapper)) {
|
||||
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||
}
|
||||
// 获取轮播图信息
|
||||
CarouselDO carouselDO = infoDAO.getCarousel();
|
||||
carouselDO.setOrder(showType ? "asc" : "desc");
|
||||
// 保存轮播图
|
||||
if (infoDAO.setCarousel(carouselDO)) {
|
||||
return ResultUtil.success();
|
||||
} else {
|
||||
return ResultUtil.error(ErrorCode.DATABASE_UPDATE_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user