作者 唐旭辉

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into dev

@@ -18,8 +18,28 @@ type BaseController struct { @@ -18,8 +18,28 @@ type BaseController struct {
18 beego.Controller 18 beego.Controller
19 } 19 }
20 20
  21 +func (this *BaseController) Options() {
  22 + this.AllowCross() //允许跨域
  23 + this.Data["json"] = map[string]interface{}{"status": 204, "message": "ok", "moreinfo": ""}
  24 + this.ServeJSON()
  25 +}
  26 +
  27 +func (this *BaseController) AllowCross() {
  28 + this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
  29 + this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
  30 + this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*")
  31 + //this.Ctx.WriteString("")
  32 +}
  33 +
21 //Prepare 实现beego.ControllerInterface 的接口 34 //Prepare 实现beego.ControllerInterface 的接口
22 func (this *BaseController) Prepare() { 35 func (this *BaseController) Prepare() {
  36 + this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
  37 + this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*")
  38 + if this.Ctx.Input.Method() == "OPTIONS" {
  39 + this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
  40 + //this.Ctx.WriteString("")
  41 + return
  42 + }
23 p := this.Ctx.Input.GetData("RouterPattern") 43 p := this.Ctx.Input.GetData("RouterPattern")
24 fmt.Println("====>r:", p) 44 fmt.Println("====>r:", p)
25 } 45 }
@@ -13,7 +13,7 @@ const ( @@ -13,7 +13,7 @@ const (
13 /*BulletinRelease */ 13 /*BulletinRelease */
14 type BulletinReleaseRequest struct { 14 type BulletinReleaseRequest struct {
15 Id int `json:"id"` 15 Id int `json:"id"`
16 - Type int `json:"type" valid:"Required"` 16 + Type int `json:"type"`
17 Title string `json:"title" valid:"Required"` 17 Title string `json:"title" valid:"Required"`
18 Content string `json:"content" valid:"Required"` 18 Content string `json:"content" valid:"Required"`
19 AllowClose int `json:"allow_close"` 19 AllowClose int `json:"allow_close"`