1234567891011121314151617181920212223242526272829303132 |
- package yb_comment
- import "hongze/hongze_yb/global"
- func Delete(userId uint64, commentId uint64)(err error) {
- tx := global.DEFAULT_MYSQL.Begin()
- defer func() {
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
- sql1 := ` Delete from yb_comment WHERE type = 1 and user_id = ? and comment_id = ?`
- err = tx.Exec(sql1, userId, commentId).Error
- if err != nil {
- return
- }
-
- sql2 := `Delete from yb_comment WHERE reply_comment_id = ? and type = 2`
- err = tx.Exec(sql2, commentId).Error
- return
- }
|