Merge branch 'r/paopao-ce-plus' into r/paopao-ce-xtra

r/paopao-ce-xtra
Michael Li 1 year ago
commit a4e54de856
No known key found for this signature in database

@ -10,7 +10,7 @@ require (
github.com/alimy/yesql v1.9.0
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible
github.com/allegro/bigcache/v3 v3.1.0
github.com/bitbus/sqlx v1.7.0
github.com/bitbus/sqlx v1.8.0
github.com/bufbuild/connect-go v1.10.0
github.com/bytedance/sonic v1.10.0
github.com/cockroachdb/errors v1.10.0

@ -182,8 +182,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bitbus/sqlx v1.7.0 h1:n/hAlfY9bI29J9uObqAtjfITgNU2+XtY1ECnJUdmCZc=
github.com/bitbus/sqlx v1.7.0/go.mod h1:MemKLfQ600g6PxUVsIDe48PlY3wOquyW2ApeiXoynFo=
github.com/bitbus/sqlx v1.8.0 h1:2mhQscUW9Qc95gUONNswkuDaJiluVUfmBP4yw2cSK7M=
github.com/bitbus/sqlx v1.8.0/go.mod h1:MemKLfQ600g6PxUVsIDe48PlY3wOquyW2ApeiXoynFo=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=

@ -58,14 +58,18 @@ func newSqlDB() (driver string, db *sql.DB, err error) {
if cfg.If("MySQL") {
driver = "mysql"
db, err = sql.Open(driver, MysqlSetting.Dsn())
logrus.Infof("use MySQL as relation database")
} else if cfg.Any("PostgreSQL", "PgSQL", "Postgres") {
driver = "pgx"
db, err = sql.Open(driver, PostgresSetting.Dsn())
logrus.Infof("use PostgreSQL as relation database")
} else if cfg.If("Sqlite3") {
driver, db, err = OpenSqlite3()
logrus.Infof("use Sqlite3 as relation database")
} else {
driver = "mysql"
db, err = sql.Open(driver, MysqlSetting.Dsn())
logrus.Infof("not set db fetuare so use MySQL as default relation database")
}
return
}

@ -7,6 +7,7 @@ package sakila
import (
"time"
"github.com/bitbus/sqlx/db"
"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"
@ -21,23 +22,19 @@ type pgcCommentManageSrv struct {
p *pgc.CommentManage
}
func (s *pgcCommentManageSrv) CreateComment(r *ms.Comment) (res *ms.Comment, err error) {
err = stmtGet(s.p.CreateComment, &res,
r.PostID, r.UserID, r.IP,
r.IPLoc, time.Now().Unix())
return
func (s *pgcCommentManageSrv) CreateComment(r *ms.Comment) (*ms.Comment, error) {
return db.Get[ms.Comment](s.p.CreateComment, r.PostID, r.UserID, r.IP, r.IPLoc, time.Now().Unix())
}
func (s *pgcCommentManageSrv) CreateCommentReply(r *ms.CommentReply) (res *ms.CommentReply, err error) {
err = stmtGet(s.p.CreateCommentReply, &res,
r.CommentID, r.UserID, r.Content,
r.AtUserID, r.IP, r.IPLoc, time.Now().Unix())
return
func (s *pgcCommentManageSrv) CreateCommentReply(r *ms.CommentReply) (*ms.CommentReply, error) {
return db.Get[ms.CommentReply](s.p.CreateCommentReply, r.CommentID,
r.UserID, r.Content, r.AtUserID,
r.IP, r.IPLoc, time.Now().Unix())
}
func (s *pgcCommentManageSrv) CreateCommentContent(r *ms.CommentContent) (res *ms.CommentContent, err error) {
err = stmtGet(s.p.CreateCommentContent, &res,
func (s *pgcCommentManageSrv) CreateCommentContent(r *ms.CommentContent) (*ms.CommentContent, error) {
return db.Get[ms.CommentContent](s.p.CreateCommentContent,
r.CommentID, r.UserID, r.Content,
r.Type, r.Sort, time.Now().Unix())
return
}

@ -9,6 +9,7 @@ import (
"github.com/alimy/tryst/cfg"
"github.com/bitbus/sqlx"
"github.com/bitbus/sqlx/db"
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/ms"
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/cc"
@ -45,9 +46,8 @@ func (s *messageSrv) GetUnreadCount(userID int64) (res int64, err error) {
return
}
func (s *messageSrv) GetMessageByID(id int64) (res *ms.Message, err error) {
err = stmtGet(s.q.GetMessageById, &res, id)
return
func (s *messageSrv) GetMessageByID(id int64) (*ms.Message, error) {
return db.Get[ms.Message](s.q.GetMessageById, id)
}
func (s *messageSrv) ReadMessage(r *ms.Message) (err error) {

@ -153,7 +153,7 @@ func (s *dataSrv) Name() string {
}
func (s *dataSrv) Version() *semver.Version {
return semver.MustParse("v0.1.0")
return semver.MustParse("v0.2.0")
}
func (s *webDataSrvA) Name() string {

@ -10,6 +10,7 @@ import (
"time"
"github.com/bitbus/sqlx"
"github.com/bitbus/sqlx/db"
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/ms"
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
@ -28,9 +29,8 @@ type securitySrv struct {
}
// GetLatestPhoneCaptcha 获取最新短信验证码
func (s *securitySrv) GetLatestPhoneCaptcha(phone string) (res *ms.Captcha, err error) {
err = stmtGet(s.q.GetLatestPhoneCaptcha, &res, phone)
return
func (s *securitySrv) GetLatestPhoneCaptcha(phone string) (*ms.Captcha, error) {
return db.Get[ms.Captcha](s.q.GetLatestPhoneCaptcha, phone)
}
// UsePhoneCaptcha 更新短信验证码

@ -10,6 +10,7 @@ import (
"github.com/alimy/tryst/cfg"
"github.com/bitbus/sqlx"
"github.com/bitbus/sqlx/db"
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/cs"
"github.com/rocboss/paopao-ce/internal/core/ms"
@ -438,9 +439,8 @@ func (s *tweetSrv) GetUserPostStarCount(userID int64) (res int64, err error) {
return
}
func (s *tweetSrv) GetUserPostCollection(postID, userID int64) (res *ms.PostCollection, err error) {
err = stmtGet(s.q.GetUserPostCollection, &res, postID, userID, userID)
return
func (s *tweetSrv) GetUserPostCollection(postID, userID int64) (*ms.PostCollection, error) {
return db.Get[ms.PostCollection](s.q.GetUserPostCollection, postID, userID, userID)
}
func (s *tweetSrv) GetUserPostCollections(userID int64, offset, limit int) (res []*ms.PostCollection, err error) {
@ -465,8 +465,7 @@ func (s *tweetSrv) GetPostContentsByIDs(ids []int64) (res []*ms.PostContent, err
}
func (s *tweetSrv) GetPostContentByID(id int64) (res *ms.PostContent, err error) {
err = stmtGet(s.q.GetPostContentById, &res, id)
return
return db.Get[ms.PostContent](s.q.GetPostContentById, &res, id)
}
func newTweetService(db *sqlx.DB) core.TweetService {

@ -7,6 +7,7 @@ package sakila
import (
"time"
"github.com/bitbus/sqlx/db"
"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"
@ -47,12 +48,10 @@ func (s *pgcTweetManageSrv) CreateAttachment(r *ms.Attachment) (res int64, err e
return
}
func (s *pgcTweetManageSrv) CreatePostStar(postID, userID int64) (res *ms.PostStar, err error) {
err = stmtGet(s.p.AddPostStar, &res, postID, userID, time.Now().Unix())
return
func (s *pgcTweetManageSrv) CreatePostStar(postID, userID int64) (*ms.PostStar, error) {
return db.Get[ms.PostStar](s.p.AddPostStar, postID, userID, time.Now().Unix())
}
func (s *pgcTweetManageSrv) CreatePostCollection(postID, userID int64) (res *ms.PostCollection, err error) {
err = stmtGet(s.p.AddPostCollection, &res, postID, userID, time.Now().Unix())
return
func (s *pgcTweetManageSrv) CreatePostCollection(postID, userID int64) (*ms.PostCollection, error) {
return db.Get[ms.PostCollection](s.p.AddPostCollection, postID, userID, time.Now().Unix())
}

@ -10,6 +10,7 @@ import (
"github.com/alimy/tryst/cfg"
"github.com/bitbus/sqlx"
"github.com/bitbus/sqlx/db"
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/ms"
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/cc"
@ -25,19 +26,16 @@ type userManageSrv struct {
q *cc.UserManage
}
func (s *userManageSrv) GetUserByID(id int64) (res *ms.User, err error) {
err = stmtGet(s.q.GetUserById, &res, id)
return
func (s *userManageSrv) GetUserByID(id int64) (*ms.User, error) {
return db.Get[ms.User](s.q.GetUserById, id)
}
func (s *userManageSrv) GetUserByUsername(username string) (res *ms.User, err error) {
err = stmtGet(s.q.GetUserByUsername, &res, username)
return
func (s *userManageSrv) GetUserByUsername(username string) (*ms.User, error) {
return db.Get[ms.User](s.q.GetUserByUsername, username)
}
func (s *userManageSrv) GetUserByPhone(phone string) (res *ms.User, err error) {
err = stmtGet(s.q.GetUserByPhone, &res, phone)
return
func (s *userManageSrv) GetUserByPhone(phone string) (*ms.User, error) {
return db.Get[ms.User](s.q.GetUserByPhone, phone)
}
func (s *userManageSrv) GetUsersByIDs(ids []int64) (res []*ms.User, err error) {

@ -9,6 +9,7 @@ import (
"github.com/alimy/tryst/cfg"
"github.com/bitbus/sqlx"
"github.com/bitbus/sqlx/db"
"github.com/rocboss/paopao-ce/internal/conf"
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/ms"
@ -25,9 +26,8 @@ type walletSrv struct {
q *cc.Wallet
}
func (s *walletSrv) GetRechargeByID(id int64) (res *ms.WalletRecharge, err error) {
err = stmtGet(s.q.GetRechargeById, &res, id)
return
func (s *walletSrv) GetRechargeByID(id int64) (*ms.WalletRecharge, error) {
return db.Get[ms.WalletRecharge](s.q.GetRechargeById, id)
}
func (s *walletSrv) CreateRecharge(userId, amount int64) (*ms.WalletRecharge, error) {

@ -7,6 +7,7 @@ package sakila
import (
"time"
"github.com/bitbus/sqlx/db"
"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"
@ -21,7 +22,6 @@ type pgcWalletSrv struct {
p *pgc.Wallet
}
func (s *pgcWalletSrv) CreateRecharge(userId, amount int64) (res *ms.WalletRecharge, err error) {
err = stmtGet(s.p.CreateRecharge, &res, userId, amount, time.Now().Unix())
return
func (s *pgcWalletSrv) CreateRecharge(userId, amount int64) (*ms.WalletRecharge, error) {
return db.Get[ms.WalletRecharge](s.p.CreateRecharge, userId, amount, time.Now().Unix())
}

Loading…
Cancel
Save