forked from free-lancers/electricity_bill_calc_service
完成获取当前系统中待审核的内容数量功能
This commit is contained in:
39
service/withdraw.go
Normal file
39
service/withdraw.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"electricity_bill_calc/global"
|
||||
"electricity_bill_calc/logger"
|
||||
"electricity_bill_calc/model"
|
||||
"github.com/doug-martin/goqu/v9"
|
||||
"github.com/georgysavva/scany/v2/pgxscan"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type _WithdrawService struct {
|
||||
log *zap.Logger
|
||||
ds goqu.DialectWrapper
|
||||
}
|
||||
|
||||
var WithdrawService = _WithdrawService{
|
||||
logger.Named("Service", "Withdraw"),
|
||||
goqu.Dialect("postgres"),
|
||||
}
|
||||
|
||||
func (wd _WithdrawService) AuditWaits() (int64, error) {
|
||||
wd.log.Info("获取当前系统中待审核的内容数量。")
|
||||
ctx, cancel := global.TimeoutContext()
|
||||
defer cancel()
|
||||
|
||||
CountWithdrawQuery, CountWithdrawQueryArgs, _ := wd.ds.
|
||||
From(goqu.T("report")).
|
||||
Where(goqu.I("withdraw").Eq(model.REPORT_WITHDRAW_APPLYING)).
|
||||
Select(goqu.COUNT("*")).ToSQL()
|
||||
|
||||
var total int64
|
||||
err := pgxscan.Get(ctx, global.DB, &total, CountWithdrawQuery,CountWithdrawQueryArgs...)
|
||||
if err != nil {
|
||||
wd.log.Error("获取当前系统中待审核的内容数量出错。")
|
||||
return 0,err
|
||||
}
|
||||
return total,nil
|
||||
}
|
Reference in New Issue
Block a user