mirror of https://github.com/rocboss/paopao-ce
parent
6c594a8b24
commit
5dc4c03a57
@ -0,0 +1,60 @@
|
||||
// Code generated by Yesql. DO NOT EDIT.
|
||||
// versions:
|
||||
// - Yesql v1.9.0
|
||||
|
||||
package pga
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/alimy/yesql"
|
||||
"github.com/bitbus/sqlx"
|
||||
)
|
||||
|
||||
var (
|
||||
_ = fmt.Errorf("error for placeholder")
|
||||
)
|
||||
|
||||
const (
|
||||
_TopicA_InsertTag = `INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num) VALUES (?, ?, ?, ?, 1) RETURNING id`
|
||||
)
|
||||
|
||||
// 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 TopicA struct {
|
||||
yesql.Namespace `yesql:"topic_a"`
|
||||
InsertTag *sqlx.Stmt `yesql:"insert_tag"`
|
||||
}
|
||||
|
||||
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{}
|
||||
if obj.InsertTag, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_InsertTag))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _TopicA_InsertTag error: %w", err)
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,190 @@
|
||||
// Code generated by Yesql. DO NOT EDIT.
|
||||
// versions:
|
||||
// - Yesql v1.9.0
|
||||
|
||||
package pgc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/alimy/yesql"
|
||||
"github.com/bitbus/sqlx"
|
||||
)
|
||||
|
||||
var (
|
||||
_ = fmt.Errorf("error for placeholder")
|
||||
)
|
||||
|
||||
const (
|
||||
_CommentManage_CreateComment = `INSERT INTO @comment (post_id, user_id, ip, ip_loc, created_on) VALUES (?, ?, ?, ?, ?) RETURNING *`
|
||||
_CommentManage_CreateCommentContent = `INSERT INTO @comment_content (comment_id, user_id, content, type, sort, created_on) VALUES (?, ?, ?, ?, ?, ?) RETURNING *`
|
||||
_CommentManage_CreateCommentReply = `INSERT INTO @comment_reply (comment_id, user_id, content, at_user_id, ip, ip_loc, created_on) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING *`
|
||||
_ContactManager_CreateContact = `INSERT INTO @contact (user_id, friend_id, status, created_on) VALUES (?, ?, ?, ?) RETURNING *`
|
||||
_Message_CreateMessage = `INSERT INTO @message (sender_user_id, receiver_user_id, type, brief, content, post_id, comment_id, reply_id, created_on) VALUES (:sender_user_id, :receiver_user_id, :type, :brief, :content, :post_id, :comment_id, :reply_id, :created_on) RETURNING id`
|
||||
_TweetManage_AddAttachment = `INSERT INTO @attachment (user_id, file_size, img_width, img_height, type, content, created_on) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING id`
|
||||
_TweetManage_AddPost = `INSERT INTO @post (user_id, tags, ip, ip_loc, attachment_price, visibility, latest_replied_on, created_on) VALUES (:user_id, :tags, :ip, :ip_loc, :attachment_price, :visibility, :latest_replied_on, :created_on) RETURNING id`
|
||||
_TweetManage_AddPostCollection = `INSERT INTO @post_collection (post_id, user_id, created_on) VALUES (?, ?, ?) RETURNING *`
|
||||
_TweetManage_AddPostContent = `INSERT INTO @post_content (post_id, user_id, content, type, sort, created_on) VALUES (:post_id, :user_id, :content, :type, :sort, :created_on) RETURNING id`
|
||||
_TweetManage_AddPostStar = `INSERT INTO @post_star (post_id, user_id, created_on) VALUES (?, ?, ?) RETURNING *`
|
||||
_UserManage_CreateUser = `INSERT INTO @user (username, nickname, password, salt, avatar, status, created_on) VALUES (:username, :nickname, :password, :salt, :avatar, :status, :created_on) RETURNING id`
|
||||
_Wallet_CreateRecharge = `INSERT INTO @wallet_recharge (user_id, amount, created_on) VALUES (?, ?, ?) RETURNING *`
|
||||
)
|
||||
|
||||
// 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 CommentManage struct {
|
||||
yesql.Namespace `yesql:"comment_manage"`
|
||||
CreateComment *sqlx.Stmt `yesql:"create_comment"`
|
||||
CreateCommentContent *sqlx.Stmt `yesql:"create_comment_content"`
|
||||
CreateCommentReply *sqlx.Stmt `yesql:"create_comment_reply"`
|
||||
}
|
||||
|
||||
type ContactManager struct {
|
||||
yesql.Namespace `yesql:"contact_manager"`
|
||||
CreateContact *sqlx.Stmt `yesql:"create_contact"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
yesql.Namespace `yesql:"message"`
|
||||
CreateMessage *sqlx.NamedStmt `yesql:"create_message"`
|
||||
}
|
||||
|
||||
type TweetManage struct {
|
||||
yesql.Namespace `yesql:"tweet_manage"`
|
||||
AddAttachment *sqlx.Stmt `yesql:"add_attachment"`
|
||||
AddPostCollection *sqlx.Stmt `yesql:"add_post_collection"`
|
||||
AddPostStar *sqlx.Stmt `yesql:"add_post_star"`
|
||||
AddPost *sqlx.NamedStmt `yesql:"add_post"`
|
||||
AddPostContent *sqlx.NamedStmt `yesql:"add_post_content"`
|
||||
}
|
||||
|
||||
type UserManage struct {
|
||||
yesql.Namespace `yesql:"user_manage"`
|
||||
CreateUser *sqlx.NamedStmt `yesql:"create_user"`
|
||||
}
|
||||
|
||||
type Wallet struct {
|
||||
yesql.Namespace `yesql:"wallet"`
|
||||
CreateRecharge *sqlx.Stmt `yesql:"create_recharge"`
|
||||
}
|
||||
|
||||
func BuildCommentManage(p PreparexBuilder, ctx ...context.Context) (obj *CommentManage, err error) {
|
||||
var c context.Context
|
||||
if len(ctx) > 0 && ctx[0] != nil {
|
||||
c = ctx[0]
|
||||
} else {
|
||||
c = context.Background()
|
||||
}
|
||||
obj = &CommentManage{}
|
||||
if obj.CreateComment, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_CommentManage_CreateComment))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _CommentManage_CreateComment error: %w", err)
|
||||
}
|
||||
if obj.CreateCommentContent, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_CommentManage_CreateCommentContent))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _CommentManage_CreateCommentContent error: %w", err)
|
||||
}
|
||||
if obj.CreateCommentReply, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_CommentManage_CreateCommentReply))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _CommentManage_CreateCommentReply error: %w", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func BuildContactManager(p PreparexBuilder, ctx ...context.Context) (obj *ContactManager, err error) {
|
||||
var c context.Context
|
||||
if len(ctx) > 0 && ctx[0] != nil {
|
||||
c = ctx[0]
|
||||
} else {
|
||||
c = context.Background()
|
||||
}
|
||||
obj = &ContactManager{}
|
||||
if obj.CreateContact, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_ContactManager_CreateContact))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _ContactManager_CreateContact error: %w", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func BuildMessage(p PreparexBuilder, ctx ...context.Context) (obj *Message, err error) {
|
||||
var c context.Context
|
||||
if len(ctx) > 0 && ctx[0] != nil {
|
||||
c = ctx[0]
|
||||
} else {
|
||||
c = context.Background()
|
||||
}
|
||||
obj = &Message{}
|
||||
if obj.CreateMessage, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Message_CreateMessage))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _Message_CreateMessage error: %w", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func BuildTweetManage(p PreparexBuilder, ctx ...context.Context) (obj *TweetManage, err error) {
|
||||
var c context.Context
|
||||
if len(ctx) > 0 && ctx[0] != nil {
|
||||
c = ctx[0]
|
||||
} else {
|
||||
c = context.Background()
|
||||
}
|
||||
obj = &TweetManage{}
|
||||
if obj.AddAttachment, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_AddAttachment))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _TweetManage_AddAttachment error: %w", err)
|
||||
}
|
||||
if obj.AddPostCollection, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_AddPostCollection))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _TweetManage_AddPostCollection error: %w", err)
|
||||
}
|
||||
if obj.AddPostStar, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_AddPostStar))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _TweetManage_AddPostStar error: %w", err)
|
||||
}
|
||||
if obj.AddPost, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_TweetManage_AddPost))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _TweetManage_AddPost error: %w", err)
|
||||
}
|
||||
if obj.AddPostContent, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_TweetManage_AddPostContent))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _TweetManage_AddPostContent error: %w", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func BuildUserManage(p PreparexBuilder, ctx ...context.Context) (obj *UserManage, err error) {
|
||||
var c context.Context
|
||||
if len(ctx) > 0 && ctx[0] != nil {
|
||||
c = ctx[0]
|
||||
} else {
|
||||
c = context.Background()
|
||||
}
|
||||
obj = &UserManage{}
|
||||
if obj.CreateUser, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_UserManage_CreateUser))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _UserManage_CreateUser error: %w", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func BuildWallet(p PreparexBuilder, ctx ...context.Context) (obj *Wallet, err error) {
|
||||
var c context.Context
|
||||
if len(ctx) > 0 && ctx[0] != nil {
|
||||
c = ctx[0]
|
||||
} else {
|
||||
c = context.Background()
|
||||
}
|
||||
obj = &Wallet{}
|
||||
if obj.CreateRecharge, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Wallet_CreateRecharge))); err != nil {
|
||||
return nil, fmt.Errorf("prepare _Wallet_CreateRecharge error: %w", err)
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
// 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 (
|
||||
"time"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
"github.com/rocboss/paopao-ce/internal/core/ms"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/pgc"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.CommentManageService = (*pgcCommentManageSrv)(nil)
|
||||
)
|
||||
|
||||
type pgcCommentManageSrv struct {
|
||||
*commentManageSrv
|
||||
p *pgc.CommentManage
|
||||
}
|
||||
|
||||
func (s *pgcCommentManageSrv) CreateComment(r *ms.Comment) (res *ms.Comment, err error) {
|
||||
err = stmtGet(s.q.CreateComment, res,
|
||||
r.PostID, r.UserID, r.IP,
|
||||
r.IPLoc, time.Now().Unix())
|
||||
return
|
||||
}
|
||||
|
||||
func (s *pgcCommentManageSrv) CreateCommentReply(r *ms.CommentReply) (res *ms.CommentReply, err error) {
|
||||
err = stmtGet(s.q.CreateCommentReply, res,
|
||||
r.CommentID, r.UserID, r.Content,
|
||||
r.AtUserID, r.IP, r.IPLoc, time.Now().Unix())
|
||||
return
|
||||
}
|
||||
|
||||
func (s *pgcCommentManageSrv) CreateCommentContent(r *ms.CommentContent) (res *ms.CommentContent, err error) {
|
||||
err = stmtGet(s.q.CreateCommentContent, res,
|
||||
r.CommentID, r.UserID, r.Content,
|
||||
r.Type, r.Sort, time.Now().Unix())
|
||||
return
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
// 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 (
|
||||
"time"
|
||||
|
||||
"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/pgc"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.ContactManageService = (*pgcContactManageSrv)(nil)
|
||||
)
|
||||
|
||||
type pgcContactManageSrv struct {
|
||||
*contactManageSrv
|
||||
p *pgc.ContactManager
|
||||
}
|
||||
|
||||
func (s *pgcContactManageSrv) pgcFetchOrNewContact(tx *sqlx.Tx, userId int64, friendId int64, status int8) (res *cs.Contact, err error) {
|
||||
if err = stmtGet(tx.Stmtx(s.q.GetContact), res, userId, friendId); err != nil {
|
||||
err = stmtGet(tx.Stmtx(s.p.CreateContact), res, userId, friendId, status, time.Now().Unix())
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
// 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 (
|
||||
"time"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
"github.com/rocboss/paopao-ce/internal/core/ms"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/pgc"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.MessageService = (*pgcMessageSrv)(nil)
|
||||
)
|
||||
|
||||
type pgcMessageSrv struct {
|
||||
*messageSrv
|
||||
p *pgc.Message
|
||||
}
|
||||
|
||||
func (s *pgcMessageSrv) CreateMessage(r *ms.Message) (*ms.Message, error) {
|
||||
r.Model = &dbr.Model{
|
||||
CreatedOn: time.Now().Unix(),
|
||||
}
|
||||
if err := s.p.CreateMessage.Get(&r.ID, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r, nil
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
// 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 (
|
||||
"time"
|
||||
|
||||
"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/pga"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.TopicService = (*pgaTopicSrvA)(nil)
|
||||
_ core.TopicServantA = (*pgaTopicSrvA)(nil)
|
||||
)
|
||||
|
||||
type pgaTopicSrvA struct {
|
||||
*topicSrvA
|
||||
p *pga.TopicA
|
||||
}
|
||||
|
||||
func (s *pgaTopicSrvA) UpsertTags(userId int64, tags []string) (res cs.TagInfoList, xerr error) {
|
||||
if len(tags) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
xerr = s.db.Withx(func(tx *sqlx.Tx) error {
|
||||
var upTags cs.TagInfoList
|
||||
err := tx.InSelect(&upTags, s.q.TagsForIncr, tags)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
if len(upTags) > 0 {
|
||||
var ids []int64
|
||||
for _, t := range upTags {
|
||||
ids = append(ids, t.ID)
|
||||
t.QuoteNum++
|
||||
// prepare remain tags just delete updated tag
|
||||
// notice ensure tags slice is distinct elements
|
||||
for i, name := range tags {
|
||||
if name == t.Tag {
|
||||
lastIdx := len(tags) - 1
|
||||
tags[i] = tags[lastIdx]
|
||||
tags = tags[:lastIdx]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if _, err := tx.InExec(s.q.IncrTagsById, now, ids); err != nil {
|
||||
return err
|
||||
}
|
||||
res = append(res, upTags...)
|
||||
}
|
||||
// process remain tags if tags is not empty
|
||||
if len(tags) == 0 {
|
||||
return nil
|
||||
}
|
||||
var (
|
||||
id int64
|
||||
ids []int64
|
||||
)
|
||||
for _, tag := range tags {
|
||||
if err = s.p.InsertTag.Get(&id, userId, tag, now, now); err != nil {
|
||||
return err
|
||||
}
|
||||
ids = append(ids, id)
|
||||
}
|
||||
var newTags cs.TagInfoList
|
||||
if err := tx.InSelect(&newTags, s.q.TagsByIdB, ids); err != nil {
|
||||
return err
|
||||
}
|
||||
res = append(res, newTags...)
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
// 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 (
|
||||
"time"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
"github.com/rocboss/paopao-ce/internal/core/ms"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/pg"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.TweetManageService = (*pgTweetManageSrv)(nil)
|
||||
)
|
||||
|
||||
type pgTweetManageSrv struct {
|
||||
*tweetManageSrv
|
||||
p *pg.TweetManage
|
||||
}
|
||||
|
||||
func (s *pgTweetManageSrv) CreatePost(r *ms.Post) (*ms.Post, error) {
|
||||
now := time.Now().Unix()
|
||||
r.Model = &dbr.Model{CreatedOn: now}
|
||||
r.LatestRepliedOn = now
|
||||
err := s.p.AddPost.Get(&r.ID, r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.cis.SendAction(core.IdxActCreatePost, r)
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (s *pgTweetManageSrv) CreatePostContent(r *ms.PostContent) (*ms.PostContent, error) {
|
||||
r.Model = &ms.Model{CreatedOn: time.Now().Unix()}
|
||||
err := s.p.AddPostContent.Get(&r.ID, r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r, nil
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
// 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 (
|
||||
"time"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
"github.com/rocboss/paopao-ce/internal/core/ms"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/pgc"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.TweetManageService = (*pgcTweetManageSrv)(nil)
|
||||
)
|
||||
|
||||
type pgcTweetManageSrv struct {
|
||||
*tweetManageSrv
|
||||
p *pgc.TweetManage
|
||||
}
|
||||
|
||||
func (s *pgcTweetManageSrv) CreatePost(r *ms.Post) (*ms.Post, error) {
|
||||
now := time.Now().Unix()
|
||||
r.Model = &ms.Model{CreatedOn: now}
|
||||
r.LatestRepliedOn = now
|
||||
err := s.p.AddPost.Get(&r.ID, r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.cis.SendAction(core.IdxActCreatePost, r)
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (s *pgcTweetManageSrv) CreatePostContent(r *ms.PostContent) (*ms.PostContent, error) {
|
||||
r.Model = &ms.Model{CreatedOn: time.Now().Unix()}
|
||||
if err := s.p.AddPostContent.Get(&r.ID, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (s *pgcTweetManageSrv) CreateAttachment(r *ms.Attachment) (res int64, err error) {
|
||||
args := []any{r.UserID, r.FileSize, r.ImgWidth, r.ImgHeight, r.Type, r.Content, time.Now().Unix()}
|
||||
err = s.p.AddAttachment.Get(&res, args...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *pgcTweetManageSrv) CreatePostStar(postID, userID int64) (res *ms.PostStar, err error) {
|
||||
err = stmtGet(s.q.AddPostStar, res, postID, userID, time.Now().Unix())
|
||||
return
|
||||
}
|
||||
|
||||
func (s *pgcTweetManageSrv) CreatePostCollection(postID, userID int64) (res *ms.PostCollection, err error) {
|
||||
err = stmtGet(s.q.AddPostCollection, res, postID, userID, time.Now().Unix())
|
||||
return
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
// 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 (
|
||||
"time"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
"github.com/rocboss/paopao-ce/internal/core/ms"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/pgc"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.UserManageService = (*pgcUserManageSrv)(nil)
|
||||
)
|
||||
|
||||
type pgcUserManageSrv struct {
|
||||
*userManageSrv
|
||||
p *pgc.UserManage
|
||||
}
|
||||
|
||||
func (s *pgcUserManageSrv) CreateUser(r *ms.User) (*ms.User, error) {
|
||||
r.Model = &ms.Model{CreatedOn: time.Now().Unix()}
|
||||
if err := s.q.CreateUser.Get(&r.ID, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r, nil
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
// 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 (
|
||||
"time"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
"github.com/rocboss/paopao-ce/internal/core/ms"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/pgc"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.WalletService = (*pgcWalletSrv)(nil)
|
||||
)
|
||||
|
||||
type pgcWalletSrv struct {
|
||||
*walletSrv
|
||||
p *pgc.Wallet
|
||||
}
|
||||
|
||||
func (s *pgcWalletSrv) CreateRecharge(userId, amount int64) (res *ms.WalletRecharge, err error) {
|
||||
err = stmtGet(s.q.CreateRecharge, res, userId, amount, time.Now().Unix())
|
||||
return
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
--------------------------------------------------------------------------------
|
||||
-- file yesql.sql
|
||||
-- file yesql_pg.sql
|
||||
-- this sql file just define global sql dml
|
||||
-- this sql file contain some PostgreSQL special sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: add_post@tweet_manage
|
||||
-- prepare: named_stmt
|
||||
INSERT INTO @post (user_id, tags, ip, ip_loc, attachment_price, visibility, latest_replied_on, created_on)
|
||||
VALUES (:user_id, :tags, :ip, :ip_loc, :attachment_price, :visibility, :latest_replied_on, :created_on)
|
||||
RETURNING id;
|
||||
--------------------------------------------------------------------------------
|
||||
-- global sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: add_post_content@tweet_manage
|
||||
-- prepare: named_stmt
|
||||
INSERT INTO @post_content (post_id, user_id, content, type, sort, created_on)
|
||||
VALUES (:post_id, :user_id, :content, :type, :sort, :created_on)
|
||||
-- name: insert_tag
|
||||
-- prepare: stmt
|
||||
INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num)
|
||||
VALUES (?, ?, ?, ?, 1)
|
||||
RETURNING id;
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
--------------------------------------------------------------------------------
|
||||
-- file yesql.sql
|
||||
-- this sql file contain some PostgreSQL special sql dml
|
||||
-- version is a*
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- topic_a sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: insert_tag@topic_a
|
||||
INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num)
|
||||
VALUES (?, ?, ?, ?, 1)
|
||||
RETURNING id;
|
@ -0,0 +1,99 @@
|
||||
--------------------------------------------------------------------------------
|
||||
-- file yesql.sql
|
||||
-- this sql file contain some PostgreSQL special sql dml
|
||||
-- version is c*
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- tweet_manage sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: add_post@tweet_manage
|
||||
-- prepare: named_stmt
|
||||
INSERT INTO @post (user_id, tags, ip, ip_loc, attachment_price, visibility, latest_replied_on, created_on)
|
||||
VALUES (:user_id, :tags, :ip, :ip_loc, :attachment_price, :visibility, :latest_replied_on, :created_on)
|
||||
RETURNING id;
|
||||
|
||||
-- name: add_post_content@tweet_manage
|
||||
-- prepare: named_stmt
|
||||
INSERT INTO @post_content (post_id, user_id, content, type, sort, created_on)
|
||||
VALUES (:post_id, :user_id, :content, :type, :sort, :created_on)
|
||||
RETURNING id;
|
||||
|
||||
-- name: add_attachment@tweet_manage
|
||||
-- prepare: stmt
|
||||
INSERT INTO @attachment (user_id, file_size, img_width, img_height, type, content, created_on)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING id;
|
||||
|
||||
-- name: add_post_star@tweet_manage
|
||||
-- prepare: stmt
|
||||
INSERT INTO @post_star (post_id, user_id, created_on)
|
||||
VALUES (?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: add_post_collection@tweet_manage
|
||||
-- prepare: stmt
|
||||
INSERT INTO @post_collection (post_id, user_id, created_on)
|
||||
VALUES (?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- user_manage sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: create_user@user_manage
|
||||
-- prepare: named_stmt
|
||||
INSERT INTO @user (username, nickname, password, salt, avatar, status, created_on)
|
||||
VALUES (:username, :nickname, :password, :salt, :avatar, :status, :created_on)
|
||||
RETURNING id;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- comment_manage sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: create_comment@comment_manage
|
||||
-- prepare: stmt
|
||||
INSERT INTO @comment (post_id, user_id, ip, ip_loc, created_on)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: create_comment_content@comment_manage
|
||||
-- prepare: stmt
|
||||
INSERT INTO @comment_content (comment_id, user_id, content, type, sort, created_on)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: create_comment_reply@comment_manage
|
||||
-- prepare: stmt
|
||||
INSERT INTO @comment_reply (comment_id, user_id, content, at_user_id, ip, ip_loc, created_on)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- contact_manager sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: create_contact@contact_manager
|
||||
-- prepare: stmt
|
||||
INSERT INTO @contact (user_id, friend_id, status, created_on) VALUES (?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- message sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: create_message@message
|
||||
-- prepare: named_stmt
|
||||
INSERT INTO @message (sender_user_id, receiver_user_id, type, brief, content, post_id, comment_id, reply_id, created_on)
|
||||
VALUES (:sender_user_id, :receiver_user_id, :type, :brief, :content, :post_id, :comment_id, :reply_id, :created_on)
|
||||
RETURNING id;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- wallet sql dml
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- name: create_recharge@wallet
|
||||
-- prepare: stmt
|
||||
INSERT INTO @wallet_recharge (user_id, amount, created_on) VALUES (?, ?, ?)
|
||||
RETURNING *;
|
Loading…
Reference in new issue