添加新闻功能

This commit is contained in:
sk1551 2020-12-25 15:00:46 +08:00
parent 0e021d2f83
commit 8650200345
10 changed files with 1678 additions and 1 deletions

View File

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询新闻中心列表
export function listNews(query) {
return request({
url: '/benyi/news/list',
method: 'get',
params: query
})
}
// 查询新闻中心详细
export function getNews(id) {
return request({
url: '/benyi/news/' + id,
method: 'get'
})
}
// 新增新闻中心
export function addNews(data) {
return request({
url: '/benyi/news',
method: 'post',
data: data
})
}
// 修改新闻中心
export function updateNews(data) {
return request({
url: '/benyi/news',
method: 'put',
data: data
})
}
// 删除新闻中心
export function delNews(id) {
return request({
url: '/benyi/news/' + id,
method: 'delete'
})
}
// 导出新闻中心
export function exportNews(query) {
return request({
url: '/benyi/news/export',
method: 'get',
params: query
})
}

View File

@ -0,0 +1,467 @@
<template>
<div class="app-container">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
label-width="68px"
>
<el-form-item label="类型" prop="type">
<el-select
v-model="queryParams.type"
placeholder="请选择类型"
clearable
size="small"
>
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['benyi:news:add']"
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['benyi:news:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['benyi:news:remove']"
>删除</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['benyi:news:export']"
>导出</el-button
>
</el-col>
</el-row>
<el-table
v-loading="loading"
:data="newsList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="编号" align="center" prop="id" />
<el-table-column label="标题" align="center" prop="title" />
<el-table-column label="摘要" align="center" prop="abstractcontent" />
<el-table-column
label="类型"
align="center"
prop="type"
:formatter="typeFormat"
/>
<el-table-column label="内容" align="center" prop="content" :show-overflow-tooltip="true">
<template slot-scope="scope">
<div v-html="scope.row.content"></div>
</template>
</el-table-column>
<el-table-column label="创建人" align="center" prop="createuserid" :formatter="userFormat" />
<el-table-column label="所属学校" align="center" prop="deptId" :formatter="deptFormat" />
<el-table-column
label="是否审核"
align="center"
prop="ischeck"
:formatter="ischeckFormat"
/>
<el-table-column
label="审核时间"
align="center"
prop="checkTime"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.checkTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['benyi:news:edit']"
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['benyi:news:remove']"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改新闻中心对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1024px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="标题" prop="title">
<el-input
v-model="form.title"
type="textarea"
placeholder="请输入内容"
/>
</el-form-item>
<el-form-item label="摘要" prop="abstractcontent">
<el-input
v-model="form.abstractcontent"
type="textarea"
placeholder="请输入内容"
/>
</el-form-item>
<!-- <el-form-item label="类型">
<el-select v-model="form.type" placeholder="请选择类型">
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item> -->
<el-form-item label="内容" prop="content">
<Editor v-model="form.content" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listNews,
getNews,
delNews,
addNews,
updateNews,
exportNews,
} from "@/api/benyi/news";
import Editor from "@/components/Editor";
import { listDept, getDept, } from "@/api/system/dept";
import { listUser, getUser, } from "@/api/system/user";
export default {
name: "News",
components: {
Editor
},
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
total: 0,
//
newsList: [],
//
title: "",
//
open: false,
//
typeOptions: [],
//
isdelOptions: [],
//
istopOptions: [],
//
ischeckOptions: [],
//
userOptions: [],
//
deptOptions: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
title: undefined,
imgurl: undefined,
abstractcontent: undefined,
type: undefined,
content: undefined,
isdel: undefined,
createuserid: undefined,
deptId: undefined,
istop: undefined,
ischeck: undefined,
checkuserid: undefined,
checkTime: undefined,
},
//
form: {},
//
rules: {},
};
},
created() {
this.getList();
this.getDeptList();
this.getUserList()
this.getDicts("sys_dm_newstype").then((response) => {
this.typeOptions = response.data;
});
this.getDicts("sys_yes_no").then((response) => {
this.isdelOptions = response.data;
});
this.getDicts("sys_yes_no").then((response) => {
this.istopOptions = response.data;
});
this.getDicts("sys_yes_no").then((response) => {
this.ischeckOptions = response.data;
});
},
methods: {
/** 查询新闻中心列表 */
getList() {
this.loading = true;
listNews(this.queryParams).then((response) => {
this.newsList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
getDeptList() {
listDept(null).then((response) => {
this.deptOptions = response.data;
});
},
//
getUserList() {
listUser(null).then((response) => {
this.userOptions = response.rows;
});
},
//
deptFormat(row, column) {
var actions = [];
var datas = this.deptOptions;
Object.keys(datas).map((key) => {
if (datas[key].deptId == "" + row.deptId) {
actions.push(datas[key].deptName);
return false;
}
});
return actions.join("");
},
//
userFormat(row, column) {
// return this.selectDictLabel(this.classOptions, row.classid);
var actions = [];
var datas = this.userOptions;
Object.keys(datas).map((key) => {
if (datas[key].userId == "" + row.createuserid) {
actions.push(datas[key].nickName);
return false;
}
});
return actions.join("");
},
//
typeFormat(row, column) {
return this.selectDictLabel(this.typeOptions, row.type);
},
//
isdelFormat(row, column) {
return this.selectDictLabel(this.isdelOptions, row.isdel);
},
//
istopFormat(row, column) {
return this.selectDictLabel(this.istopOptions, row.istop);
},
//
ischeckFormat(row, column) {
return this.selectDictLabel(this.ischeckOptions, row.ischeck);
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: undefined,
title: undefined,
imgurl: undefined,
abstractcontent: undefined,
type: undefined,
content: undefined,
isdel: undefined,
createuserid: undefined,
createTime: undefined,
deptId: undefined,
istop: undefined,
ischeck: undefined,
checkuserid: undefined,
checkTime: undefined,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id);
this.single = selection.length != 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加新闻中心";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
getNews(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改新闻中心";
});
},
/** 提交按钮 */
submitForm: function () {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != undefined) {
updateNews(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addNews(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm(
'是否确认删除新闻中心编号为"' + ids + '"的数据项?',
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}
)
.then(function () {
return delNews(ids);
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
})
.catch(function () {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm("是否确认导出所有新闻中心数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return exportNews(queryParams);
})
.then((response) => {
this.download(response.msg);
})
.catch(function () {});
},
},
};
</script>

View File

@ -0,0 +1,469 @@
<template>
<div class="app-container">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
label-width="68px"
>
<el-form-item label="类型" prop="type">
<el-select
v-model="queryParams.type"
placeholder="请选择类型"
clearable
size="small"
>
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item label="是否审核" prop="ischeck">
<el-select
v-model="queryParams.ischeck"
placeholder="请选择类型"
clearable
size="small"
>
<el-option
v-for="dict in ischeckOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<div class="mb8 btn-list">
<el-button
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['benyi:news:edit']"
>审批</el-button
>
</div>
<el-table
v-loading="loading"
:data="newsList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="编号" align="center" prop="id" />
<el-table-column label="标题" align="center" prop="title" />
<el-table-column label="摘要" align="center" prop="abstractcontent" />
<el-table-column
label="类型"
align="center"
prop="type"
:formatter="typeFormat"
/>
<el-table-column
label="内容"
align="center"
prop="content"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">
<div v-html="scope.row.content"></div>
</template>
</el-table-column>
<el-table-column
label="创建人"
align="center"
prop="createuserid"
:formatter="userFormat"
/>
<el-table-column
label="所属学校"
align="center"
prop="deptId"
:formatter="deptFormat"
/>
<el-table-column
label="是否审核"
align="center"
prop="ischeck"
:formatter="ischeckFormat"
/>
<el-table-column
label="审核时间"
align="center"
prop="checkTime"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.checkTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['benyi:news:edit']"
>审批</el-button
>
<!-- <el-button
size="mini"
type="text"
icon="el-icon-view"
@click="handleView(scope.row)"
v-hasPermi="['benyi:news:query']"
>预览</el-button
> -->
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改新闻中心对话框 -->
<el-dialog
:title="title"
:visible.sync="open"
width="1024px"
append-to-body
>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="标题" prop="title">
<el-input
v-model="form.title"
type="textarea"
placeholder="请输入内容"
:disabled="true"
/>
</el-form-item>
<el-form-item label="摘要" prop="abstractcontent">
<el-input
v-model="form.abstractcontent"
type="textarea"
placeholder="请输入内容"
:disabled="true"
/>
</el-form-item>
<!-- <el-form-item label="类型">
<el-select v-model="form.type" placeholder="请选择类型">
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item> -->
<el-form-item label="内容" prop="content" >
<Editor v-model="form.content" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="是否审批通过" prop="ischeck">
<el-radio-group v-model="form.ischeck">
<el-radio label="Y"></el-radio>
<el-radio label="N"></el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listNews,
getNews,
delNews,
addNews,
updateNews,
exportNews,
} from "@/api/benyi/news";
import Editor from "@/components/Editor";
import { listDept, getDept } from "@/api/system/dept";
import { listUser, getUser } from "@/api/system/user";
export default {
name: "News",
components: {
Editor,
},
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
total: 0,
//
newsList: [],
//
title: "",
//
open: false,
//
typeOptions: [],
//
isdelOptions: [],
//
istopOptions: [],
//
ischeckOptions: [],
//
userOptions: [],
//
deptOptions: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
title: undefined,
imgurl: undefined,
abstractcontent: undefined,
type: undefined,
content: undefined,
isdel: undefined,
createuserid: undefined,
deptId: undefined,
istop: undefined,
ischeck: "N",
checkuserid: undefined,
checkTime: undefined,
},
//
form: {},
//
rules: {
ischeck: [
{ required: true, message: "审批意见不能为空", trigger: "blur" },
],
},
};
},
created() {
this.getList();
this.getDeptList();
this.getUserList();
this.getDicts("sys_dm_newstype").then((response) => {
this.typeOptions = response.data;
});
this.getDicts("sys_yes_no").then((response) => {
this.isdelOptions = response.data;
});
this.getDicts("sys_yes_no").then((response) => {
this.istopOptions = response.data;
});
this.getDicts("sys_yes_no").then((response) => {
this.ischeckOptions = response.data;
});
},
methods: {
/** 查询新闻中心列表 */
getList() {
this.loading = true;
listNews(this.queryParams).then((response) => {
this.newsList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
getDeptList() {
listDept(null).then((response) => {
this.deptOptions = response.data;
});
},
//
getUserList() {
listUser(null).then((response) => {
this.userOptions = response.rows;
});
},
//
deptFormat(row, column) {
var actions = [];
var datas = this.deptOptions;
Object.keys(datas).map((key) => {
if (datas[key].deptId == "" + row.deptId) {
actions.push(datas[key].deptName);
return false;
}
});
return actions.join("");
},
//
userFormat(row, column) {
// return this.selectDictLabel(this.classOptions, row.classid);
var actions = [];
var datas = this.userOptions;
Object.keys(datas).map((key) => {
if (datas[key].userId == "" + row.createuserid) {
actions.push(datas[key].nickName);
return false;
}
});
return actions.join("");
},
//
typeFormat(row, column) {
return this.selectDictLabel(this.typeOptions, row.type);
},
//
isdelFormat(row, column) {
return this.selectDictLabel(this.isdelOptions, row.isdel);
},
//
istopFormat(row, column) {
return this.selectDictLabel(this.istopOptions, row.istop);
},
//
ischeckFormat(row, column) {
return this.selectDictLabel(this.ischeckOptions, row.ischeck);
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: undefined,
title: undefined,
imgurl: undefined,
abstractcontent: undefined,
type: undefined,
content: undefined,
isdel: undefined,
createuserid: undefined,
createTime: undefined,
deptId: undefined,
istop: undefined,
ischeck: undefined,
checkuserid: undefined,
checkTime: undefined,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id);
this.single = selection.length != 1;
this.multiple = !selection.length;
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
getNews(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = "审批新闻";
});
},
/** 提交按钮 */
submitForm: function () {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != undefined) {
var now = new Date();
this.form.checkTime = now.toLocaleDateString();
updateNews(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("审批成功");
this.open = false;
this.getList();
}
});
}
}
});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm("是否确认导出所有新闻中心数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return exportNews(queryParams);
})
.then((response) => {
this.download(response.msg);
})
.catch(function () {});
},
},
};
</script>
<style lang="scss" scoped>
.el-select {
width: 100%;
}
.my-date-picker {
width: 100%;
}
.edit-btns {
.el-button {
display: block;
margin: 0 auto;
}
}
.no-margin ::v-deep.el-form-item__content {
margin: 0 !important;
}
</style>

