mirror of https://github.com/rocboss/paopao-ce
parent
f4dcc0e0df
commit
40765e837d
@ -0,0 +1,87 @@
|
||||
// Code generated by go-mir. DO NOT EDIT.
|
||||
// versions:
|
||||
// - mir 5.3
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/alimy/mir/v5"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
type Blockship interface {
|
||||
_default_
|
||||
|
||||
ListBlocks(*web.ListBlocksReq) (*web.ListBlocksResp, error)
|
||||
UnblockUser(*web.UnblockUserReq) error
|
||||
BlockUser(*web.BlockUserReq) error
|
||||
|
||||
mustEmbedUnimplementedBlockshipServant()
|
||||
}
|
||||
|
||||
// RegisterBlockshipServant register Blockship servant to gin
|
||||
func RegisterBlockshipServant(e *gin.Engine, s Blockship) {
|
||||
router := e.Group("v1")
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("GET", "user/blocks", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
req := new(web.ListBlocksReq)
|
||||
if err := s.Bind(c, req); err != nil {
|
||||
s.Render(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.ListBlocks(req)
|
||||
s.Render(c, resp, err)
|
||||
})
|
||||
router.Handle("POST", "user/unblock", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
req := new(web.UnblockUserReq)
|
||||
if err := s.Bind(c, req); err != nil {
|
||||
s.Render(c, nil, err)
|
||||
return
|
||||
}
|
||||
s.Render(c, nil, s.UnblockUser(req))
|
||||
})
|
||||
router.Handle("POST", "user/block", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
req := new(web.BlockUserReq)
|
||||
if err := s.Bind(c, req); err != nil {
|
||||
s.Render(c, nil, err)
|
||||
return
|
||||
}
|
||||
s.Render(c, nil, s.BlockUser(req))
|
||||
})
|
||||
}
|
||||
|
||||
// UnimplementedBlockshipServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedBlockshipServant struct{}
|
||||
|
||||
func (UnimplementedBlockshipServant) ListBlocks(req *web.ListBlocksReq) (*web.ListBlocksResp, error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedBlockshipServant) UnblockUser(req *web.UnblockUserReq) error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedBlockshipServant) BlockUser(req *web.BlockUserReq) error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedBlockshipServant) mustEmbedUnimplementedBlockshipServant() {}
|
||||
@ -0,0 +1,82 @@
|
||||
// Code generated by go-mir. DO NOT EDIT.
|
||||
// versions:
|
||||
// - mir 5.3
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/alimy/mir/v5"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
type CheckInActivitity interface {
|
||||
_default_
|
||||
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
GetCheckInRank(*web.GetCheckInRankReq) (*web.GetCheckInRankResp, error)
|
||||
UserCheckIn(*web.UserCheckInReq) (*web.UserCheckInResp, error)
|
||||
|
||||
mustEmbedUnimplementedCheckInActivitityServant()
|
||||
}
|
||||
|
||||
// RegisterCheckInActivitityServant register CheckInActivitity servant to gin
|
||||
func RegisterCheckInActivitityServant(e *gin.Engine, s CheckInActivitity) {
|
||||
router := e.Group("v1")
|
||||
// use chain for router
|
||||
middlewares := s.Chain()
|
||||
router.Use(middlewares...)
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("GET", "checkin/rank", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
req := new(web.GetCheckInRankReq)
|
||||
var bv _binding_ = req
|
||||
if err := bv.Bind(c); err != nil {
|
||||
s.Render(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.GetCheckInRank(req)
|
||||
s.Render(c, resp, err)
|
||||
})
|
||||
router.Handle("POST", "checkin", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
req := new(web.UserCheckInReq)
|
||||
var bv _binding_ = req
|
||||
if err := bv.Bind(c); err != nil {
|
||||
s.Render(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.UserCheckIn(req)
|
||||
s.Render(c, resp, err)
|
||||
})
|
||||
}
|
||||
|
||||
// UnimplementedCheckInActivitityServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedCheckInActivitityServant struct{}
|
||||
|
||||
func (UnimplementedCheckInActivitityServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedCheckInActivitityServant) GetCheckInRank(req *web.GetCheckInRankReq) (*web.GetCheckInRankResp, error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCheckInActivitityServant) UserCheckIn(req *web.UserCheckInReq) (*web.UserCheckInResp, error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCheckInActivitityServant) mustEmbedUnimplementedCheckInActivitityServant() {}
|
||||
@ -0,0 +1,87 @@
|
||||
// Code generated by go-mir. DO NOT EDIT.
|
||||
// versions:
|
||||
// - mir 5.3
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/alimy/mir/v5"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
type Muteship interface {
|
||||
_default_
|
||||
|
||||
ListMutes(*web.ListMutesReq) (*web.ListMutesResp, error)
|
||||
UnmuteUser(*web.UnmuteUserReq) error
|
||||
MuteUser(*web.MuteUserReq) error
|
||||
|
||||
mustEmbedUnimplementedMuteshipServant()
|
||||
}
|
||||
|
||||
// RegisterMuteshipServant register Muteship servant to gin
|
||||
func RegisterMuteshipServant(e *gin.Engine, s Muteship) {
|
||||
router := e.Group("v1")
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("GET", "user/mutes", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
req := new(web.ListMutesReq)
|
||||
if err := s.Bind(c, req); err != nil {
|
||||
s.Render(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.ListMutes(req)
|
||||
s.Render(c, resp, err)
|
||||
})
|
||||
router.Handle("POST", "user/unmute", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
req := new(web.UnmuteUserReq)
|
||||
if err := s.Bind(c, req); err != nil {
|
||||
s.Render(c, nil, err)
|
||||
return
|
||||
}
|
||||
s.Render(c, nil, s.UnmuteUser(req))
|
||||
})
|
||||
router.Handle("POST", "user/mute", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
req := new(web.MuteUserReq)
|
||||
if err := s.Bind(c, req); err != nil {
|
||||
s.Render(c, nil, err)
|
||||
return
|
||||
}
|
||||
s.Render(c, nil, s.MuteUser(req))
|
||||
})
|
||||
}
|
||||
|
||||
// UnimplementedMuteshipServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedMuteshipServant struct{}
|
||||
|
||||
func (UnimplementedMuteshipServant) ListMutes(req *web.ListMutesReq) (*web.ListMutesResp, error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedMuteshipServant) UnmuteUser(req *web.UnmuteUserReq) error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedMuteshipServant) MuteUser(req *web.MuteUserReq) error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedMuteshipServant) mustEmbedUnimplementedMuteshipServant() {}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,27 +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 core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
|
||||
)
|
||||
|
||||
// UserLevelService 用户等级服务接口
|
||||
type UserLevelService interface {
|
||||
// GetLevelByExperience 根据经验值获取用户等级
|
||||
GetLevelByExperience(experience int) (*dbr.UserLevel, error)
|
||||
|
||||
// GetAllLevels 获取所有等级配置
|
||||
GetAllLevels() ([]*dbr.UserLevel, error)
|
||||
|
||||
// CreateLevel 创建等级配置
|
||||
CreateLevel(level *dbr.UserLevel) (*dbr.UserLevel, error)
|
||||
|
||||
// UpdateLevel 更新等级配置
|
||||
UpdateLevel(level *dbr.UserLevel) error
|
||||
|
||||
// DeleteLevel 删除等级配置
|
||||
DeleteLevel(level int) error
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
// Copyright 2024 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 ms
|
||||
|
||||
// ArticleContentT 长文章内容类型
|
||||
type ArticleContentT int
|
||||
|
||||
const (
|
||||
ArticleContentTypeTitle ArticleContentT = 1 + iota
|
||||
ArticleContentTypeText
|
||||
ArticleContentTypeImage
|
||||
ArticleContentTypeVideo
|
||||
ArticleContentTypeAudio
|
||||
ArticleContentTypeLink
|
||||
ArticleContentTypeAttachment
|
||||
ArticleContentTypePaidAttachment
|
||||
)
|
||||
|
||||
// ArticleVisibleT 长文章可见性类型
|
||||
type ArticleVisibleT int
|
||||
|
||||
const (
|
||||
ArticleVisiblePrivate ArticleVisibleT = 0 + iota // 私密
|
||||
ArticleVisiblePaid // 付费可见
|
||||
ArticleVisibleReserved1 // 保留
|
||||
ArticleVisibleReserved2 // 保留
|
||||
ArticleVisibleFriend // 好友可见
|
||||
ArticleVisibleFollowing // 关注可见
|
||||
ArticleVisibleReserved3 // 保留
|
||||
ArticleVisibleReserved4 // 保留
|
||||
ArticleVisiblePublic // 公开
|
||||
)
|
||||
|
||||
// Article 文章别名
|
||||
type Article = interface{}
|
||||
|
||||
// ArticleContent 文章内容别名
|
||||
type ArticleContent = interface{}
|
||||
|
||||
// ArticleSeries 文章系列别名
|
||||
type ArticleSeries = interface{}
|
||||
|
||||
// ArticleSeriesItem 系列文章关联别名
|
||||
type ArticleSeriesItem = interface{}
|
||||
|
||||
// ArticleCollection 文章收藏别名
|
||||
type ArticleCollection = interface{}
|
||||
|
||||
// ArticleStar 文章点赞别名
|
||||
type ArticleStar = interface{}
|
||||
|
||||
// ArticleComment 文章评论别名
|
||||
type ArticleComment = interface{}
|
||||
|
||||
// ArticleCommentReply 文章评论回复别名
|
||||
type ArticleCommentReply = interface{}
|
||||
@ -0,0 +1,77 @@
|
||||
// Copyright 2024 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 jinzhu
|
||||
|
||||
import (
|
||||
"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/sirupsen/logrus"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.UserBlockManageService = (*userBlockManageSrv)(nil)
|
||||
)
|
||||
|
||||
type userBlockManageSrv struct {
|
||||
db *gorm.DB
|
||||
b *dbr.UserBlock
|
||||
u *dbr.User
|
||||
}
|
||||
|
||||
func newUserBlockManageService(db *gorm.DB) core.UserBlockManageService {
|
||||
return &userBlockManageSrv{
|
||||
db: db,
|
||||
b: &dbr.UserBlock{},
|
||||
u: &dbr.User{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *userBlockManageSrv) BlockUser(userId int64, targetUserId int64, reason string) error {
|
||||
if _, err := s.b.GetUserBlock(s.db, userId, targetUserId); err != nil {
|
||||
block := &dbr.UserBlock{
|
||||
UserId: userId,
|
||||
TargetUserId: targetUserId,
|
||||
Reason: reason,
|
||||
}
|
||||
if _, err = block.Create(s.db); err != nil {
|
||||
logrus.Errorf("userBlockManageSrv.blockUser create new block err:%s", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *userBlockManageSrv) UnblockUser(userId int64, targetUserId int64) error {
|
||||
return s.b.DelUserBlock(s.db, userId, targetUserId)
|
||||
}
|
||||
|
||||
func (s *userBlockManageSrv) ListBlocks(userId int64, limit, offset int) (*ms.UserBlockList, error) {
|
||||
blocks, total, err := s.b.ListUserBlocks(s.db, userId, limit, offset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := &ms.UserBlockList{
|
||||
Total: total,
|
||||
}
|
||||
for _, block := range blocks {
|
||||
res.Blocks = append(res.Blocks, ms.UserBlockItem{
|
||||
UserId: block.UserId,
|
||||
TargetUserId: block.TargetUserId,
|
||||
Reason: block.Reason,
|
||||
CreatedOn: block.CreatedOn,
|
||||
})
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (s *userBlockManageSrv) IsBlocked(userId int64, targetUserId int64) bool {
|
||||
return s.b.IsBlocked(s.db, userId, targetUserId)
|
||||
}
|
||||
|
||||
func (s *userBlockManageSrv) IsBlocking(userId int64, targetUserId int64) bool {
|
||||
return s.b.IsBlocked(s.db, targetUserId, userId)
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
// Copyright 2024 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 dbr
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserBlock struct {
|
||||
*Model
|
||||
UserId int64 `json:"user_id"`
|
||||
TargetUserId int64 `json:"target_user_id"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
func (UserBlock) TableName() string {
|
||||
return "p_user_block"
|
||||
}
|
||||
|
||||
func (b *UserBlock) GetUserBlock(db *gorm.DB, userId, targetUserId int64) (*UserBlock, error) {
|
||||
var block UserBlock
|
||||
err := db.Unscoped().Where("user_id = ? AND target_user_id = ?", userId, targetUserId).First(&block).Error
|
||||
if err != nil {
|
||||
logrus.Debugf("UserBlock.GetUserBlock get block error:%s", err)
|
||||
return nil, err
|
||||
}
|
||||
return &block, nil
|
||||
}
|
||||
|
||||
func (b *UserBlock) DelUserBlock(db *gorm.DB, userId, targetUserId int64) error {
|
||||
return db.Unscoped().Where("user_id = ? AND target_user_id = ?", userId, targetUserId).Delete(b).Error
|
||||
}
|
||||
|
||||
func (b *UserBlock) ListUserBlocks(db *gorm.DB, userId int64, limit int, offset int) (res []*UserBlock, total int64, err error) {
|
||||
db = db.Model(b).Where("user_id=?", userId)
|
||||
if err = db.Count(&total).Error; err != nil {
|
||||
return
|
||||
}
|
||||
if offset >= 0 && limit > 0 {
|
||||
db = db.Offset(offset).Limit(limit)
|
||||
}
|
||||
if err = db.Find(&res).Error; err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (b *UserBlock) IsBlocked(db *gorm.DB, userId, targetUserId int64) bool {
|
||||
if _, err := b.GetUserBlock(db, userId, targetUserId); err == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (b *UserBlock) Create(db *gorm.DB) (*UserBlock, error) {
|
||||
err := db.Create(b).Error
|
||||
return b, err
|
||||
}
|
||||
|
||||
func (b *UserBlock) UpdateInUnscoped(db *gorm.DB) error {
|
||||
return db.Unscoped().Save(b).Error
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
// 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 dbr
|
||||
|
||||
// RelationTyp 用户关系类型
|
||||
type RelationTyp uint8
|
||||
|
||||
const (
|
||||
RelationUnknown RelationTyp = iota
|
||||
RelationSelf
|
||||
RelationFriend
|
||||
RelationFollower
|
||||
RelationFollowing
|
||||
RelationAdmin
|
||||
RelationGuest
|
||||
)
|
||||
|
||||
// String 返回关系类型的字符串表示
|
||||
func (t RelationTyp) String() string {
|
||||
switch t {
|
||||
case RelationSelf:
|
||||
return "self"
|
||||
case RelationFriend:
|
||||
return "friend"
|
||||
case RelationFollower:
|
||||
return "follower"
|
||||
case RelationFollowing:
|
||||
return "following"
|
||||
case RelationAdmin:
|
||||
return "admin"
|
||||
case RelationUnknown:
|
||||
fallthrough
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
// UserInfo 用户基本信息
|
||||
type UserInfo struct {
|
||||
ID int64 `json:"id"`
|
||||
Nickname string `json:"nickname"`
|
||||
Username string `json:"username"`
|
||||
Status int `json:"status"`
|
||||
Avatar string `json:"avatar"`
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
CreatedOn int64 `json:"created_on"`
|
||||
}
|
||||
|
||||
// UserInfoList 用户信息列表
|
||||
type UserInfoList []*UserInfo
|
||||
|
||||
// VistUser 访问用户信息
|
||||
type VistUser struct {
|
||||
Username string
|
||||
UserId int64
|
||||
RelTyp RelationTyp
|
||||
}
|
||||
|
||||
// UserProfile 用户资料
|
||||
type UserProfile struct {
|
||||
ID int64 `json:"id" db:"id"`
|
||||
Nickname string `json:"nickname"`
|
||||
Username string `json:"username"`
|
||||
Phone string `json:"phone"`
|
||||
Status int `json:"status"`
|
||||
Avatar string `json:"avatar"`
|
||||
Balance int64 `json:"balance"`
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
CreatedOn int64 `json:"created_on"`
|
||||
TweetsCount int `json:"tweets_count"`
|
||||
Experience int `json:"experience"`
|
||||
Level int `json:"level"`
|
||||
}
|
||||
@ -1,53 +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 dbr
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// UserLevel 用户等级配置模型
|
||||
type UserLevel struct {
|
||||
Level int `gorm:"column:level;primaryKey" json:"level"` // 等级
|
||||
MinExperience int `gorm:"column:min_experience" json:"min_experience"` // 最小经验值
|
||||
MaxExperience int `gorm:"column:max_experience" json:"max_experience"` // 最大经验值
|
||||
Name string `gorm:"column:name" json:"name"` // 等级名称
|
||||
Description string `gorm:"column:description" json:"description"` // 等级描述
|
||||
}
|
||||
|
||||
// TableName 指定表名映射
|
||||
func (u *UserLevel) TableName() string {
|
||||
return "p_user_level"
|
||||
}
|
||||
|
||||
// GetByExperience 根据经验值获取等级
|
||||
func (u *UserLevel) GetByExperience(db *gorm.DB, experience int) (*UserLevel, error) {
|
||||
var level UserLevel
|
||||
err := db.Where("min_experience <= ? AND max_experience >= ?", experience, experience).First(&level).Error
|
||||
return &level, err
|
||||
}
|
||||
|
||||
// GetAll 获取所有等级配置
|
||||
func (u *UserLevel) GetAll(db *gorm.DB) ([]*UserLevel, error) {
|
||||
var levels []*UserLevel
|
||||
err := db.Order("level ASC").Find(&levels).Error
|
||||
return levels, err
|
||||
}
|
||||
|
||||
// Create 创建等级配置
|
||||
func (u *UserLevel) Create(db *gorm.DB) (*UserLevel, error) {
|
||||
err := db.Create(&u).Error
|
||||
return u, err
|
||||
}
|
||||
|
||||
// Update 更新等级配置
|
||||
func (u *UserLevel) Update(db *gorm.DB) error {
|
||||
return db.Model(&UserLevel{}).Where("level = ?", u.Level).Save(u).Error
|
||||
}
|
||||
|
||||
// Delete 删除等级配置
|
||||
func (u *UserLevel) Delete(db *gorm.DB) error {
|
||||
return db.Where("level = ?", u.Level).Delete(&UserLevel{}).Error
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
// Copyright 2024 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 dbr
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserMute struct {
|
||||
*Model
|
||||
UserId int64 `json:"user_id"`
|
||||
TargetUserId int64 `json:"target_user_id"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
func (UserMute) TableName() string {
|
||||
return "p_user_mute"
|
||||
}
|
||||
|
||||
func (m *UserMute) GetUserMute(db *gorm.DB, userId, targetUserId int64) (*UserMute, error) {
|
||||
var mute UserMute
|
||||
err := db.Unscoped().Where("user_id = ? AND target_user_id = ?", userId, targetUserId).First(&mute).Error
|
||||
if err != nil {
|
||||
logrus.Debugf("UserMute.GetUserMute get mute error:%s", err)
|
||||
return nil, err
|
||||
}
|
||||
return &mute, nil
|
||||
}
|
||||
|
||||
func (m *UserMute) DelUserMute(db *gorm.DB, userId, targetUserId int64) error {
|
||||
return db.Unscoped().Where("user_id = ? AND target_user_id = ?", userId, targetUserId).Delete(m).Error
|
||||
}
|
||||
|
||||
func (m *UserMute) ListUserMutes(db *gorm.DB, userId int64, limit int, offset int) (res []*UserMute, total int64, err error) {
|
||||
db = db.Model(m).Where("user_id=?", userId)
|
||||
if err = db.Count(&total).Error; err != nil {
|
||||
return
|
||||
}
|
||||
if offset >= 0 && limit > 0 {
|
||||
db = db.Offset(offset).Limit(limit)
|
||||
}
|
||||
if err = db.Find(&res).Error; err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (m *UserMute) IsMuted(db *gorm.DB, userId, targetUserId int64) bool {
|
||||
if _, err := m.GetUserMute(db, userId, targetUserId); err == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *UserMute) Create(db *gorm.DB) (*UserMute, error) {
|
||||
err := db.Create(m).Error
|
||||
return m, err
|
||||
}
|
||||
|
||||
func (m *UserMute) UpdateInUnscoped(db *gorm.DB) error {
|
||||
return db.Unscoped().Save(m).Error
|
||||
}
|
||||
@ -1,54 +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 jinzhu
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.UserLevelService = (*userLevelSrv)(nil)
|
||||
)
|
||||
|
||||
// userLevelSrv 实现用户等级服务接口
|
||||
type userLevelSrv struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
// newUserLevelService 创建用户等级服务实例
|
||||
func newUserLevelService(db *gorm.DB) core.UserLevelService {
|
||||
return &userLevelSrv{
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
// GetLevelByExperience 根据经验值获取用户等级
|
||||
func (s *userLevelSrv) GetLevelByExperience(experience int) (*dbr.UserLevel, error) {
|
||||
level := &dbr.UserLevel{}
|
||||
return level.GetByExperience(s.db, experience)
|
||||
}
|
||||
|
||||
// GetAllLevels 获取所有等级配置
|
||||
func (s *userLevelSrv) GetAllLevels() ([]*dbr.UserLevel, error) {
|
||||
level := &dbr.UserLevel{}
|
||||
return level.GetAll(s.db)
|
||||
}
|
||||
|
||||
// CreateLevel 创建等级配置
|
||||
func (s *userLevelSrv) CreateLevel(level *dbr.UserLevel) (*dbr.UserLevel, error) {
|
||||
return level.Create(s.db)
|
||||
}
|
||||
|
||||
// UpdateLevel 更新等级配置
|
||||
func (s *userLevelSrv) UpdateLevel(level *dbr.UserLevel) error {
|
||||
return level.Update(s.db)
|
||||
}
|
||||
|
||||
// DeleteLevel 删除等级配置
|
||||
func (s *userLevelSrv) DeleteLevel(level int) error {
|
||||
return (&dbr.UserLevel{Level: level}).Delete(s.db)
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
// Copyright 2024 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 jinzhu
|
||||
|
||||
import (
|
||||
"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/sirupsen/logrus"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.UserMuteManageService = (*userMuteManageSrv)(nil)
|
||||
)
|
||||
|
||||
type userMuteManageSrv struct {
|
||||
db *gorm.DB
|
||||
m *dbr.UserMute
|
||||
u *dbr.User
|
||||
}
|
||||
|
||||
func newUserMuteManageService(db *gorm.DB) core.UserMuteManageService {
|
||||
return &userMuteManageSrv{
|
||||
db: db,
|
||||
m: &dbr.UserMute{},
|
||||
u: &dbr.User{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *userMuteManageSrv) MuteUser(userId int64, targetUserId int64, reason string) error {
|
||||
if _, err := s.m.GetUserMute(s.db, userId, targetUserId); err != nil {
|
||||
mute := &dbr.UserMute{
|
||||
UserId: userId,
|
||||
TargetUserId: targetUserId,
|
||||
Reason: reason,
|
||||
}
|
||||
if _, err = mute.Create(s.db); err != nil {
|
||||
logrus.Errorf("userMuteManageSrv.muteUser create new mute err:%s", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *userMuteManageSrv) UnmuteUser(userId int64, targetUserId int64) error {
|
||||
return s.m.DelUserMute(s.db, userId, targetUserId)
|
||||
}
|
||||
|
||||
func (s *userMuteManageSrv) ListMutes(userId int64, limit, offset int) (*ms.UserMuteList, error) {
|
||||
mutes, total, err := s.m.ListUserMutes(s.db, userId, limit, offset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := &ms.UserMuteList{
|
||||
Total: total,
|
||||
}
|
||||
for _, mute := range mutes {
|
||||
res.Mutes = append(res.Mutes, ms.UserMuteItem{
|
||||
UserId: mute.UserId,
|
||||
TargetUserId: mute.TargetUserId,
|
||||
Reason: mute.Reason,
|
||||
CreatedOn: mute.CreatedOn,
|
||||
})
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (s *userMuteManageSrv) IsMuted(userId int64, targetUserId int64) bool {
|
||||
return s.m.IsMuted(s.db, userId, targetUserId)
|
||||
}
|
||||
@ -0,0 +1,310 @@
|
||||
// Copyright 2024 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 web
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/rocboss/paopao-ce/internal/core/ms"
|
||||
"github.com/rocboss/paopao-ce/internal/model/joint"
|
||||
"github.com/rocboss/paopao-ce/internal/servants/base"
|
||||
"github.com/rocboss/paopao-ce/pkg/app"
|
||||
"github.com/rocboss/paopao-ce/pkg/convert"
|
||||
"github.com/rocboss/paopao-ce/pkg/xerror"
|
||||
)
|
||||
|
||||
// 长文章相关请求和响应结构
|
||||
|
||||
type ArticleContentItem struct {
|
||||
Type ms.ArticleContentT `json:"type" binding:"required"`
|
||||
Content string `json:"content" binding:"required"`
|
||||
Sort int64 `json:"sort"`
|
||||
}
|
||||
|
||||
type CreateArticleReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
Title string `json:"title" binding:"required,max=200"`
|
||||
Summary string `json:"summary" binding:"max=500"`
|
||||
SeriesID *int64 `json:"series_id"`
|
||||
Contents []ArticleContentItem `json:"contents" binding:"required,dive"`
|
||||
Visibility ms.ArticleVisibleT `json:"visibility"`
|
||||
Price int64 `json:"price"`
|
||||
Tags []string `json:"tags"`
|
||||
}
|
||||
|
||||
type CreateArticleResp struct {
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateArticleReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
Title string `json:"title" binding:"required,max=200"`
|
||||
Summary string `json:"summary" binding:"max=500"`
|
||||
SeriesID *int64 `json:"series_id"`
|
||||
Contents []ArticleContentItem `json:"contents" binding:"required,dive"`
|
||||
Visibility ms.ArticleVisibleT `json:"visibility"`
|
||||
Price int64 `json:"price"`
|
||||
Tags []string `json:"tags"`
|
||||
}
|
||||
|
||||
type DeleteArticleReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type GetArticleReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `form:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type GetArticleResp struct {
|
||||
joint.CacheResp
|
||||
}
|
||||
|
||||
type ListArticlesReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
Query string `form:"query"`
|
||||
Visibility []ms.ArticleVisibleT `form:"visibility"`
|
||||
Type string `form:"type"`
|
||||
Style string `form:"style"`
|
||||
Page int `form:"-" binding:"-"`
|
||||
PageSize int `form:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type ListArticlesResp struct {
|
||||
joint.CachePageResp
|
||||
}
|
||||
|
||||
type ArticleStarReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type ArticleStarResp struct {
|
||||
Status bool `json:"status"`
|
||||
}
|
||||
|
||||
type ArticleCollectionReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type ArticleCollectionResp struct {
|
||||
Status bool `json:"status"`
|
||||
}
|
||||
|
||||
type CreateArticleCommentReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
Content string `json:"content" binding:"required,max=1000"`
|
||||
}
|
||||
|
||||
type CreateArticleCommentResp struct {
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
|
||||
type DeleteArticleCommentReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type ArticleCommentsReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `form:"id" binding:"required"`
|
||||
Page int `form:"-" binding:"-"`
|
||||
PageSize int `form:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type ArticleCommentsResp struct {
|
||||
joint.CachePageResp
|
||||
}
|
||||
|
||||
type CreateArticleCommentReplyReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
CommentID int64 `json:"comment_id" binding:"required"`
|
||||
ReplyToID *int64 `json:"reply_to_id"`
|
||||
Content string `json:"content" binding:"required,max=1000"`
|
||||
}
|
||||
|
||||
type CreateArticleCommentReplyResp struct {
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
|
||||
type DeleteArticleCommentReplyReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type CreateArticleSeriesReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
Title string `json:"title" binding:"required,max=200"`
|
||||
Description string `json:"description" binding:"max=1000"`
|
||||
Cover string `json:"cover"`
|
||||
Visibility ms.ArticleVisibleT `json:"visibility"`
|
||||
Tags []string `json:"tags"`
|
||||
}
|
||||
|
||||
type CreateArticleSeriesResp struct {
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateArticleSeriesReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
Title string `json:"title" binding:"required,max=200"`
|
||||
Description string `json:"description" binding:"max=1000"`
|
||||
Cover string `json:"cover"`
|
||||
Visibility ms.ArticleVisibleT `json:"visibility"`
|
||||
Tags []string `json:"tags"`
|
||||
}
|
||||
|
||||
type DeleteArticleSeriesReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type GetArticleSeriesReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `form:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type GetArticleSeriesResp struct {
|
||||
joint.CacheResp
|
||||
}
|
||||
|
||||
type ListArticleSeriesReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
Query string `form:"query"`
|
||||
Visibility []ms.ArticleVisibleT `form:"visibility"`
|
||||
Page int `form:"-" binding:"-"`
|
||||
PageSize int `form:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type ListArticleSeriesResp struct {
|
||||
joint.CachePageResp
|
||||
}
|
||||
|
||||
type AddToSeriesReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
SeriesID int64 `json:"series_id" binding:"required"`
|
||||
ArticleID int64 `json:"article_id" binding:"required"`
|
||||
Sort int `json:"sort"`
|
||||
}
|
||||
|
||||
type RemoveFromSeriesReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
SeriesID int64 `json:"series_id" binding:"required"`
|
||||
ArticleID int64 `json:"article_id" binding:"required"`
|
||||
}
|
||||
|
||||
type GetUserArticlesReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
Username string `form:"username" binding:"required"`
|
||||
Style string `form:"style"`
|
||||
Page int `form:"-" binding:"-"`
|
||||
PageSize int `form:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type GetUserArticlesResp struct {
|
||||
joint.CachePageResp
|
||||
}
|
||||
|
||||
type GetUserArticleCollectionsReq BasePageReq
|
||||
type GetUserArticleCollectionsResp base.PageResp
|
||||
|
||||
type GetUserArticleStarsReq BasePageReq
|
||||
type GetUserArticleStarsResp base.PageResp
|
||||
|
||||
type ArticleStarStatusReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `form:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type ArticleStarStatusResp struct {
|
||||
Status bool `json:"status"`
|
||||
}
|
||||
|
||||
type ArticleCollectionStatusReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `form:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type ArticleCollectionStatusResp struct {
|
||||
Status bool `json:"status"`
|
||||
}
|
||||
|
||||
type AdminDeleteArticleReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
Reason string `json:"reason" binding:"required"`
|
||||
}
|
||||
|
||||
// Bind methods for request validation and binding
|
||||
|
||||
func (r *ListArticlesReq) Bind(c *gin.Context) error {
|
||||
r.Page, r.PageSize = app.GetPageInfo(c)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *ArticleCommentsReq) Bind(c *gin.Context) error {
|
||||
r.Page, r.PageSize = app.GetPageInfo(c)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *ListArticleSeriesReq) Bind(c *gin.Context) error {
|
||||
r.Page, r.PageSize = app.GetPageInfo(c)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *GetUserArticlesReq) Bind(c *gin.Context) error {
|
||||
r.Page, r.PageSize = app.GetPageInfo(c)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *GetUserArticleCollectionsReq) Bind(c *gin.Context) error {
|
||||
return (*BasePageReq)(r).Bind(c)
|
||||
}
|
||||
|
||||
func (r *GetUserArticleStarsReq) Bind(c *gin.Context) error {
|
||||
return (*BasePageReq)(r).Bind(c)
|
||||
}
|
||||
|
||||
func (r *ArticleStarStatusReq) Bind(c *gin.Context) error {
|
||||
userId, exist := base.UserIdFrom(c)
|
||||
if !exist {
|
||||
return xerror.UnauthorizedAuthNotExist
|
||||
}
|
||||
r.BaseInfo = BaseInfo{
|
||||
User: &ms.User{Model: &ms.Model{ID: userId}},
|
||||
}
|
||||
r.ID = convert.StrTo(c.Query("id")).MustInt64()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *ArticleCollectionStatusReq) Bind(c *gin.Context) error {
|
||||
userId, exist := base.UserIdFrom(c)
|
||||
if !exist {
|
||||
return xerror.UnauthorizedAuthNotExist
|
||||
}
|
||||
r.BaseInfo = BaseInfo{
|
||||
User: &ms.User{Model: &ms.Model{ID: userId}},
|
||||
}
|
||||
r.ID = convert.StrTo(c.Query("id")).MustInt64()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *CreateArticleReq) ValidateContents() error {
|
||||
totalWords := 0
|
||||
for _, content := range r.Contents {
|
||||
if content.Type == ms.ArticleContentTypeText {
|
||||
// 计算字数,这里简化为字符数,实际应该用中文分词库
|
||||
totalWords += len([]rune(content.Content))
|
||||
}
|
||||
}
|
||||
if totalWords > 50000 {
|
||||
return xerror.NewError(400, "文章字数超过50000字限制")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
// Copyright 2024 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 web
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model/joint"
|
||||
"github.com/rocboss/paopao-ce/internal/servants/base"
|
||||
)
|
||||
|
||||
type BlockUserReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
UserId int64 `json:"user_id" binding:"required"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
type UnblockUserReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
UserId int64 `json:"user_id" binding:"required"`
|
||||
}
|
||||
|
||||
type ListBlocksReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
joint.BasePageInfo
|
||||
}
|
||||
|
||||
type ListBlocksResp base.PageResp
|
||||
@ -0,0 +1,28 @@
|
||||
// Copyright 2024 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 web
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model/joint"
|
||||
"github.com/rocboss/paopao-ce/internal/servants/base"
|
||||
)
|
||||
|
||||
type MuteUserReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
UserId int64 `json:"user_id" binding:"required"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
type UnmuteUserReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
UserId int64 `json:"user_id" binding:"required"`
|
||||
}
|
||||
|
||||
type ListMutesReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
joint.BasePageInfo
|
||||
}
|
||||
|
||||
type ListMutesResp base.PageResp
|
||||
@ -1,4 +1,18 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v5"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
// CheckInActivitity 签到活动
|
||||
type CheckInActivitity struct {
|
||||
Schema `mir:"v1,chain"`
|
||||
|
||||
// UserCheckIn 用户签到
|
||||
UserCheckIn func(Post, web.UserCheckInReq) web.UserCheckInResp `mir:"checkin"`
|
||||
|
||||
// GetCheckInRank 获取签到排行榜
|
||||
GetCheckInRank func(Get, web.GetCheckInRankReq) web.GetCheckInRankResp `mir:"checkin/rank"`
|
||||
}
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v5"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
// Blockship 拉黑模式 服务
|
||||
type Blockship struct {
|
||||
Schema `mir:"v1"`
|
||||
|
||||
// BlockUser 拉黑用户
|
||||
BlockUser func(Post, web.BlockUserReq) `mir:"user/block"`
|
||||
|
||||
// UnblockUser 取消拉黑用户
|
||||
UnblockUser func(Post, web.UnblockUserReq) `mir:"user/unblock"`
|
||||
|
||||
// ListBlocks 获取用户的拉黑列表
|
||||
ListBlocks func(Get, web.ListBlocksReq) web.ListBlocksResp `mir:"user/blocks"`
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v5"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
// Muteship 屏蔽模式 服务
|
||||
type Muteship struct {
|
||||
Schema `mir:"v1"`
|
||||
|
||||
// MuteUser 屏蔽用户
|
||||
MuteUser func(Post, web.MuteUserReq) `mir:"user/mute"`
|
||||
|
||||
// UnmuteUser 取消屏蔽用户
|
||||
UnmuteUser func(Post, web.UnmuteUserReq) `mir:"user/unmute"`
|
||||
|
||||
// ListMutes 获取用户的屏蔽列表
|
||||
ListMutes func(Get, web.ListMutesReq) web.ListMutesResp `mir:"user/mutes"`
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
-- 删除用户签到记录表
|
||||
DROP TABLE IF EXISTS `p_user_checkin`;
|
||||
|
||||
-- 删除运营设置表
|
||||
DROP TABLE IF EXISTS `p_operation_settings`;
|
||||
|
||||
-- 删除用户表的经验值字段
|
||||
ALTER TABLE `p_user` DROP COLUMN `experience`;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
-- 为用户表添加经验值字段
|
||||
ALTER TABLE `p_user` ADD COLUMN `experience` int(11) NOT NULL DEFAULT 0 COMMENT '用户经验值' AFTER `balance`;
|
||||
|
||||
-- 创建运营设置表
|
||||
CREATE TABLE IF NOT EXISTS `p_operation_settings` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`key` varchar(255) NOT NULL COMMENT '设置键',
|
||||
`value` text NOT NULL COMMENT '设置值',
|
||||
`description` varchar(500) DEFAULT NULL COMMENT '设置描述',
|
||||
`created_on` int(11) NOT NULL DEFAULT 0,
|
||||
`updated_on` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_key` (`key`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='运营设置表';
|
||||
|
||||
-- 创建用户签到记录表
|
||||
CREATE TABLE IF NOT EXISTS `p_user_checkin` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||
`checkin_date` date NOT NULL COMMENT '签到日期',
|
||||
`experience_gained` int(11) NOT NULL DEFAULT 0 COMMENT '获得的经验值',
|
||||
`created_on` int(11) NOT NULL DEFAULT 0,
|
||||
`updated_on` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_user_date` (`user_id`, `checkin_date`),
|
||||
KEY `idx_user_id` (`user_id`),
|
||||
KEY `idx_checkin_date` (`checkin_date`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户签到记录表';
|
||||
|
||||
-- 插入默认运营设置
|
||||
INSERT INTO `p_operation_settings` (`key`, `value`, `description`, `created_on`, `updated_on`) VALUES
|
||||
('checkin_enabled', 'true', '签到功能是否启用', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
|
||||
('checkin_exp_range_min', '5', '签到最小经验值', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
|
||||
('checkin_exp_range_max', '15', '签到最大经验值', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
|
||||
('checkin_rank_length', '10', '签到排行榜显示人数', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
|
||||
('level_to_exp', '{"lv1":[0,100],"lv2":[101,300],"lv3":[301,600],"lv4":[601,1000],"lv5":[1001,1500]}', '经验-等级对应关系', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
-- 重新创建用户等级表
|
||||
CREATE TABLE IF NOT EXISTS `p_user_level` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`level` int(11) NOT NULL COMMENT '等级',
|
||||
`min_experience` int(11) NOT NULL COMMENT '最小经验值',
|
||||
`max_experience` int(11) NOT NULL COMMENT '最大经验值',
|
||||
`created_on` int(11) NOT NULL DEFAULT 0,
|
||||
`updated_on` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_level` (`level`),
|
||||
UNIQUE KEY `idx_min_experience` (`min_experience`),
|
||||
UNIQUE KEY `idx_max_experience` (`max_experience`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户等级配置表';
|
||||
|
||||
-- 插入初始等级数据
|
||||
INSERT INTO `p_user_level` (`level`, `min_experience`, `max_experience`, `created_on`, `updated_on`) VALUES
|
||||
(1, 0, 100, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
|
||||
(2, 101, 300, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
|
||||
(3, 301, 600, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
|
||||
(4, 601, 1000, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
|
||||
(5, 1001, 1500, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
|
||||
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
-- 删除用户等级表
|
||||
DROP TABLE IF EXISTS `p_user_level`;
|
||||
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
-- 删除长文章相关表
|
||||
|
||||
DROP TABLE IF EXISTS `p_article_comment_replies`;
|
||||
DROP TABLE IF EXISTS `p_article_comments`;
|
||||
DROP TABLE IF EXISTS `p_article_stars`;
|
||||
DROP TABLE IF EXISTS `p_article_collections`;
|
||||
DROP TABLE IF EXISTS `p_article_series_items`;
|
||||
DROP TABLE IF EXISTS `p_article_series`;
|
||||
DROP TABLE IF EXISTS `p_article_contents`;
|
||||
DROP TABLE IF EXISTS `p_articles`;
|
||||
@ -0,0 +1,4 @@
|
||||
-- 撤销用户拉黑和屏蔽功能相关表
|
||||
|
||||
DROP TABLE IF EXISTS `p_user_mutes`;
|
||||
DROP TABLE IF EXISTS `p_user_blocks`;
|
||||
@ -0,0 +1,33 @@
|
||||
-- 添加用户拉黑和屏蔽功能相关表
|
||||
|
||||
-- 用户拉黑表
|
||||
CREATE TABLE IF NOT EXISTS `p_user_blocks` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` bigint(20) NOT NULL COMMENT '发起拉黑的用户ID',
|
||||
`target_user_id` bigint(20) NOT NULL COMMENT '被拉黑的用户ID',
|
||||
`reason` varchar(500) DEFAULT '' COMMENT '拉黑原因',
|
||||
`created_on` int(11) NOT NULL DEFAULT 0,
|
||||
`modified_on` int(11) NOT NULL DEFAULT 0,
|
||||
`is_del` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_user_target` (`user_id`, `target_user_id`),
|
||||
KEY `idx_user_id` (`user_id`),
|
||||
KEY `idx_target_user_id` (`target_user_id`),
|
||||
KEY `idx_created_on` (`created_on`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户拉黑表';
|
||||
|
||||
-- 用户屏蔽表
|
||||
CREATE TABLE IF NOT EXISTS `p_user_mutes` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` bigint(20) NOT NULL COMMENT '发起屏蔽的用户ID',
|
||||
`target_user_id` bigint(20) NOT NULL COMMENT '被屏蔽的用户ID',
|
||||
`reason` varchar(500) DEFAULT '' COMMENT '屏蔽原因',
|
||||
`created_on` int(11) NOT NULL DEFAULT 0,
|
||||
`modified_on` int(11) NOT NULL DEFAULT 0,
|
||||
`is_del` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_user_target` (`user_id`, `target_user_id`),
|
||||
KEY `idx_user_id` (`user_id`),
|
||||
KEY `idx_target_user_id` (`target_user_id`),
|
||||
KEY `idx_created_on` (`created_on`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户屏蔽表';
|
||||
@ -0,0 +1,12 @@
|
||||
-- 删除用户签到记录表
|
||||
DROP TABLE IF EXISTS "p_user_checkin";
|
||||
|
||||
-- 删除运营设置表
|
||||
DROP TABLE IF EXISTS "p_operation_settings";
|
||||
|
||||
-- 删除用户表的经验值字段
|
||||
ALTER TABLE "p_user" DROP COLUMN "experience";
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
-- 为用户表添加经验值字段
|
||||
ALTER TABLE "p_user" ADD COLUMN "experience" integer NOT NULL DEFAULT 0;
|
||||
|
||||
-- 创建运营设置表
|
||||
CREATE TABLE IF NOT EXISTS "p_operation_settings" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"key" varchar(255) NOT NULL UNIQUE,
|
||||
"value" text NOT NULL,
|
||||
"description" varchar(500),
|
||||
"created_on" integer NOT NULL DEFAULT 0,
|
||||
"updated_on" integer NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
-- 创建用户签到记录表
|
||||
CREATE TABLE IF NOT EXISTS "p_user_checkin" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"user_id" bigint NOT NULL,
|
||||
"checkin_date" date NOT NULL,
|
||||
"experience_gained" integer NOT NULL DEFAULT 0,
|
||||
"created_on" integer NOT NULL DEFAULT 0,
|
||||
"updated_on" integer NOT NULL DEFAULT 0,
|
||||
UNIQUE ("user_id", "checkin_date")
|
||||
);
|
||||
|
||||
-- 创建索引
|
||||
CREATE INDEX IF NOT EXISTS "idx_user_checkin_user_id" ON "p_user_checkin" ("user_id");
|
||||
CREATE INDEX IF NOT EXISTS "idx_user_checkin_checkin_date" ON "p_user_checkin" ("checkin_date");
|
||||
|
||||
-- 插入默认运营设置
|
||||
INSERT INTO "p_operation_settings" ("key", "value", "description", "created_on", "updated_on") VALUES
|
||||
('checkin_enabled', 'true', '签到功能是否启用', extract(epoch from now())::integer, extract(epoch from now())::integer),
|
||||
('checkin_exp_range_min', '5', '签到最小经验值', extract(epoch from now())::integer, extract(epoch from now())::integer),
|
||||
('checkin_exp_range_max', '15', '签到最大经验值', extract(epoch from now())::integer, extract(epoch from now())::integer),
|
||||
('checkin_rank_length', '10', '签到排行榜显示人数', extract(epoch from now())::integer, extract(epoch from now())::integer),
|
||||
('level_to_exp', '{"lv1":[0,100],"lv2":[101,300],"lv3":[301,600],"lv4":[601,1000],"lv5":[1001,1500]}', '经验-等级对应关系', extract(epoch from now())::integer, extract(epoch from now())::integer);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
-- 重新创建用户等级表
|
||||
CREATE TABLE IF NOT EXISTS "p_user_level" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"level" integer NOT NULL,
|
||||
"min_experience" integer NOT NULL,
|
||||
"max_experience" integer NOT NULL,
|
||||
"created_on" integer NOT NULL DEFAULT 0,
|
||||
"updated_on" integer NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
-- 创建索引
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "idx_user_level_level" ON "p_user_level" ("level");
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "idx_user_level_min_experience" ON "p_user_level" ("min_experience");
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "idx_user_level_max_experience" ON "p_user_level" ("max_experience");
|
||||
|
||||
-- 插入初始等级数据
|
||||
INSERT INTO "p_user_level" ("level", "min_experience", "max_experience", "created_on", "updated_on") VALUES
|
||||
(1, 0, 100, extract(epoch from now())::integer, extract(epoch from now())::integer),
|
||||
(2, 101, 300, extract(epoch from now())::integer, extract(epoch from now())::integer),
|
||||
(3, 301, 600, extract(epoch from now())::integer, extract(epoch from now())::integer),
|
||||
(4, 601, 1000, extract(epoch from now())::integer, extract(epoch from now())::integer),
|
||||
(5, 1001, 1500, extract(epoch from now())::integer, extract(epoch from now())::integer);
|
||||
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
-- 删除用户等级表
|
||||
DROP TABLE IF EXISTS "p_user_level";
|
||||
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
-- 撤销用户拉黑和屏蔽功能相关表
|
||||
|
||||
DROP TABLE IF EXISTS "p_user_mutes";
|
||||
DROP TABLE IF EXISTS "p_user_blocks";
|
||||
@ -0,0 +1,47 @@
|
||||
-- 添加用户拉黑和屏蔽功能相关表
|
||||
|
||||
-- 用户拉黑表
|
||||
CREATE TABLE IF NOT EXISTS "p_user_blocks" (
|
||||
"id" bigserial NOT NULL PRIMARY KEY,
|
||||
"user_id" bigint NOT NULL,
|
||||
"target_user_id" bigint NOT NULL,
|
||||
"reason" varchar(500) DEFAULT '',
|
||||
"created_on" integer NOT NULL DEFAULT 0,
|
||||
"modified_on" integer NOT NULL DEFAULT 0,
|
||||
"is_del" integer NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
-- 创建索引
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "uk_user_blocks_user_target" ON "p_user_blocks" ("user_id", "target_user_id");
|
||||
CREATE INDEX IF NOT EXISTS "idx_user_blocks_user_id" ON "p_user_blocks" ("user_id");
|
||||
CREATE INDEX IF NOT EXISTS "idx_user_blocks_target_user_id" ON "p_user_blocks" ("target_user_id");
|
||||
CREATE INDEX IF NOT EXISTS "idx_user_blocks_created_on" ON "p_user_blocks" ("created_on");
|
||||
|
||||
-- 添加注释
|
||||
COMMENT ON TABLE "p_user_blocks" IS '用户拉黑表';
|
||||
COMMENT ON COLUMN "p_user_blocks"."user_id" IS '发起拉黑的用户ID';
|
||||
COMMENT ON COLUMN "p_user_blocks"."target_user_id" IS '被拉黑的用户ID';
|
||||
COMMENT ON COLUMN "p_user_blocks"."reason" IS '拉黑原因';
|
||||
|
||||
-- 用户屏蔽表
|
||||
CREATE TABLE IF NOT EXISTS "p_user_mutes" (
|
||||
"id" bigserial NOT NULL PRIMARY KEY,
|
||||
"user_id" bigint NOT NULL,
|
||||
"target_user_id" bigint NOT NULL,
|
||||
"reason" varchar(500) DEFAULT '',
|
||||
"created_on" integer NOT NULL DEFAULT 0,
|
||||
"modified_on" integer NOT NULL DEFAULT 0,
|
||||
"is_del" integer NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
-- 创建索引
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "uk_user_mutes_user_target" ON "p_user_mutes" ("user_id", "target_user_id");
|
||||
CREATE INDEX IF NOT EXISTS "idx_user_mutes_user_id" ON "p_user_mutes" ("user_id");
|
||||
CREATE INDEX IF NOT EXISTS "idx_user_mutes_target_user_id" ON "p_user_mutes" ("target_user_id");
|
||||
CREATE INDEX IF NOT EXISTS "idx_user_mutes_created_on" ON "p_user_mutes" ("created_on");
|
||||
|
||||
-- 添加注释
|
||||
COMMENT ON TABLE "p_user_mutes" IS '用户屏蔽表';
|
||||
COMMENT ON COLUMN "p_user_mutes"."user_id" IS '发起屏蔽的用户ID';
|
||||
COMMENT ON COLUMN "p_user_mutes"."target_user_id" IS '被屏蔽的用户ID';
|
||||
COMMENT ON COLUMN "p_user_mutes"."reason" IS '屏蔽原因';
|
||||
@ -0,0 +1,39 @@
|
||||
-- 为用户表添加经验值字段
|
||||
ALTER TABLE p_user ADD COLUMN experience INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
-- 创建运营设置表
|
||||
CREATE TABLE IF NOT EXISTS p_operation_settings (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
key TEXT NOT NULL UNIQUE,
|
||||
value TEXT NOT NULL,
|
||||
description TEXT,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
updated_on INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
-- 创建用户签到记录表
|
||||
CREATE TABLE IF NOT EXISTS p_user_checkin (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
checkin_date TEXT NOT NULL,
|
||||
experience_gained INTEGER NOT NULL DEFAULT 0,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
updated_on INTEGER NOT NULL DEFAULT 0,
|
||||
UNIQUE(user_id, checkin_date)
|
||||
);
|
||||
|
||||
-- 创建索引
|
||||
CREATE INDEX IF NOT EXISTS idx_user_checkin_user_id ON p_user_checkin(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_user_checkin_checkin_date ON p_user_checkin(checkin_date);
|
||||
|
||||
-- 插入默认运营设置
|
||||
INSERT INTO p_operation_settings (key, value, description, created_on, updated_on) VALUES
|
||||
('checkin_enabled', 'true', '签到功能是否启用', strftime('%s', 'now'), strftime('%s', 'now')),
|
||||
('checkin_exp_range_min', '5', '签到最小经验值', strftime('%s', 'now'), strftime('%s', 'now')),
|
||||
('checkin_exp_range_max', '15', '签到最大经验值', strftime('%s', 'now'), strftime('%s', 'now')),
|
||||
('checkin_rank_length', '10', '签到排行榜显示人数', strftime('%s', 'now'), strftime('%s', 'now')),
|
||||
('level_to_exp', '{"lv1":[0,100],"lv2":[101,300],"lv3":[301,600],"lv4":[601,1000],"lv5":[1001,1500]}', '经验-等级对应关系', strftime('%s', 'now'), strftime('%s', 'now'));
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
-- 重新创建用户等级表
|
||||
CREATE TABLE IF NOT EXISTS p_user_level (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
level INTEGER NOT NULL,
|
||||
min_experience INTEGER NOT NULL,
|
||||
max_experience INTEGER NOT NULL,
|
||||
created_on INTEGER NOT NULL DEFAULT 0,
|
||||
updated_on INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
-- 创建索引
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_user_level_level ON p_user_level(level);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_user_level_min_experience ON p_user_level(min_experience);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_user_level_max_experience ON p_user_level(max_experience);
|
||||
|
||||
-- 插入初始等级数据
|
||||
INSERT INTO p_user_level (level, min_experience, max_experience, created_on, updated_on) VALUES
|
||||
(1, 0, 100, strftime('%s', 'now'), strftime('%s', 'now')),
|
||||
(2, 101, 300, strftime('%s', 'now'), strftime('%s', 'now')),
|
||||
(3, 301, 600, strftime('%s', 'now'), strftime('%s', 'now')),
|
||||
(4, 601, 1000, strftime('%s', 'now'), strftime('%s', 'now')),
|
||||
(5, 1001, 1500, strftime('%s', 'now'), strftime('%s', 'now'));
|
||||
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
-- 删除用户等级表
|
||||
DROP TABLE IF EXISTS p_user_level;
|
||||
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
-- 撤销用户拉黑和屏蔽功能相关表
|
||||
|
||||
DROP TABLE IF EXISTS `p_user_mutes`;
|
||||
DROP TABLE IF EXISTS `p_user_blocks`;
|
||||
@ -0,0 +1,35 @@
|
||||
-- 添加用户拉黑和屏蔽功能相关表
|
||||
|
||||
-- 用户拉黑表
|
||||
CREATE TABLE IF NOT EXISTS `p_user_blocks` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`target_user_id` INTEGER NOT NULL,
|
||||
`reason` TEXT DEFAULT '',
|
||||
`created_on` INTEGER NOT NULL DEFAULT 0,
|
||||
`modified_on` INTEGER NOT NULL DEFAULT 0,
|
||||
`is_del` INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
-- 创建索引
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS `uk_user_blocks_user_target` ON `p_user_blocks` (`user_id`, `target_user_id`);
|
||||
CREATE INDEX IF NOT EXISTS `idx_user_blocks_user_id` ON `p_user_blocks` (`user_id`);
|
||||
CREATE INDEX IF NOT EXISTS `idx_user_blocks_target_user_id` ON `p_user_blocks` (`target_user_id`);
|
||||
CREATE INDEX IF NOT EXISTS `idx_user_blocks_created_on` ON `p_user_blocks` (`created_on`);
|
||||
|
||||
-- 用户屏蔽表
|
||||
CREATE TABLE IF NOT EXISTS `p_user_mutes` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`target_user_id` INTEGER NOT NULL,
|
||||
`reason` TEXT DEFAULT '',
|
||||
`created_on` INTEGER NOT NULL DEFAULT 0,
|
||||
`modified_on` INTEGER NOT NULL DEFAULT 0,
|
||||
`is_del` INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
-- 创建索引
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS `uk_user_mutes_user_target` ON `p_user_mutes` (`user_id`, `target_user_id`);
|
||||
CREATE INDEX IF NOT EXISTS `idx_user_mutes_user_id` ON `p_user_mutes` (`user_id`);
|
||||
CREATE INDEX IF NOT EXISTS `idx_user_mutes_target_user_id` ON `p_user_mutes` (`target_user_id`);
|
||||
CREATE INDEX IF NOT EXISTS `idx_user_mutes_created_on` ON `p_user_mutes` (`created_on`);
|
||||
Loading…
Reference in new issue