Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
package currencyser
import (
"91porn-server/common/stderr"
"91porn-server/models/v/currencymod"
)
// Add 新增裸聊资料
func Add(in *AddCond) stderr.Code {
// 插入数据库
n, err := in.Document()
if err != nil {
return stderr.ErrReqForbidden
}
if err := currencymod.Add(n); err != nil {
return stderr.ErrDbInsertError
}
return stderr.Success
}
// Edit 编辑裸聊资料
func Edit(in *EditCond) stderr.Code {
if err := currencymod.Edit(in.Cond(), in.Update()); err != nil {
return stderr.ErrDbUpdateError
}
return stderr.Success
}
// QueryAll 查询裸聊列表
func QueryAll(in *QueryAllCond) (interface{}, stderr.Code) {
var data = map[string]interface{}{
"data": []interface{}{},
"total": 0,
}
count, err := currencymod.QueryCount(in.Query())
if err != nil {
return data, stderr.ErrDbQueryError
}
if count == 0 {
return data, stderr.Success
}
data["total"] = count
list, err := currencymod.QueryAll(in.Query(), in.Options())
if err != nil {
return data, stderr.ErrDbQueryError
}
data["data"] = list
return data, stderr.Success
}
+135
View File
@@ -0,0 +1,135 @@
package currencyser
import (
"encoding/json"
"fmt"
"time"
"91porn-server/common/log"
"91porn-server/models/commod"
"91porn-server/models/v/currencymod"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo/options"
)
type AddCond struct {
Name string `json:"name"` //货币名称
Type commod.CurrencyType `json:"type"` //货币类型
Coins int64 `json:"coins"` //购买货币数
Price int64 `json:"price"` //价格 单位:元
CouponDesc string `json:"couponDesc"` //优惠描述
GiveVipDays int `json:"giveVipDays"` //赠送vip天数
LouFengUnlockTimes int `json:"louFengUnlockTimes"` //赠送楼凤解锁次数
GiveGameCoin int64 `json:"giveGameCoin"` //赠送游戏金币
GiveFruitCoin int64 `json:"giveFruitCoin"` //赠送果币
GiveGold int64 `json:"giveGold"` //赠送金币
FirstGiveVipDays int `json:"firstGiveVipDays"` //首次赠送vip天数
FirstGiveGameCoin int64 `json:"firstGiveGameCoin"` //首次赠送游戏金币
NotFirst bool `json:"notFirst"` //非首充依然赠送
Active bool `json:"active"` //是否激活
}
func (cond *AddCond) Document() (interface{}, error) {
data, err := json.Marshal(&cond)
if err != nil {
log.Error(fmt.Sprintf("新增裸聊json序列化异常[%v]", err))
return nil, err
}
var n currencymod.Currency
if err = json.Unmarshal(data, &n); err != nil {
log.Error(fmt.Sprintf("新增裸聊json反序列化异常[%v]", err))
return nil, err
}
n.CreatedAt = time.Now()
n.UpdatedAt = time.Now()
return n, nil
}
type EditCond struct {
ID primitive.ObjectID `json:"id" binding:"required"` //裸聊ID
Name *string `json:"name"` //货币名称
Type *commod.CurrencyType `json:"type"` //货币类型
Coins *int64 `json:"coins"` //购买货币数
Price *int64 `json:"price"` //价格 单位:元
CouponDesc *string `json:"couponDesc"` //优惠描述
GiveVipDays *int `json:"giveVipDays"` //赠送vip天数
LouFengUnlockTimes *int `json:"louFengUnlockTimes"` //赠送楼凤解锁次数
GiveGold *int64 `json:"giveGold"` //赠送金币
GiveGameCoin *int64 `json:"giveGameCoin"` //赠送游戏金币
GiveFruitCoin *int64 `json:"giveFruitCoin"` //赠送果币
NotFirst *bool `json:"notFirst"` //非首充依然赠送
IsActive *bool `json:"isActive"` //是否激活
FirstGiveVipDays *int `json:"firstGiveVipDays" bson:"firstGiveVipDays"` //首次赠送vip天数
FirstGiveGameCoin *int64 `json:"firstGiveGameCoin" bson:"firstGiveGameCoin"` //首次赠送游戏金币
}
func (cond *EditCond) Cond() primitive.M {
return bson.M{"_id": cond.ID}
}
func (cond *EditCond) Update() primitive.M {
var update = bson.M{}
if cond.Name != nil {
update["name"] = cond.Name
}
if cond.Type != nil {
update["type"] = cond.Type
}
if cond.Coins != nil {
update["coins"] = cond.Coins
}
if cond.Price != nil {
update["price"] = cond.Price
}
if cond.CouponDesc != nil {
update["couponDesc"] = cond.CouponDesc
}
if cond.GiveVipDays != nil {
update["giveVipDays"] = cond.GiveVipDays
}
if cond.LouFengUnlockTimes != nil {
update["louFengUnlockTimes"] = cond.LouFengUnlockTimes
}
if cond.GiveGold != nil {
update["giveGold"] = cond.GiveGold
}
if cond.GiveGameCoin != nil {
update["giveGameCoin"] = cond.GiveGameCoin
}
if cond.GiveFruitCoin != nil {
update["giveFruitCoin"] = cond.GiveFruitCoin
}
if cond.NotFirst != nil {
update["notFirst"] = cond.NotFirst
}
if cond.IsActive != nil {
update["isActive"] = cond.IsActive
}
if cond.FirstGiveVipDays != nil {
update["firstGiveVipDays"] = cond.FirstGiveVipDays
}
if cond.FirstGiveGameCoin != nil {
update["firstGiveGameCoin"] = cond.FirstGiveGameCoin
}
return bson.M{"$set": update}
}
type QueryAllCond struct {
IsActive *bool `form:"isActive"` //是否激活
Type commod.CurrencyType `form:"type" binding:"required"` //货币类型
Page commod.Page
}
func (cond *QueryAllCond) Query() primitive.M {
var query = bson.M{"type": cond.Type}
if cond.IsActive != nil {
query["isActive"] = cond.IsActive
}
return query
}
func (cond *QueryAllCond) Options() *options.FindOptions {
return options.Find().SetLimit(int64(cond.Page.Limit())).SetSkip(int64(cond.Page.Skip())).SetSort(bson.D{{Key: "coins", Value: 1}})
}