|
|
@@ -0,0 +1,60 @@
|
|
|
+package com.cyksj.web.controller.manage.form;
|
|
|
+
|
|
|
+import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
+import com.cyksj.dto.Result;
|
|
|
+import com.cyksj.enums.GatewayResponse;
|
|
|
+import com.cyksj.model.entity.QuestionnairePromotion;
|
|
|
+import com.cyksj.service.mange.form.QuestionnairePromotionService;
|
|
|
+import com.ejlchina.searcher.BeanSearcher;
|
|
|
+import com.ejlchina.searcher.SearchResult;
|
|
|
+import com.ejlchina.searcher.util.MapUtils;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+/*
|
|
|
+ *项目名: netflix
|
|
|
+ *文件名: QuestionnairePromotionController
|
|
|
+ *创建者: JavaZou
|
|
|
+ *创建时间:2023/6/14 11:36
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/manage/questionnaire")
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class QuestionnairePromotionController {
|
|
|
+ private final QuestionnairePromotionService promotionService;
|
|
|
+
|
|
|
+ private final BeanSearcher beanSearcher;
|
|
|
+
|
|
|
+ private final HttpServletRequest request;
|
|
|
+
|
|
|
+ @PostMapping("/post")
|
|
|
+ public Result<String> saveQuestionnaire(@RequestBody @Validated QuestionnairePromotion promotion) {
|
|
|
+ promotionService.saveOrUpdatePromotion(promotion);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/put")
|
|
|
+ public Result<String> updateQuestionnaire(@RequestBody @Validated QuestionnairePromotion promotion) {
|
|
|
+ promotionService.saveOrUpdatePromotion(promotion);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete/{id}")
|
|
|
+ public Result<String> delById(@PathVariable Long id) {
|
|
|
+ QuestionnairePromotion byId = promotionService.getById(id);
|
|
|
+ if (byId == null || !byId.getDeleted()) throw BusinessRuntimeException.getInstance("该记录已被删除");
|
|
|
+ byId.setDeleted(false);
|
|
|
+ promotionService.updateById(byId);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ public Result<SearchResult<QuestionnairePromotion>> getPromotions() {
|
|
|
+ SearchResult<QuestionnairePromotion> search = beanSearcher.search(QuestionnairePromotion.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .field(QuestionnairePromotion::getDeleted, true).build());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
+}
|