|
@@ -32,10 +32,15 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public ArticleTweet queryArticleById(String id) {
|
|
|
|
|
- String sql = "SELECT (select IFNULL(count(*),0) from article_collect where article_id = :id and is_lose = 0) as collect_num,hd.name as location_name,u.user_name,at.* FROM article_tweet at" +
|
|
|
|
|
|
|
+ public ArticleTweet queryArticleById(String id, Integer userId) {
|
|
|
|
|
+ String caseSql = userId == null ? "" : "case ac.id when null then 0 else 1 end is_collect,";
|
|
|
|
|
+ String leftSql = userId == null ? "" : "left join article_collect ac on ac.is_lose = 0 and ac.article_id = at.id and ac.user_id = " + userId + " ";
|
|
|
|
|
+
|
|
|
|
|
+ String sql = "SELECT " + caseSql + "(select IFNULL(count(*),0) from article_collect where article_id = :id and is_lose = 0) as collect_num,hd.name as location_name,u.user_name,at.* " +
|
|
|
|
|
+ "FROM article_tweet at " +
|
|
|
"inner join users u on u.id = at.user_id " +
|
|
"inner join users u on u.id = at.user_id " +
|
|
|
- "left join hotel_dict hd on hd.code = 10 and hd.id = at.location_id" +
|
|
|
|
|
|
|
+ "left join hotel_dict hd on hd.code = 10 and hd.id = at.location_id " +
|
|
|
|
|
+ leftSql +
|
|
|
"WHERE at.id = :id ";
|
|
"WHERE at.id = :id ";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("id", id);
|
|
sps.addValue("id", id);
|
|
@@ -56,7 +61,7 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
@Override
|
|
@Override
|
|
|
public int insert(ArticleTweet articleTweet) {
|
|
public int insert(ArticleTweet articleTweet) {
|
|
|
KeyHolder key = new GeneratedKeyHolder();
|
|
KeyHolder key = new GeneratedKeyHolder();
|
|
|
- String sql = "insert into `article_tweet`(user_id,title,content,location_id,hotel_id,create_id,create_date,status,approve)" +
|
|
|
|
|
|
|
+ String sql = "insert into `article_tweet` (user_id,title,content,location_id,hotel_id,create_id,create_date,status,approve) " +
|
|
|
"values(:userId,:title,:content,:locationId,:hotelId,:createId,:createDate,:status,:approve) ";
|
|
"values(:userId,:title,:content,:locationId,:hotelId,:createId,:createDate,:status,:approve) ";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("userId", articleTweet.getUserId());
|
|
sps.addValue("userId", articleTweet.getUserId());
|
|
@@ -108,7 +113,8 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
public List<HotelVo> queryHotelPage(String sqlx, int page, int rows) {
|
|
public List<HotelVo> queryHotelPage(String sqlx, int page, int rows) {
|
|
|
SqlUtil.filterKeyword(sqlx);
|
|
SqlUtil.filterKeyword(sqlx);
|
|
|
int start = (page - 1) * rows;// 每页的起始下标
|
|
int start = (page - 1) * rows;// 每页的起始下标
|
|
|
- String sql = "select h.id,h.hname as name,h.cover_img,h.score_hotel as score,am.type from admin_manager am\n" +
|
|
|
|
|
|
|
+ String sql = "select h.id,h.hname as name,h.cover_img,h.score_hotel as score,am.type " +
|
|
|
|
|
+ "from admin_manager am\n" +
|
|
|
"inner join hotel h on h.status = 1 and h.manager_id = am.id\n" +
|
|
"inner join hotel h on h.status = 1 and h.manager_id = am.id\n" +
|
|
|
"where am.status = 1 and am." + sqlx + " ORDER BY name asc limit :start,:rows ";
|
|
"where am.status = 1 and am." + sqlx + " ORDER BY name asc limit :start,:rows ";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
@@ -135,7 +141,8 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
@Override
|
|
@Override
|
|
|
public List<HotelVo> queryHotels(String sqlx) {
|
|
public List<HotelVo> queryHotels(String sqlx) {
|
|
|
SqlUtil.filterKeyword(sqlx);
|
|
SqlUtil.filterKeyword(sqlx);
|
|
|
- String sql = "select h.manager_id,(select IFNULL(count(*),0) from booking_comment where status = 1 and hotel_id = h.id) as comment,h.id,h.hname as name,h.cover_img,h.score_hotel as score,am.type from hotel h\n" +
|
|
|
|
|
|
|
+ String sql = "select h.manager_id,(select IFNULL(count(*),0) from booking_comment where status = 1 and hotel_id = h.id) as comment,h.id,h.hname as name,h.cover_img,h.score_hotel as score,am.type " +
|
|
|
|
|
+ "from hotel h\n" +
|
|
|
"left join admin_manager am on am.status = 1 and h.manager_id = am.id\n" +
|
|
"left join admin_manager am on am.status = 1 and h.manager_id = am.id\n" +
|
|
|
"where h.status = 1 and h." + sqlx + " ORDER BY name asc limit 0,2";
|
|
"where h.status = 1 and h." + sqlx + " ORDER BY name asc limit 0,2";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
@@ -152,7 +159,8 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
SqlUtil.filterKeyword(sqlx);
|
|
SqlUtil.filterKeyword(sqlx);
|
|
|
int start = (page - 1) * rows;// 每页的起始下标
|
|
int start = (page - 1) * rows;// 每页的起始下标
|
|
|
String sql =
|
|
String sql =
|
|
|
- "select h.manager_id,(select IFNULL(count(*),0) from booking_comment where status = 1 and hotel_id = h.id) as comment,h.id,h.hname as name,h.cover_img,h.score_hotel as score,am.type from hotel h\n" +
|
|
|
|
|
|
|
+ "select h.manager_id,(select IFNULL(count(*),0) from booking_comment where status = 1 and hotel_id = h.id) as comment,h.id,h.hname as name,h.cover_img,h.score_hotel as score,am.type " +
|
|
|
|
|
+ "from hotel h\n" +
|
|
|
"left join admin_manager am on am.status = 1 and h.manager_id = am.id\n" +
|
|
"left join admin_manager am on am.status = 1 and h.manager_id = am.id\n" +
|
|
|
"where h.status = 1 and h." + sqlx + " ORDER BY name asc limit :start,:rows ";
|
|
"where h.status = 1 and h." + sqlx + " ORDER BY name asc limit :start,:rows ";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
@@ -169,8 +177,7 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
@Override
|
|
@Override
|
|
|
public int queryHotelTotalByHotleId(String sqlx) {
|
|
public int queryHotelTotalByHotleId(String sqlx) {
|
|
|
SqlUtil.filterKeyword(sqlx);
|
|
SqlUtil.filterKeyword(sqlx);
|
|
|
- String sql = "select h.manager_id,(select IFNULL(count(*),0) from booking_comment where status = 1 and hotel_id = h.id) as comment,h.id,h.hname as name,h.cover_img,h.score_hotel as score,am.type from hotel h\n" +
|
|
|
|
|
- "left join admin_manager am on am.status = 1 and h.manager_id = am.id\n" +
|
|
|
|
|
|
|
+ String sql = "select count(*) from hotel h\n" +
|
|
|
"where h.status = 1 and h." + sqlx;
|
|
"where h.status = 1 and h." + sqlx;
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
@@ -179,21 +186,25 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
@Override
|
|
@Override
|
|
|
public List<FileInfo> queryList(String sqlx) {
|
|
public List<FileInfo> queryList(String sqlx) {
|
|
|
SqlUtil.filterKeyword(sqlx);
|
|
SqlUtil.filterKeyword(sqlx);
|
|
|
- String sql = "SELECT id,link_id,url,name FROM `article_file_info` WHERE type=1 " + sqlx;
|
|
|
|
|
|
|
+ String sql = "SELECT id,link_id,url,name " +
|
|
|
|
|
+ "FROM `article_file_info` WHERE type=1 " + sqlx;
|
|
|
List<FileInfo> list = null;
|
|
List<FileInfo> list = null;
|
|
|
try {
|
|
try {
|
|
|
list = namedParameterJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(FileInfo.class));
|
|
list = namedParameterJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(FileInfo.class));
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
- if (list != null && list.size() > 0) return list;
|
|
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public UserCollect queryUserCollect(Integer parentId, Integer userId) {
|
|
public UserCollect queryUserCollect(Integer parentId, Integer userId) {
|
|
|
- String sql = "SELECT * FROM user_collect WHERE is_lose=0 and parent_userid = :parentId and user_id = :userId";
|
|
|
|
|
|
|
+ String sql = "SELECT * FROM user_collect " +
|
|
|
|
|
+ "WHERE is_lose=0 and parent_userid = :parentId and user_id = :userId";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("parentId", parentId);
|
|
sps.addValue("parentId", parentId);
|
|
|
sps.addValue("userId", userId);
|
|
sps.addValue("userId", userId);
|
|
@@ -213,7 +224,8 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<LikeListVo> queryArticleLikes(Integer articleId) {
|
|
public List<LikeListVo> queryArticleLikes(Integer articleId) {
|
|
|
- String sql = "select (select IFNULL(count(*),0) from article_tweet where user_id = al.like_id) as article_number,(select IFNULL(count(*),0) from user_collect where is_lose = 0 and parent_userid = al.like_id) as fans_number,al.like_id as id,al.like_image as image,al.like_name as name from article_likes al\n" +
|
|
|
|
|
|
|
+ String sql = "select (select IFNULL(count(*),0) from article_tweet where user_id = al.like_id) as article_number,(select IFNULL(count(*),0) from user_collect where is_lose = 0 and parent_userid = al.like_id) as fans_number,al.like_id as id,al.like_image as image,al.like_name as name " +
|
|
|
|
|
+ "from article_likes al\n" +
|
|
|
"where al.is_lose = 0 and al.article_id = :articleId order by al.create_date desc limit 0,10";
|
|
"where al.is_lose = 0 and al.article_id = :articleId order by al.create_date desc limit 0,10";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("articleId", articleId);
|
|
sps.addValue("articleId", articleId);
|
|
@@ -231,8 +243,9 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<ArticleCommentVo> queryArticleComment(Integer articleId) {
|
|
public List<ArticleCommentVo> queryArticleComment(Integer articleId) {
|
|
|
- String sql = "select id,comment_parent_id as parent_id,comment_id as user_id,comment_name as user_name,comment_image as image,content,create_date as date from article_comment " +
|
|
|
|
|
- "where article_id = :articleId and comment_parent_id = 0" +
|
|
|
|
|
|
|
+ String sql = "select id,comment_parent_id as parent_id,comment_id as user_id,comment_name as user_name,comment_image as image,content,create_date as date " +
|
|
|
|
|
+ "from article_comment " +
|
|
|
|
|
+ "where article_id = :articleId and comment_parent_id = 0 " +
|
|
|
"ORDER BY create_date desc limit 0,3";
|
|
"ORDER BY create_date desc limit 0,3";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("articleId", articleId);
|
|
sps.addValue("articleId", articleId);
|
|
@@ -263,8 +276,9 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
@Override
|
|
@Override
|
|
|
public List<ArticleCommentVo> queryCommentPageByArticle(Integer articleId, int page, int rows) {
|
|
public List<ArticleCommentVo> queryCommentPageByArticle(Integer articleId, int page, int rows) {
|
|
|
int start = (page - 1) * rows;// 每页的起始下标
|
|
int start = (page - 1) * rows;// 每页的起始下标
|
|
|
- String sql = "select id,comment_parent_id as parent_id,comment_id as user_id,comment_name as user_name,comment_image as image,content,create_date as date from article_comment " +
|
|
|
|
|
- "where article_id = :articleId and comment_parent_id = 0" +
|
|
|
|
|
|
|
+ String sql = "select id,comment_parent_id as parent_id,comment_id as user_id,comment_name as user_name,comment_image as image,content,create_date as date " +
|
|
|
|
|
+ "from article_comment " +
|
|
|
|
|
+ "where article_id = :articleId and comment_parent_id = 0 " +
|
|
|
"ORDER BY create_date desc limit :start,:rows";
|
|
"ORDER BY create_date desc limit :start,:rows";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("start", start);
|
|
sps.addValue("start", start);
|
|
@@ -280,7 +294,7 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int queryCommentTotalByArticle(Integer articleId) {
|
|
public int queryCommentTotalByArticle(Integer articleId) {
|
|
|
- String sql = "select id,comment_parent_id as parent_id,comment_id as user_id,comment_name as user_name,comment_image as image,content,create_date as date from article_comment " +
|
|
|
|
|
|
|
+ String sql = "select count(*) from article_comment " +
|
|
|
"where article_id = :articleId and comment_parent_id = 0";
|
|
"where article_id = :articleId and comment_parent_id = 0";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("articleId", articleId);
|
|
sps.addValue("articleId", articleId);
|
|
@@ -290,8 +304,9 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<ArticleCommentVo> queryCommentsByArticle(Integer articleId) {
|
|
public List<ArticleCommentVo> queryCommentsByArticle(Integer articleId) {
|
|
|
- String sql = "select id,comment_parent_id as parent_id,comment_id as user_id,comment_name as user_name,comment_image as image,content,create_date as date from article_comment " +
|
|
|
|
|
- "where article_id = :articleId and comment_parent_id > 0" +
|
|
|
|
|
|
|
+ String sql = "select id,comment_parent_id as parent_id,comment_id as user_id,comment_name as user_name,comment_image as image,content,create_date as date " +
|
|
|
|
|
+ "from article_comment " +
|
|
|
|
|
+ "where article_id = :articleId and comment_parent_id > 0 " +
|
|
|
"order BY create_date desc";
|
|
"order BY create_date desc";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("articleId", articleId);
|
|
sps.addValue("articleId", articleId);
|
|
@@ -351,8 +366,8 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int queryOwnerArticleTotal(Integer userId, String sqlWhere) {
|
|
public int queryOwnerArticleTotal(Integer userId, String sqlWhere) {
|
|
|
- String sql = "select count(*) from article_tweet \n" +
|
|
|
|
|
- "where user_id = :userId " + sqlWhere;
|
|
|
|
|
|
|
+ String sql = "select count(*) from article_tweet at \n" +
|
|
|
|
|
+ "where at.user_id = :userId " + sqlWhere;
|
|
|
|
|
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("userId", userId);
|
|
sps.addValue("userId", userId);
|
|
@@ -379,16 +394,17 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
innSql = "inner join article_collect acc on acc.is_lose = 0 and acc.article_id = at.id and acc.user_id = :userId\n";//收藏
|
|
innSql = "inner join article_collect acc on acc.is_lose = 0 and acc.article_id = at.id and acc.user_id = :userId\n";//收藏
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- String sqlWhere = townId == null ? "" : "at.location_id = '" + townId + "'";
|
|
|
|
|
|
|
+ String sqlWhere = townId == null ? "" : "and at.location_id = '" + townId + "'";
|
|
|
|
|
|
|
|
String sql = "select at.id,at.location_id as town_id,hd.name as town_name,at.title,at.user_id,u.user_name,\n" + caseSql +
|
|
String sql = "select at.id,at.location_id as town_id,hd.name as town_name,at.title,at.user_id,u.user_name,\n" + caseSql +
|
|
|
"(select count(*) from article_collect where is_lose = 0 and article_id = at.id) as collect_num\n" +
|
|
"(select count(*) from article_collect where is_lose = 0 and article_id = at.id) as collect_num\n" +
|
|
|
"from article_tweet at\n" +
|
|
"from article_tweet at\n" +
|
|
|
- "left join hotel_dict hd on dh.id = at.location_id\n" +
|
|
|
|
|
|
|
+ "left join hotel_dict hd on hd.id = at.location_id\n" +
|
|
|
"left join users u on u.id = at.user_id\n" +
|
|
"left join users u on u.id = at.user_id\n" +
|
|
|
leftSql +
|
|
leftSql +
|
|
|
innSql +
|
|
innSql +
|
|
|
- "where at.approve = 2 " + sqlWhere;
|
|
|
|
|
|
|
+ "where at.approve = 2 " + sqlWhere +
|
|
|
|
|
+ "order by at.create_date desc ";
|
|
|
|
|
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("start", start);
|
|
sps.addValue("start", start);
|
|
@@ -412,9 +428,9 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
innSql = "inner join article_collect acc on acc.is_lose = 0 and acc.article_id = at.id and acc.user_id = :userId\n";//收藏
|
|
innSql = "inner join article_collect acc on acc.is_lose = 0 and acc.article_id = at.id and acc.user_id = :userId\n";//收藏
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- String sqlWhere = townId == null ? "" : "at.location_id = '" + townId + "'";
|
|
|
|
|
|
|
+ String sqlWhere = townId == null ? "" : "and at.location_id = '" + townId + "'";
|
|
|
|
|
|
|
|
- String sql = "select count(at.*) from article_tweet at\n" +
|
|
|
|
|
|
|
+ String sql = "select count(*) from article_tweet at\n" +
|
|
|
innSql +
|
|
innSql +
|
|
|
"where at.approve = 2 " + sqlWhere;
|
|
"where at.approve = 2 " + sqlWhere;
|
|
|
|
|
|
|
@@ -426,9 +442,49 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ public List<ArticleListVo> relatedTweetPage(Integer userId, String townId, Integer articleId, int page, int rows) {
|
|
|
|
|
+ int start = (page - 1) * rows;// 每页的起始下标
|
|
|
|
|
+
|
|
|
|
|
+ String sql = "select at.id,at.location_id as town_id,hd.name as town_name,at.title,at.user_id,u.user_name,case ac.id when null then 0 else 1 end is_collect,\n" +
|
|
|
|
|
+ "(select count(*) from article_collect where is_lose = 0 and article_id = at.id) as collect_num\n" +
|
|
|
|
|
+ "from article_tweet at\n" +
|
|
|
|
|
+ "left join hotel_dict hd on hd.id = at.location_id\n" +
|
|
|
|
|
+ "left join users u on u.id = at.user_id\n" +
|
|
|
|
|
+ "left join article_collect ac on ac.is_lose = 0 and ac.article_id = at.id and ac.user_id = :userId\n" +
|
|
|
|
|
+ "where at.approve = 2 and at.location_id = :townId and at.id != :articleId\n" +
|
|
|
|
|
+ "order by at.create_date desc ";
|
|
|
|
|
+
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("start", start);
|
|
|
|
|
+ sps.addValue("rows", rows);
|
|
|
|
|
+ sps.addValue("userId", userId);
|
|
|
|
|
+ sps.addValue("townId", townId);
|
|
|
|
|
+ sps.addValue("articleId", articleId);
|
|
|
|
|
+ List<ArticleListVo> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(ArticleListVo.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int relatedTweetTotal(String townId, Integer articleId) {
|
|
|
|
|
+
|
|
|
|
|
+ String sql = "select count(*) from article_tweet at\n" +
|
|
|
|
|
+ "where at.approve = 2 and at.location_id = :townId and at.id != :articleId";
|
|
|
|
|
+
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("townId", townId);
|
|
|
|
|
+ sps.addValue("articleId", articleId);
|
|
|
|
|
+ return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
public ArticleCollect queryArticleCollect(Integer articleId, Integer userId) {
|
|
public ArticleCollect queryArticleCollect(Integer articleId, Integer userId) {
|
|
|
String sql = "select * from article_collect\n" +
|
|
String sql = "select * from article_collect\n" +
|
|
|
- "where article_id = :articleId and user_id = :userId ";
|
|
|
|
|
|
|
+ "where article_id = :articleId and user_id = :userId ";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("articleId", articleId);
|
|
sps.addValue("articleId", articleId);
|
|
|
sps.addValue("userId", userId);
|
|
sps.addValue("userId", userId);
|
|
@@ -448,10 +504,10 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int updateArticleCollect(ArticleCollect articleCollect) {
|
|
public int updateArticleCollect(ArticleCollect articleCollect) {
|
|
|
- String sql ="";
|
|
|
|
|
|
|
+ String sql = "";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
- if(articleCollect.getId() == null){
|
|
|
|
|
- sql = "insert into article_collect (article_id,user_id,is_lose,create_id,create_date,status)" +
|
|
|
|
|
|
|
+ if (articleCollect.getId() == null) {
|
|
|
|
|
+ sql = "insert into article_collect (article_id,user_id,is_lose,create_id,create_date,status) " +
|
|
|
"values(:articleId,:userId,:isLose,:createId,:createDate,:status) ";
|
|
"values(:articleId,:userId,:isLose,:createId,:createDate,:status) ";
|
|
|
|
|
|
|
|
sps.addValue("articleId", articleCollect.getArticleId());
|
|
sps.addValue("articleId", articleCollect.getArticleId());
|
|
@@ -460,7 +516,7 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
sps.addValue("createId", articleCollect.getCreateId());
|
|
sps.addValue("createId", articleCollect.getCreateId());
|
|
|
sps.addValue("createDate", articleCollect.getCreateDate());
|
|
sps.addValue("createDate", articleCollect.getCreateDate());
|
|
|
sps.addValue("status", articleCollect.getStatus());
|
|
sps.addValue("status", articleCollect.getStatus());
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
sql = "update article_collect set is_lose = :isLose where id = :id";
|
|
sql = "update article_collect set is_lose = :isLose where id = :id";
|
|
|
sps.addValue("isLose", articleCollect.getIsLose());
|
|
sps.addValue("isLose", articleCollect.getIsLose());
|
|
|
sps.addValue("id", articleCollect.getId());
|
|
sps.addValue("id", articleCollect.getId());
|
|
@@ -478,7 +534,7 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
@Override
|
|
@Override
|
|
|
public int insertArticleComment(ArticleComment articleComment) {
|
|
public int insertArticleComment(ArticleComment articleComment) {
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
- String sql = "insert into article_comment (article_id,comment_parent_id,comment_id,comment_name,comment_image,content,create_id,create_date,status)" +
|
|
|
|
|
|
|
+ String sql = "insert into article_comment (article_id,comment_parent_id,comment_id,comment_name,comment_image,content,create_id,create_date,status) " +
|
|
|
"values(:articleId,:commentParentId,:commentId,:commentName,:commentImage,:content,:createId,:createDate,:status) ";
|
|
"values(:articleId,:commentParentId,:commentId,:commentName,:commentImage,:content,:createId,:createDate,:status) ";
|
|
|
|
|
|
|
|
sps.addValue("articleId", articleComment.getArticleId());
|
|
sps.addValue("articleId", articleComment.getArticleId());
|
|
@@ -504,7 +560,7 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
@Override
|
|
@Override
|
|
|
public UserCollect queryUserCollectNoLose(Integer authorId, Integer userId) {
|
|
public UserCollect queryUserCollectNoLose(Integer authorId, Integer userId) {
|
|
|
String sql = "select * from user_collect\n" +
|
|
String sql = "select * from user_collect\n" +
|
|
|
- "where parent_userid = :authorId and user_id = :userId ";
|
|
|
|
|
|
|
+ "where parent_userid = :authorId and user_id = :userId ";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("authorId", authorId);
|
|
sps.addValue("authorId", authorId);
|
|
|
sps.addValue("userId", userId);
|
|
sps.addValue("userId", userId);
|
|
@@ -524,10 +580,10 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int updateUserCollect(UserCollect userCollect) {
|
|
public int updateUserCollect(UserCollect userCollect) {
|
|
|
- String sql ="";
|
|
|
|
|
|
|
+ String sql = "";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
- if(userCollect.getId() == null){
|
|
|
|
|
- sql = "insert into user_collect (parent_userid,user_id,is_lose,create_id,create_date,status)" +
|
|
|
|
|
|
|
+ if (userCollect.getId() == null) {
|
|
|
|
|
+ sql = "insert into user_collect (parent_userid,user_id,is_lose,create_id,create_date,status) " +
|
|
|
"values(:parentUserid,:userId,:isLose,:createId,:createDate,:status) ";
|
|
"values(:parentUserid,:userId,:isLose,:createId,:createDate,:status) ";
|
|
|
|
|
|
|
|
sps.addValue("parentUserid", userCollect.getParentUserid());
|
|
sps.addValue("parentUserid", userCollect.getParentUserid());
|
|
@@ -536,7 +592,7 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
sps.addValue("createId", userCollect.getCreateId());
|
|
sps.addValue("createId", userCollect.getCreateId());
|
|
|
sps.addValue("createDate", userCollect.getCreateDate());
|
|
sps.addValue("createDate", userCollect.getCreateDate());
|
|
|
sps.addValue("status", userCollect.getStatus());
|
|
sps.addValue("status", userCollect.getStatus());
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
sql = "update user_collect set is_lose = :isLose where id = :id";
|
|
sql = "update user_collect set is_lose = :isLose where id = :id";
|
|
|
sps.addValue("isLose", userCollect.getIsLose());
|
|
sps.addValue("isLose", userCollect.getIsLose());
|
|
|
sps.addValue("id", userCollect.getId());
|
|
sps.addValue("id", userCollect.getId());
|
|
@@ -574,10 +630,10 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int updateArticleLike(ArticleLikes articleLikes) {
|
|
public int updateArticleLike(ArticleLikes articleLikes) {
|
|
|
- String sql ="";
|
|
|
|
|
|
|
+ String sql = "";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
- if(articleLikes.getId() == null){
|
|
|
|
|
- sql = "insert into article_collect (article_id,like_id,like_name,like_image,is_lose,create_id,create_date,status)" +
|
|
|
|
|
|
|
+ if (articleLikes.getId() == null) {
|
|
|
|
|
+ sql = "insert into article_likes (article_id,like_id,like_name,like_image,is_lose,create_id,create_date,status) " +
|
|
|
"values(:articleId,:likeId,:likeName,:likeImage,:isLose,:createId,:createDate,:status) ";
|
|
"values(:articleId,:likeId,:likeName,:likeImage,:isLose,:createId,:createDate,:status) ";
|
|
|
|
|
|
|
|
sps.addValue("articleId", articleLikes.getArticleId());
|
|
sps.addValue("articleId", articleLikes.getArticleId());
|
|
@@ -588,8 +644,8 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
sps.addValue("createId", articleLikes.getCreateId());
|
|
sps.addValue("createId", articleLikes.getCreateId());
|
|
|
sps.addValue("createDate", articleLikes.getCreateDate());
|
|
sps.addValue("createDate", articleLikes.getCreateDate());
|
|
|
sps.addValue("status", articleLikes.getStatus());
|
|
sps.addValue("status", articleLikes.getStatus());
|
|
|
- }else{
|
|
|
|
|
- sql = "update article_collect set is_lose = :isLose where id = :id";
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sql = "update article_likes set is_lose = :isLose where id = :id";
|
|
|
sps.addValue("isLose", articleLikes.getIsLose());
|
|
sps.addValue("isLose", articleLikes.getIsLose());
|
|
|
sps.addValue("id", articleLikes.getId());
|
|
sps.addValue("id", articleLikes.getId());
|
|
|
}
|
|
}
|
|
@@ -603,4 +659,10 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
return num;
|
|
return num;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 相关推文
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ //select * from article_tweet where location_id = '' and user_id != 1 and approve = 2
|
|
|
}
|
|
}
|