mirror of https://github.com/rocboss/paopao-ce
commit
7b15f1b568
@ -0,0 +1,222 @@
|
||||
// Code generated by Yesql. DO NOT EDIT.
|
||||
// versions:
|
||||
// - Yesql v1.8.4
|
||||
|
||||
package ac
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/alimy/yesql"
|
||||
"github.com/bitbus/sqlx"
|
||||
)
|
||||
|
||||
const (
|
||||
_ShipIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
|
||||
_SimpleIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
|
||||
_TopicA_DecrTagsById = `UPDATE @tag SET quote_num=quote_num-1, modified_on=? WHERE id IN (?)`
|
||||
_TopicA_ExistTopicUser = `SELECT 1 FROM @topic_user WHERE user_id=? AND topic_id=? AND is_del=0`
|
||||
_TopicA_FollowTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id "u.id", 1 as is_following, c.is_top, u.nickname "u.nickname", u.username "u.username", u.status "u.status", u.avatar "u.avatar", u.is_admin "u.is_admin" FROM @topic_user c JOIN @user u ON c.user_id = u.id JOIN @tag t ON c.topic_id = t.id WHERE c.is_del = 0 AND t.quote_num > 0 AND AND c.user_id=? ORDER BY t.quote_num DESC LIMIT ? OFFSET ?`
|
||||
_TopicA_FollowTopic = `INSERT INTO @topic_user(user_id, topic_id, created_on) VALUES (?, ?, ?)`
|
||||
_TopicA_HotTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id "u.id", u.nickname "u.nickname", u.username "u.username", u.status "u.status", u.avatar "u.avatar", u.is_admin "u.is_admin" FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.quote_num DESC LIMIT ? OFFSET ?`
|
||||
_TopicA_IncrTagsById = `UPDATE @tag SET quote_num=quote_num+1, is_del=0, modified_on=? WHERE id IN (?)`
|
||||
_TopicA_InsertTag = `INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num) VALUES (?, ?, ?, ?, 1)`
|
||||
_TopicA_NewestTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id "u.id", u.nickname "u.nickname", u.username "u.username", u.status "u.status", u.avatar "u.avatar", u.is_admin "u.is_admin" FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.id DESC LIMIT ? OFFSET ?`
|
||||
_TopicA_StickTopic = `UPDATE @topic_user SET is_top=1-is_top; modified_on=? WHERE user_id=? AND topic_id=? AND is_del=0`
|
||||
_TopicA_TagsByIdA = `SELECT id FROM @tag WHERE id IN (?) AND is_del = 0 AND quote_num > 0`
|
||||
_TopicA_TagsByIdB = `SELECT id, user_id, tag, quote_num FROM @tag WHERE id IN (?)`
|
||||
_TopicA_TagsByKeywordA = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 ORDER BY quote_num DESC LIMIT 6`
|
||||
_TopicA_TagsByKeywordB = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 AND tag LIKE ? ORDER BY quote_num DESC LIMIT 6`
|
||||
_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`
|
||||
_TweetA_AttachmentByTweetId = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetA_FavoriteByTweetId = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetA_ReactionByTweetId = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetA_TweetInfoById = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetA_TweetItemById = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetA_UserFavorites = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetA_UserInfo = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetA_UserReactions = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetA_UserTweetsByAdmin = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetA_UserTweetsByFriend = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetA_UserTweetsByGuest = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetA_UserTweetsBySelf = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetHelpA_UserInfo = `SELECT * FROM @user WHERE username=?`
|
||||
_TweetManageA_UserInfo = `SELECT * FROM @user WHERE username=?`
|
||||
)
|
||||
|
||||
// PreparexContext enhances the Conn interface with context.
|
||||
type PreparexContext interface {
|
||||
// PrepareContext prepares a statement.
|
||||
// The provided context is used for the preparation of the statement, not for
|
||||
// the execution of the statement.
|
||||
PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)
|
||||
|
||||
// PrepareNamedContext returns an sqlx.NamedStmt
|
||||
PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error)
|
||||
|
||||
// Rebind rebind query to adapte SQL Driver
|
||||
Rebind(query string) string
|
||||
}
|
||||
|
||||
// PreparexBuilder preparex builder interface for sqlx
|
||||
type PreparexBuilder interface {
|
||||
PreparexContext
|
||||
QueryHook(query string) string
|
||||
}
|
||||
|
||||
type ShipIndexA struct {
|
||||
yesql.Namespace `yesql:"ship_index_a"`
|
||||
UserInfo string `yesql:"user_info"`
|
||||
}
|
||||
|
||||
type SimpleIndexA struct {
|
||||
yesql.Namespace `yesql:"simple_index_a"`
|
||||
UserInfo string `yesql:"user_info"`
|
||||
}
|
||||
|
||||
type TopicA struct {
|
||||
yesql.Namespace `yesql:"topic_a"`
|
||||
DecrTagsById string `yesql:"decr_tags_by_id"`
|
||||
IncrTagsById string `yesql:"incr_tags_by_id"`
|
||||
TagsByIdA string `yesql:"tags_by_id_a"`
|
||||
TagsByIdB string `yesql:"tags_by_id_b"`
|
||||
TagsForIncr string `yesql:"tags_for_incr"`
|
||||
TopicInfos string `yesql:"topic_infos"`
|
||||
ExistTopicUser *sqlx.Stmt `yesql:"exist_topic_user"`
|
||||
FollowTags *sqlx.Stmt `yesql:"follow_tags"`
|
||||
FollowTopic *sqlx.Stmt `yesql:"follow_topic"`
|
||||
HotTags *sqlx.Stmt `yesql:"hot_tags"`
|
||||
InsertTag *sqlx.Stmt `yesql:"insert_tag"`
|
||||
NewestTags *sqlx.Stmt `yesql:"newest_tags"`
|
||||
StickTopic *sqlx.Stmt `yesql:"stick_topic"`
|
||||
TagsByKeywordA *sqlx.Stmt `yesql:"tags_by_keyword_a"`
|
||||
TagsByKeywordB *sqlx.Stmt `yesql:"tags_by_keyword_b"`
|
||||
TopicIsTop *sqlx.Stmt `yesql:"topic_is_top"`
|
||||
UnfollowTopic *sqlx.Stmt `yesql:"unfollow_topic"`
|
||||
}
|
||||
|
||||
type TweetA struct {
|
||||
yesql.Namespace `yesql:"tweet_a"`
|
||||
AttachmentByTweetId string `yesql:"attachment_by_tweet_id"`
|
||||
FavoriteByTweetId string `yesql:"favorite_by_tweet_id"`
|
||||
ReactionByTweetId string `yesql:"reaction_by_tweet_id"`
|
||||
TweetInfoById string `yesql:"tweet_info_by_id"`
|
||||
TweetItemById string `yesql:"tweet_item_by_id"`
|
||||
UserFavorites string `yesql:"user_favorites"`
|
||||
UserInfo string `yesql:"user_info"`
|
||||
UserReactions string `yesql:"user_reactions"`
|
||||
UserTweetsByAdmin string `yesql:"user_tweets_by_admin"`
|
||||
UserTweetsByFriend string `yesql:"user_tweets_by_friend"`
|
||||
UserTweetsByGuest string `yesql:"user_tweets_by_guest"`
|
||||
UserTweetsBySelf string `yesql:"user_tweets_by_self"`
|
||||
}
|
||||
|
||||
type TweetHelpA struct {
|
||||
yesql.Namespace `yesql:"tweet_help_a"`
|
||||
UserInfo string `yesql:"user_info"`
|
||||
}
|
||||
|
||||
type TweetManageA struct {
|
||||
yesql.Namespace `yesql:"tweet_manage_a"`
|
||||
UserInfo string `yesql:"user_info"`
|
||||
}
|
||||
|
||||
func BuildShipIndexA(p PreparexBuilder) (obj *ShipIndexA, err error) {
|
||||
obj = &ShipIndexA{
|
||||
UserInfo: p.QueryHook(_ShipIndexA_UserInfo),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func BuildSimpleIndexA(p PreparexBuilder) (obj *SimpleIndexA, err error) {
|
||||
obj = &SimpleIndexA{
|
||||
UserInfo: p.QueryHook(_SimpleIndexA_UserInfo),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func BuildTopicA(p PreparexBuilder, ctx ...context.Context) (obj *TopicA, err error) {
|
||||
var c context.Context
|
||||
if len(ctx) > 0 && ctx[0] != nil {
|
||||
c = ctx[0]
|
||||
} else {
|
||||
c = context.Background()
|
||||
}
|
||||
obj = &TopicA{
|
||||
DecrTagsById: p.QueryHook(_TopicA_DecrTagsById),
|
||||
IncrTagsById: p.QueryHook(_TopicA_IncrTagsById),
|
||||
TagsByIdA: p.QueryHook(_TopicA_TagsByIdA),
|
||||
TagsByIdB: p.QueryHook(_TopicA_TagsByIdB),
|
||||
TagsForIncr: p.QueryHook(_TopicA_TagsForIncr),
|
||||
TopicInfos: p.QueryHook(_TopicA_TopicInfos),
|
||||
}
|
||||
if obj.ExistTopicUser, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_ExistTopicUser))); err != nil {
|
||||
return
|
||||
}
|
||||
if obj.FollowTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_FollowTags))); err != nil {
|
||||
return
|
||||
}
|
||||
if obj.FollowTopic, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_FollowTopic))); err != nil {
|
||||
return
|
||||
}
|
||||
if obj.HotTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_HotTags))); err != nil {
|
||||
return
|
||||
}
|
||||
if obj.InsertTag, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_InsertTag))); err != nil {
|
||||
return
|
||||
}
|
||||
if obj.NewestTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_NewestTags))); err != nil {
|
||||
return
|
||||
}
|
||||
if obj.StickTopic, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_StickTopic))); err != nil {
|
||||
return
|
||||
}
|
||||
if obj.TagsByKeywordA, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_TagsByKeywordA))); err != nil {
|
||||
return
|
||||
}
|
||||
if obj.TagsByKeywordB, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_TagsByKeywordB))); err != nil {
|
||||
return
|
||||
}
|
||||
if obj.TopicIsTop, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_TopicIsTop))); err != nil {
|
||||
return
|
||||
}
|
||||
if obj.UnfollowTopic, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_UnfollowTopic))); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func BuildTweetA(p PreparexBuilder) (obj *TweetA, err error) {
|
||||
obj = &TweetA{
|
||||
AttachmentByTweetId: p.QueryHook(_TweetA_AttachmentByTweetId),
|
||||
FavoriteByTweetId: p.QueryHook(_TweetA_FavoriteByTweetId),
|
||||
ReactionByTweetId: p.QueryHook(_TweetA_ReactionByTweetId),
|
||||
TweetInfoById: p.QueryHook(_TweetA_TweetInfoById),
|
||||
TweetItemById: p.QueryHook(_TweetA_TweetItemById),
|
||||
UserFavorites: p.QueryHook(_TweetA_UserFavorites),
|
||||
UserInfo: p.QueryHook(_TweetA_UserInfo),
|
||||
UserReactions: p.QueryHook(_TweetA_UserReactions),
|
||||
UserTweetsByAdmin: p.QueryHook(_TweetA_UserTweetsByAdmin),
|
||||
UserTweetsByFriend: p.QueryHook(_TweetA_UserTweetsByFriend),
|
||||
UserTweetsByGuest: p.QueryHook(_TweetA_UserTweetsByGuest),
|
||||
UserTweetsBySelf: p.QueryHook(_TweetA_UserTweetsBySelf),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func BuildTweetHelpA(p PreparexBuilder) (obj *TweetHelpA, err error) {
|
||||
obj = &TweetHelpA{
|
||||
UserInfo: p.QueryHook(_TweetHelpA_UserInfo),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func BuildTweetManageA(p PreparexBuilder) (obj *TweetManageA, err error) {
|
||||
obj = &TweetManageA{
|
||||
UserInfo: p.QueryHook(_TweetManageA_UserInfo),
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
// Code generated by Yesql. DO NOT EDIT.
|
||||
// versions:
|
||||
// - Yesql v1.8.4
|
||||
|
||||
package yesql
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/bitbus/sqlx"
|
||||
)
|
||||
|
||||
const (
|
||||
_TagsFromNames = `SELECT * FROM @tag WHERE tag IN (?) AND is_del=0`
|
||||
_UpdateTagQuote = `UPDATE @tag SET quote_num=?, modified_on=? WHERE id=? AND is_del=0`
|
||||
)
|
||||
|
||||
// PreparexContext enhances the Conn interface with context.
|
||||
type PreparexContext interface {
|
||||
// PrepareContext prepares a statement.
|
||||
// The provided context is used for the preparation of the statement, not for
|
||||
// the execution of the statement.
|
||||
PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)
|
||||
|
||||
// PrepareNamedContext returns an sqlx.NamedStmt
|
||||
PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error)
|
||||
|
||||
// Rebind rebind query to adapte SQL Driver
|
||||
Rebind(query string) string
|
||||
}
|
||||
|
||||
// PreparexBuilder preparex builder interface for sqlx
|
||||
type PreparexBuilder interface {
|
||||
PreparexContext
|
||||
QueryHook(query string) string
|
||||
}
|
||||
|
||||
type Yesql struct {
|
||||
TagsFromNames string `yesql:"tags_from_names"`
|
||||
UpdateTagQuote *sqlx.Stmt `yesql:"update_tag_quote"`
|
||||
}
|
||||
|
||||
func BuildYesql(p PreparexBuilder, ctx ...context.Context) (obj *Yesql, err error) {
|
||||
var c context.Context
|
||||
if len(ctx) > 0 && ctx[0] != nil {
|
||||
c = ctx[0]
|
||||
} else {
|
||||
c = context.Background()
|
||||
}
|
||||
obj = &Yesql{
|
||||
TagsFromNames: p.QueryHook(_TagsFromNames),
|
||||
}
|
||||
if obj.UpdateTagQuote, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_UpdateTagQuote))); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
// Copyright 2023 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package sakila
|
||||
|
||||
import (
|
||||
"github.com/bitbus/sqlx"
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
"github.com/rocboss/paopao-ce/internal/core/cs"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/ac"
|
||||
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.TweetServantA = (*tweetSrvA)(nil)
|
||||
_ core.TweetManageServantA = (*tweetManageSrvA)(nil)
|
||||
_ core.TweetHelpServantA = (*tweetHelpSrvA)(nil)
|
||||
)
|
||||
|
||||
type tweetSrvA struct {
|
||||
*sqlxSrv
|
||||
q *ac.TweetA
|
||||
}
|
||||
|
||||
type tweetManageSrvA struct {
|
||||
*sqlxSrv
|
||||
cis core.CacheIndexService
|
||||
q *ac.TweetManageA
|
||||
}
|
||||
|
||||
type tweetHelpSrvA struct {
|
||||
*sqlxSrv
|
||||
q *ac.TweetHelpA
|
||||
}
|
||||
|
||||
func (s *tweetSrvA) TweetInfoById(id int64) (*cs.TweetInfo, error) {
|
||||
// TODO
|
||||
return nil, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetSrvA) TweetItemById(id int64) (*cs.TweetItem, error) {
|
||||
// TODO
|
||||
return nil, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetSrvA) UserTweets(visitorId, userId int64) (res cs.TweetList, err error) {
|
||||
// TODO
|
||||
return nil, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetSrvA) ReactionByTweetId(userId int64, tweetId int64) (*cs.ReactionItem, error) {
|
||||
// TODO
|
||||
return nil, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetSrvA) UserReactions(userId int64, limit int, offset int) (cs.ReactionList, error) {
|
||||
// TODO
|
||||
return nil, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetSrvA) FavoriteByTweetId(userId int64, tweetId int64) (*cs.FavoriteItem, error) {
|
||||
// TODO
|
||||
return nil, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetSrvA) UserFavorites(userId int64, limit int, offset int) (cs.FavoriteList, error) {
|
||||
// TODO
|
||||
return nil, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetSrvA) AttachmentByTweetId(userId int64, tweetId int64) (*cs.AttachmentBill, error) {
|
||||
// TODO
|
||||
return nil, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetManageSrvA) CreateAttachment(obj *cs.Attachment) (int64, error) {
|
||||
// TODO
|
||||
return 0, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetManageSrvA) CreateTweet(userId int64, req *cs.NewTweetReq) (*cs.TweetItem, error) {
|
||||
// TODO
|
||||
return nil, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetManageSrvA) DeleteTweet(userId int64, tweetId int64) ([]string, error) {
|
||||
// TODO
|
||||
return nil, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetManageSrvA) LockTweet(userId int64, tweetId int64) error {
|
||||
// TODO
|
||||
return debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetManageSrvA) StickTweet(userId int64, tweetId int64) error {
|
||||
// TODO
|
||||
return debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetManageSrvA) VisibleTweet(userId int64, visibility cs.TweetVisibleType) error {
|
||||
// TODO
|
||||
return debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetManageSrvA) CreateReaction(userId int64, tweetId int64) error {
|
||||
// TODO
|
||||
return debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetManageSrvA) DeleteReaction(userId int64, reactionId int64) error {
|
||||
// TODO
|
||||
return debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetManageSrvA) CreateFavorite(userId int64, tweetId int64) error {
|
||||
// TODO
|
||||
return debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetManageSrvA) DeleteFavorite(userId int64, favoriteId int64) error {
|
||||
// TODO
|
||||
return debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetHelpSrvA) RevampTweets(tweets cs.TweetList) (cs.TweetList, error) {
|
||||
// TODO
|
||||
return nil, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (s *tweetHelpSrvA) MergeTweets(tweets cs.TweetInfo) (cs.TweetList, error) {
|
||||
// TODO
|
||||
return nil, debug.ErrNotImplemented
|
||||
}
|
||||
|
||||
func newTweetServantA(db *sqlx.DB) core.TweetServantA {
|
||||
return &tweetSrvA{
|
||||
sqlxSrv: newSqlxSrv(db),
|
||||
q: acBuildFn(db, ac.BuildTweetA),
|
||||
}
|
||||
}
|
||||
|
||||
func newTweetManageServantA(db *sqlx.DB, cacheIndex core.CacheIndexService) core.TweetManageServantA {
|
||||
return &tweetManageSrvA{
|
||||
sqlxSrv: newSqlxSrv(db),
|
||||
cis: cacheIndex,
|
||||
q: acBuildFn(db, ac.BuildTweetManageA),
|
||||
}
|
||||
}
|
||||
|
||||
func newTweetHelpServantA(db *sqlx.DB) core.TweetHelpServantA {
|
||||
return &tweetHelpSrvA{
|
||||
sqlxSrv: newSqlxSrv(db),
|
||||
q: acBuildFn(db, ac.BuildTweetHelpA),
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,226 @@
|
||||
--------------------------------------------------------------------------------
|
||||
-- file yesql_ac.sql
|
||||
-- this sql file define all sql dml for next "A" version data logic
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- ship_index_a sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: user_info@ship_index_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- simple_index_a sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: user_info@simple_index_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- tweet_a sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: user_info@tweet_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
-- name: tweet_info_by_id@tweet_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
-- name: tweet_item_by_id@tweet_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
-- name: user_tweets_by_admin@tweet_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
-- name: user_tweets_by_self@tweet_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
-- name: user_tweets_by_friend@tweet_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
-- name: user_tweets_by_guest@tweet_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
-- name: reaction_by_tweet_id@tweet_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
-- name: user_reactions@tweet_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
-- name: favorite_by_tweet_id@tweet_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
-- name: user_favorites@tweet_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
-- name: attachment_by_tweet_id@tweet_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- tweet_manage_a sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: user_info@tweet_manage_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- tweet_help_a sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: user_info@tweet_help_a
|
||||
-- prepare: raw
|
||||
SELECT * FROM @user WHERE username=?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- topic_a sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: newest_tags@topic_a
|
||||
-- get newest tag information
|
||||
-- prepare: stmt
|
||||
SELECT t.id id,
|
||||
t.user_id user_id,
|
||||
t.tag tag,
|
||||
t.quote_num quote_num,
|
||||
u.id "u.id",
|
||||
u.nickname "u.nickname",
|
||||
u.username "u.username",
|
||||
u.status "u.status",
|
||||
u.avatar "u.avatar",
|
||||
u.is_admin "u.is_admin"
|
||||
FROM @tag t
|
||||
JOIN @user u ON t.user_id = u.id
|
||||
WHERE t.is_del = 0 AND t.quote_num > 0
|
||||
ORDER BY t.id DESC
|
||||
LIMIT ? OFFSET ?;
|
||||
|
||||
-- name: hot_tags@topic_a
|
||||
-- get get host tag information
|
||||
-- prepare: stmt
|
||||
SELECT t.id id,
|
||||
t.user_id user_id,
|
||||
t.tag tag,
|
||||
t.quote_num quote_num,
|
||||
u.id "u.id",
|
||||
u.nickname "u.nickname",
|
||||
u.username "u.username",
|
||||
u.status "u.status",
|
||||
u.avatar "u.avatar",
|
||||
u.is_admin "u.is_admin"
|
||||
FROM @tag t
|
||||
JOIN @user u ON t.user_id = u.id
|
||||
WHERE t.is_del = 0 AND t.quote_num > 0
|
||||
ORDER BY t.quote_num DESC
|
||||
LIMIT ? OFFSET ?;
|
||||
|
||||
-- name: follow_tags@topic_a
|
||||
-- get get follow tag information
|
||||
-- prepare: stmt
|
||||
SELECT t.id id,
|
||||
t.user_id user_id,
|
||||
t.tag tag,
|
||||
t.quote_num quote_num,
|
||||
u.id "u.id",
|
||||
1 as is_following,
|
||||
c.is_top,
|
||||
u.nickname "u.nickname",
|
||||
u.username "u.username",
|
||||
u.status "u.status",
|
||||
u.avatar "u.avatar",
|
||||
u.is_admin "u.is_admin"
|
||||
FROM @topic_user c
|
||||
JOIN @user u ON c.user_id = u.id
|
||||
JOIN @tag t ON c.topic_id = t.id
|
||||
WHERE c.is_del = 0 AND t.quote_num > 0 AND AND c.user_id=?
|
||||
ORDER BY t.quote_num DESC
|
||||
LIMIT ? OFFSET ?;
|
||||
|
||||
-- name: topic_infos@topic_a
|
||||
-- prepare: raw
|
||||
-- clause: in
|
||||
SELECT topic_id, is_top
|
||||
FROM @topic_user
|
||||
WHERE is_del=0 AND user_id=? AND topic_id IN ?;
|
||||
|
||||
-- name: exist_topic_user@topic_a
|
||||
-- prepare: stmt
|
||||
SELECT 1 FROM @topic_user WHERE user_id=? AND topic_id=? AND is_del=0;
|
||||
|
||||
-- name: follow_topic@topic_a
|
||||
-- prepare: stmt
|
||||
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=?
|
||||
WHERE user_id=? AND topic_id=? AND is_del=0;
|
||||
|
||||
-- name: stick_topic@topic_a
|
||||
-- prepare: stmt
|
||||
UPDATE @topic_user
|
||||
SET is_top=1-is_top; modified_on=?
|
||||
WHERE user_id=? AND topic_id=? AND is_del=0;
|
||||
|
||||
-- name: topic_is_top@topic_a
|
||||
-- prepare: stmt
|
||||
SELECT is_top FROM @topic_user WHERE user_id=? AND topic_id=? AND is_del=0;
|
||||
|
||||
-- name: tags_by_keyword_a@topic_a
|
||||
-- get tags by keyword
|
||||
SELECT id, user_id, tag, quote_num
|
||||
FROM @tag
|
||||
WHERE is_del = 0
|
||||
ORDER BY quote_num DESC
|
||||
LIMIT 6;
|
||||
|
||||
-- name: tags_by_keyword_b@topic_a
|
||||
SELECT id, user_id, tag, quote_num
|
||||
FROM @tag WHERE is_del = 0 AND tag LIKE ?
|
||||
ORDER BY quote_num DESC
|
||||
LIMIT 6;
|
||||
|
||||
-- name: insert_tag@topic_a
|
||||
INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num)
|
||||
VALUES (?, ?, ?, ?, 1);
|
||||
|
||||
-- name: tags_by_id_a@topic_a
|
||||
-- prepare: raw
|
||||
-- clause: in
|
||||
SELECT id FROM @tag WHERE id IN (?) AND is_del = 0 AND quote_num > 0;
|
||||
|
||||
-- name: tags_by_id_b@topic_a
|
||||
-- prepare: raw
|
||||
-- clause: in
|
||||
SELECT id, user_id, tag, quote_num FROM @tag WHERE id IN (?);
|
||||
|
||||
-- name: decr_tags_by_id@topic_a
|
||||
-- prepare: raw
|
||||
-- clause: in
|
||||
UPDATE @tag SET quote_num=quote_num-1, modified_on=? WHERE id IN (?);
|
||||
|
||||
-- name: tags_for_incr@topic_a
|
||||
-- prepare: raw
|
||||
-- clause: in
|
||||
SELECT id, user_id, tag, quote_num FROM @tag WHERE tag IN (?);
|
||||
|
||||
-- name: incr_tags_by_id@topic_a
|
||||
-- prepare: raw
|
||||
-- clause: in
|
||||
UPDATE @tag SET quote_num=quote_num+1, is_del=0, modified_on=? WHERE id IN (?);
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue