|
@@ -18,15 +18,15 @@ import (
|
|
|
|
|
|
type Site struct {
|
|
type Site struct {
|
|
*xweb.Action
|
|
*xweb.Action
|
|
- loadIndex xweb.Mapper `xweb:"/center/site/sitelist"` //控制中心
|
|
|
|
|
|
+ siteList xweb.Mapper `xweb:"/center/site/sitelist"` //控制中心
|
|
saveSite xweb.Mapper `xweb:"/center/site/savesite"` //新增站点
|
|
saveSite xweb.Mapper `xweb:"/center/site/savesite"` //新增站点
|
|
importFile xweb.Mapper `xweb:"/center/site/importfile"` //导入站点
|
|
importFile xweb.Mapper `xweb:"/center/site/importfile"` //导入站点
|
|
deleteSite xweb.Mapper `xweb:"/center/site/delete"` //删除站点
|
|
deleteSite xweb.Mapper `xweb:"/center/site/delete"` //删除站点
|
|
- getLuas xweb.Mapper `xweb:"/center/site/getluas/(.*)"` //删除站点
|
|
|
|
- getLuasBySite xweb.Mapper `xweb:"/center/site/getluasbysite"` //删除站点
|
|
|
|
|
|
+ getLuas xweb.Mapper `xweb:"/center/site/getluas/(.*)"` //
|
|
|
|
+ getLuasBySite xweb.Mapper `xweb:"/center/site/getluasbysite"` //
|
|
}
|
|
}
|
|
|
|
|
|
-func (s *Site) LoadIndex() {
|
|
|
|
|
|
+func (s *Site) SiteList() {
|
|
if s.Method() == "POST" {
|
|
if s.Method() == "POST" {
|
|
platform := s.GetString("platform")
|
|
platform := s.GetString("platform")
|
|
event := s.GetString("event")
|
|
event := s.GetString("event")
|
|
@@ -68,7 +68,8 @@ func (s *Site) LoadIndex() {
|
|
sort = fmt.Sprintf(sort, orderName, orderType)
|
|
sort = fmt.Sprintf(sort, orderName, orderType)
|
|
sites, _ := util.MgoE.Find(sp.Config.SiteColl, query, sort, ``, false, start, limit)
|
|
sites, _ := util.MgoE.Find(sp.Config.SiteColl, query, sort, ``, false, start, limit)
|
|
count := util.MgoE.Count(sp.Config.SiteColl, query)
|
|
count := util.MgoE.Count(sp.Config.SiteColl, query)
|
|
- for _, s := range *sites {
|
|
|
|
|
|
+ for k, s := range *sites {
|
|
|
|
+ s["num"] = k + 1 + start
|
|
remarktime := qu.Int64All(s["remarktime"])
|
|
remarktime := qu.Int64All(s["remarktime"])
|
|
s["remarktime"] = qu.FormatDateByInt64(&remarktime, qu.Date_Full_Layout)
|
|
s["remarktime"] = qu.FormatDateByInt64(&remarktime, qu.Date_Full_Layout)
|
|
}
|
|
}
|
|
@@ -79,6 +80,11 @@ func (s *Site) LoadIndex() {
|
|
events = append(events, k)
|
|
events = append(events, k)
|
|
}
|
|
}
|
|
sort.Strings(events)
|
|
sort.Strings(events)
|
|
|
|
+ //向web页面传递模板方法
|
|
|
|
+ // funcMap := template.FuncMap{"test": func(events []string) string { return strings.Join(events, ",") }}
|
|
|
|
+ // s.App.FuncMaps = funcMap
|
|
|
|
+ //向页面传递cookie
|
|
|
|
+ //s.SetCookie(&http.Cookie{Name: "testcookie", Value: "testcookie1"})
|
|
s.T["events"] = events
|
|
s.T["events"] = events
|
|
s.T["sitetypes"] = sp.Config.SiteType
|
|
s.T["sitetypes"] = sp.Config.SiteType
|
|
s.T["areas"] = util.Area
|
|
s.T["areas"] = util.Area
|
|
@@ -106,10 +112,15 @@ func (s *Site) SaveSite() {
|
|
sitetype := s.GetString("sitetype")
|
|
sitetype := s.GetString("sitetype")
|
|
psite := s.GetString("psite")
|
|
psite := s.GetString("psite")
|
|
ssite := s.GetString("ssite")
|
|
ssite := s.GetString("ssite")
|
|
- tmpdomain, status, event, platform, remarktime := util.GetLuasInfoBySite(site)
|
|
|
|
|
|
+ tmpdomain, status, event, platform, tmparea, tmpcity, tmpdistrict, remarktime := util.GetLuasInfoBySite(site)
|
|
if domain == "" {
|
|
if domain == "" {
|
|
domain = tmpdomain
|
|
domain = tmpdomain
|
|
}
|
|
}
|
|
|
|
+ if area == "" {
|
|
|
|
+ area = tmparea
|
|
|
|
+ city = tmpcity
|
|
|
|
+ district = tmpdistrict
|
|
|
|
+ }
|
|
update := map[string]interface{}{
|
|
update := map[string]interface{}{
|
|
"site": site,
|
|
"site": site,
|
|
"another_name": othername,
|
|
"another_name": othername,
|
|
@@ -173,10 +184,15 @@ func (s *Site) ImportFile() {
|
|
site_type := r.Cells[7].Value
|
|
site_type := r.Cells[7].Value
|
|
p_site := r.Cells[8].Value
|
|
p_site := r.Cells[8].Value
|
|
s_site := r.Cells[9].Value
|
|
s_site := r.Cells[9].Value
|
|
- tmpdomain, status, event, platform, remarktime := util.GetLuasInfoBySite(site)
|
|
|
|
|
|
+ tmpdomain, status, event, platform, tmparea, tmpcity, tmpdistrict, remarktime := util.GetLuasInfoBySite(site)
|
|
if domain == "" {
|
|
if domain == "" {
|
|
domain = tmpdomain
|
|
domain = tmpdomain
|
|
}
|
|
}
|
|
|
|
+ if area == "" {
|
|
|
|
+ area = tmparea
|
|
|
|
+ city = tmpcity
|
|
|
|
+ district = tmpdistrict
|
|
|
|
+ }
|
|
save := map[string]interface{}{
|
|
save := map[string]interface{}{
|
|
"site": site,
|
|
"site": site,
|
|
"another_name": another_name,
|
|
"another_name": another_name,
|
|
@@ -206,18 +222,26 @@ func (s *Site) ImportFile() {
|
|
|
|
|
|
func (s *Site) DeleteSite() {
|
|
func (s *Site) DeleteSite() {
|
|
defer qu.Catch()
|
|
defer qu.Catch()
|
|
- id := s.GetString("id")
|
|
|
|
- set := map[string]interface{}{
|
|
|
|
- "$set": map[string]interface{}{
|
|
|
|
- "delete": true,
|
|
|
|
- "deletetime": time.Now().Unix(),
|
|
|
|
- },
|
|
|
|
|
|
+ ids := s.GetString("id")
|
|
|
|
+ arr := [][]map[string]interface{}{}
|
|
|
|
+ for _, id := range strings.Split(ids, ",") {
|
|
|
|
+ update := []map[string]interface{}{
|
|
|
|
+ map[string]interface{}{"_id": mgo.StringTOBsonId(id)},
|
|
|
|
+ map[string]interface{}{
|
|
|
|
+ "$set": map[string]interface{}{
|
|
|
|
+ "delete": true,
|
|
|
|
+ "deletetime": time.Now().Unix(),
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ arr = append(arr, update)
|
|
}
|
|
}
|
|
- if util.MgoE.UpdateById(sp.Config.SiteColl, id, set) {
|
|
|
|
|
|
+ if util.MgoE.UpdateBulk(sp.Config.SiteColl, arr...) {
|
|
s.ServeJson(map[string]interface{}{"d": true})
|
|
s.ServeJson(map[string]interface{}{"d": true})
|
|
} else {
|
|
} else {
|
|
s.ServeJson(map[string]interface{}{"d": false})
|
|
s.ServeJson(map[string]interface{}{"d": false})
|
|
}
|
|
}
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
func (s *Site) GetLuas(site string) {
|
|
func (s *Site) GetLuas(site string) {
|