Compare commits
1 Commits
dev
...
fearure-No
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
205f347d08 |
@@ -0,0 +1,39 @@
|
|||||||
|
package com.bao.dating.controller;
|
||||||
|
|
||||||
|
import com.bao.dating.pojo.entity.Notice;
|
||||||
|
import com.bao.dating.service.NoticeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/notice")
|
||||||
|
public class NoticeController {
|
||||||
|
@Autowired
|
||||||
|
private NoticeService noticeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有公告数据
|
||||||
|
* @return 公告列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public List<Notice> getNoticeList() {
|
||||||
|
return noticeService.getNoticeList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否有公告数据
|
||||||
|
* @return true=有数据 false=无数据
|
||||||
|
*/
|
||||||
|
@GetMapping("/hasData")
|
||||||
|
public boolean hasNoticeData() {
|
||||||
|
List<Notice> noticeList = noticeService.getNoticeList();
|
||||||
|
return !noticeList.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/main/java/com/bao/dating/mapper/NoticeMapper.java
Normal file
16
src/main/java/com/bao/dating/mapper/NoticeMapper.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.bao.dating.mapper;
|
||||||
|
|
||||||
|
import com.bao.dating.pojo.entity.Notice;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告Mapper接口
|
||||||
|
*/
|
||||||
|
public interface NoticeMapper {
|
||||||
|
/**
|
||||||
|
* 查询所有公告
|
||||||
|
* @return 公告列表
|
||||||
|
*/
|
||||||
|
List<Notice> selectNoticeList();
|
||||||
|
}
|
||||||
40
src/main/java/com/bao/dating/pojo/entity/Notice.java
Normal file
40
src/main/java/com/bao/dating/pojo/entity/Notice.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package com.bao.dating.pojo.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告实体类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Notice {
|
||||||
|
/**
|
||||||
|
* 公告ID
|
||||||
|
*/
|
||||||
|
private Long noticeId;
|
||||||
|
/**
|
||||||
|
* 公告标题
|
||||||
|
*/
|
||||||
|
private String noticeTitle;
|
||||||
|
/**
|
||||||
|
* 公告内容
|
||||||
|
*/
|
||||||
|
private String noticeContent;
|
||||||
|
/**
|
||||||
|
* 状态(0正常 1关闭)
|
||||||
|
*/
|
||||||
|
private String noticeStatus;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
16
src/main/java/com/bao/dating/service/NoticeService.java
Normal file
16
src/main/java/com/bao/dating/service/NoticeService.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.bao.dating.service;
|
||||||
|
|
||||||
|
import com.bao.dating.pojo.entity.Notice;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告服务接口
|
||||||
|
*/
|
||||||
|
public interface NoticeService {
|
||||||
|
/**
|
||||||
|
* 查询所有公告
|
||||||
|
* @return 公告列表
|
||||||
|
*/
|
||||||
|
List<Notice> getNoticeList();
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.bao.dating.service.impl;
|
||||||
|
|
||||||
|
import com.bao.dating.mapper.NoticeMapper;
|
||||||
|
import com.bao.dating.pojo.entity.Notice;
|
||||||
|
import com.bao.dating.service.NoticeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
@Service
|
||||||
|
public class NoticeServiceImpl implements NoticeService {
|
||||||
|
@Autowired
|
||||||
|
private NoticeMapper noticeMapper;
|
||||||
|
@Override
|
||||||
|
public List<Notice> getNoticeList() {
|
||||||
|
return noticeMapper.selectNoticeList();
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/main/resources/com/bao/dating/mapper/NoticeMapper.xml
Normal file
20
src/main/resources/com/bao/dating/mapper/NoticeMapper.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bao.dating.mapper.NoticeMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询结果列 -->
|
||||||
|
<sql id="Notice_Column_List">
|
||||||
|
notice_id, notice_title, notice_content, notice_status, create_time, update_time
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 查询所有公告 -->
|
||||||
|
<select id="selectNoticeList" resultType="com.bao.dating.pojo.entity.Notice">
|
||||||
|
select
|
||||||
|
<include refid="Notice_Column_List"/>
|
||||||
|
from sys_notice
|
||||||
|
where notice_status = '0'
|
||||||
|
order by create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user