diff --git a/internal/dao/sakila/auto/ac/yesql.go b/internal/dao/sakila/auto/ac/yesql.go index 67823b9b..46d8af7b 100644 --- a/internal/dao/sakila/auto/ac/yesql.go +++ b/internal/dao/sakila/auto/ac/yesql.go @@ -35,7 +35,7 @@ const ( _TopicA_TagsForIncr = `SELECT id, user_id, tag, quote_num FROM @tag WHERE tag IN (?)` _TopicA_TopicInfos = `SELECT topic_id, is_top FROM @topic_user WHERE is_del=0 AND user_id=? AND topic_id IN (?)` _TopicA_TopicIsTop = `SELECT is_top FROM @topic_user WHERE user_id=? AND topic_id=? AND is_del=0` - _TopicA_UnfollowTopic = `UPDATE @topic_user SET is_del=1, deleted_on=? WHERE user_id=? AND topic_id=? AND is_del=0` + _TopicA_UnfollowTopic = `DELETE FROM @topic_user WHERE user_id=? AND topic_id=? AND is_del=0` _TweetA_AttachmentByTweetId = `SELECT * FROM @user WHERE username=?` _TweetA_FavoriteByTweetId = `SELECT * FROM @user WHERE username=?` _TweetA_ReactionByTweetId = `SELECT * FROM @user WHERE username=?` diff --git a/internal/dao/sakila/topics.go b/internal/dao/sakila/topics.go index b4be80be..baf46b56 100644 --- a/internal/dao/sakila/topics.go +++ b/internal/dao/sakila/topics.go @@ -139,14 +139,14 @@ func (s *topicSrvA) GetFollowTags(userId int64, limit int, offset int) (res cs.T func (s *topicSrvA) FollowTopic(userId int64, topicId int64) (err error) { exist := false - if err = s.q.ExistTopicUser.Get(&exist, userId, topicId); err == nil { + if err = s.q.ExistTopicUser.Get(&exist, userId, topicId); err != nil { _, err = s.q.FollowTopic.Exec(userId, topicId, time.Now().Unix()) } return } func (s *topicSrvA) UnfollowTopic(userId int64, topicId int64) error { - _, err := s.q.UnfollowTopic.Exec(userId, topicId, time.Now().Unix()) + _, err := s.q.UnfollowTopic.Exec(userId, topicId) return err } diff --git a/internal/dao/sakila/yesql/yesql_ac.sql b/internal/dao/sakila/yesql/yesql_ac.sql index a5082b91..9e36c114 100644 --- a/internal/dao/sakila/yesql/yesql_ac.sql +++ b/internal/dao/sakila/yesql/yesql_ac.sql @@ -168,8 +168,7 @@ INSERT INTO @topic_user(user_id, topic_id, created_on) VALUES (?, ?, ?) -- name: unfollow_topic@topic_a -- prepare: stmt -UPDATE @topic_user -SET is_del=1, deleted_on=? +DELETE FROM @topic_user WHERE user_id=? AND topic_id=? AND is_del=0; -- name: stick_topic@topic_a