diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitAttributeController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitAttributeController.java new file mode 100644 index 0000000..880a5e1 --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitAttributeController.java @@ -0,0 +1,107 @@ +package com.ruoyi.business.controller; + +import com.ruoyi.business.domain.HwMonitorUnitAttribute; +import com.ruoyi.business.service.HwMonitorUnitAttributeService; +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; + +/** + * 监控单元属性表(HwMonitorUnitAttribute)表控制层 + * + * @author makejava + * @since 2024-09-04 13:20:30 + */ +@RestController +@RequestMapping("hwMonitorUnitAttribute") +public class HwMonitorUnitAttributeController { + /** + * 服务对象 + */ + @Resource + private HwMonitorUnitAttributeService hwMonitorUnitAttributeService; + + /** + * 分页查询 + * + * @param hwMonitorUnitAttribute 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 + */ + @GetMapping + public ResponseEntity> queryByPage(HwMonitorUnitAttribute hwMonitorUnitAttribute, PageRequest pageRequest) { + return ResponseEntity.ok(this.hwMonitorUnitAttributeService.queryByPage(hwMonitorUnitAttribute, pageRequest)); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("{id}") + public ResponseEntity queryById(@PathVariable("id") Long id) { + return ResponseEntity.ok(this.hwMonitorUnitAttributeService.queryById(id)); + } + + /** + * 新增数据 + * + * @param hwMonitorUnitAttribute 实体 + * @return 新增结果 + */ + @PostMapping + public ResponseEntity add(HwMonitorUnitAttribute hwMonitorUnitAttribute) { + return ResponseEntity.ok(this.hwMonitorUnitAttributeService.insert(hwMonitorUnitAttribute)); + } + + /** + * 编辑数据 + * + * @param hwMonitorUnitAttribute 实体 + * @return 编辑结果 + */ + @PutMapping + public ResponseEntity edit(HwMonitorUnitAttribute hwMonitorUnitAttribute) { + return ResponseEntity.ok(this.hwMonitorUnitAttributeService.update(hwMonitorUnitAttribute)); + } + + /** + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ + @DeleteMapping + public ResponseEntity deleteById(Long id) { + return ResponseEntity.ok(this.hwMonitorUnitAttributeService.deleteById(id)); + } + + @PostMapping("/addUnitAttribute") + public AjaxResult addUnitAttribute(@RequestBody HwMonitorUnitAttribute hwMonitorUnitAttribute){ + int rows = hwMonitorUnitAttributeService.addUnitAttribute(hwMonitorUnitAttribute); + return AjaxResult.success(rows); + } + + @GetMapping("/selectAttributeByUnitId") + public AjaxResult selectAttributeByUnitId(Long monitorUnitId){ + return AjaxResult.success(hwMonitorUnitAttributeService.selectAttributeByUnitId(monitorUnitId)); + } + + @PostMapping("/updateAttributeByUniitId") + public AjaxResult updateAttributeByUniitId(@RequestBody HwMonitorUnitAttribute hwMonitorUnitAttribute){ + return AjaxResult.success(hwMonitorUnitAttributeService.updateAttributeByUniitId(hwMonitorUnitAttribute)); + } + + @DeleteMapping("/deleteAttributeByUniitId/{attributeId}") + public AjaxResult deleteAttributeByUniitId(@PathVariable Long attributeId){ + return AjaxResult.success(hwMonitorUnitAttributeService.deleteAttributeByUniitId(attributeId)); + } + +} + diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwMonitorUnitAttribute.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwMonitorUnitAttribute.java new file mode 100644 index 0000000..b31f01d --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwMonitorUnitAttribute.java @@ -0,0 +1,114 @@ +package com.ruoyi.business.domain; + +import java.io.Serializable; +import java.util.Date; + +/** + * 监控单元属性表(HwMonitorUnitAttribute)实体类 + * + * @author makejava + * @since 2024-09-04 13:20:33 + */ +public class HwMonitorUnitAttribute implements Serializable { + private static final long serialVersionUID = -41167481835416588L; + /** + * 监控单元属性ID + */ + private Long attributeId; + /** + * 监控单元ID + */ + private Long monitorUnitId; + /** + * 监控单元属性名称 + */ + private String attributeName; + /** + * 监控单元属性值 + */ + private String attributeValue; + /** + * 创建人 + */ + private String createBy; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新人 + */ + private String updateBy; + /** + * 更新时间 + */ + private Date updateTime; + + + public Long getAttributeId() { + return attributeId; + } + + public void setAttributeId(Long attributeId) { + this.attributeId = attributeId; + } + + public Long getMonitorUnitId() { + return monitorUnitId; + } + + public void setMonitorUnitId(Long monitorUnitId) { + this.monitorUnitId = monitorUnitId; + } + + public String getAttributeName() { + return attributeName; + } + + public void setAttributeName(String attributeName) { + this.attributeName = attributeName; + } + + public String getAttributeValue() { + return attributeValue; + } + + public void setAttributeValue(String attributeValue) { + this.attributeValue = attributeValue; + } + + 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-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitAttributeDao.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitAttributeDao.java new file mode 100644 index 0000000..593e09e --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwMonitorUnitAttributeDao.java @@ -0,0 +1,92 @@ +package com.ruoyi.business.mapper; + + +import com.ruoyi.business.domain.HwMonitorUnitAttribute; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +/** + * 监控单元属性表(HwMonitorUnitAttribute)表数据库访问层 + * + * @author makejava + * @since 2024-09-04 13:20:30 + */ +public interface HwMonitorUnitAttributeDao { + + /** + * 通过ID查询单条数据 + * + * @param attributeId 主键 + * @return 实例对象 + */ + HwMonitorUnitAttribute queryById(Long attributeId); + + /** + * 查询指定行数据 + * + * @param hwMonitorUnitAttribute 查询条件 + * @param pageable 分页对象 + * @return 对象列表 + */ + List queryAllByLimit(HwMonitorUnitAttribute hwMonitorUnitAttribute, @Param("pageable") Pageable pageable); + + /** + * 统计总行数 + * + * @param hwMonitorUnitAttribute 查询条件 + * @return 总行数 + */ + long count(HwMonitorUnitAttribute hwMonitorUnitAttribute); + + /** + * 新增数据 + * + * @param hwMonitorUnitAttribute 实例对象 + * @return 影响行数 + */ + int insert(HwMonitorUnitAttribute hwMonitorUnitAttribute); + + /** + * 批量新增数据(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 hwMonitorUnitAttribute 实例对象 + * @return 影响行数 + */ + int update(HwMonitorUnitAttribute hwMonitorUnitAttribute); + + /** + * 通过主键删除数据 + * + * @param attributeId 主键 + * @return 影响行数 + */ + int deleteById(Long attributeId); + + List selectAttributeByUnitId(Long monitorUnitId); + + int updateAttributeByUniitId(HwMonitorUnitAttribute hwMonitorUnitAttribute); + + int deleteAttributeByUniitId(Long attributeId); + + List selectAttributes(Long unitId); +} + diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/HwMonitorUnitAttributeService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/HwMonitorUnitAttributeService.java new file mode 100644 index 0000000..df14465 --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/HwMonitorUnitAttributeService.java @@ -0,0 +1,68 @@ +package com.ruoyi.business.service; + + +import com.ruoyi.business.domain.HwMonitorUnitAttribute; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +import java.util.List; + +/** + * 监控单元属性表(HwMonitorUnitAttribute)表服务接口 + * + * @author makejava + * @since 2024-09-04 13:20:34 + */ +public interface HwMonitorUnitAttributeService { + + /** + * 通过ID查询单条数据 + * + * @param attributeId 主键 + * @return 实例对象 + */ + HwMonitorUnitAttribute queryById(Long attributeId); + + /** + * 分页查询 + * + * @param hwMonitorUnitAttribute 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 + */ + Page queryByPage(HwMonitorUnitAttribute hwMonitorUnitAttribute, PageRequest pageRequest); + + /** + * 新增数据 + * + * @param hwMonitorUnitAttribute 实例对象 + * @return 实例对象 + */ + HwMonitorUnitAttribute insert(HwMonitorUnitAttribute hwMonitorUnitAttribute); + + /** + * 修改数据 + * + * @param hwMonitorUnitAttribute 实例对象 + * @return 实例对象 + */ + HwMonitorUnitAttribute update(HwMonitorUnitAttribute hwMonitorUnitAttribute); + + /** + * 通过主键删除数据 + * + * @param attributeId 主键 + * @return 是否成功 + */ + boolean deleteById(Long attributeId); + + int addUnitAttribute(HwMonitorUnitAttribute hwMonitorUnitAttribute); + + List selectAttributeByUnitId(Long monitorUnitId); + + int updateAttributeByUniitId(HwMonitorUnitAttribute hwMonitorUnitAttribute); + + int deleteAttributeByUniitId(Long attributeId); + + List selectAttributes(Long unitId); +} diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitAttributeServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitAttributeServiceImpl.java new file mode 100644 index 0000000..292876a --- /dev/null +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitAttributeServiceImpl.java @@ -0,0 +1,116 @@ +package com.ruoyi.business.service.impl; + + +import com.ruoyi.business.domain.HwMonitorUnitAttribute; +import com.ruoyi.business.mapper.HwMonitorUnitAttributeDao; +import com.ruoyi.business.service.HwMonitorUnitAttributeService; +import com.ruoyi.common.security.utils.SecurityUtils; +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; +import java.util.Date; +import java.util.List; + +/** + * 监控单元属性表(HwMonitorUnitAttribute)表服务实现类 + * + * @author makejava + * @since 2024-09-04 13:20:34 + */ +@Service("hwMonitorUnitAttributeService") +public class HwMonitorUnitAttributeServiceImpl implements HwMonitorUnitAttributeService { + @Resource + private HwMonitorUnitAttributeDao hwMonitorUnitAttributeDao; + + /** + * 通过ID查询单条数据 + * + * @param attributeId 主键 + * @return 实例对象 + */ + @Override + public HwMonitorUnitAttribute queryById(Long attributeId) { + return this.hwMonitorUnitAttributeDao.queryById(attributeId); + } + + /** + * 分页查询 + * + * @param hwMonitorUnitAttribute 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 + */ + @Override + public Page queryByPage(HwMonitorUnitAttribute hwMonitorUnitAttribute, PageRequest pageRequest) { + long total = this.hwMonitorUnitAttributeDao.count(hwMonitorUnitAttribute); + return new PageImpl<>(this.hwMonitorUnitAttributeDao.queryAllByLimit(hwMonitorUnitAttribute, pageRequest), pageRequest, total); + } + + /** + * 新增数据 + * + * @param hwMonitorUnitAttribute 实例对象 + * @return 实例对象 + */ + @Override + public HwMonitorUnitAttribute insert(HwMonitorUnitAttribute hwMonitorUnitAttribute) { + this.hwMonitorUnitAttributeDao.insert(hwMonitorUnitAttribute); + return hwMonitorUnitAttribute; + } + + /** + * 修改数据 + * + * @param hwMonitorUnitAttribute 实例对象 + * @return 实例对象 + */ + @Override + public HwMonitorUnitAttribute update(HwMonitorUnitAttribute hwMonitorUnitAttribute) { + this.hwMonitorUnitAttributeDao.update(hwMonitorUnitAttribute); + return this.queryById(hwMonitorUnitAttribute.getAttributeId()); + } + + /** + * 通过主键删除数据 + * + * @param attributeId 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Long attributeId) { + return this.hwMonitorUnitAttributeDao.deleteById(attributeId) > 0; + } + + @Override + public int addUnitAttribute(HwMonitorUnitAttribute hwMonitorUnitAttribute) { + hwMonitorUnitAttribute.setCreateBy(SecurityUtils.getUsername()); + hwMonitorUnitAttribute.setCreateTime(new Date()); + return hwMonitorUnitAttributeDao.insert(hwMonitorUnitAttribute); + } + + @Override + public List selectAttributeByUnitId(Long monitorUnitId) { + return hwMonitorUnitAttributeDao.selectAttributeByUnitId(monitorUnitId); + } + + @Override + public int updateAttributeByUniitId(HwMonitorUnitAttribute hwMonitorUnitAttribute) { + return hwMonitorUnitAttributeDao.updateAttributeByUniitId(hwMonitorUnitAttribute); + + } + + @Override + public List selectAttributes(Long aLong) { + return hwMonitorUnitAttributeDao.selectAttributes(aLong); + } + + @Override + public int deleteAttributeByUniitId(Long unitId) { + return hwMonitorUnitAttributeDao.deleteAttributeByUniitId(unitId); + } + + +}