View File

@ -0,0 +1,116 @@
package com.ruoyi.project.benyi.controller;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.project.common.SchoolCommon;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.benyi.domain.BySchoolNews;
import com.ruoyi.project.benyi.service.IBySchoolNewsService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;
/**
* 新闻中心Controller
*
* @author tsbz
* @date 2020-12-25
*/
@RestController
@RequestMapping("/benyi/news")
public class BySchoolNewsController extends BaseController
{
@Autowired
private IBySchoolNewsService bySchoolNewsService;
@Autowired
private SchoolCommon schoolCommon;
/**
* 查询新闻中心列表
*/
@PreAuthorize("@ss.hasPermi('benyi:news:list')")
@GetMapping("/list")
public TableDataInfo list(BySchoolNews bySchoolNews)
{
bySchoolNews.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId());
startPage();
List<BySchoolNews> list = bySchoolNewsService.selectBySchoolNewsList(bySchoolNews);
return getDataTable(list);
}
/**
* 导出新闻中心列表
*/
@PreAuthorize("@ss.hasPermi('benyi:news:export')")
@Log(title = "新闻中心", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(BySchoolNews bySchoolNews)
{
List<BySchoolNews> list = bySchoolNewsService.selectBySchoolNewsList(bySchoolNews);
ExcelUtil<BySchoolNews> util = new ExcelUtil<BySchoolNews>(BySchoolNews.class);
return util.exportExcel(list, "news");
}
/**
* 获取新闻中心详细信息
*/
@PreAuthorize("@ss.hasPermi('benyi:news:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(bySchoolNewsService.selectBySchoolNewsById(id));
}
/**
* 新增新闻中心
*/
@PreAuthorize("@ss.hasPermi('benyi:news:add')")
@Log(title = "新闻中心", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BySchoolNews bySchoolNews)
{
bySchoolNews.setIsdel("N");
bySchoolNews.setCreateTime(new Date());
bySchoolNews.setCreateuserid(SecurityUtils.getLoginUser().getUser().getUserId());
bySchoolNews.setIscheck("N");
bySchoolNews.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId());
bySchoolNews.setType("1");
return toAjax(bySchoolNewsService.insertBySchoolNews(bySchoolNews));
}
/**
* 修改新闻中心
*/
@PreAuthorize("@ss.hasPermi('benyi:news:edit')")
@Log(title = "新闻中心", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BySchoolNews bySchoolNews)
{
return toAjax(bySchoolNewsService.updateBySchoolNews(bySchoolNews));
}
/**
* 删除新闻中心
*/
@PreAuthorize("@ss.hasPermi('benyi:news:remove')")
@Log(title = "新闻中心", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(bySchoolNewsService.deleteBySchoolNewsByIds(ids));
}
}

