#!/bin/bash
ip=$1
nav_url=$2
PORT="3306"
USERNAME="qa"
PASSWORD="qatest"
DBNAME="mall"
TABLENAME="ad_detail"
mysqld="-h${ip} -P${PORT} -u${USERNAME} -p${PASSWORD}"
date=`date "+%Y-%m-%d %H:%M:%S"`
date_next_year=`date -d "next year" "+%Y-%m-%d %H:%M:%S"`
function doMysql()
{
	update_sql="update ${TABLENAME} set enable=0 where type=16 and sort=1"
	mysql $mysqld ${DBNAME} -e "${update_sql}"
	insert_sql="INSERT INTO ${TABLENAME} (type, sort, start_date, end_date, image_url, nav_url, name, text, removed, created_at, updated_at, enable, min_version, expand_data, code)
VALUES
	(16, 1, '$date', '$date_next_year', 'Fk1o1SKzPPsax0eFboLAjzkusmo2', '$nav_url', N'现金贷轮播', '', 0, '$date', '$date', 1, NULL, N'{\"needLogin\":0,\"iosAlert\":\"本活动由信用钱包提供，与苹果无关\",\"skipBtn\":0,\"displayTime\":5}', '1498016852359')"
	echo $insert_sql
	mysql $mysqld ${DBNAME} -e "${insert_sql}"
}

doMysql
echo "done!!! $date"
