20. SpringBoot+Vue集成系统公告

447 字约 1 分钟读完1043 次阅读更新于 2026/5/3

设计表 notice

CREATE TABLE `notice` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '标题',
  `content` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '内容',
  `userid` int(11) DEFAULT NULL COMMENT '发布人id',
  `time` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '发布时间',
  `open` tinyint(1) DEFAULT '1' COMMENT '是否公开',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统公告表';

后台 crud

Notice

package com.example.springboot.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

@Data
public class Notice {
    @TableId(type= IdType.AUTO)
    private Integer id;
    private String title;
    private String content;
    private Integer userid;
    private String time;

    // 这个注解表示这个字段不在数据库表里  是用来做业务处理用的
    @TableField(exist = false)
    private String user;

}


NoticeController

怎么设置字段的默认值?
在数据库设置即可
image.png

前台 vue

Notice.vue

Home.vue