SpringBoot實現評論回覆功能(資料庫設計)

2022-09-28 20:51:27 字數 2312 閱讀 1862

springboot----物品點讚功能實現

springboot----物品功能實現

springboot----檔案()上傳與顯示(**)

這個是模仿b站的那種,感覺挺好看的,同時也是因為csdn搜到了乙個類似的,對於第一次做有參考要好做的多。

效果圖:

分為評論主表和子表。主表存放的是對物品的評論,而子表存放的是對該評論的回覆,就是物品 1–n主表 1 – n子表。

主表:set foreign_key_checks=0;

-- ----------------------------

-- table structure for comments_info

-- -------------------www.cppcns.com---------

drop table if exists `comments_info`;

create table `comments_info` (

`in_id` int(10) not null auto_increment comment '評論主鍵id',

`good_id` int(10) not null comment '被評論物品gid',

`from_openid` varchar(32) not null comment '評論者id',

`from_name` varchar(32) not null comment '評論者名字',

`from_**atar` varchar(512) default '' comment '評論者頭像',

`like_num` int(11) default '0' comment '點讚的數量',

`cont程式設計客棧ent` varchar(512) default null comment '評論內容',

`create_time` timestamp not null default current_timestamp comment '建立時間',

`user_state` int(3) default null comment '使用者是否認證',

primary key (`in_id`),

key `owner_id` (`good_id`)

) engine=innodb auto_increment=82 default charset=utf8mb4 comment='評論主表';

子表:set foreign_key_checks=0;

-- ----------------------------

-- table struwww.cppcns.comcture for comments_reply

-- ----------------------------

drop table if exists `comments_reply`;

create table `comments_reply` (

`rid` int(11) not null auto_increment,

`comment_id` int(10) not null comment '評論主表id',

`from_openid` varchar(32) not null comment '評論者id',

`from_name` varchar(32) not null comment '評論者名字',

`from_**atar` varchar(512) default '' comment '評論者頭像',

`to_openid` varchar(32) not null comment '被評論者id',

`to_name` varchar(32) not null comment '被評論者名字',

`to_**atar` varchar(512) default '' comment '被評論者頭像',

`content` varchar(512) default null comment '評論內容',

`create_time` timestamp not null default current_timestamp comment '建立時間',

`like_num` int(11) default null comment '點讚',

`user_state` int(3) default null comment '使用者是否認證',

primary key (`rid`),

key `comment_id` (`comment_id`)

) engine=innodb auto_increment=91 default charset=utf8mb4 comment='評論回覆表';

程式設計客棧

SpringBoot實現單元測試時回滾事務

springboot跑個單元測試只需要在測試類加兩個註解就行了。runwith springrunner.class springboottest然而這樣的單元測試預設是提交事務的,一般的場景下都是要對事務進行回滾的。要支援回滾,只需要增加乙個 transactional註解即可。runwith s...

springboot事務手動回滾

專案中的事務,我們一般都是使用註解式事務,在service層加上 transactional,或者加在具體方法上。但有的時候我們需要手動回滾事務,如以下兩種情況 1 try.catch到異常之後需要回滾事務。如阿里巴巴開發手冊中就提到 強制 有 try 塊放到了事務 中,catch 異常後,如果需要...

SpringBoot 事務回滾失敗

要麼全部成功,要麼全部失敗,不允許部分成功部分失敗。serviceimpl類內部方法的呼叫。addstudent 方法能夠執行,updatestudent 方法因為有錯誤會丟擲異常,但是事務回滾失敗。直接呼叫方法,實際上是通過this呼叫,也就是直接呼叫了方法,而不是通過spring上下文獲得 類,...