未验证 提交 0a1be11a 编写于 作者: 江南一点雨 提交者: GitHub

Merge pull request #39 from linxbin/master

新建栏目时,增加栏目名称不为空的判断;增加回收站文章还原到原处的功能
......@@ -93,6 +93,14 @@ public class ArticleController {
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<>();
......
......@@ -36,7 +36,13 @@ public class CategoryController {
@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", "添加成功!");
}
......
......@@ -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);
......
......@@ -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=",">
......
......@@ -113,6 +113,10 @@ public class ArticleService {
}
}
public int restoreArticle(Integer articleId) {
return articleMapper.updateArticleStateById(articleId, 1); // 从回收站还原在原处
}
public Article getArticleById(Long aid) {
Article article = articleMapper.getArticleById(aid);
articleMapper.pvIncrement(aid);
......
......@@ -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>
......
......@@ -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"
......@@ -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 ? '将该文件放入回收站,是否继续?' : '永久删除该文件, 是否继续?', '提示', {
......@@ -208,6 +239,6 @@
});
}
},
props: ['state', 'showEdit', 'showDelete', 'activeName']
props: ['state', 'showEdit', 'showDelete', 'activeName', 'showRestore']
}
</script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册