From 69d73d1afcec564ec505106ca5fa5c0b24914597 Mon Sep 17 00:00:00 2001 From: maxw Date: Fri, 30 Aug 2024 12:03:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=B8=83=E5=B1=80=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8A=9F=E8=83=BD=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LayoutConfigController.java | 110 ++++++++++++ .../controller/LayoutDescController.java | 84 +++++++++ .../com/ruoyi/basic/domain/LayoutConfig.java | 119 +++++++++++++ .../com/ruoyi/basic/domain/LayoutDesc.java | 107 ++++++++++++ .../ruoyi/basic/mapper/LayoutConfigDao.java | 87 ++++++++++ .../com/ruoyi/basic/mapper/LayoutDescDao.java | 21 +++ .../basic/service/LayoutConfigService.java | 66 ++++++++ .../basic/service/LayoutDescService.java | 57 +++++++ .../service/impl/LayoutConfigServiceImpl.java | 141 +++++++++++++++ .../service/impl/LayoutDescServiceImpl.java | 52 ++++++ .../mapper/basic/LayoutConfigDao.xml | 160 ++++++++++++++++++ .../resources/mapper/basic/LayoutDescDao.xml | 136 +++++++++++++++ 12 files changed, 1140 insertions(+) create mode 100644 ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/controller/LayoutConfigController.java create mode 100644 ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/controller/LayoutDescController.java create mode 100644 ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/domain/LayoutConfig.java create mode 100644 ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/domain/LayoutDesc.java create mode 100644 ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/mapper/LayoutConfigDao.java create mode 100644 ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/mapper/LayoutDescDao.java create mode 100644 ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/LayoutConfigService.java create mode 100644 ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/LayoutDescService.java create mode 100644 ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutConfigServiceImpl.java create mode 100644 ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutDescServiceImpl.java create mode 100644 ruoyi-modules/hw-basic/src/main/resources/mapper/basic/LayoutConfigDao.xml create mode 100644 ruoyi-modules/hw-basic/src/main/resources/mapper/basic/LayoutDescDao.xml diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/controller/LayoutConfigController.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/controller/LayoutConfigController.java new file mode 100644 index 0000000..e2a5d44 --- /dev/null +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/controller/LayoutConfigController.java @@ -0,0 +1,110 @@ +package com.ruoyi.basic.controller; + + + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.ruoyi.basic.domain.LayoutConfig; +import com.ruoyi.basic.service.LayoutConfigService; + +import com.ruoyi.common.core.web.domain.AjaxResult; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * 布局配置表(LayoutConfig)表控制层 + * + * @author makejava + * @since 2024-08-26 16:38:10 + */ +@RestController +@RequestMapping("layoutConfig") +public class LayoutConfigController { + /** + * 服务对象 + */ + @Resource + private LayoutConfigService layoutConfigService; + + /** + * 分页查询 + * + * @param layoutConfig 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 + */ + @GetMapping + public ResponseEntity> queryByPage(LayoutConfig layoutConfig, PageRequest pageRequest) { + return ResponseEntity.ok(this.layoutConfigService.queryByPage(layoutConfig, pageRequest)); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("{id}") + public ResponseEntity queryById(@PathVariable("id") Long id) { + return ResponseEntity.ok(this.layoutConfigService.queryById(id)); + } + + /** + * 新增数据 + * + * @param layoutConfig 实体 + * @return 新增结果 + */ + @PostMapping + public ResponseEntity add(LayoutConfig layoutConfig) { + return ResponseEntity.ok(this.layoutConfigService.insert(layoutConfig)); + } + + /** + * 编辑数据 + * + * @param layoutConfig 实体 + * @return 编辑结果 + */ + @PutMapping + public ResponseEntity edit(LayoutConfig layoutConfig) { + return ResponseEntity.ok(this.layoutConfigService.update(layoutConfig)); + } + + /** + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ + @DeleteMapping + public ResponseEntity deleteById(Long id) { + return ResponseEntity.ok(this.layoutConfigService.deleteById(id)); + } + // 添加组件新配置 + @PostMapping("/insertLayoutConfig") + public AjaxResult insertLayoutConfig(@RequestBody Map config) throws JsonProcessingException { + System.out.println(config.get("items")); + List items = (List)config.get("items"); + String option = config.get("option").toString(); + return layoutConfigService.insertSceneConfig(items,option); + + } + // 查询所有场景 + @GetMapping("/selectAllScenes") + public AjaxResult selectAllScenes(){ + return layoutConfigService.selectAllScenes(); + } + + // 根据场景id查询 + @GetMapping("selectConfigById") + public AjaxResult selectConfigById(String sceneId){ + return layoutConfigService.selectConfigById(sceneId); + } + +} diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/controller/LayoutDescController.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/controller/LayoutDescController.java new file mode 100644 index 0000000..ebcad5b --- /dev/null +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/controller/LayoutDescController.java @@ -0,0 +1,84 @@ +package com.ruoyi.basic.controller; + + +import com.ruoyi.basic.domain.LayoutDesc; +import com.ruoyi.basic.service.LayoutDescService; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * 布局详情表(LayoutDesc)表控制层 + * + * @author makejava + * @since 2024-08-26 16:47:45 + */ +@RestController +@RequestMapping("layoutDesc") +public class LayoutDescController { + /** + * 服务对象 + */ + @Resource + private LayoutDescService layoutDescService; + + /** + * 分页查询 + * + * @param layoutDesc 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 + */ + @GetMapping + public ResponseEntity> queryByPage(LayoutDesc layoutDesc, PageRequest pageRequest) { + return ResponseEntity.ok(this.layoutDescService.queryByPage(layoutDesc, pageRequest)); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("{id}") + public ResponseEntity queryById(@PathVariable("id") Long id) { + return ResponseEntity.ok(this.layoutDescService.queryById(id)); + } + + /** + * 新增数据 + * + * @param layoutDesc 实体 + * @return 新增结果 + */ + @PostMapping + public ResponseEntity add(LayoutDesc layoutDesc) { + return ResponseEntity.ok(this.layoutDescService.insert(layoutDesc)); + } + + /** + * 编辑数据 + * + * @param layoutDesc 实体 + * @return 编辑结果 + */ + @PutMapping + public ResponseEntity edit(LayoutDesc layoutDesc) { + return ResponseEntity.ok(this.layoutDescService.update(layoutDesc)); + } + + /** + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ + @DeleteMapping + public ResponseEntity deleteById(Long id) { + return ResponseEntity.ok(this.layoutDescService.deleteById(id)); + } + +} diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/domain/LayoutConfig.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/domain/LayoutConfig.java new file mode 100644 index 0000000..4905a2f --- /dev/null +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/domain/LayoutConfig.java @@ -0,0 +1,119 @@ +package com.ruoyi.basic.domain; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 布局配置表(LayoutConfig)实体类 + * + * @author makejava + * @since 2024-08-26 16:38:23 + */ +@Data +public class LayoutConfig implements Serializable { + private static final long serialVersionUID = 540707408890304966L; + /** + * 配置id + */ + private Long configId; + /** + * 布局id + */ + private String layoutId; + /** + * 组件类型 + */ + private String type; + /** + * 布局描述 + */ + private String configDesc; + /** + * 创建者 + */ + private String createBy; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新者 + */ + private String updateBy; + /** + * 更新时间 + */ + private Date updateTime; + private String sceneConfig; + private String value2; + private String value3; + private String value4; + + +// public Long getConfigId() { +// return configId; +// } +// +// public void setConfigId(Long configId) { +// this.configId = configId; +// } +// +// public String getLayoutId() { +// return layoutId; +// } +// +// public void setLayoutId(String layoutId) { +// this.layoutId = layoutId; +// } +// +// public String getType() { +// return type; +// } +// +// public void setType(String type) { +// this.type = type; +// } +// +// public String getConfigDesc() { +// return configDesc; +// } +// +// public void setConfigDesc(String configDesc) { +// this.configDesc = configDesc; +// } +// +// public String getCreateBy() { +// return createBy; +// } +// +// public void setCreateBy(String createBy) { +// this.createBy = createBy; +// } +// +// public Date getCreateTime() { +// return createTime; +// } +// +// public void setCreateTime(Date createTime) { +// this.createTime = createTime; +// } +// +// public String getUpdateBy() { +// return updateBy; +// } +// +// public void setUpdateBy(String updateBy) { +// this.updateBy = updateBy; +// } +// +// public Date getUpdateTime() { +// return updateTime; +// } +// +// public void setUpdateTime(Date updateTime) { +// this.updateTime = updateTime; +// } + +} diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/domain/LayoutDesc.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/domain/LayoutDesc.java new file mode 100644 index 0000000..c539678 --- /dev/null +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/domain/LayoutDesc.java @@ -0,0 +1,107 @@ +package com.ruoyi.basic.domain; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 布局配置表(LayoutConfig)实体类 + * + * @author makejava + * @since 2024-08-26 16:38:23 + */ +@Data +public class LayoutDesc implements Serializable { + private static final long serialVersionUID = 540707408890304966L; + + /** + * 布局id + */ + private String layoutId; + /** + * 布局描述 + */ + private String layoutDesc; + /** + * 创建者 + */ + private String createBy; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新者 + */ + private String updateBy; + /** + * 更新时间 + */ + private Date updateTime; + private String sceneConfig; + private String value2; + private String value3; + private String value4; + + + +// +// public String getLayoutId() { +// return layoutId; +// } +// +// public void setLayoutId(String layoutId) { +// this.layoutId = layoutId; +// } +// public String getSceneConfig() { +// return sceneConfig; +// } +// +// public void setSceneConfig(String sceneConfig) { +// this.sceneConfig = sceneConfig; +// } +// +// +// +// public String getLayoutDesc() { +// return layoutDesc; +// } +// +// public void setLayoutDesc(String layoutDesc) { +// this.layoutDesc = layoutDesc; +// } +// +// public String getCreateBy() { +// return createBy; +// } +// +// public void setCreateBy(String createBy) { +// this.createBy = createBy; +// } +// +// public Date getCreateTime() { +// return createTime; +// } +// +// public void setCreateTime(Date createTime) { +// this.createTime = createTime; +// } +// +// public String getUpdateBy() { +// return updateBy; +// } +// +// public void setUpdateBy(String updateBy) { +// this.updateBy = updateBy; +// } +// +// public Date getUpdateTime() { +// return updateTime; +// } +// +// public void setUpdateTime(Date updateTime) { +// this.updateTime = updateTime; +// } + +} diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/mapper/LayoutConfigDao.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/mapper/LayoutConfigDao.java new file mode 100644 index 0000000..b2951ce --- /dev/null +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/mapper/LayoutConfigDao.java @@ -0,0 +1,87 @@ +package com.ruoyi.basic.mapper; + +import com.ruoyi.basic.domain.LayoutConfig; +import com.ruoyi.basic.domain.LayoutDesc; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +/** + * 布局配置表(LayoutConfig)表数据库访问层 + * + * @author makejava + * @since 2024-08-26 16:38:12 + */ +public interface LayoutConfigDao { + + /** + * 通过ID查询单条数据 + * + * @param configId 主键 + * @return 实例对象 + */ + LayoutConfig queryById(Long configId); + + /** + * 查询指定行数据 + * + * @param layoutConfig 查询条件 + * @param pageable 分页对象 + * @return 对象列表 + */ + List queryAllByLimit(LayoutConfig layoutConfig, @Param("pageable") Pageable pageable); + + /** + * 统计总行数 + * + * @param layoutConfig 查询条件 + * @return 总行数 + */ + long count(LayoutConfig layoutConfig); + + /** + * 新增数据 + * + * @param layoutConfig 实例对象 + * @return 影响行数 + */ + int insert(LayoutConfig layoutConfig); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param layoutConfig 实例对象 + * @return 影响行数 + */ + int update(LayoutConfig layoutConfig); + + /** + * 通过主键删除数据 + * + * @param configId 主键 + * @return 影响行数 + */ + int deleteById(Long configId); + + List selectConfigById(String sceneId); + + List selectAllScenes(); +} diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/mapper/LayoutDescDao.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/mapper/LayoutDescDao.java new file mode 100644 index 0000000..7ec9159 --- /dev/null +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/mapper/LayoutDescDao.java @@ -0,0 +1,21 @@ +package com.ruoyi.basic.mapper; + + +import com.ruoyi.basic.domain.LayoutDesc; + +import java.util.List; + +/** + * 布局配置表(LayoutConfig)表数据库访问层 + * + * @author makejava + * @since 2024-08-26 16:38:12 + */ +public interface LayoutDescDao { + + + int insert(LayoutDesc layoutDesc); + + List selectAllScenes(); + +} diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/LayoutConfigService.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/LayoutConfigService.java new file mode 100644 index 0000000..9f67332 --- /dev/null +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/LayoutConfigService.java @@ -0,0 +1,66 @@ +package com.ruoyi.basic.service; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.ruoyi.basic.domain.LayoutConfig; +import com.ruoyi.common.core.web.domain.AjaxResult; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +import java.util.List; + +/** + * 布局配置表(LayoutConfig)表服务接口 + * + * @author makejava + * @since 2024-08-26 16:38:28 + */ +public interface LayoutConfigService { + + /** + * 通过ID查询单条数据 + * + * @param configId 主键 + * @return 实例对象 + */ + LayoutConfig queryById(Long configId); + + /** + * 分页查询 + * + * @param layoutConfig 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 + */ + Page queryByPage(LayoutConfig layoutConfig, PageRequest pageRequest); + + /** + * 新增数据 + * + * @param layoutConfig 实例对象 + * @return 实例对象 + */ + LayoutConfig insert(LayoutConfig layoutConfig); + + /** + * 修改数据 + * + * @param layoutConfig 实例对象 + * @return 实例对象 + */ + LayoutConfig update(LayoutConfig layoutConfig); + + /** + * 通过主键删除数据 + * + * @param configId 主键 + * @return 是否成功 + */ + boolean deleteById(Long configId); + + AjaxResult insertSceneConfig(List items, String option) throws JsonProcessingException; + + AjaxResult selectConfigById(String sceneId); + + AjaxResult selectAllScenes(); + +} diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/LayoutDescService.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/LayoutDescService.java new file mode 100644 index 0000000..7a5a50c --- /dev/null +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/LayoutDescService.java @@ -0,0 +1,57 @@ +package com.ruoyi.basic.service; + + +import com.ruoyi.basic.domain.LayoutDesc; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +/** + * 布局详情表(LayoutDesc)表服务接口 + * + * @author makejava + * @since 2024-08-26 16:47:47 + */ +public interface LayoutDescService { + + /** + * 通过ID查询单条数据 + * + * @param layoutId 主键 + * @return 实例对象 + */ + LayoutDesc queryById(Long layoutId); + + /** + * 分页查询 + * + * @param layoutDesc 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 + */ + Page queryByPage(LayoutDesc layoutDesc, PageRequest pageRequest); + + /** + * 新增数据 + * + * @param layoutDesc 实例对象 + * @return 实例对象 + */ + LayoutDesc insert(LayoutDesc layoutDesc); + + /** + * 修改数据 + * + * @param layoutDesc 实例对象 + * @return 实例对象 + */ + LayoutDesc update(LayoutDesc layoutDesc); + + /** + * 通过主键删除数据 + * + * @param layoutId 主键 + * @return 是否成功 + */ + boolean deleteById(Long layoutId); + +} diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutConfigServiceImpl.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutConfigServiceImpl.java new file mode 100644 index 0000000..bdf17bb --- /dev/null +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutConfigServiceImpl.java @@ -0,0 +1,141 @@ +package com.ruoyi.basic.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.nacos.shaded.com.google.gson.Gson; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ruoyi.basic.domain.LayoutConfig; + +import com.ruoyi.basic.domain.LayoutDesc; +import com.ruoyi.basic.mapper.LayoutConfigDao; +import com.ruoyi.basic.mapper.LayoutDescDao; +import com.ruoyi.basic.service.LayoutConfigService; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.system.api.model.LoginUser; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +/** + * 布局配置表(LayoutConfig)表服务实现类 + * + * @author makejava + * @since 2024-08-26 16:38:47 + */ +@Service("layoutConfigService") +public class LayoutConfigServiceImpl implements LayoutConfigService { + @Resource + private LayoutConfigDao layoutConfigDao; + @Resource + private LayoutDescDao layoutDescDao; + + /** + * 通过ID查询单条数据 + * + * @param configId 主键 + * @return 实例对象 + */ + @Override + public LayoutConfig queryById(Long configId) { + return this.layoutConfigDao.queryById(configId); + } + + + /** + * 分页查询 + * + * @param layoutConfig 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 + */ + @Override + public Page queryByPage(LayoutConfig layoutConfig, PageRequest pageRequest) { + long total = this.layoutConfigDao.count(layoutConfig); + return new PageImpl<>(this.layoutConfigDao.queryAllByLimit(layoutConfig, pageRequest), pageRequest, total); + } + + /** + * 新增数据 + * + * @param layoutConfig 实例对象 + * @return 实例对象 + */ + @Override + public LayoutConfig insert(LayoutConfig layoutConfig) { + this.layoutConfigDao.insert(layoutConfig); + return layoutConfig; + } + + /** + * 修改数据 + * + * @param layoutConfig 实例对象 + * @return 实例对象 + */ + @Override + public LayoutConfig update(LayoutConfig layoutConfig) { + this.layoutConfigDao.update(layoutConfig); + return this.queryById(layoutConfig.getConfigId()); + } + + /** + * 通过主键删除数据 + * + * @param configId 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Long configId) { + return this.layoutConfigDao.deleteById(configId) > 0; + } + + @Override + public AjaxResult insertSceneConfig(List items, String option) throws JsonProcessingException { + String layoutId = UUID.randomUUID().toString().replaceAll("-", ""); + LoginUser loginUser = SecurityUtils.getLoginUser(); + LayoutDesc layoutDesc = new LayoutDesc(); + layoutDesc.setLayoutId(layoutId); + layoutDesc.setSceneConfig(option); +// layoutDesc.setCreateBy(loginUser.getUsername()); + Date date = new Date(); + layoutDesc.setCreateTime(date); + List layoutConfigs = new ArrayList<>(); + for (Object item : items) { + LayoutConfig layoutConfig = new LayoutConfig(); + layoutConfig.setLayoutId(layoutId); + ObjectMapper objectMapper = new ObjectMapper(); + String itemString = objectMapper.writeValueAsString(item); + JsonNode jsonNode = objectMapper.readTree(itemString); + String type = jsonNode.get("type").asText(); + layoutConfig.setType(type); + layoutConfig.setConfigDesc(itemString); +// layoutConfig.setCreateBy(loginUser.getUsername()); + layoutConfig.setCreateTime(date); + layoutConfigs.add(layoutConfig); + } + int descCount = layoutDescDao.insert(layoutDesc); + int configCount = layoutConfigDao.insertBatch(layoutConfigs); + return AjaxResult.success(); + } + + @Override + public AjaxResult selectConfigById(String sceneId) { + List layoutConfigs = layoutConfigDao.selectConfigById(sceneId); + return AjaxResult.success(layoutConfigs); + } + + @Override + public AjaxResult selectAllScenes() { + List layoutDescs = layoutDescDao.selectAllScenes(); + return AjaxResult.success(layoutDescs); + } +} diff --git a/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutDescServiceImpl.java b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutDescServiceImpl.java new file mode 100644 index 0000000..f7e4eaf --- /dev/null +++ b/ruoyi-modules/hw-basic/src/main/java/com/ruoyi/basic/service/impl/LayoutDescServiceImpl.java @@ -0,0 +1,52 @@ +package com.ruoyi.basic.service.impl; + + + +import com.ruoyi.basic.domain.LayoutDesc; +import com.ruoyi.basic.mapper.LayoutDescDao; +import com.ruoyi.basic.service.LayoutDescService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; + +import javax.annotation.Resource; + +/** + * 布局详情表(LayoutDesc)表服务实现类 + * + * @author makejava + * @since 2024-08-26 16:47:47 + */ +@Service("layoutDescService") +public class LayoutDescServiceImpl implements LayoutDescService { + @Autowired + private LayoutDescDao layoutDescDao; + + + @Override + public LayoutDesc queryById(Long layoutId) { + return null; + } + + @Override + public Page queryByPage(LayoutDesc layoutDesc, PageRequest pageRequest) { + return null; + } + + @Override + public LayoutDesc insert(LayoutDesc layoutDesc) { + return null; + } + + @Override + public LayoutDesc update(LayoutDesc layoutDesc) { + return null; + } + + @Override + public boolean deleteById(Long layoutId) { + return false; + } +} diff --git a/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/LayoutConfigDao.xml b/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/LayoutConfigDao.xml new file mode 100644 index 0000000..ac96dcf --- /dev/null +++ b/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/LayoutConfigDao.xml @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into layout_config(layout_id, type, config_desc, create_by, create_time, update_by, update_time) + values (#{layoutId}, #{type},#{configDesc}, #{layoutDesc}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}) + + + + insert into layout_config(layout_id, type, config_desc, create_by, create_time, update_by, update_time) + values + + (#{entity.layoutId}, #{entity.type}, #{entity.configDesc}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime}) + + + + + insert into layout_config(layout_id, type, layout_desc, create_by, create_time, update_by, update_time) + values + + (#{entity.layoutId}, #{entity.type}, #{entity.layoutDesc}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime}) + + on duplicate key update + layout_id = values(layout_id), + type = values(type), + layout_desc = values(layout_desc), + create_by = values(create_by), + create_time = values(create_time), + update_by = values(update_by), + update_time = values(update_time) + + + + + update layout_config + + + layout_id = #{layoutId}, + + + type = #{type}, + + + layout_desc = #{layoutDesc}, + + + create_by = #{createBy}, + + + create_time = #{createTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + + + where config_id = #{configId} + + + + + delete from layout_config where config_id = #{configId} + + + diff --git a/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/LayoutDescDao.xml b/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/LayoutDescDao.xml new file mode 100644 index 0000000..140d41d --- /dev/null +++ b/ruoyi-modules/hw-basic/src/main/resources/mapper/basic/LayoutDescDao.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into layout_desc(layout_id,layout_desc, create_by, create_time, update_by, update_time,scene_config) + values (#{layoutId},#{layoutDesc}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime},#{sceneConfig}) + + + + insert into layout_desc(layout_desc, create_by, create_time, update_by, update_time) + values + + (#{entity.layoutDesc}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime}) + + + + + insert into layout_desc(layout_desc, create_by, create_time, update_by, update_time) + values + + (#{entity.layoutDesc}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime}) + + on duplicate key update + layout_desc = values(layout_desc), + create_by = values(create_by), + create_time = values(create_time), + update_by = values(update_by), + update_time = values(update_time) + + + + + update layout_desc + + + layout_desc = #{layoutDesc}, + + + create_by = #{createBy}, + + + create_time = #{createTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + + + where layout_id = #{layoutId} + + + + + delete from layout_desc where layout_id = #{layoutId} + + +