func (c *RegisterController) RegisterPasswdUpLoad() { phone := c.GetString("phone") passwd1 := c.GetString("passwd1") passwd2 := c.GetString("passwd2") //phone := c.Ctx.Input.Param(":phone") //passwd1 := c.Ctx.Input.Param(":passwd1") //passwd2 := c.Ctx.Input.Param(":passwd2") fmt.Println(phone) fmt.Println(passwd1) fmt.Println(passwd2) cell := map[string]string{} ret := lib.JudgePasswd(passwd1, passwd2) cell["type"] = strconv.Itoa(ret) var dbret bool dbret = false if ret == common.PASSWDOK { time_str := lib.GetTime(0) fmt.Println(time_str) inSql := "insert into user(phone, passwd, create_time) values (?, ?,?)" dbret = models.GetMysqlInstance().Insert(inSql, phone, passwd1, time_str) if !dbret { cell["type"] = strconv.Itoa(common.PASSWDINSERTERROR) } } b, err := json.Marshal(cell) if err != nil { fmt.Println("error", err) } c.Ctx.WriteString(string(b)) }
func (c *DongtaiController) ReqRecommendCells() { var ticket string module := c.GetString("module") flag := c.GetString("flag") num := c.GetString("num") ticket = c.GetString("ticket") num1, _ := strconv.Atoi(num) //module := c.Ctx.Input.Param(":module") //flag := c.Ctx.Input.Param(":flag") //num := c.Ctx.Input.Param(":num") //ticket = c.Ctx.Input.Param(":ticket") //num1, _ := strconv.Atoi(c.Ctx.Input.Param(":num")) fmt.Println(module) fmt.Println(num1) fmt.Println(flag) fmt.Println(ticket) if ticket == "0" && flag == "0" { time := lib.GetTime(-60 * 60 * 24 * 90) ticket = models.GetTicket(time, module) } ticketinfo := lib.GetInfoByTicket(ticket) //time := ticketinfo[0] id, _ := strconv.Atoi(ticketinfo[1]) if flag == "1" { id = id - num1 - 1 } cells := []map[string]string{} news := models.GetDongtaiInfo(id, module, num1) /////////////////////way 1 crawler for _, new := range news { cell := map[string]string{} cell["image_address"] = new["imagename"] cell["image_content"] = new["newslink"] cell["title"] = new["title"] ticket := lib.MakeTicket(new["create_time"], new["id"]) cell["ticket"] = ticket cells = append(cells, cell) } /*******************way 2 myself curImages, err := lib.GetNextImages(models.Module_images[module], ticket, flag, num); cells := []map[string]string{} var filename string for _, image := range curImages { cell := map[string]string{} filename = lib.GetFileName(image) cell["image_address"] = imageServer + "/" + beego.AppConfig.String("imageDir") + "/" + module + "/" + image cell["image_content"] = platformServer + "/dongtai/cell/" + module + "&" + image cell["ticket"] = filename cells = append(cells, cell) } */ b, err := json.Marshal(cells) if err != nil { fmt.Println("error", err) } c.Ctx.WriteString(string(b)) }