forked from free-lancers/electricity_bill_calc_service
[天神模式]删除符合条件表计公摊关系完成
This commit is contained in:
@@ -175,3 +175,25 @@ func (gm _GMService) DeleteEnterprises(uid string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gm _GMService) DeleteMeterPooling(pId string, mId []string) error {
|
||||
ctx, cancel := global.TimeoutContext()
|
||||
defer cancel()
|
||||
tx, err := global.DB.Begin(ctx)
|
||||
if err != nil {
|
||||
gm.l.Error("开启数据库事务失败。", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
if err := repository.GMRepository.DeleteMeterPoolings(ctx, tx, pId, mId); err != nil {
|
||||
gm.l.Error("无法删除指定表记公摊关系。", zap.Error(err))
|
||||
tx.Rollback(ctx)
|
||||
return err
|
||||
}
|
||||
err = tx.Commit(ctx)
|
||||
if err != nil {
|
||||
gm.l.Error("未能成功提交数据库事务。", zap.Error(err))
|
||||
tx.Rollback(ctx)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user