59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
package withdrawctrl
|
|
|
|
import (
|
|
"91porn-server/common"
|
|
"91porn-server/common/stderr"
|
|
"91porn-server/models/v/txnactmod"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
func FindAct(ctx *gin.Context) {
|
|
q := txnactmod.Query{}
|
|
if err := ctx.ShouldBind(&q); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
|
return
|
|
}
|
|
infos, err := txnactmod.FindMany(q)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, stderr.Success, infos)
|
|
}
|
|
|
|
func EditAct(ctx *gin.Context) {
|
|
var p struct {
|
|
ID primitive.ObjectID `json:"id"`
|
|
txnactmod.TransactionActSelector
|
|
}
|
|
if err := ctx.ShouldBind(&p); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
|
|
|
return
|
|
}
|
|
c, err := txnactmod.Update(p.ID, &p.TransactionActSelector)
|
|
if err != nil || c < 0 {
|
|
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, stderr.Success, "")
|
|
}
|
|
|
|
func DelAct(ctx *gin.Context) {
|
|
var p struct {
|
|
ID primitive.ObjectID `json:"id"`
|
|
}
|
|
if err := ctx.ShouldBind(&p); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
|
return
|
|
}
|
|
c, err := txnactmod.DeleteByID(p.ID)
|
|
if err != nil || c < 0 {
|
|
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, stderr.Success, "")
|
|
}
|