View File

@ -0,0 +1,239 @@
package com.ruoyi.project.benyi.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.web.domain.BaseEntity;
/**
* 新闻中心对象 by_school_news
*
* @author tsbz
* @date 2020-12-25
*/
public class BySchoolNews extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 编号
*/
private Long id;
/**
* 标题
*/
@Excel(name = "标题")
private String title;
/**
* 封面图片
*/
@Excel(name = "封面图片")
private String imgurl;
/**
* 摘要
*/
@Excel(name = "摘要")
private String abstractcontent;
/**
* 类型
*/
@Excel(name = "类型")
private String type;
/**
* 内容
*/
@Excel(name = "内容")
private String content;
/**
* 是否删除
*/
@Excel(name = "是否删除")
private String isdel;
/**
* 创建人
*/
@Excel(name = "创建人")
private Long createuserid;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createTime;
/**
* 所属学校
*/
@Excel(name = "所属学校")
private Long deptId;
/**
* 是否置顶
*/
@Excel(name = "是否置顶")
private String istop;
/**
* 是否审核
*/
@Excel(name = "是否审核")
private String ischeck;
/**
* 审核人
*/
@Excel(name = "审核人")
private Long checkuserid;
/**
* 审核时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date checkTime;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public void setImgurl(String imgurl) {
this.imgurl = imgurl;
}
public String getImgurl() {
return imgurl;
}
public void setAbstractcontent(String abstractcontent) {
this.abstractcontent = abstractcontent;
}
public String getAbstractcontent() {
return abstractcontent;
}
public void setType(String type) {
this.type = type;
}
public String getType() {
return type;
}
public void setContent(String content) {
this.content = content;
}
public String getContent() {
return content;
}
public void setIsdel(String isdel) {
this.isdel = isdel;
}
public String getIsdel() {
return isdel;
}
public void setCreateuserid(Long createuserid) {
this.createuserid = createuserid;
}
public Long getCreateuserid() {
return createuserid;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public Long getDeptId() {
return deptId;
}
public void setIstop(String istop) {
this.istop = istop;
}
public String getIstop() {
return istop;
}
public void setIscheck(String ischeck) {
this.ischeck = ischeck;
}
public String getIscheck() {
return ischeck;
}
public void setCheckuserid(Long checkuserid) {
this.checkuserid = checkuserid;
}
public Long getCheckuserid() {
return checkuserid;
}
public void setCheckTime(Date checkTime) {
this.checkTime = checkTime;
}
public Date getCheckTime() {
return checkTime;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("title", getTitle())
.append("imgurl", getImgurl())
.append("abstractcontent", getAbstractcontent())
.append("type", getType())
.append("content", getContent())
.append("isdel", getIsdel())
.append("createuserid", getCreateuserid())
.append("createTime", getCreateTime())
.append("deptId", getDeptId())
.append("istop", getIstop())
.append("ischeck", getIscheck())
.append("checkuserid", getCheckuserid())
.append("checkTime", getCheckTime())
.toString();
}
@Override
public Date getCreateTime() {
return createTime;
}
@Override
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.project.benyi.mapper;
import java.util.List;
import com.ruoyi.project.benyi.domain.BySchoolNews;
/**
* 新闻中心Mapper接口
*
* @author tsbz
* @date 2020-12-25
*/
public interface BySchoolNewsMapper
{
/**
* 查询新闻中心
*
* @param id 新闻中心ID
* @return 新闻中心
*/
public BySchoolNews selectBySchoolNewsById(Long id);
/**
* 查询新闻中心列表
*
* @param bySchoolNews 新闻中心
* @return 新闻中心集合
*/
public List<BySchoolNews> selectBySchoolNewsList(BySchoolNews bySchoolNews);
/**
* 新增新闻中心
*
* @param bySchoolNews 新闻中心
* @return 结果
*/
public int insertBySchoolNews(BySchoolNews bySchoolNews);
/**
* 修改新闻中心
*
* @param bySchoolNews 新闻中心
* @return 结果
*/
public int updateBySchoolNews(BySchoolNews bySchoolNews);
/**
* 删除新闻中心
*
* @param id 新闻中心ID
* @return 结果
*/
public int deleteBySchoolNewsById(Long id);
/**
* 批量删除新闻中心
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteBySchoolNewsByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.project.benyi.service;
import java.util.List;
import com.ruoyi.project.benyi.domain.BySchoolNews;
/**
* 新闻中心Service接口
*
* @author tsbz
* @date 2020-12-25
*/
public interface IBySchoolNewsService
{
/**
* 查询新闻中心
*
* @param id 新闻中心ID
* @return 新闻中心
*/
public BySchoolNews selectBySchoolNewsById(Long id);
/**
* 查询新闻中心列表
*
* @param bySchoolNews 新闻中心
* @return 新闻中心集合
*/
public List<BySchoolNews> selectBySchoolNewsList(BySchoolNews bySchoolNews);
/**
* 新增新闻中心
*
* @param bySchoolNews 新闻中心
* @return 结果
*/
public int insertBySchoolNews(BySchoolNews bySchoolNews);
/**
* 修改新闻中心
*
* @param bySchoolNews 新闻中心
* @return 结果
*/
public int updateBySchoolNews(BySchoolNews bySchoolNews);
/**
* 批量删除新闻中心
*
* @param ids 需要删除的新闻中心ID
* @return 结果
*/
public int deleteBySchoolNewsByIds(Long[] ids);
/**
* 删除新闻中心信息
*
* @param id 新闻中心ID
* @return 结果
*/
public int deleteBySchoolNewsById(Long id);
}

View File

@ -0,0 +1,95 @@
package com.ruoyi.project.benyi.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.benyi.mapper.BySchoolNewsMapper;
import com.ruoyi.project.benyi.domain.BySchoolNews;
import com.ruoyi.project.benyi.service.IBySchoolNewsService;
/**
* 新闻中心Service业务层处理
*
* @author tsbz
* @date 2020-12-25
*/
@Service
public class BySchoolNewsServiceImpl implements IBySchoolNewsService
{
@Autowired
private BySchoolNewsMapper bySchoolNewsMapper;
/**
* 查询新闻中心
*
* @param id 新闻中心ID
* @return 新闻中心
*/
@Override
public BySchoolNews selectBySchoolNewsById(Long id)
{
return bySchoolNewsMapper.selectBySchoolNewsById(id);
}
/**
* 查询新闻中心列表
*
* @param bySchoolNews 新闻中心
* @return 新闻中心
*/
@Override
public List<BySchoolNews> selectBySchoolNewsList(BySchoolNews bySchoolNews)
{
return bySchoolNewsMapper.selectBySchoolNewsList(bySchoolNews);
}
/**
* 新增新闻中心
*
* @param bySchoolNews 新闻中心
* @return 结果
*/
@Override
public int insertBySchoolNews(BySchoolNews bySchoolNews)
{
bySchoolNews.setCreateTime(DateUtils.getNowDate());
return bySchoolNewsMapper.insertBySchoolNews(bySchoolNews);
}
/**
* 修改新闻中心
*
* @param bySchoolNews 新闻中心
* @return 结果
*/
@Override
public int updateBySchoolNews(BySchoolNews bySchoolNews)
{
return bySchoolNewsMapper.updateBySchoolNews(bySchoolNews);
}
/**
* 批量删除新闻中心
*
* @param ids 需要删除的新闻中心ID
* @return 结果
*/
@Override
public int deleteBySchoolNewsByIds(Long[] ids)
{
return bySchoolNewsMapper.deleteBySchoolNewsByIds(ids);
}
/**
* 删除新闻中心信息
*
* @param id 新闻中心ID
* @return 结果
*/
@Override
public int deleteBySchoolNewsById(Long id)
{
return bySchoolNewsMapper.deleteBySchoolNewsById(id);
}
}

View File

@ -46,7 +46,7 @@ public class SysDeptController extends BaseController {
/** /**
* 获取部门列表 * 获取部门列表
*/ */
@PreAuthorize("@ss.hasPermi('system:dept:list')") @PreAuthorize("@ss.hasPermi('system:dept:list')" + "||@ss.hasPermi('benyi:news:list')")
@GetMapping("/list") @GetMapping("/list")
public AjaxResult list(SysDept dept) { public AjaxResult list(SysDept dept) {
List<SysDept> depts = deptService.selectDeptList(dept); List<SysDept> depts = deptService.selectDeptList(dept);

View File

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.project.benyi.mapper.BySchoolNewsMapper">
<resultMap type="BySchoolNews" id="BySchoolNewsResult">
<result property="id" column="id"/>
<result property="title" column="title"/>
<result property="imgurl" column="imgurl"/>
<result property="abstractcontent" column="abstractcontent"/>
<result property="type" column="type"/>
<result property="content" column="content"/>
<result property="isdel" column="isdel"/>
<result property="createuserid" column="createuserid"/>
<result property="createTime" column="create_time"/>
<result property="deptId" column="dept_id"/>
<result property="istop" column="istop"/>
<result property="ischeck" column="ischeck"/>
<result property="checkuserid" column="checkuserid"/>
<result property="checkTime" column="check_time"/>
</resultMap>
<sql id="selectBySchoolNewsVo">
select id, title, imgurl, abstractcontent, type, content, isdel, createuserid, create_time, dept_id, istop, ischeck, checkuserid, check_time from by_school_news
</sql>
<select id="selectBySchoolNewsList" parameterType="BySchoolNews" resultMap="BySchoolNewsResult">
<include refid="selectBySchoolNewsVo"/>
<where>
<if test="title != null and title != ''">and title = #{title}</if>
<if test="imgurl != null and imgurl != ''">and imgurl = #{imgurl}</if>
<if test="abstractcontent != null and abstractcontent != ''">and abstractcontent = #{abstractcontent}</if>
<if test="type != null and type != ''">and type = #{type}</if>
<if test="content != null and content != ''">and content = #{content}</if>
<if test="isdel != null and isdel != ''">and isdel = #{isdel}</if>
<if test="createuserid != null ">and createuserid = #{createuserid}</if>
<if test="deptId != null ">and dept_id = #{deptId}</if>
<if test="istop != null and istop != ''">and istop = #{istop}</if>
<if test="ischeck != null and ischeck != ''">and ischeck = #{ischeck}</if>
<if test="checkuserid != null ">and checkuserid = #{checkuserid}</if>
<if test="checkTime != null ">and check_time = #{checkTime}</if>
</where>
</select>
<select id="selectBySchoolNewsById" parameterType="Long" resultMap="BySchoolNewsResult">
<include refid="selectBySchoolNewsVo"/>
where id = #{id}
</select>
<insert id="insertBySchoolNews" parameterType="BySchoolNews" useGeneratedKeys="true" keyProperty="id">
insert into by_school_news
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">title,</if>
<if test="imgurl != null and imgurl != ''">imgurl,</if>
<if test="abstractcontent != null and abstractcontent != ''">abstractcontent,</if>
<if test="type != null and type != ''">type,</if>
<if test="content != null and content != ''">content,</if>
<if test="isdel != null and isdel != ''">isdel,</if>
<if test="createuserid != null ">createuserid,</if>
<if test="createTime != null ">create_time,</if>
<if test="deptId != null ">dept_id,</if>
<if test="istop != null and istop != ''">istop,</if>
<if test="ischeck != null and ischeck != ''">ischeck,</if>
<if test="checkuserid != null ">checkuserid,</if>
<if test="checkTime != null ">check_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">#{title},</if>
<if test="imgurl != null and imgurl != ''">#{imgurl},</if>
<if test="abstractcontent != null and abstractcontent != ''">#{abstractcontent},</if>
<if test="type != null and type != ''">#{type},</if>
<if test="content != null and content != ''">#{content},</if>
<if test="isdel != null and isdel != ''">#{isdel},</if>
<if test="createuserid != null ">#{createuserid},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="deptId != null ">#{deptId},</if>
<if test="istop != null and istop != ''">#{istop},</if>
<if test="ischeck != null and ischeck != ''">#{ischeck},</if>
<if test="checkuserid != null ">#{checkuserid},</if>
<if test="checkTime != null ">#{checkTime},</if>
</trim>
</insert>
<update id="updateBySchoolNews" parameterType="BySchoolNews">
update by_school_news
<trim prefix="SET" suffixOverrides=",">
<if test="title != null and title != ''">title = #{title},</if>
<if test="imgurl != null and imgurl != ''">imgurl = #{imgurl},</if>
<if test="abstractcontent != null and abstractcontent != ''">abstractcontent = #{abstractcontent},</if>
<if test="type != null and type != ''">type = #{type},</if>
<if test="content != null and content != ''">content = #{content},</if>
<if test="isdel != null and isdel != ''">isdel = #{isdel},</if>
<if test="createuserid != null ">createuserid = #{createuserid},</if>
<if test="createTime != null ">create_time = #{createTime},</if>
<if test="deptId != null ">dept_id = #{deptId},</if>
<if test="istop != null and istop != ''">istop = #{istop},</if>
<if test="ischeck != null and ischeck != ''">ischeck = #{ischeck},</if>
<if test="checkuserid != null ">checkuserid = #{checkuserid},</if>
<if test="checkTime != null ">check_time = #{checkTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteBySchoolNewsById" parameterType="Long">
delete from by_school_news where id = #{id}
</delete>
<delete id="deleteBySchoolNewsByIds" parameterType="String">
delete from by_school_news where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>