123456789101112131415161718192021222324252627282930313233343536373839 |
- package controllers
- import (
- "TripUpRate/g"
- "TripUpRate/models"
- "encoding/json"
- beego "github.com/beego/beego/v2/server/web"
- "time"
- )
- type GetUpRateController struct {
- beego.Controller
- }
- func (c *GetUpRateController) Post() {
- parm := g.TaskInfo{}
- data := c.Ctx.Input.RequestBody
- err := json.Unmarshal(data, &parm)
- if err != nil {
- c.Data["json"] = models.Res{
- Code: 1,
- Msg: "参数效验错误",
- }
- } else {
- parm.Enddate = time.Now().Add(30 * time.Minute)
- //判断协程是否已存在,不存在则启动协程
- info, _ := g.TaskList.Load(parm.Dptcity + parm.Arrcity)
- g.TaskList.Store(parm.Dptcity+parm.Arrcity, parm)
- if info == nil {
- go g.ForClick(parm.Dptcity + parm.Arrcity)
- }
- c.Data["json"] = models.Res{
- Code: 0,
- Msg: parm.Dptcity + "-" + parm.Arrcity + "航线验价刷单服务启动成功",
- }
- }
- c.ServeJSON()
- }
|