69 lines
2.5 KiB
Go
69 lines
2.5 KiB
Go
package controllers
|
|
|
|
import (
|
|
"github.com/astaxie/beego"
|
|
|
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
|
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/teleinfo"
|
|
)
|
|
|
|
//——————————————————————————————————————————————————————————————————————————————
|
|
// AddTeleinfoController
|
|
//——————————————————————————————————————————————————————————————————————————————
|
|
type AddTeleinfoController struct {
|
|
beego.Controller
|
|
}
|
|
|
|
func (c *AddTeleinfoController) Prepare() {
|
|
c.Data["version"] = variables.Version
|
|
}
|
|
|
|
func (c *AddTeleinfoController) Get() {
|
|
adresse := c.GetString(teleinfo.AdresseCompteur)
|
|
tarif := c.GetString(teleinfo.OptionTarifaire)
|
|
option := c.GetString(teleinfo.OptionBase)
|
|
hp, _ := c.GetInt(teleinfo.HeurePleinne)
|
|
hc, _ := c.GetInt(teleinfo.HeureCreuse)
|
|
|
|
teleinfo.AddData(adresse, tarif, option, int64(hp), int64(hc))
|
|
|
|
cpt := teleinfo.GetCompteurByAdresse(adresse)
|
|
if cpt == nil || cpt.Id == 0 {
|
|
teleinfo.AddCompteur(adresse)
|
|
}
|
|
c.Ctx.Output.Body([]byte(""))
|
|
}
|
|
|
|
|
|
|
|
//——————————————————————————————————————————————————————————————————————————————
|
|
// ViewTeleinfoController
|
|
//——————————————————————————————————————————————————————————————————————————————
|
|
type ViewTeleinfoController struct {
|
|
beego.Controller
|
|
}
|
|
|
|
func (c *ViewTeleinfoController) Prepare() {
|
|
c.Data["IsViewTeleinfo"] = true
|
|
c.Data["version"] = variables.Version
|
|
}
|
|
|
|
func (c *ViewTeleinfoController) Get() {
|
|
c.Data["compteurs"] = teleinfo.GetAllCompteur()
|
|
|
|
adresse := c.Ctx.Input.Param(":compteur")
|
|
cpt := teleinfo.GetCompteurByAdresse(adresse)
|
|
if cpt.Id != 0 {
|
|
c.Data["isCompteurSelected"] = true
|
|
c.Data["dataCompteur"] = teleinfo.GetLastDataForCompteur(cpt.AdresseCompteur)
|
|
c.Data["compteurAdresse"] = cpt.AdresseCompteur
|
|
if cpt.Description != "" {
|
|
c.Data["compteurDescription"] = cpt.Description
|
|
} else {
|
|
c.Data["compteurDescription"] = cpt.AdresseCompteur
|
|
}
|
|
}
|
|
|
|
c.TplNames = "teleinfo.tpl"
|
|
}
|