93 lines
3.0 KiB
Go
93 lines
3.0 KiB
Go
package logic
|
|
|
|
import (
|
|
"service/api/consts"
|
|
account_cancellationproto "service/api/proto/account_cancellation/proto"
|
|
"service/app/mix/dao"
|
|
"service/dbstruct"
|
|
"service/library/idgenerator"
|
|
"service/library/logger"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
goproto "google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
type AccountCancellation struct {
|
|
store *dao.Store
|
|
}
|
|
|
|
func NewAccountCancellation(store *dao.Store) (a *AccountCancellation) {
|
|
a = &AccountCancellation{
|
|
store: store,
|
|
}
|
|
return
|
|
}
|
|
|
|
func (p *AccountCancellation) OpCreate(ctx *gin.Context, req *account_cancellationproto.OpCreateReq) error {
|
|
req.AccountCancellation.Id = goproto.Int64(idgenerator.GenAccountCancellationId())
|
|
req.AccountCancellation.Ct = goproto.Int64(time.Now().Unix())
|
|
req.AccountCancellation.Ut = goproto.Int64(time.Now().Unix())
|
|
req.AccountCancellation.DelFlag = goproto.Int64(consts.Exist)
|
|
err := p.store.CreateAccountCancellation(ctx, req.AccountCancellation)
|
|
if err != nil {
|
|
logger.Error("CreateAccountCancellation fail, err: %v", err)
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *AccountCancellation) OpUpdateByMidAndStatus(ctx *gin.Context, req *account_cancellationproto.OpUpdateReq, status int64) error {
|
|
err := p.store.UpdateAccountCancellationByMidAndStatus(ctx, req.AccountCancellation, status)
|
|
if err != nil {
|
|
logger.Error("UpdateAccountCancellationByMidAndStatus fail, err: %v", err)
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *AccountCancellation) OpUpdateByDuetimeAndStatus(ctx *gin.Context, req *account_cancellationproto.OpUpdateReq, duetime int64, status int64) error {
|
|
err := p.store.UpdateAccountCancellationByDuetimeAndStatus(ctx, req.AccountCancellation, duetime, status)
|
|
if err != nil {
|
|
logger.Error("UpdateAccountCancellationByDueTimeAndStatus fail, err: %v", err)
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *AccountCancellation) OpUpdateByIds(ctx *gin.Context, req *account_cancellationproto.OpUpdateReq, ids []int64) error {
|
|
err := p.store.UpdateAccountCancellationByIds(ctx, req.AccountCancellation, ids)
|
|
if err != nil {
|
|
logger.Error("UpdateAccountCancellationByDueTimeAndStatus fail, err: %v", err)
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *AccountCancellation) OpDelete(ctx *gin.Context, id int64) error {
|
|
err := p.store.DeleteAccountCancellation(ctx, id)
|
|
if err != nil {
|
|
logger.Error("DeleteAccountCancellation fail, err: %v", err)
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *AccountCancellation) OpList(ctx *gin.Context, req *account_cancellationproto.OpListReq) ([]*dbstruct.AccountCancellation, error) {
|
|
list, err := p.store.GetAccountCancellationList(ctx, req)
|
|
if err != nil {
|
|
logger.Error("GetAccountCancellationList fail, err: %v", err)
|
|
return make([]*dbstruct.AccountCancellation, 0), err
|
|
}
|
|
return list, nil
|
|
}
|
|
|
|
func (p *AccountCancellation) OpListByMid(ctx *gin.Context, req *account_cancellationproto.OpListByMidReq) (*dbstruct.AccountCancellation, error) {
|
|
accountCancellation, err := p.store.GetAccountCancellationListByMid(ctx, req)
|
|
if err != nil {
|
|
logger.Error("GetAccountCancellationListByMid fail, err: %v", err)
|
|
return nil, err
|
|
}
|
|
return accountCancellation, nil
|
|
}
|