// 获取站点配置 func (this *partnerRep) GetSiteConf(partnerId int) *partner.SiteConf { var siteConf partner.SiteConf if err := this.Connector.GetOrm().Get(partnerId, &siteConf); err == nil { if len(siteConf.Host) == 0 { var usr string this.Connector.ExecScalar( `SELECT usr FROM pt_partner WHERE id=?`, &usr, partnerId) siteConf.Host = fmt.Sprintf("%s.%s", usr, infrastructure.GetApp().Config(). GetString(variable.ServerDomain)) } return &siteConf } return nil }
func (this *partnerRep) SaveSiteConf(partnerId int, v *partner.SiteConf) error { defer this.renew(v.PartnerId) var err error if v.PartnerId > 0 { _, _, err = this.Connector.GetOrm().Save(v.PartnerId, v) } else { v.PartnerId = partnerId _, _, err = this.Connector.GetOrm().Save(nil, v) } return err }
func (this *configC) SiteConf_post(ctx *web.Context) { partnerId := this.GetPartnerId(ctx) r, w := ctx.Request, ctx.ResponseWriter var result gof.Message r.ParseForm() e := partner.SiteConf{} web.ParseFormToEntity(r.Form, &e) //更新 origin := dps.PartnerService.GetSiteConf(partnerId) e.Host = origin.Host e.PartnerId = partnerId err := dps.PartnerService.SaveSiteConf(partnerId, &e) if err != nil { result = gof.Message{Result: false, Message: err.Error()} } else { result = gof.Message{Result: true, Message: ""} } w.Write(result.Marshal()) }