-
Notifications
You must be signed in to change notification settings - Fork 0
/
coverage_area_c.go
47 lines (39 loc) · 1.07 KB
/
coverage_area_c.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package partner
import (
"github.com/jsix/gof"
"github.com/jsix/gof/web"
"go2o/src/core/domain/interface/delivery"
"go2o/src/core/service/dps"
"go2o/src/x/echox"
"html/template"
"net/http"
)
type coverageAreaC struct {
}
func (this *coverageAreaC) CoverageAreList(ctx *echox.Context) error {
d := ctx.NewData()
return ctx.RenderOK("delivery.coverage_area_list.html", d)
}
func (this *coverageAreaC) Create(ctx *echox.Context) error {
d := ctx.NewData()
d.Map["entity"] = template.JS("{}")
return ctx.RenderOK("delivery.create_area.html", d)
}
// 保存配送区域(POST)
func (this *coverageAreaC) SaveArea(ctx *echox.Context) error {
r := ctx.HttpRequest()
if r.Method == "POST" {
var result gof.Message
r.ParseForm()
coverageArea := delivery.CoverageValue{}
web.ParseFormToEntity(r.Form, &coverageArea)
id, err := dps.DeliverService.CreateCoverageArea(&coverageArea)
if err != nil {
result = gof.Message{Message: err.Error()}
} else {
result = gof.Message{Result: true, Message: "", Data: id}
}
return ctx.JSON(http.StatusOK, result)
}
return nil
}