|
@@ -61,8 +61,8 @@ 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,user_name,user_photo,title,content,location_id,hotel_id,create_id,create_date,status,approve,type,is_top) " +
|
|
|
|
|
- "values(:userId,:userName,:userPhoto,:title,:content,:locationId,:hotelId,:createId,:createDate,:status,:approve,:type,:is_top) ";
|
|
|
|
|
|
|
+ String sql = "insert into `article_tweet` (user_id,user_name,user_photo,title,content,location_id,hotel_id,create_id,create_date,status,approve,publish_way,is_top) " +
|
|
|
|
|
+ "values(:userId,:userName,:userPhoto,:title,:content,:locationId,:hotelId,:createId,:createDate,:status,:approve,:publishWay,:is_top) ";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("userId", articleTweet.getUserId());
|
|
sps.addValue("userId", articleTweet.getUserId());
|
|
|
sps.addValue("userName", articleTweet.getUserName());
|
|
sps.addValue("userName", articleTweet.getUserName());
|
|
@@ -75,9 +75,8 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
sps.addValue("createDate", articleTweet.getCreateDate());
|
|
sps.addValue("createDate", articleTweet.getCreateDate());
|
|
|
sps.addValue("status", articleTweet.getStatus());
|
|
sps.addValue("status", articleTweet.getStatus());
|
|
|
sps.addValue("approve", articleTweet.getApprove());
|
|
sps.addValue("approve", articleTweet.getApprove());
|
|
|
- sps.addValue("type", articleTweet.getType());
|
|
|
|
|
|
|
+ sps.addValue("publishWay", articleTweet.getPublishWay());
|
|
|
sps.addValue("is_top", articleTweet.getIsTop());
|
|
sps.addValue("is_top", articleTweet.getIsTop());
|
|
|
-
|
|
|
|
|
int num = 0;
|
|
int num = 0;
|
|
|
try {
|
|
try {
|
|
|
num = namedParameterJdbcTemplate.update(sql, sps, key);
|
|
num = namedParameterJdbcTemplate.update(sql, sps, key);
|
|
@@ -88,6 +87,32 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
return num;
|
|
return num;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public int update(ArticleTweet articleTweet) {
|
|
|
|
|
+ String sql = "update `article_tweet` set user_id=:userId,user_name=:userName,user_photo=:userPhoto,title=:title,content=:content,location_id=:locationId,hotel_id=:hotelId,create_id=:createId,create_date=:createDate,status=:status,approve=:approve,publish_way=:publishWay,is_top=:is_top where id=:id ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("userId", articleTweet.getUserId());
|
|
|
|
|
+ sps.addValue("userName", articleTweet.getUserName());
|
|
|
|
|
+ sps.addValue("userPhoto", articleTweet.getUserPhoto());
|
|
|
|
|
+ sps.addValue("title", articleTweet.getTitle());
|
|
|
|
|
+ sps.addValue("content", articleTweet.getContent());
|
|
|
|
|
+ sps.addValue("locationId", articleTweet.getLocationId());
|
|
|
|
|
+ sps.addValue("hotelId", articleTweet.getHotelId());
|
|
|
|
|
+ sps.addValue("createId", articleTweet.getCreateId());
|
|
|
|
|
+ sps.addValue("createDate", articleTweet.getCreateDate());
|
|
|
|
|
+ sps.addValue("status", articleTweet.getStatus());
|
|
|
|
|
+ sps.addValue("approve", articleTweet.getApprove());
|
|
|
|
|
+ sps.addValue("publishWay", articleTweet.getPublishWay());
|
|
|
|
|
+ sps.addValue("is_top", articleTweet.getIsTop());
|
|
|
|
|
+ sps.addValue("id", articleTweet.getId());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try {
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int updateArticleApprove(ArticleTweet articleTweet) {
|
|
public int updateArticleApprove(ArticleTweet articleTweet) {
|
|
@@ -113,6 +138,81 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
return m.length;
|
|
return m.length;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public int insertArticleFile(ArticleFileInfo articleFileInfos) {
|
|
|
|
|
+ KeyHolder key = new GeneratedKeyHolder();
|
|
|
|
|
+ String sql = "insert into article_file_info (link_id, url, name ,create_date ,type) " +
|
|
|
|
|
+ "VALUES (:linkId, :url, :name ,:createDate ,:type) ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("linkId", articleFileInfos.getLinkId());
|
|
|
|
|
+ sps.addValue("url", articleFileInfos.getUrl());
|
|
|
|
|
+ sps.addValue("name", articleFileInfos.getName());
|
|
|
|
|
+ sps.addValue("createDate", articleFileInfos.getCreateDate());
|
|
|
|
|
+ sps.addValue("type", articleFileInfos.getType());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try {
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps, key);
|
|
|
|
|
+ num = key.getKey().intValue();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int delArticleFileBatch(int id){
|
|
|
|
|
+ String sql = "delete from `article_file_info` where id=:id ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("id", id);
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int delArticle(int id){
|
|
|
|
|
+ String sql = "delete from `article_tweet` where id=:id ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("id", id);
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int delArticleFile(int link_id){
|
|
|
|
|
+ String sql = "delete from `article_file_info` where link_id=:link_id ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("link_id", link_id);
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int updateArticleTop(ArticleTweet articleTweet) {
|
|
|
|
|
+ String sql = "update article_tweet set is_top=:isTop where id = :id";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("isTop", articleTweet.getIsTop());
|
|
|
|
|
+ sps.addValue("id", articleTweet.getId());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try {
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<HotelVo> queryHotelPage(String sqlx, int page, int rows) {
|
|
public List<HotelVo> queryHotelPage(String sqlx, int page, int rows) {
|
|
@@ -308,7 +408,6 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
"where article_id = :articleId";
|
|
"where article_id = :articleId";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("articleId", articleId);
|
|
sps.addValue("articleId", articleId);
|
|
|
-
|
|
|
|
|
return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -480,6 +579,47 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public List<ArticleListVo> queryManageArticlesPage(String keyWord, String townId, int page, int rows) {
|
|
|
|
|
+ int start = (page - 1) * rows;// 每页的起始下标
|
|
|
|
|
+
|
|
|
|
|
+ String innSql = "";
|
|
|
|
|
+ String leftSql = "";
|
|
|
|
|
+ String caseSql = "";
|
|
|
|
|
+
|
|
|
|
|
+ String sqlWhere = townId == null ? "" : "and at.location_id = '" + townId + "' ";
|
|
|
|
|
+ sqlWhere = sqlWhere + (keyWord == null ? "" : "and (at.title like '%" + keyWord + "%') ");
|
|
|
|
|
+ String sql = "select at.id,at.location_id as town_id,hd.name as town_name,at.title,at.user_id,at.user_name,at.user_photo,at.content,at.create_date,at.publish_way, \n" + caseSql +
|
|
|
|
|
+ "(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" +
|
|
|
|
|
+ leftSql +
|
|
|
|
|
+ innSql +
|
|
|
|
|
+ "where at.approve = 2 " + sqlWhere +
|
|
|
|
|
+ "order by at.create_date desc ";
|
|
|
|
|
+
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("start", start);
|
|
|
|
|
+ sps.addValue("rows", rows);
|
|
|
|
|
+ List<ArticleListVo> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(ArticleListVo.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int queryManageArticlesTotal(String keyWord, String townId) {
|
|
|
|
|
+
|
|
|
|
|
+ String innSql = "";
|
|
|
|
|
+ String sqlWhere = townId == null ? "" : "and at.location_id = '" + townId + "' ";
|
|
|
|
|
+ sqlWhere = sqlWhere + (keyWord == null ? "" : "and (at.title like '%" + keyWord + "%') ");
|
|
|
|
|
+ String sql = "select count(*) from article_tweet at\n" +
|
|
|
|
|
+ innSql +
|
|
|
|
|
+ "where at.approve = 2 " + sqlWhere;
|
|
|
|
|
+
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<ArticleListVo> relatedTweetPage(Integer userId, String townId, Integer articleId, int page, int rows) {
|
|
public List<ArticleListVo> relatedTweetPage(Integer userId, String townId, Integer articleId, int page, int rows) {
|
|
@@ -509,10 +649,8 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int relatedTweetTotal(String townId, Integer articleId) {
|
|
public int relatedTweetTotal(String townId, Integer articleId) {
|
|
|
-
|
|
|
|
|
String sql = "select count(*) from article_tweet at\n" +
|
|
String sql = "select count(*) from article_tweet at\n" +
|
|
|
"where at.approve = 2 and at.location_id = :townId and at.id != :articleId";
|
|
"where at.approve = 2 and at.location_id = :townId and at.id != :articleId";
|
|
|
-
|
|
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("townId", townId);
|
|
sps.addValue("townId", townId);
|
|
|
sps.addValue("articleId", articleId);
|
|
sps.addValue("articleId", articleId);
|
|
@@ -803,7 +941,22 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ public List<ArticleTweet> queryTops(){
|
|
|
|
|
+ String sql = "select * from `article_tweet` where `status`=1 and `is_top`=1 ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ List<ArticleTweet> list = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(ArticleTweet.class));
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|