|
@@ -2,6 +2,7 @@ package com.huaxu.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.huaxu.common.FileUploadUtil;
|
|
|
import com.huaxu.dto.DeviceDto;
|
|
|
import com.huaxu.entity.SceneTypeEntity;
|
|
|
import com.huaxu.model.AjaxMessage;
|
|
@@ -11,16 +12,19 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Date;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import com.huaxu.entity.SceneEntity;
|
|
|
import com.huaxu.service.SceneService;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
/**
|
|
|
* 场景信息页面控制器
|
|
@@ -33,11 +37,13 @@ import com.huaxu.service.SceneService;
|
|
|
public class SceneController {
|
|
|
@Autowired
|
|
|
private SceneService sceneService;
|
|
|
+ @Value("${SMS.sys_config_path}")
|
|
|
+ private String baseDir;
|
|
|
|
|
|
@ApiOperation(value = "分页查询场景")
|
|
|
- @RequestMapping(value = "/selectPage",method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/selectPage", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
- public AjaxMessage<Pagination<SceneEntity>> selectPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @RequestParam(value = "sceneName", required = false) String sceneName) {
|
|
|
+ public AjaxMessage<Pagination<SceneEntity>> selectPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @RequestParam(value = "sceneName", required = false) String sceneName) {
|
|
|
IPage<SceneEntity> iPage = new Page<>(pageNum, pageSize);
|
|
|
SceneEntity sceneEntity = new SceneEntity();
|
|
|
sceneEntity.setSceneName(sceneName);
|
|
@@ -45,6 +51,7 @@ public class SceneController {
|
|
|
Pagination<SceneEntity> pages = new Pagination<>(iPage);
|
|
|
return new AjaxMessage<>(ResultStatus.OK, pages);
|
|
|
}
|
|
|
+
|
|
|
@ApiOperation(value = "查询场景树")
|
|
|
@RequestMapping(value = "/selectList", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
@@ -53,6 +60,25 @@ public class SceneController {
|
|
|
List<SceneEntity> menuEntities = sceneService.findAllList(sceneEntity);
|
|
|
return new AjaxMessage<>(ResultStatus.OK, menuEntities);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "场景图片")
|
|
|
+ @RequestMapping(value = "addSceneImage", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public AjaxMessage<String> addUserPhoto(@ApiParam(value = "场景图片", required = true) @RequestParam("avatarfile") MultipartFile file) {
|
|
|
+ String avatar = "";
|
|
|
+ if (!file.isEmpty()) {
|
|
|
+ try {
|
|
|
+ avatar = FileUploadUtil.uploadWeb(baseDir, file);
|
|
|
+ } catch (IOException e) {
|
|
|
+ return new AjaxMessage<>(ResultStatus.ERROR, e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, avatar);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新增
|
|
|
*/
|
|
@@ -60,6 +86,7 @@ public class SceneController {
|
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public AjaxMessage<Integer> addScene(@ApiParam(value = "场景", required = true) @RequestBody SceneEntity scene) {
|
|
|
+
|
|
|
int result = sceneService.addScene(scene) ? 1 : 0;
|
|
|
return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
}
|
|
@@ -71,7 +98,7 @@ public class SceneController {
|
|
|
@ApiOperation(value = "按ID查询场景")
|
|
|
@RequestMapping(value = "/selectById", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
- public AjaxMessage<SceneEntity> selectById(@ApiParam(value = "ID", required = true) @RequestParam Long id) {
|
|
|
+ public AjaxMessage<SceneEntity> selectById(@ApiParam(value = "ID", required = true) @RequestParam Long id) {
|
|
|
SceneEntity scene = sceneService.findSceneById(id);
|
|
|
return new AjaxMessage<>(ResultStatus.OK, scene);
|
|
|
}
|
|
@@ -94,6 +121,11 @@ public class SceneController {
|
|
|
@RequestMapping(value = "/deleteByIds", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public AjaxMessage<Integer> del(@ApiParam(value = "场景ID", required = true) @RequestBody Long[] ids) {
|
|
|
+
|
|
|
+ List<SceneEntity> scenes = sceneService.findByParentSceneIds(ids);
|
|
|
+ if (scenes.size() > 0) {
|
|
|
+ return new AjaxMessage<>(ResultStatus.EXSIT_IS_PARENT_ERROR);
|
|
|
+ }
|
|
|
int result = sceneService.delSceneByIds(ids) ? 1 : 0;
|
|
|
return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
}
|