|
@@ -0,0 +1,109 @@
|
|
|
|
+package com.huaxu.controller;
|
|
|
|
+
|
|
|
|
+import com.huaxu.model.AjaxMessage;
|
|
|
|
+import com.huaxu.model.LoginUser;
|
|
|
|
+import com.huaxu.model.ResultStatus;
|
|
|
|
+import com.huaxu.util.UserUtil;
|
|
|
|
+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.stereotype.Controller;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+import com.huaxu.entity.SceneTypeEntity;
|
|
|
|
+import com.huaxu.service.SceneTypeService;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 场景类型页面控制器
|
|
|
|
+ * @author WYY
|
|
|
|
+ * @date 2020-11-17 19:31
|
|
|
|
+ */
|
|
|
|
+@Controller
|
|
|
|
+@RequestMapping("/scenetype/scenetype")
|
|
|
|
+@Api(tags = "场景类型管理")
|
|
|
|
+public class SceneTypeController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SceneTypeService sceneTypeService;
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "按父级节点查询子节点信息")
|
|
|
|
+ @RequestMapping(value = "/selectListByParentId", method = RequestMethod.GET)
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public AjaxMessage<List<SceneTypeEntity>> list(@ApiParam(value = "父级ID", required = true) @RequestParam Long id) {
|
|
|
|
+ SceneTypeEntity sceneType = new SceneTypeEntity();
|
|
|
|
+ sceneType.setParentScenetypeId(id);
|
|
|
|
+ List<SceneTypeEntity> page = sceneTypeService.findListByParentID(sceneType);
|
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询所有场景类型")
|
|
|
|
+ @RequestMapping(value = "/selectList", method = RequestMethod.GET)
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public AjaxMessage<List<SceneTypeEntity>> selectAllList(@ApiParam(value = "名称", required = false) @RequestParam(required = false) String name) {
|
|
|
|
+ SceneTypeEntity sceneType = new SceneTypeEntity();
|
|
|
|
+ sceneType.setSceneTypeName(name);
|
|
|
|
+ List<SceneTypeEntity> page = sceneTypeService.findList(sceneType);
|
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation(value = "新增")
|
|
|
|
+ @RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public AjaxMessage<Integer> addSceneType(@ApiParam(value = "场景类型", required = true) @RequestBody SceneTypeEntity sceneType) {
|
|
|
|
+ int result = sceneTypeService.addSceneType(sceneType) ? 1 : 0;
|
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 批量新增
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/batchAdd", method = RequestMethod.POST)
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @ApiOperation(value = "批量新增或修改")
|
|
|
|
+ public AjaxMessage<Integer> addSceneType(@ApiParam(value = "场景类型", required = true) @RequestBody ArrayList<SceneTypeEntity> sceneTypes) {
|
|
|
|
+ LoginUser currentUser = UserUtil.getCurrentUser();
|
|
|
|
+ for (SceneTypeEntity item : sceneTypes) {
|
|
|
|
+ item.setTenantId(currentUser.getTenantId());
|
|
|
|
+ item.setStatus(1);
|
|
|
|
+ }
|
|
|
|
+ int result = sceneTypeService.saveOrUpdateBatch(sceneTypes) ? 1 : 0;
|
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改保存场景类型
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/edit", method = RequestMethod.POST)
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @ApiOperation(value = "修改")
|
|
|
|
+ public AjaxMessage<Integer> editSceneType(@ApiParam(value = "场景类型", required = true) @RequestBody SceneTypeEntity sceneType) {
|
|
|
|
+ int result = sceneTypeService.updateSceneTypeById(sceneType) ? 1 : 0;
|
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation(value = "批量删除")
|
|
|
|
+ @RequestMapping(value = "/deleteByIds", method = RequestMethod.POST)
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public AjaxMessage<Integer> del(@ApiParam(value = "场景类型ID", required = true) @RequestBody Long[] ids) {
|
|
|
|
+ int result = sceneTypeService.delSceneTypeByIds(ids) ? 1 : 0;
|
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "按ID查询场景类型")
|
|
|
|
+ @RequestMapping(value = "/selectById", method = RequestMethod.GET)
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public AjaxMessage<SceneTypeEntity> selectById(@ApiParam(value = "ID", required = true) @RequestParam Long id) {
|
|
|
|
+ SceneTypeEntity sceneTypeEntity = sceneTypeService.findSceneTypeById(id);
|
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, sceneTypeEntity);
|
|
|
|
+ }
|
|
|
|
+}
|