package auth import ( "dt_automate/dbpool" "fmt" "log" machine_code "github.com/super-l/machine-code" ) func Auth_main() map[string]string { var auth_s dbpool.Douy_info fmt.Println("电脑序列号:", machine_code.Machine.BoardSerialNumber) if machine_code.Machine.BoardSerialNumber != "" { //查询sql 获取用户信息 rows, err := dbpool.QueryRows("SELECT * FROM `douy`.`douy_info` WHERE serialNumber = ?;", machine_code.Machine.BoardSerialNumber) if err != nil { log.Println(err) } defer rows.Close() // var typecho_userss []dbpool.Typecho_users for rows.Next() { if err := rows.Scan(&auth_s.Mobile_phone_number, &auth_s.SerialNumber, &auth_s.Username, &auth_s.Initial_time, &auth_s.End_time, &auth_s.Surplus_time, &auth_s.Key); err != nil { log.Println(err) } // typecho_userss = append(typecho_userss, users) } if err := rows.Err(); err != nil { log.Fatal(err) } // log.Println("查询到的结果:", auth_s) } else { log.Println("该设备未申请授权,该设备码为:", machine_code.Machine.BoardSerialNumber) } aa := map[string]string{ "mobile_phone_number": auth_s.Mobile_phone_number.String, "serialNumber": auth_s.SerialNumber.String, "username": auth_s.Username.String, "initial_time": auth_s.Initial_time.String, "end_time": auth_s.End_time.String, "surplus_time": auth_s.Surplus_time.String, "key": auth_s.Key.String, } // b, err := json.Marshal(aa) // if err != nil { // log.Println(err) // } // log.Println(string(b)) return aa }