public string getCaresList(string userId) { Dictionary <string, object> allMap = new Dictionary <string, object>(); if (userId.Length == 0) { allMap.Add("result", "1"); allMap.Add("message", "用户id不能为空!"); return(JsonHelper.ToJson(allMap)); } DataSet ds0 = dbMysql.seleDB("select * from t_people where id = " + userId + ""); if (ds0.Tables[0].Rows.Count == 0) { allMap.Add("result", "1"); allMap.Add("message", "该用户不存在!"); return(JsonHelper.ToJson(allMap)); } string sql = "SELECT p.* FROM t_fans AS f LEFT JOIN t_people AS p ON f.careId = p.id WHERE f.selfId = " + userId; DataSet ds = dbMysql.seleDB(sql); if (ds.Tables[0].Rows.Count == 0) { return("{\"result\":\"0\", \"caresList\":[]}"); } else { return("{\"result\":\"0\", \"caresList\":" + Db2JsonUtil.DataTable2JsonList(ds.Tables[0]) + "}"); } }
public string getWeiboCommentList(string userId, string weiboId, string count) { Dictionary <string, object> allMap = new Dictionary <string, object>(); if (userId.Length == 0) { allMap.Add("result", "1"); allMap.Add("message", "用户id不能为空!"); return(JsonHelper.ToJson(allMap)); } if (count.Length == 0) { count = "10"; } if (weiboId.Length == 0) { allMap.Add("result", "1"); allMap.Add("message", "微博id不能为空!"); return(JsonHelper.ToJson(allMap)); } DataSet ds0 = dbMysql.seleDB("select * from t_people where id = " + userId + ""); if (ds0.Tables[0].Rows.Count == 0) { allMap.Add("result", "1"); allMap.Add("message", "该用户不存在!"); return(JsonHelper.ToJson(allMap)); } DataSet ds1 = dbMysql.seleDB("select * from t_weibo where id = " + weiboId + ""); if (ds1.Tables[0].Rows.Count == 0) { allMap.Add("result", "1"); allMap.Add("message", "不存在该微博!"); return(JsonHelper.ToJson(allMap)); } string sql = "SELECT t_comment.*, t_people.headUrl, t_people.loginName, t_people.name, t_people.sex FROM t_comment LEFT JOIN t_people ON t_comment.userId = t_people.id WHERE t_comment.weiboId = " + weiboId + " ORDER BY t_comment.id DESC LIMIT 0, " + count; DataSet ds = dbMysql.seleDB(sql); if (ds.Tables[0].Rows.Count == 0) { return("{\"result\":\"0\", \"commentList\":[]}"); } else { return("{\"result\":\"0\", \"commentList\":" + Db2JsonUtil.DataTable2JsonList(ds.Tables[0]) + "}"); } }
/** * -------------------------------------以上是suwei的微博接口----------------------------------------------- */ // [WebMethod(Description = "<span style='color:#f74'>连接MySql数据库测试; select * from zl_user </span>")] public string AA_DB_MySqlDB(string tabName) { DbHelpMysql dbMysql = new DbHelpMysql(); DataSet ds = dbMysql.seleDB("select * from " + tabName); // Dictionary<string,object> allMap = new Dictionary<string, object>(); // Dictionary<string,object> voMap = JsonHelper.DataRowToDictionary(ds.Tables[0].Rows[0]); // allMap.Add("result", "0"); // allMap.Add("people", voMap); // return JsonHelper.ToJson(allMap); // return DataTableJson(ds.Tables[0]); return(Db2JsonUtil.DataTable2JsonList(ds.Tables[0])); // return DataTableJson(ds.Tables[0]); }
public string getWeiBoList(string userId, string count, string itemId, string flag) { Dictionary <string, object> allMap = new Dictionary <string, object>(); string sql = "select * from t_weibo limit 0, 3"; DataSet ds = dbMysql.seleDB(sql); if (ds.Tables[0].Rows.Count == 0) { return("{\"result\":\"0\", \"fileList\":[]}"); } else { return("{\"result\":\"0\", \"fileList\":" + Db2JsonUtil.DataTable2JsonList(ds.Tables[0]) + "}"); } // allMap.Add("result", "0"); // allMap.Add("fileList", ds.Tables[0]); // return JsonHelper.ToJson(allMap); }
public string getLeaveMsgList(string userId, string lastId, string count) { Dictionary <string, object> allMap = new Dictionary <string, object>(); if (userId.Length == 0) { allMap.Add("result", "1"); allMap.Add("message", "用户id不能为空!"); return(JsonHelper.ToJson(allMap)); } if (userId.Length == 0) { count = "10"; } string sql; if (lastId.Length == 0 || lastId.Equals("0")) { sql = "SELECT t_people.loginName, t_people.name, t_people.headUrl, t_people.sex, t_people.age, t_people.phone, t_leave_msg.* FROM t_leave_msg LEFT JOIN t_people ON t_leave_msg.fromUserId = t_people.id WHERE toUserId = " + userId + " ORDER BY id DESC LIMIT 0, " + count; } else { sql = "SELECT t_people.loginName, t_people.name, t_people.headUrl, t_people.sex, t_people.age, t_people.phone, t_leave_msg.* FROM t_leave_msg LEFT JOIN t_people ON t_leave_msg.fromUserId = t_people.id WHERE toUserId = " + userId + " AND t_leave_msg.id < " + lastId + " ORDER BY id DESC LIMIT 0, " + count; } DataSet ds = dbMysql.seleDB(sql); if (ds.Tables[0].Rows.Count == 0) { return("{\"result\":\"0\", \"leaveMsgList\":[]}"); } else { return("{\"result\":\"0\", \"leaveMsgList\":" + Db2JsonUtil.DataTable2JsonList(ds.Tables[0]) + "}"); } }
public string getWeiBoList(string userId, string count, string itemId, string flag) { Dictionary <string, object> allMap = new Dictionary <string, object>(); if (userId.Length == 0) { allMap.Add("result", "1"); allMap.Add("message", "用户id不能为空!"); return(JsonHelper.ToJson(allMap)); } DataSet ds0 = dbMysql.seleDB("select * from t_people where id = '" + userId + "'"); if (ds0.Tables[0].Rows.Count == 0) { allMap.Add("result", "1"); allMap.Add("message", "该用户不存在!"); return(JsonHelper.ToJson(allMap)); } if (count.Length == 0) { count = "10"; } string sql; // 向下刷新 if (flag.Equals("1")) { if (itemId.Length == 0 || itemId.Equals("0")) { sql = "SELECT IFNULL(t_praise_nums.praiseCount, 0) AS praiseNum, IFNULL(t_comment_nums.commentCount, 0) AS commentNum, CASE WHEN t_praise.id IS NULL THEN 0 ELSE 1 END AS hasPraise, t_weibo.*, t_people.headUrl, t_people.loginName, t_people.name, t_people.sex FROM t_weibo LEFT JOIN t_people ON t_weibo.userId = t_people.id LEFT JOIN t_praise ON t_weibo.id = t_praise.weiboId AND t_praise.userId = " + userId + " LEFT JOIN t_praise_nums ON t_weibo.id = t_praise_nums.weiboId LEFT JOIN t_comment_nums ON t_weibo.id = t_comment_nums.weiboId ORDER BY t_weibo.id DESC LIMIT 0, " + count; } else { sql = "SELECT IFNULL(t_praise_nums.praiseCount, 0) AS praiseNum, IFNULL(t_comment_nums.commentCount, 0) AS commentNum, CASE WHEN t_praise.id IS NULL THEN 0 ELSE 1 END AS hasPraise, t_weibo.*, t_people.headUrl, t_people.loginName, t_people.name, t_people.sex FROM t_weibo LEFT JOIN t_people ON t_weibo.userId = t_people.id LEFT JOIN t_praise ON t_weibo.id = t_praise.weiboId AND t_praise.userId = " + userId + " LEFT JOIN t_praise_nums ON t_weibo.id = t_praise_nums.weiboId LEFT JOIN t_comment_nums ON t_weibo.id = t_comment_nums.weiboId WHERE t_weibo.id < " + itemId + " ORDER BY t_weibo.id DESC LIMIT 0, " + count; } } // 向上刷新 else { if (itemId.Length == 0 || itemId.Equals("0")) { sql = "SELECT IFNULL(t_praise_nums.praiseCount, 0) AS praiseNum, IFNULL(t_comment_nums.commentCount, 0) AS commentNum, CASE WHEN t_praise.id IS NULL THEN 0 ELSE 1 END AS hasPraise, t_weibo.*, t_people.headUrl, t_people.loginName, t_people.name, t_people.sex FROM t_weibo LEFT JOIN t_people ON t_weibo.userId = t_people.id LEFT JOIN t_praise ON t_weibo.id = t_praise.weiboId AND t_praise.userId = " + userId + " LEFT JOIN t_praise_nums ON t_weibo.id = t_praise_nums.weiboId LEFT JOIN t_comment_nums ON t_weibo.id = t_comment_nums.weiboId ORDER BY t_weibo.id DESC LIMIT 0, " + count; } else { // SELECT * FROM (SELECT * FROM t_weibo WHERE id > 0 ORDER BY id ASC LIMIT 0, 5) AS t_temp ORDER BY id DESC sql = "SELECT * FROM (SELECT IFNULL(t_praise_nums.praiseCount, 0) AS praiseNum, IFNULL(t_comment_nums.commentCount, 0) AS commentNum, CASE WHEN t_praise.id IS NULL THEN 0 ELSE 1 END AS hasPraise, t_weibo.*, t_people.headUrl, t_people.loginName, t_people.name, t_people.sex FROM t_weibo LEFT JOIN t_people ON t_weibo.userId = t_people.id LEFT JOIN t_praise ON t_weibo.id = t_praise.weiboId AND t_praise.userId = " + userId + " LEFT JOIN t_praise_nums ON t_weibo.id = t_praise_nums.weiboId LEFT JOIN t_comment_nums ON t_weibo.id = t_comment_nums.weiboId WHERE t_weibo.id > " + itemId + " ORDER BY t_weibo.id ASC LIMIT 0, " + count + " ) AS t_temp ORDER BY t_temp.id DESC "; } } DataSet ds = dbMysql.seleDB(sql); if (ds.Tables[0].Rows.Count == 0) { return("{\"result\":\"0\", \"fileList\":[]}"); } else { return("{\"result\":\"0\", \"fileList\":" + Db2JsonUtil.DataTable2JsonList(ds.Tables[0]) + "}"); } // allMap.Add("result", "0"); // allMap.Add("fileList", ds.Tables[0]); // return JsonHelper.ToJson(allMap); }