|
@@ -0,0 +1,98 @@
|
|
|
+package com.fdkankan.openApi.controller.www;
|
|
|
+
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaIgnore;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.openApi.aop.ValidateApi;
|
|
|
+import com.fdkankan.openApi.dto.www.SceneShowContentDto;
|
|
|
+import com.fdkankan.openApi.entity.www.SceneShowContent;
|
|
|
+import com.fdkankan.openApi.service.www.ISceneShowContentService;
|
|
|
+import com.fdkankan.openApi.vo.www.SceneShowContentVo;
|
|
|
+import com.fdkankan.web.response.ResultData;
|
|
|
+import jdk.nashorn.internal.ir.annotations.Ignore;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 场景展示消息 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2024-04-16
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/scene/content")
|
|
|
+public class SceneShowContentController {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISceneShowContentService sceneShowContentService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存场景展示消息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @SaIgnore
|
|
|
+ @ValidateApi
|
|
|
+ @PostMapping("/save")
|
|
|
+ public ResultData save(@RequestBody List<SceneShowContentDto> dtos){
|
|
|
+ if(CollUtil.isEmpty(dtos)){
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+ List<Long> ids = dtos.stream().filter(v -> Objects.nonNull(v.getId())).map(v -> v.getId()).collect(Collectors.toList());
|
|
|
+ if(CollUtil.isNotEmpty(ids)){
|
|
|
+ List<SceneShowContent> dbList = sceneShowContentService.listByIds(ids);
|
|
|
+ List<Long> dbIds = dbList.stream().map(v -> v.getId()).collect(Collectors.toList());
|
|
|
+ List<Long> notExistsIds = ids.stream().filter(id -> !dbIds.contains(id)).collect(Collectors.toList());
|
|
|
+ if(CollUtil.isNotEmpty(notExistsIds)){
|
|
|
+ return ResultData.error(ErrorCode.PARAM_FORMAT_ERROR.code(), "id不正确:" + JSON.toJSONString(notExistsIds));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<SceneShowContent> sceneShowContents = BeanUtil.copyToList(dtos, SceneShowContent.class);
|
|
|
+ sceneShowContentService.saveOrUpdateBatch(sceneShowContents);
|
|
|
+ return ResultData.ok(BeanUtil.copyToList(sceneShowContents, SceneShowContentVo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存场景展示消息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @SaIgnore
|
|
|
+ @ValidateApi
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ public ResultData delete(@RequestBody List<Long> ids){
|
|
|
+ if(CollUtil.isEmpty(ids)){
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+ sceneShowContentService.removeByIds(ids);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存场景展示消息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @SaIgnore
|
|
|
+ @ValidateApi
|
|
|
+ @GetMapping("/list")
|
|
|
+ public ResultData list(@RequestParam("num")String num){
|
|
|
+ List<SceneShowContent> list = sceneShowContentService.list(new LambdaQueryWrapper<SceneShowContent>().eq(SceneShowContent::getNum, num));
|
|
|
+ return ResultData.ok(BeanUtil.copyToList(list, SceneShowContentVo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|