Commit 9be15ab8 authored by lixinglin's avatar lixinglin

Merge remote-tracking branch 'origin/master'

parents 393b29aa 92ed8542
package com.ruoyi.system.controller;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.NoticeInfo;
import com.ruoyi.system.service.INoticeInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 公告信息Controller
*
* @author ruoyi
* @date 2023-12-14
*/
@Controller
@RequestMapping("/notice/info")
public class NoticeInfoController extends BaseController
{
private String prefix = "notice/info";
@Autowired
private INoticeInfoService noticeInfoService;
@RequiresPermissions("notice:info:view")
@GetMapping()
public String info()
{
return prefix + "/info";
}
/**
* 查询公告信息列表
*/
@RequiresPermissions("notice:info:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(NoticeInfo noticeInfo)
{
startPage();
List<NoticeInfo> list = noticeInfoService.selectNoticeInfoList(noticeInfo);
return getDataTable(list);
}
/**
* 导出公告信息列表
*/
@RequiresPermissions("notice:info:export")
@Log(title = "公告信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(NoticeInfo noticeInfo)
{
List<NoticeInfo> list = noticeInfoService.selectNoticeInfoList(noticeInfo);
ExcelUtil<NoticeInfo> util = new ExcelUtil<NoticeInfo>(NoticeInfo.class);
return util.exportExcel(list, "公告信息数据");
}
/**
* 新增公告信息
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存公告信息
*/
@RequiresPermissions("notice:info:add")
@Log(title = "公告信息", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(NoticeInfo noticeInfo)
{
return toAjax(noticeInfoService.insertNoticeInfo(noticeInfo));
}
/**
* 修改公告信息
*/
@RequiresPermissions("notice:info:edit")
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
NoticeInfo noticeInfo = noticeInfoService.selectNoticeInfoById(id);
mmap.put("noticeInfo", noticeInfo);
return prefix + "/edit";
}
/**
* 修改保存公告信息
*/
@RequiresPermissions("notice:info:edit")
@Log(title = "公告信息", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(NoticeInfo noticeInfo)
{
return toAjax(noticeInfoService.updateNoticeInfo(noticeInfo));
}
/**
* 删除公告信息
*/
@RequiresPermissions("notice:info:remove")
@Log(title = "公告信息", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(noticeInfoService.deleteNoticeInfoByIds(ids));
}
}
package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 公告信息对象 notice_info
*
* @author ruoyi
* @date 2023-12-14
*/
public class NoticeInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 标题 */
@Excel(name = "标题")
private String name;
/** 详情 */
@Excel(name = "详情")
private String content;
/** 跳转链接 */
@Excel(name = "跳转链接")
private String url;
/** 0-禁用 1-正常 */
@Excel(name = "0-禁用 1-正常")
private String status;
/** 0-禁用 1-正常 */
@Excel(name = "类型")
private String type;
/** 乐观锁 */
@Excel(name = "乐观锁")
private Long version;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setUrl(String url)
{
this.url = url;
}
public String getUrl()
{
return url;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setVersion(Long version)
{
this.version = version;
}
public Long getVersion()
{
return version;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("content", getContent())
.append("url", getUrl())
.append("status", getStatus())
.append("type", getType())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.append("version", getVersion())
.toString();
}
}
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.NoticeInfo;
/**
* 公告信息Mapper接口
*
* @author ruoyi
* @date 2023-12-14
*/
public interface NoticeInfoMapper
{
/**
* 查询公告信息
*
* @param id 公告信息主键
* @return 公告信息
*/
public NoticeInfo selectNoticeInfoById(Long id);
/**
* 查询公告信息列表
*
* @param noticeInfo 公告信息
* @return 公告信息集合
*/
public List<NoticeInfo> selectNoticeInfoList(NoticeInfo noticeInfo);
/**
* 新增公告信息
*
* @param noticeInfo 公告信息
* @return 结果
*/
public int insertNoticeInfo(NoticeInfo noticeInfo);
/**
* 修改公告信息
*
* @param noticeInfo 公告信息
* @return 结果
*/
public int updateNoticeInfo(NoticeInfo noticeInfo);
/**
* 删除公告信息
*
* @param id 公告信息主键
* @return 结果
*/
public int deleteNoticeInfoById(Long id);
/**
* 批量删除公告信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteNoticeInfoByIds(String[] ids);
}
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.NoticeInfo;
/**
* 公告信息Service接口
*
* @author ruoyi
* @date 2023-12-14
*/
public interface INoticeInfoService
{
/**
* 查询公告信息
*
* @param id 公告信息主键
* @return 公告信息
*/
public NoticeInfo selectNoticeInfoById(Long id);
/**
* 查询公告信息列表
*
* @param noticeInfo 公告信息
* @return 公告信息集合
*/
public List<NoticeInfo> selectNoticeInfoList(NoticeInfo noticeInfo);
/**
* 新增公告信息
*
* @param noticeInfo 公告信息
* @return 结果
*/
public int insertNoticeInfo(NoticeInfo noticeInfo);
/**
* 修改公告信息
*
* @param noticeInfo 公告信息
* @return 结果
*/
public int updateNoticeInfo(NoticeInfo noticeInfo);
/**
* 批量删除公告信息
*
* @param ids 需要删除的公告信息主键集合
* @return 结果
*/
public int deleteNoticeInfoByIds(String ids);
/**
* 删除公告信息信息
*
* @param id 公告信息主键
* @return 结果
*/
public int deleteNoticeInfoById(Long id);
}
package com.ruoyi.system.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.system.mapper.NoticeInfoMapper;
import com.ruoyi.system.domain.NoticeInfo;
import com.ruoyi.system.service.INoticeInfoService;
import com.ruoyi.common.core.text.Convert;
/**
* 公告信息Service业务层处理
*
* @author ruoyi
* @date 2023-12-14
*/
@Service
public class NoticeInfoServiceImpl implements INoticeInfoService
{
@Autowired
private NoticeInfoMapper noticeInfoMapper;
/**
* 查询公告信息
*
* @param id 公告信息主键
* @return 公告信息
*/
@Override
public NoticeInfo selectNoticeInfoById(Long id)
{
return noticeInfoMapper.selectNoticeInfoById(id);
}
/**
* 查询公告信息列表
*
* @param noticeInfo 公告信息
* @return 公告信息
*/
@Override
public List<NoticeInfo> selectNoticeInfoList(NoticeInfo noticeInfo)
{
return noticeInfoMapper.selectNoticeInfoList(noticeInfo);
}
/**
* 新增公告信息
*
* @param noticeInfo 公告信息
* @return 结果
*/
@Override
public int insertNoticeInfo(NoticeInfo noticeInfo)
{
noticeInfo.setCreateTime(DateUtils.getNowDate());
return noticeInfoMapper.insertNoticeInfo(noticeInfo);
}
/**
* 修改公告信息
*
* @param noticeInfo 公告信息
* @return 结果
*/
@Override
public int updateNoticeInfo(NoticeInfo noticeInfo)
{
noticeInfo.setUpdateTime(DateUtils.getNowDate());
return noticeInfoMapper.updateNoticeInfo(noticeInfo);
}
/**
* 批量删除公告信息
*
* @param ids 需要删除的公告信息主键
* @return 结果
*/
@Override
public int deleteNoticeInfoByIds(String ids)
{
return noticeInfoMapper.deleteNoticeInfoByIds(Convert.toStrArray(ids));
}
/**
* 删除公告信息信息
*
* @param id 公告信息主键
* @return 结果
*/
@Override
public int deleteNoticeInfoById(Long id)
{
return noticeInfoMapper.deleteNoticeInfoById(id);
}
}
<?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.system.mapper.NoticeInfoMapper">
<resultMap type="NoticeInfo" id="NoticeInfoResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="content" column="content" />
<result property="url" column="url" />
<result property="status" column="status" />
<result property="type" column="type" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="version" column="version" />
</resultMap>
<sql id="selectNoticeInfoVo">
select id, name, content, url, status,type, create_time, create_by, update_time, update_by, version from notice_info
</sql>
<select id="selectNoticeInfoList" parameterType="NoticeInfo" resultMap="NoticeInfoResult">
<include refid="selectNoticeInfoVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="content != null and content != ''"> and content = #{content}</if>
<if test="url != null and url != ''"> and url = #{url}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="version != null "> and version = #{version}</if>
</where>
</select>
<select id="selectNoticeInfoById" parameterType="Long" resultMap="NoticeInfoResult">
<include refid="selectNoticeInfoVo"/>
where id = #{id}
</select>
<insert id="insertNoticeInfo" parameterType="NoticeInfo" useGeneratedKeys="true" keyProperty="id">
insert into notice_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="content != null">content,</if>
<if test="url != null">url,</if>
<if test="status != null">status,</if>
<if test="type != null">type,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="version != null">version,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="content != null">#{content},</if>
<if test="url != null">#{url},</if>
<if test="status != null">#{status},</if>
<if test="type != null">#{type},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="version != null">#{version},</if>
</trim>
</insert>
<update id="updateNoticeInfo" parameterType="NoticeInfo">
update notice_info
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="content != null">content = #{content},</if>
<if test="url != null">url = #{url},</if>
<if test="status != null">status = #{status},</if>
<if test="type != null">status = #{type},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="version != null">version = #{version},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteNoticeInfoById" parameterType="Long">
delete from notice_info where id = #{id}
</delete>
<delete id="deleteNoticeInfoByIds" parameterType="String">
delete from notice_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增公告信息')" />
<th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-info-add">
<div class="form-group">
<label class="col-sm-3 control-label">标题:</label>
<div class="col-sm-8">
<input name="name" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">详情:</label>
<div class="col-sm-8">
<!-- <input type="hidden" class="form-control" name="content">-->
<!-- <div class="summernote" id="content"></div>-->
<textarea name="content" class="form-control" rows="5"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">跳转链接:</label>
<div class="col-sm-8">
<input name="url" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
<select name="status" class="form-control m-b" th:with="type=${@dict.getType('sys_carousel_status')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">类型:</label>
<div class="col-sm-8">
<input name="type" class="form-control" type="text">
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: summernote-js" />
<script th:inline="javascript">
var prefix = ctx + "notice/info"
$("#form-info-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-info-add').serialize());
}
}
$(function() {
$('.summernote').summernote({
lang: 'zh-CN',
dialogsInBody: true,
callbacks: {
onChange: function(contents, $edittable) {
$("input[name='" + this.id + "']").val(contents);
},
onImageUpload: function(files) {
var obj = this;
var data = new FormData();
data.append("file", files[0]);
$.ajax({
type: "post",
url: ctx + "common/upload",
data: data,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
$('#' + obj.id).summernote('insertImage', result.url);
} else {
$.modal.alertError(result.msg);
}
},
error: function(error) {
$.modal.alertWarning("图片上传失败。");
}
});
}
}
});
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改公告信息')" />
<th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-info-edit" th:object="${noticeInfo}">
<input name="id" th:field="*{id}" type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label">标题:</label>
<div class="col-sm-8">
<input name="name" th:field="*{name}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">详情:</label>
<div class="col-sm-8">
<!-- <input type="hidden" class="form-control" th:field="*{content}">-->
<!-- <div class="summernote" id="content"></div>-->
<textarea name="content" class="form-control" rows="5">[[*{content}]]</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">跳转链接:</label>
<div class="col-sm-8">
<input name="url" th:field="*{url}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
<select id="status" name="status" class="form-control m-b" th:with="type=${@dict.getType('sys_carousel_status')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{status}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
<input name="type" th:field="*{type}" class="form-control" type="text">
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: summernote-js" />
<script th:inline="javascript">
var prefix = ctx + "notice/info";
$("#form-info-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-info-edit').serialize());
}
}
$(function() {
$('.summernote').each(function(i) {
$('#' + this.id).summernote({
lang: 'zh-CN',
dialogsInBody: true,
callbacks: {
onChange: function(contents, $edittable) {
$("input[name='" + this.id + "']").val(contents);
},
onImageUpload: function(files) {
var obj = this;
var data = new FormData();
data.append("file", files[0]);
$.ajax({
type: "post",
url: ctx + "common/upload",
data: data,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
$('#' + obj.id).summernote('insertImage', result.url);
} else {
$.modal.alertError(result.msg);
}
},
error: function(error) {
$.modal.alertWarning("图片上传失败。");
}
});
}
}
});
var content = $("input[name='" + this.id + "']").val();
$('#' + this.id).summernote('code', content);
})
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('公告信息列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
<label>标题:</label>
<input type="text" name="name"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="notice:info:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="notice:info:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="notice:info:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="notice:info:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('notice:info:edit')}]];
var removeFlag = [[${@permission.hasPermi('notice:info:remove')}]];
var prefix = ctx + "notice/info";
var datas = [[${@dict.getType('sys_carousel_status')}]];
$(function() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "公告信息",
columns: [{
checkbox: true
},
{
field: 'id',
title: 'id',
visible: false
},
{
field: 'name',
title: '标题'
},
{
field: 'content',
title: '详情'
},
{
field: 'url',
title: '跳转链接'
},
{
field: 'status',
title: '状态',
formatter: function (value, row, index) {
return $.table.selectDictLabel(datas, value);
}
},
{
field: 'type',
title: '类型'
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment