fix(meter):终端用户表计档案完成查询调整。
This commit is contained in:
parent
ed83fbc77c
commit
01953132ca
|
@ -2,6 +2,7 @@ package controller
|
|||
|
||||
import (
|
||||
"electricity_bill_calc/excel"
|
||||
"electricity_bill_calc/logger"
|
||||
"electricity_bill_calc/model"
|
||||
"electricity_bill_calc/response"
|
||||
"electricity_bill_calc/security"
|
||||
|
@ -14,6 +15,7 @@ import (
|
|||
"github.com/jinzhu/copier"
|
||||
"github.com/samber/lo"
|
||||
"github.com/shopspring/decimal"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func InitializeMeter04kVController(router *gin.Engine) {
|
||||
|
@ -149,6 +151,7 @@ func modifySingle04kVMeter(c *gin.Context) {
|
|||
formData := new(_MeterModificationFormData)
|
||||
c.BindJSON(formData)
|
||||
copier.Copy(meterDetail, formData)
|
||||
logger.Named("Controller", "Meter").Debug("Check #1", zap.Any("meter", meterDetail))
|
||||
err = service.Meter04kVService.UpdateSingleMeter(meterDetail)
|
||||
if err != nil {
|
||||
result.Error(http.StatusInternalServerError, err.Error())
|
||||
|
|
|
@ -19,9 +19,9 @@ type Meter04KV struct {
|
|||
ContactPhone *string `json:"contactPhone" excel:"phone"`
|
||||
Ratio decimal.Decimal `bun:",notnull,default:1" json:"ratio" excel:"ratio"`
|
||||
Seq int64 `bun:"type:bigint,notnull" json:"seq" excel:"seq"`
|
||||
IsPublicMeter bool `bun:"public_meter,notnull,default:false" json:"isPublicMeter" excel:"public"`
|
||||
WillDilute bool `bun:"dilute,notnull,default:false" json:"willDilute" excel:"dilute"`
|
||||
Enabled bool `bun:",notnull,default:true" json:"enabled"`
|
||||
IsPublicMeter bool `bun:"public_meter,notnull" json:"isPublicMeter" excel:"public"`
|
||||
WillDilute bool `bun:"dilute,notnull" json:"willDilute" excel:"dilute"`
|
||||
Enabled bool `bun:",notnull" json:"enabled"`
|
||||
ParkDetail *Park `bun:"rel:belongs-to,join:park_id=id" json:"-"`
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ func (_Meter04kVService) Get04kVMeterDetail(park, code string) (*model.Meter04KV
|
|||
var meter = new(model.Meter04KV)
|
||||
ctx, cancel := global.TimeoutContext()
|
||||
defer cancel()
|
||||
err := global.DB.NewSelect().Model(&meter).
|
||||
err := global.DB.NewSelect().Model(meter).
|
||||
Where("code = ?", code).
|
||||
Where("park_id = ?", park).
|
||||
Scan(ctx)
|
||||
|
@ -101,7 +101,7 @@ func (_Meter04kVService) insertNewMeter(tx *bun.Tx, ctx *context.Context, meter
|
|||
}
|
||||
|
||||
func (_Meter04kVService) updateMeter(tx *bun.Tx, ctx *context.Context, meter model.Meter04KV) error {
|
||||
_, err := tx.NewUpdate().Model(meter).
|
||||
_, err := tx.NewUpdate().Model(&meter).
|
||||
Where("code = ?", meter.Code).
|
||||
Where("park_id = ?", meter.ParkId).
|
||||
Column("address", "customer_name", "contact_name", "contact_phone", "ratio", "seq", "public_meter", "dilute", "enabled").
|
||||
|
|
Loading…
Reference in New Issue
Block a user