diff --git a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/dto/SysNoticeQuery.java b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/dto/SysNoticeQuery.java new file mode 100644 index 00000000..da5eaf60 --- /dev/null +++ b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/dto/SysNoticeQuery.java @@ -0,0 +1,12 @@ +package com.ruoyi.system.domain.dto; + +import com.ruoyi.system.domain.vo.SysNoticeVO; +import lombok.Data; + +/** + * @author wjh + * 2025/1/15 + */ +@Data +public class SysNoticeQuery extends SysNoticeVO { +} diff --git a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/enums/NoticeStatus.java b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/enums/NoticeStatus.java new file mode 100644 index 00000000..db4d92a3 --- /dev/null +++ b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/enums/NoticeStatus.java @@ -0,0 +1,20 @@ +package com.ruoyi.system.domain.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author wjh + * 2025/1/15 + */ +@Getter +@AllArgsConstructor +public enum NoticeStatus { + + ENABLED("0", "启用"), + DISABLED("1", "禁用"); + + private final String status; + private final String msg; + +} diff --git a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/vo/SysNoticeVO.java b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/vo/SysNoticeVO.java new file mode 100644 index 00000000..78896a40 --- /dev/null +++ b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/vo/SysNoticeVO.java @@ -0,0 +1,12 @@ +package com.ruoyi.system.domain.vo; + +import com.ruoyi.system.domain.SysNotice; +import lombok.Data; + +/** + * @author wjh + * 2025/1/15 + */ +@Data +public class SysNoticeVO extends SysNotice { +} diff --git a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java index c34f0a27..632d87a2 100644 --- a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java +++ b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java @@ -1,34 +1,37 @@ package com.ruoyi.system.mapper; -import java.util.List; import com.ruoyi.system.domain.SysNotice; +import com.ruoyi.system.domain.dto.SysNoticeQuery; +import com.ruoyi.system.domain.vo.SysNoticeVO; + +import java.util.List; /** * 通知公告表 数据层 - * + * * @author ruoyi */ public interface SysNoticeMapper { /** * 查询公告信息 - * + * * @param noticeId 公告ID * @return 公告信息 */ - public SysNotice selectNoticeById(Long noticeId); + public SysNoticeVO selectNoticeById(Long noticeId); /** * 查询公告列表 - * + * * @param notice 公告信息 * @return 公告集合 */ - public List selectNoticeList(SysNotice notice); + public List selectNoticeList(SysNoticeQuery notice); /** * 新增公告 - * + * * @param notice 公告信息 * @return 结果 */ @@ -36,7 +39,7 @@ public interface SysNoticeMapper /** * 修改公告 - * + * * @param notice 公告信息 * @return 结果 */ @@ -44,7 +47,7 @@ public interface SysNoticeMapper /** * 批量删除公告 - * + * * @param noticeId 公告ID * @return 结果 */ @@ -52,7 +55,7 @@ public interface SysNoticeMapper /** * 批量删除公告信息 - * + * * @param noticeIds 需要删除的公告ID * @return 结果 */ diff --git a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java index 47ce1b71..45d72051 100644 --- a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java +++ b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java @@ -1,34 +1,37 @@ package com.ruoyi.system.service; -import java.util.List; import com.ruoyi.system.domain.SysNotice; +import com.ruoyi.system.domain.dto.SysNoticeQuery; +import com.ruoyi.system.domain.vo.SysNoticeVO; + +import java.util.List; /** * 公告 服务层 - * + * * @author ruoyi */ public interface ISysNoticeService { /** * 查询公告信息 - * + * * @param noticeId 公告ID * @return 公告信息 */ - public SysNotice selectNoticeById(Long noticeId); + public SysNoticeVO selectNoticeById(Long noticeId); /** * 查询公告列表 - * - * @param notice 公告信息 + * + * @param query 公告信息 * @return 公告集合 */ - public List selectNoticeList(SysNotice notice); + public List selectNoticeList(SysNoticeQuery query); /** * 新增公告 - * + * * @param notice 公告信息 * @return 结果 */ @@ -36,7 +39,7 @@ public interface ISysNoticeService /** * 修改公告 - * + * * @param notice 公告信息 * @return 结果 */ @@ -44,17 +47,19 @@ public interface ISysNoticeService /** * 删除公告信息 - * + * * @param noticeId 公告ID * @return 结果 */ public int deleteNoticeById(Long noticeId); - + /** * 批量删除公告信息 - * + * * @param noticeIds 需要删除的公告ID * @return 结果 */ public int deleteNoticeByIds(Long[] noticeIds); + + SysNoticeVO selectOne(SysNoticeQuery query); } diff --git a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java index 765438b8..21aedd7c 100644 --- a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java +++ b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java @@ -1,15 +1,20 @@ package com.ruoyi.system.service.impl; -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; +import com.github.pagehelper.PageHelper; +import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.system.domain.SysNotice; +import com.ruoyi.system.domain.dto.SysNoticeQuery; +import com.ruoyi.system.domain.vo.SysNoticeVO; import com.ruoyi.system.mapper.SysNoticeMapper; import com.ruoyi.system.service.ISysNoticeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; /** * 公告 服务层实现 - * + * * @author ruoyi */ @Service @@ -20,31 +25,31 @@ public class SysNoticeServiceImpl implements ISysNoticeService /** * 查询公告信息 - * + * * @param noticeId 公告ID * @return 公告信息 */ @Override - public SysNotice selectNoticeById(Long noticeId) + public SysNoticeVO selectNoticeById(Long noticeId) { return noticeMapper.selectNoticeById(noticeId); } /** * 查询公告列表 - * - * @param notice 公告信息 + * + * @param query 公告信息 * @return 公告集合 */ @Override - public List selectNoticeList(SysNotice notice) + public List selectNoticeList(SysNoticeQuery query) { - return noticeMapper.selectNoticeList(notice); + return noticeMapper.selectNoticeList(query); } /** * 新增公告 - * + * * @param notice 公告信息 * @return 结果 */ @@ -56,7 +61,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService /** * 修改公告 - * + * * @param notice 公告信息 * @return 结果 */ @@ -68,7 +73,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService /** * 删除公告对象 - * + * * @param noticeId 公告ID * @return 结果 */ @@ -80,7 +85,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService /** * 批量删除公告信息 - * + * * @param noticeIds 需要删除的公告ID * @return 结果 */ @@ -89,4 +94,11 @@ public class SysNoticeServiceImpl implements ISysNoticeService { return noticeMapper.deleteNoticeByIds(noticeIds); } + + @Override + public SysNoticeVO selectOne(SysNoticeQuery query) { + PageHelper.startPage(1, 1); + List list = this.selectNoticeList(query); + return CollectionUtils.firstElement(list); + } } diff --git a/smart-switch-ruoyi/smart-switch-system/src/main/resources/mapper/system/SysNoticeMapper.xml b/smart-switch-ruoyi/smart-switch-system/src/main/resources/mapper/system/SysNoticeMapper.xml index 65d30794..f909f685 100644 --- a/smart-switch-ruoyi/smart-switch-system/src/main/resources/mapper/system/SysNoticeMapper.xml +++ b/smart-switch-ruoyi/smart-switch-system/src/main/resources/mapper/system/SysNoticeMapper.xml @@ -3,31 +3,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - + + + - select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark + select + notice_id, + notice_title, + notice_type, + cast(notice_content as char) as notice_content, + status, + create_by, + create_time, + update_by, + update_time, + remark from sys_notice - + - - @@ -39,9 +38,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND create_by like concat('%', #{createBy}, '%') + + AND `status` = #{status} + - + insert into sys_notice ( notice_title, @@ -61,9 +63,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" sysdate() ) - + - update sys_notice + update sys_notice notice_title = #{noticeTitle}, notice_type = #{noticeType}, @@ -74,16 +76,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where notice_id = #{noticeId} - + delete from sys_notice where notice_id = #{noticeId} - + - delete from sys_notice where notice_id in + delete from sys_notice where notice_id in #{noticeId} - - \ No newline at end of file + + diff --git a/smart-switch-service/src/main/java/com/ruoyi/iot/domain/IotDeviceInfo.java b/smart-switch-service/src/main/java/com/ruoyi/iot/domain/IotDeviceInfo.java index 8563a478..f714106d 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/iot/domain/IotDeviceInfo.java +++ b/smart-switch-service/src/main/java/com/ruoyi/iot/domain/IotDeviceInfo.java @@ -1,7 +1,6 @@ package com.ruoyi.iot.domain; import com.ruoyi.ss.device.domain.enums.DeviceOutageWay; -import lombok.Builder; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -14,7 +13,6 @@ import java.util.Date; * 2024/3/20 */ @Data -@Builder public class IotDeviceInfo { private String mac; @@ -35,18 +33,18 @@ public class IotDeviceInfo { private BigDecimal vxs; // 电压系数 public static IotDeviceInfo newDefaultInstance() { - return IotDeviceInfo.builder() - .v(BigDecimal.ZERO) - .p(BigDecimal.ZERO) - .a(BigDecimal.ZERO) - .w(BigDecimal.ZERO) - .s("0") - .m(BigDecimal.ZERO) - .set(DeviceOutageWay.IMMEDIATE.getValue()) - .time(BigDecimal.ZERO) - .model(null) - .version(null) - .vxs(BigDecimal.ONE) - .build(); + IotDeviceInfo info = new IotDeviceInfo(); + info.setV(BigDecimal.ZERO); + info.setP(BigDecimal.ZERO); + info.setA(BigDecimal.ZERO); + info.setW(BigDecimal.ZERO); + info.setS("0"); + info.setM(BigDecimal.ZERO); + info.setSet(DeviceOutageWay.IMMEDIATE.getValue()); + info.setTime(BigDecimal.ZERO); + info.setModel(null); + info.setVersion(null); + info.setVxs(BigDecimal.ONE); + return info; } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/article/mapper/SmArticleMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/article/mapper/SmArticleMapper.xml index 089c3e7b..42a22918 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/article/mapper/SmArticleMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/article/mapper/SmArticleMapper.xml @@ -83,7 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) and a.is_hot = #{isHot} - and find_in_set(#{classifyAncestorId}, sc.ancestors) + and ( sc.classify_id = #{classifyAncestorId} or ( find_in_set(#{classifyAncestorId}, sc.ancestors))) and a.article_id in @@ -91,7 +91,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - order by a.create_time desc