Пример #1
0
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))
}
Пример #2
0
func (c *LeagueController) ReqinSchoolLeagueCells() {
	schoolid := c.GetString("schoolid")
	num := c.GetString("num")
	ticket := c.GetString("ticket")
	fmt.Println(num)
	fmt.Println(schoolid)
	fmt.Println(ticket)

	mydb := models.GetMysqlInstance()
	db := mydb.GetDb()
	qSql := "select * from league where schoolid = ? and id > ? limit " + num
	rows, err := db.Query(qSql, schoolid, ticket)
	if err != nil {
		log.Println(err)
	}

	defer rows.Close()
	var id int
	var leagueid int
	var logoid int
	var posterid int
	var name string
	var team_num int
	var team_fans int
	var league_type string
	var create_time string
	var start_time string
	var end_time string
	cells := []map[string]string{}
	for rows.Next() {
		cell := map[string]string{}
		err := rows.Scan(&id, &schoolid, &leagueid, &logoid, &posterid, &name, &team_num, &team_fans, &league_type, &create_time, &start_time, &end_time)
		if err != nil {
			log.Fatal(err)
		}

		cell["league_id"] = strconv.Itoa(leagueid)
		cell["league_logo_address"] = imageServer + "/" + beego.AppConfig.String("leagueLogoDir") + "/" + strconv.Itoa(logoid) + ".jpg"
		cell["league_poster_address"] = imageServer + "/" + beego.AppConfig.String("leaguePosterDir") + "/" + strconv.Itoa(posterid) + ".jpg"
		cell["league_name"] = name
		cell["league_team_num"] = strconv.Itoa(team_num)
		cell["league_fans_num"] = strconv.Itoa(team_fans)
		cell["league_type"] = league_type
		cell["league_start_date"] = start_time
		cell["league_end_date"] = end_time
		cell["ticket"] = strconv.Itoa(id)
		cells = append(cells, cell)
		//fmt.Println(id, schoolid, leagueid)
	}

	b, err := json.Marshal(cells)
	if err != nil {
		fmt.Println("error", err)
	}

	c.Ctx.WriteString(string(b))
}
Пример #3
0
func (c *LoginController) LoginCheck() {
	loginway := c.GetString("loginway")
	loginvalue := c.GetString("loginid")
	passwd := c.GetString("passwd")
	//loginway := c.Ctx.Input.Param(":loginway")
	//loginvalue := c.Ctx.Input.Param(":value")
	//passwd := c.Ctx.Input.Param(":passwd")
	fmt.Println(loginvalue)
	fmt.Println(passwd)

	mydb := models.GetMysqlInstance()
	db := mydb.GetDb()
	qSql := fmt.Sprintf("select passwd,schoolno from user where %s = ?", loginway)
	fmt.Println(qSql)
	rows, err := db.Query(qSql, loginvalue)
	if err != nil {
		log.Println(err)
	}

	defer rows.Close()
	var passwdb string
	var schoolno string
	var isUser bool
	isUser = false
	for rows.Next() {
		isUser = true
		err := rows.Scan(&passwdb, &schoolno)
		if err != nil {
			log.Fatal(err)
		}
	}

	cell := map[string]string{}
	cell["type"] = strconv.Itoa(common.USERNOEXIST)
	if isUser {
		cell["type"] = strconv.Itoa(common.USERWRONGPASSWD)
		if lib.Base64Encode(passwd) == lib.Base64Encode(passwdb) {
			cell["type"] = strconv.Itoa(common.USERLESSINFO)
			cell["schoolid"] = schoolno
			if schoolno != "" {
				cell["type"] = strconv.Itoa(common.USERPERFECT)
			}
		}
	}

	b, err := json.Marshal(cell)
	if err != nil {
		fmt.Println("error", err)
	}

	c.Ctx.WriteString(string(b))
}