文章伪删除

master
luoxj 5 years ago
parent ce8319edf3
commit 6346898cca
  1. 4
      doc/5.0.0-to-5.1-mysql.sql
  2. 6
      doc/mcms-5.1.sql
  3. 7
      src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java
  4. 6
      src/main/java/net/mingsoft/cms/dao/IContentDao.java
  5. 27
      src/main/java/net/mingsoft/cms/dao/IContentDao.xml

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -27,6 +27,7 @@ import net.mingsoft.base.dao.IBaseDao;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.cms.biz.ICategoryBiz;
import net.mingsoft.cms.dao.ICategoryDao;
import net.mingsoft.cms.dao.IContentDao;
import net.mingsoft.cms.entity.CategoryEntity;
import net.mingsoft.basic.util.PinYinUtil;
import org.apache.commons.lang3.StringUtils;
@ -48,6 +49,9 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz {
@Autowired
private ICategoryDao categoryDao;
@Autowired
private IContentDao contentDao;
@Override
protected IBaseDao getDao() {
@ -157,7 +161,8 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz {
ids[i] = Integer.parseInt(childrenList.get(i).getId());
}
categoryDao.delete(ids);
deleteEntity(categoryId);
// 删除文章
contentDao.deleteEntityByCategoryIds(ids);
}
}
}

@ -34,4 +34,10 @@ public interface IContentDao extends IBaseDao {
*/
int getSearchCount(@Param("tableName") String tableName, @Param("diyList") List diyList,@Param("map") Map<String, Object> map,
@Param("websiteId") int websiteId, @Param("ids") String ids);
/**
* 分类编号删除文章
* @param ids
*/
void deleteEntityByCategoryIds(@Param("ids") int[] ids);
}

@ -159,13 +159,14 @@
<!--根据id获取-->
<select id="getEntity" resultMap="resultMap" parameterType="int">
select * from cms_content where id=#{id}
select * from cms_content where id=#{id} and del=0
</select>
<!--根据实体获取-->
<select id="getByEntity" resultMap="resultMap" parameterType="net.mingsoft.cms.entity.ContentEntity">
select * from cms_content
<where>
del=0
<if test="contentTitle != null and contentTitle != ''">and content_title like CONCAT('%',#{contentTitle},'%')</if>
<if test="contentCategoryId != null and contentCategoryId != ''">and content_category_id=#{contentCategoryId}</if>
<if test="contentType != null and contentType != ''">and content_type=#{contentType}</if>
@ -185,7 +186,6 @@
<if test="createDate != null"> and create_date=#{createDate} </if>
<if test="updateBy &gt; 0"> and update_by=#{updateBy} </if>
<if test="updateDate != null"> and update_date=#{updateDate} </if>
<if test="del != null"> and del=#{del} </if>
</where>
limit 0,1
</select>
@ -193,12 +193,21 @@
<!--删除-->
<delete id="deleteEntity" parameterType="int">
delete from cms_content where id=#{id}
update cms_content set del=1 where id=#{id}
</delete>
<!--删除-->
<delete id="deleteEntityByCategoryIds" >
update cms_content set del=1
<where>
content_category_id in <foreach collection="ids" item="item" index="index"
open="(" separator="," close=")">#{item}</foreach>
</where>
</delete>
<!--批量删除-->
<delete id="delete" >
delete from cms_content
update cms_content set del=1
<where>
id in <foreach collection="ids" item="item" index="index"
open="(" separator="," close=")">#{item}</foreach>
@ -206,7 +215,7 @@
</delete>
<!--查询全部-->
<select id="queryAll" resultMap="resultMap">
select * from cms_content order by id desc
select * from cms_content where del=0 order by id desc
</select>
<!--条件查询-->
<select id="query" resultMap="resultContentMap">
@ -214,6 +223,7 @@
select ct.*,cc.category_path from cms_content ct
join cms_category cc on ct.content_category_id=cc.id
<where>
ct.del=0
<if test="contentTitle != null and contentTitle != ''"> and content_title like CONCAT('%',#{contentTitle},'%')</if>
<if test="contentCategoryId != null and contentCategoryId != ''"> and content_category_id=#{contentCategoryId}</if>
<if test="contentType != null and contentType != ''"> and content_type LIKE CONCAT('%',#{contentType},'%')</if>
@ -233,7 +243,6 @@
<if test="createDate != null"> and ct.create_date=#{createDate} </if>
<if test="updateBy &gt; 0"> and ct.update_by=#{updateBy} </if>
<if test="updateDate != null"> and update_date=#{updateDate} </if>
<if test="del != null"> and ct.del=#{del} </if>
</where>
)ct ORDER BY date_format(ct.content_datetime,'%Y-%m-%d') desc,content_sort desc
</select>
@ -254,9 +263,9 @@
cms_content.id article_id,c.*
FROM cms_content
LEFT JOIN cms_category c ON content_category_id = c.id
where
where del=0
<if test="appId &gt; 0">
cms_content.app_id = #{appId}
and cms_content.app_id = #{appId}
</if>
<!-- 查询子栏目数据 -->
<if test="contentCategoryId &gt; 0">
@ -302,7 +311,7 @@
<if test="tableName!=null and tableName!='' and diyMap!=null">left join ${tableName} d on d.link_id=a.id
</if>
<where>
a.app_id = #{websiteId}
a.del=0 and a.app_id = #{websiteId}
<if test="ids!=null and ids!=''">
and FIND_IN_SET(content_category_id,#{ids})
</if>

Loading…
Cancel
Save