feat(notice): 新增系统公告接口及后台实现

This commit is contained in:
2026-02-11 19:14:07 +08:00
parent 553eadfaa6
commit edd78aa0ca
7 changed files with 201 additions and 0 deletions

View File

@@ -10,6 +10,8 @@ import com.yupi.springbootinit.service.AiCommentService;
import com.yupi.springbootinit.service.AiTemplateService;
import com.yupi.springbootinit.service.CommonService;
import com.yupi.springbootinit.service.CountryInfoService;
import com.yupi.springbootinit.service.SystemNoticeService;
import com.yupi.springbootinit.model.entity.SystemNotice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@@ -39,6 +41,9 @@ public class CommonController {
@Resource
private AiCommentService aiCommentService;
@Resource
private SystemNoticeService systemNoticeService;
@PostMapping("country_info")
public BaseResponse<List<CountryInfoVO>> countryInfo() {
@@ -74,4 +79,11 @@ public class CommonController {
public BaseResponse<String> health(){
return ResultUtils.success("ok");
}
@GetMapping("notice")
public BaseResponse<List<SystemNotice>> getActiveNotice(){
return ResultUtils.success(systemNoticeService.getActiveNoticeList());
}
}

View File

@@ -0,0 +1,12 @@
package com.yupi.springbootinit.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yupi.springbootinit.model.entity.SystemNotice;
/*
* @author: ziin
* @date: 2026/2/10 20:25
*/
public interface SystemNoticeMapper extends BaseMapper<SystemNotice> {
}

View File

@@ -0,0 +1,107 @@
package com.yupi.springbootinit.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
import lombok.Data;
/*
* @author: ziin
* @date: 2026/2/10 20:25
*/
/**
* 通知公告表
*/
@ApiModel(description="通知公告表")
@Data
@TableName(value = "system_notice")
public class SystemNotice {
/**
* 公告ID
*/
@TableId(value = "id", type = IdType.AUTO)
@ApiModelProperty(value="公告ID")
private Long id;
/**
* 公告标题
*/
@TableField(value = "title")
@ApiModelProperty(value="公告标题")
private String title;
/**
* 公告内容
*/
@TableField(value = "content")
@ApiModelProperty(value="公告内容")
private String content;
/**
* 公告类型1通知 2公告
*/
@TableField(value = "`type`")
@ApiModelProperty(value="公告类型1通知 2公告")
private Byte type;
/**
* 公告状态0正常 1关闭
*/
@TableField(value = "`status`")
@ApiModelProperty(value="公告状态0正常 1关闭")
private Byte status;
/**
* 创建者
*/
@TableField(value = "creator")
@ApiModelProperty(value="创建者")
private String creator;
/**
* 创建时间
*/
@TableField(value = "create_time")
@ApiModelProperty(value="创建时间")
private Date createTime;
/**
* 更新者
*/
@TableField(value = "updater")
@ApiModelProperty(value="更新者")
private String updater;
/**
* 更新时间
*/
@TableField(value = "update_time")
@ApiModelProperty(value="更新时间")
private Date updateTime;
/**
* 是否删除
*/
@TableField(value = "deleted")
@ApiModelProperty(value="是否删除")
private Boolean deleted;
/**
* 租户编号
*/
@TableField(value = "tenant_id")
@ApiModelProperty(value="租户编号")
private Long tenantId;
/**
* 分类
*/
@TableField(value = "category")
@ApiModelProperty(value="分类")
private String category;
}

View File

@@ -0,0 +1,20 @@
package com.yupi.springbootinit.service;
import com.yupi.springbootinit.model.entity.SystemNotice;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/*
* @author: ziin
* @date: 2026/2/10 20:25
*/
public interface SystemNoticeService extends IService<SystemNotice>{
/**
* 查询当前状态为开启的公告列表
*/
List<SystemNotice> getActiveNoticeList();
}

View File

@@ -0,0 +1,25 @@
package com.yupi.springbootinit.service.impl;
import org.springframework.stereotype.Service;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yupi.springbootinit.model.entity.SystemNotice;
import com.yupi.springbootinit.mapper.SystemNoticeMapper;
import com.yupi.springbootinit.service.SystemNoticeService;
/*
* @author: ziin
* @date: 2026/2/10 20:25
*/
@Service
public class SystemNoticeServiceImpl extends ServiceImpl<SystemNoticeMapper, SystemNotice> implements SystemNoticeService{
@Override
public List<SystemNotice> getActiveNoticeList() {
LambdaQueryWrapper<SystemNotice> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SystemNotice::getStatus, 0);
return this.list(queryWrapper);
}
}

View File

@@ -0,0 +1,25 @@
<?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.yupi.springbootinit.mapper.SystemNoticeMapper">
<resultMap id="BaseResultMap" type="com.yupi.springbootinit.model.entity.SystemNotice">
<!--@mbg.generated-->
<!--@Table system_notice-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="content" jdbcType="LONGVARCHAR" property="content" />
<result column="type" jdbcType="TINYINT" property="type" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="updater" jdbcType="VARCHAR" property="updater" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="deleted" jdbcType="BIT" property="deleted" />
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
<result column="category" jdbcType="VARCHAR" property="category" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, title, content, `type`, `status`, creator, create_time, updater, update_time,
deleted, tenant_id, category
</sql>
</mapper>

Binary file not shown.