package com.dy.pipIrrOperation.feedbackReply; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.pipIrrGlobal.pojoOp.OpeFeedbackReply; import io.swagger.v3.oas.annotations.Parameter; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import java.util.Objects; import java.util.Optional; /** * @author :WuZeYu * @Date :2024/7/31 16:19 * @LastEditTime :2024/7/31 16:19 * @Description */ @Slf4j @RestController @RequestMapping(path="feedbackReply") @RequiredArgsConstructor public class FeedbackReplyCtrl { private final FeedbackReplySv feedbackReplySv; /** * 添加问题反馈回复 * @param reply * @param bindingResult * @return */ @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop public BaseResponse add(@RequestBody @Valid OpeFeedbackReply reply, @Parameter(hidden = true) BindingResult bindingResult){ if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } Integer rec = Optional.ofNullable(feedbackReplySv.add(reply)).orElse(0); if (rec == 0) { return BaseResponseUtils.buildFail("添加失败"); } return BaseResponseUtils.buildSuccess(true); } }