@@ -0,0 +1,58 @@
|
||||
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, "")
|
||||
}
|
||||
Reference in New Issue
Block a user