Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ public RespBean updateArticleState(Long[] aids, Integer state) {
return new RespBean("error", "删除失败!");
}

@RequestMapping(value = "/restore", method = RequestMethod.PUT)
public RespBean restoreArticle(Integer articleId) {
if (articleService.restoreArticle(articleId) == 1) {
return new RespBean("success", "还原成功!");
}
return new RespBean("error", "还原失败!");
}

@RequestMapping("/dataStatistics")
public Map<String,Object> dataStatistics() {
Map<String, Object> map = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ public RespBean deleteById(@PathVariable String ids) {

@RequestMapping(value = "/", method = RequestMethod.POST)
public RespBean addNewCate(Category category) {

if ("".equals(category.getCateName()) || category.getCateName() == null) {
return new RespBean("error", "请输入栏目名称!");
}

int result = categoryService.addCategory(category);

if (result == 1) {
return new RespBean("success", "添加成功!");
}
Expand Down
2 changes: 2 additions & 0 deletions blogserver/src/main/java/org/sang/mapper/ArticleMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public interface ArticleMapper {

int updateArticleState(@Param("aids") Long aids[], @Param("state") Integer state);

int updateArticleStateById(@Param("articleId") Integer articleId, @Param("state") Integer state);

int deleteArticleById(@Param("aids") Long[] aids);

Article getArticleById(Long aid);
Expand Down
4 changes: 3 additions & 1 deletion blogserver/src/main/java/org/sang/mapper/ArticleMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
#{aid}
</foreach>
</update>

<update id="updateArticleStateById" >
UPDATE article SET state=#{state} WHERE id = #{articleId}
</update>
<delete id="deleteArticleById">
DELETE FROM article WHERE id IN
<foreach collection="aids" item="aid" open="(" close=")" separator=",">
Expand Down
4 changes: 4 additions & 0 deletions blogserver/src/main/java/org/sang/service/ArticleService.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public int updateArticleState(Long[] aids, Integer state) {
}
}

public int restoreArticle(Integer articleId) {
return articleMapper.updateArticleStateById(articleId, 1); // 从回收站还原在原处
}

public Article getArticleById(Long aid) {
Article article = articleMapper.getArticleById(aid);
articleMapper.pvIncrement(aid);
Expand Down
10 changes: 5 additions & 5 deletions vueblog/src/components/ArticleList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
<el-main class="main">
<el-tabs v-model="activeName" @tab-click="handleClick" type="card">
<el-tab-pane label="全部文章" name="all">
<blog_table state="-1" :showEdit="false" :showDelete="false" :activeName="activeName"></blog_table>
<blog_table state="-1" :showEdit="false" :showDelete="false" :showRestore="false" :activeName="activeName"></blog_table>
</el-tab-pane>
<el-tab-pane label="已发表" name="post">
<blog_table state="1" :showEdit="true" :showDelete="true" :activeName="activeName"></blog_table>
<blog_table state="1" :showEdit="true" :showDelete="true" :showRestore="false" :activeName="activeName"></blog_table>
</el-tab-pane>
<el-tab-pane label="草稿箱" name="draft">
<blog_table state="0" :showEdit="true" :showDelete="true" :activeName="activeName"></blog_table>
<blog_table state="0" :showEdit="true" :showDelete="true" :showRestore="false" :activeName="activeName"></blog_table>
</el-tab-pane>
<el-tab-pane label="回收站" name="dustbin">
<blog_table state="2" :showEdit="false" :showDelete="true" :activeName="activeName"></blog_table>
<blog_table state="2" :showEdit="false" :showDelete="true" :showRestore="true" :activeName="activeName"></blog_table>
</el-tab-pane>
<el-tab-pane label="博客管理" name="blogmana" v-if="isAdmin">
<blog_table state="-2" :showEdit="false" :showDelete="true" :activeName="activeName"></blog_table>
<blog_table state="-2" :showEdit="false" :showDelete="true" :showRestore="false" :activeName="activeName"></blog_table>
</el-tab-pane>
<el-tab-pane label="博客配置" name="blogcfg">
<blog_cfg></blog_cfg>
Expand Down
33 changes: 32 additions & 1 deletion vueblog/src/components/BlogTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
size="mini"
@click="handleEdit(scope.$index, scope.row)" v-if="showEdit">编辑
</el-button>
<el-button
size="mini"
@click="handleRestore(scope.$index, scope.row)" v-if="showRestore">还原
</el-button>
<el-button
size="mini"
type="danger"
Expand Down Expand Up @@ -168,6 +172,33 @@
this.dustbinData.push(row.id);
this.deleteToDustBin(row.state);
},
handleRestore(index, row) {
let _this = this;
this.$confirm('将该文件还原到原处,是否继续?','提示',{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
} ).then(() => {
_this.loading = true;
putRequest('/article/restore', {articleId: row.id}).then(resp=> {
if (resp.status == 200) {
var data = resp.data;
_this.$message({type: data.status, message: data.msg});
if (data.status == 'success') {
window.bus.$emit('blogTableReload')//通过选项卡都重新加载数据
}
} else {
_this.$message({type: 'error', message: '还原失败!'});
}
_this.loading = false;
});
}).catch(() => {
_this.$message({
type: 'info',
message: '已取消还原'
});
});
},
deleteToDustBin(state){
var _this = this;
this.$confirm(state != 2 ? '将该文件放入回收站,是否继续?' : '永久删除该文件, 是否继续?', '提示', {
Expand Down Expand Up @@ -208,6 +239,6 @@
});
}
},
props: ['state', 'showEdit', 'showDelete', 'activeName']
props: ['state', 'showEdit', 'showDelete', 'activeName', 'showRestore']
}
</script>