完成获取系统基准线损率功能
This commit is contained in:
parent
251c44049a
commit
39e404451e
|
@ -36,12 +36,18 @@ type ServiceSetting struct {
|
||||||
HostSerial int64
|
HostSerial int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//读取基准线损率
|
||||||
|
type BaseLossSetting struct {
|
||||||
|
Base string
|
||||||
|
}
|
||||||
|
|
||||||
// 定义全局变量
|
// 定义全局变量
|
||||||
var (
|
var (
|
||||||
ServerSettings *ServerSetting
|
ServerSettings *ServerSetting
|
||||||
DatabaseSettings *DatabaseSetting
|
DatabaseSettings *DatabaseSetting
|
||||||
RedisSettings *RedisSetting
|
RedisSettings *RedisSetting
|
||||||
ServiceSettings *ServiceSetting
|
ServiceSettings *ServiceSetting
|
||||||
|
BaseLoss *BaseLossSetting
|
||||||
)
|
)
|
||||||
|
|
||||||
// 读取配置到全局变量
|
// 读取配置到全局变量
|
||||||
|
@ -69,5 +75,10 @@ func SetupSetting() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = s.ReadSection("BaselineLineLossRatio", &BaseLoss)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
24
controller/foundation.go
Normal file
24
controller/foundation.go
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"electricity_bill_calc/config"
|
||||||
|
"electricity_bill_calc/logger"
|
||||||
|
"electricity_bill_calc/response"
|
||||||
|
"electricity_bill_calc/security"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var foundLog = logger.Named("Handler", "Foundation")
|
||||||
|
|
||||||
|
func InitializeFoundationHandlers(router *fiber.App) {
|
||||||
|
router.Get("/norm/authorized/loss/rate", security.MustAuthenticated, getNormAuthorizedLossRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getNormAuthorizedLossRate(c *fiber.Ctx) error {
|
||||||
|
foundLog.Info("获取系统中定义的基准核定线损率")
|
||||||
|
result := response.NewResult(c)
|
||||||
|
BaseLoss := config.BaseLoss
|
||||||
|
return result.Success("已经获取到系统设置的基准核定线损率。",
|
||||||
|
fiber.Map{"normAuthorizedLossRate": BaseLoss},
|
||||||
|
)
|
||||||
|
}
|
|
@ -56,6 +56,7 @@ func App() *fiber.App {
|
||||||
|
|
||||||
|
|
||||||
controller.InitializeWithdrawHandlers(app)
|
controller.InitializeWithdrawHandlers(app)
|
||||||
|
controller.InitializeFoundationHandlers(app)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,3 +21,5 @@ Service:
|
||||||
ItemsPageSize: 20
|
ItemsPageSize: 20
|
||||||
CacheLifeTime: 5m
|
CacheLifeTime: 5m
|
||||||
HostSerial: 5
|
HostSerial: 5
|
||||||
|
BaselineLineLossRatio:
|
||||||
|
Base: 基准线损率
|
Loading…
Reference in New Issue
Block a user