|
@@ -0,0 +1,145 @@
|
|
|
|
|
+package com.cyksj.web.controller.manage.goods;
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
+import com.cyksj.dto.Result;
|
|
|
|
|
+import com.cyksj.enums.GatewayResponse;
|
|
|
|
|
+import com.cyksj.mapper.GoodsDonQaRelateMapper;
|
|
|
|
|
+import com.cyksj.model.entity.GoodsDonQa;
|
|
|
|
|
+import com.cyksj.model.entity.GoodsDonQaRelate;
|
|
|
|
|
+import com.cyksj.model.views.GoodsDonQaView;
|
|
|
|
|
+import com.cyksj.service.mange.GoodsDonQaService;
|
|
|
|
|
+import com.cyksj.service.mange.RefreshCacheService;
|
|
|
|
|
+import com.ejlchina.searcher.BeanSearcher;
|
|
|
|
|
+import com.ejlchina.searcher.SearchResult;
|
|
|
|
|
+import com.ejlchina.searcher.util.MapUtils;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/** admin/平台管理/常见问题
|
|
|
|
|
+ * 项目名: yhlxj2
|
|
|
|
|
+ * 文件名: GoodsDonQuestionController
|
|
|
|
|
+ * 创建者: JavaZou
|
|
|
|
|
+ * 创建时间:2024/5/24 15:52
|
|
|
|
|
+ */
|
|
|
|
|
+@RequestMapping("/manage/goods/question")
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+public class GoodsDonQuestionController {
|
|
|
|
|
+
|
|
|
|
|
+ private final GoodsDonQaService goodsDonQaService;
|
|
|
|
|
+
|
|
|
|
|
+ private final BeanSearcher beanSearcher;
|
|
|
|
|
+
|
|
|
|
|
+ private final HttpServletRequest request;
|
|
|
|
|
+
|
|
|
|
|
+ private final RefreshCacheService refreshCacheService;
|
|
|
|
|
+
|
|
|
|
|
+ private final GoodsDonQaRelateMapper goodsDonQaRelateMapper;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增问题
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/post")
|
|
|
|
|
+ public Result<String> post(@RequestBody GoodsDonQa goodsDonQa) {
|
|
|
|
|
+ goodsDonQaService.saveOrdUpdateQa(goodsDonQa);
|
|
|
|
|
+ refreshCacheService.goodsQuestionCache();
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除问题
|
|
|
|
|
+ */
|
|
|
|
|
+ @DeleteMapping("/del/{id}")
|
|
|
|
|
+ public Result<String> delById(@PathVariable Long id) {
|
|
|
|
|
+ GoodsDonQa byId = goodsDonQaService.getById(id);
|
|
|
|
|
+ if (byId != null && byId.getDeleted()) {
|
|
|
|
|
+ byId.setDeleted(false);
|
|
|
|
|
+ goodsDonQaService.updateById(byId);
|
|
|
|
|
+ goodsDonQaRelateMapper.update(null, Wrappers.lambdaUpdate(GoodsDonQaRelate.class)
|
|
|
|
|
+ .set(GoodsDonQaRelate::getDeleted, 0)
|
|
|
|
|
+ .eq(GoodsDonQaRelate::getQuestionId, id)
|
|
|
|
|
+ .eq(GoodsDonQaRelate::getDeleted, 1));
|
|
|
|
|
+ refreshCacheService.goodsQuestionCache();
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新问题
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/update")
|
|
|
|
|
+ public Result<String> update(@RequestBody GoodsDonQa goodsDonQa) {
|
|
|
|
|
+ goodsDonQaService.saveOrdUpdateQa(goodsDonQa);
|
|
|
|
|
+ refreshCacheService.goodsQuestionCache();
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 上下架
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/update/status/{id}")
|
|
|
|
|
+ public Result<String> updateStatusById(@PathVariable Long id) {
|
|
|
|
|
+ GoodsDonQa byId = goodsDonQaService.getById(id);
|
|
|
|
|
+ if (byId != null) {
|
|
|
|
|
+ byId.setStatus(!byId.getStatus());
|
|
|
|
|
+ goodsDonQaService.updateById(byId);
|
|
|
|
|
+ refreshCacheService.goodsQuestionCache();
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 批量上下架
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/update/status/batch")
|
|
|
|
|
+ public Result<String> batchUpdateStatusByIds(@RequestParam("ids") List<Long> ids, Boolean status) {
|
|
|
|
|
+ goodsDonQaService.update(null, Wrappers.lambdaUpdate(GoodsDonQa.class)
|
|
|
|
|
+ .set(GoodsDonQa::getStatus, status)
|
|
|
|
|
+ .ne(GoodsDonQa::getStatus, status)
|
|
|
|
|
+ .in(GoodsDonQa::getId, ids)
|
|
|
|
|
+ .eq(GoodsDonQa::getDeleted, 1));
|
|
|
|
|
+ refreshCacheService.goodsQuestionCache();
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 问题列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get")
|
|
|
|
|
+ public Result<SearchResult<GoodsDonQaView>> get() {
|
|
|
|
|
+ SearchResult<GoodsDonQaView> search = beanSearcher.search(GoodsDonQaView.class, MapUtils.flatBuilder(request.getParameterMap()).build());
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 问题详情
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/detail/{id}")
|
|
|
|
|
+ public Result<GoodsDonQa> getDetailById(@PathVariable Long id) {
|
|
|
|
|
+ GoodsDonQa byId = goodsDonQaService.getDetailById(id);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(byId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 排序
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/sorted")
|
|
|
|
|
+ public Result<String> sorted(@RequestBody GoodsDonQa goodsDonQa) {
|
|
|
|
|
+ Long id = goodsDonQa.getId();
|
|
|
|
|
+ Integer sorted = goodsDonQa.getSorted();
|
|
|
|
|
+ GoodsDonQa byId = goodsDonQaService.getById(id);
|
|
|
|
|
+ if (byId != null) {
|
|
|
|
|
+ byId.setSorted(sorted);
|
|
|
|
|
+ goodsDonQaService.updateById(byId);
|
|
|
|
|
+ refreshCacheService.goodsQuestionCache();
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|