公告信息业务实现
parent
6193495f8e
commit
59b685eb30
|
@ -0,0 +1,105 @@
|
|||
package com.muyu.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.system.domain.Announcement;
|
||||
import com.muyu.system.service.IAnnouncementService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 公告Controller
|
||||
*
|
||||
* @author Yy
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/announcement")
|
||||
public class AnnouncementController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IAnnouncementService announcementService;
|
||||
|
||||
/**
|
||||
* 查询公告列表
|
||||
*/
|
||||
@RequiresPermissions("system:announcement:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<Announcement>> list(Announcement announcement)
|
||||
{
|
||||
startPage();
|
||||
List<Announcement> list = announcementService.selectAnnouncementList(announcement);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出公告列表
|
||||
*/
|
||||
@RequiresPermissions("system:announcement:export")
|
||||
@Log(title = "公告", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Announcement announcement)
|
||||
{
|
||||
List<Announcement> list = announcementService.selectAnnouncementList(announcement);
|
||||
ExcelUtil<Announcement> util = new ExcelUtil<Announcement>(Announcement.class);
|
||||
util.exportExcel(response, list, "公告数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公告详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:announcement:query")
|
||||
@GetMapping(value = "/{announcementId}")
|
||||
public Result getInfo(@PathVariable("announcementId") Long announcementId)
|
||||
{
|
||||
return success(announcementService.selectAnnouncementByAnnouncementId(announcementId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增公告
|
||||
*/
|
||||
@RequiresPermissions("system:announcement:add")
|
||||
@Log(title = "公告", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody Announcement announcement)
|
||||
{
|
||||
return toAjax(announcementService.insertAnnouncement(announcement));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改公告
|
||||
*/
|
||||
@RequiresPermissions("system:announcement:edit")
|
||||
@Log(title = "公告", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result edit(@RequestBody Announcement announcement)
|
||||
{
|
||||
return toAjax(announcementService.updateAnnouncement(announcement));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除公告
|
||||
*/
|
||||
@RequiresPermissions("system:announcement:remove")
|
||||
@Log(title = "公告", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{announcementIds}")
|
||||
public Result remove(@PathVariable Long[] announcementIds)
|
||||
{
|
||||
return toAjax(announcementService.deleteAnnouncementByAnnouncementIds(announcementIds));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
|
||||
/**
|
||||
* 公告对象 announcement
|
||||
*
|
||||
* @author Yy
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
public class Announcement extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 序号 */
|
||||
private Long announcementId;
|
||||
|
||||
/** 公告标题 */
|
||||
@Excel(name = "公告标题")
|
||||
private String announcementTi;
|
||||
|
||||
/** 公告类型 */
|
||||
@Excel(name = "公告类型")
|
||||
private Long announcementType;
|
||||
|
||||
/** 公告状态 */
|
||||
@Excel(name = "公告状态")
|
||||
private Long announcementState;
|
||||
|
||||
/** 创建者 */
|
||||
@Excel(name = "创建者")
|
||||
private String name;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date time;
|
||||
|
||||
public void setAnnouncementId(Long announcementId)
|
||||
{
|
||||
this.announcementId = announcementId;
|
||||
}
|
||||
|
||||
public Long getAnnouncementId()
|
||||
{
|
||||
return announcementId;
|
||||
}
|
||||
public void setAnnouncementTi(String announcementTi)
|
||||
{
|
||||
this.announcementTi = announcementTi;
|
||||
}
|
||||
|
||||
public String getAnnouncementTi()
|
||||
{
|
||||
return announcementTi;
|
||||
}
|
||||
public void setAnnouncementType(Long announcementType)
|
||||
{
|
||||
this.announcementType = announcementType;
|
||||
}
|
||||
|
||||
public Long getAnnouncementType()
|
||||
{
|
||||
return announcementType;
|
||||
}
|
||||
public void setAnnouncementState(Long announcementState)
|
||||
{
|
||||
this.announcementState = announcementState;
|
||||
}
|
||||
|
||||
public Long getAnnouncementState()
|
||||
{
|
||||
return announcementState;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public void setTime(Date time)
|
||||
{
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public Date getTime()
|
||||
{
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("announcementId", getAnnouncementId())
|
||||
.append("announcementTi", getAnnouncementTi())
|
||||
.append("announcementType", getAnnouncementType())
|
||||
.append("announcementState", getAnnouncementState())
|
||||
.append("name", getName())
|
||||
.append("time", getTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.muyu.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.system.domain.Announcement;
|
||||
|
||||
/**
|
||||
* 公告Mapper接口
|
||||
*
|
||||
* @author Yy
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
public interface AnnouncementMapper
|
||||
{
|
||||
/**
|
||||
* 查询公告
|
||||
*
|
||||
* @param announcementId 公告主键
|
||||
* @return 公告
|
||||
*/
|
||||
public Announcement selectAnnouncementByAnnouncementId(Long announcementId);
|
||||
|
||||
/**
|
||||
* 查询公告列表
|
||||
*
|
||||
* @param announcement 公告
|
||||
* @return 公告集合
|
||||
*/
|
||||
public List<Announcement> selectAnnouncementList(Announcement announcement);
|
||||
|
||||
/**
|
||||
* 新增公告
|
||||
*
|
||||
* @param announcement 公告
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAnnouncement(Announcement announcement);
|
||||
|
||||
/**
|
||||
* 修改公告
|
||||
*
|
||||
* @param announcement 公告
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAnnouncement(Announcement announcement);
|
||||
|
||||
/**
|
||||
* 删除公告
|
||||
*
|
||||
* @param announcementId 公告主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAnnouncementByAnnouncementId(Long announcementId);
|
||||
|
||||
/**
|
||||
* 批量删除公告
|
||||
*
|
||||
* @param announcementIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAnnouncementByAnnouncementIds(Long[] announcementIds);
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.muyu.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.system.domain.Announcement;
|
||||
|
||||
/**
|
||||
* 公告Service接口
|
||||
*
|
||||
* @author Yy
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
public interface IAnnouncementService
|
||||
{
|
||||
/**
|
||||
* 查询公告
|
||||
*
|
||||
* @param announcementId 公告主键
|
||||
* @return 公告
|
||||
*/
|
||||
public Announcement selectAnnouncementByAnnouncementId(Long announcementId);
|
||||
|
||||
/**
|
||||
* 查询公告列表
|
||||
*
|
||||
* @param announcement 公告
|
||||
* @return 公告集合
|
||||
*/
|
||||
public List<Announcement> selectAnnouncementList(Announcement announcement);
|
||||
|
||||
/**
|
||||
* 新增公告
|
||||
*
|
||||
* @param announcement 公告
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAnnouncement(Announcement announcement);
|
||||
|
||||
/**
|
||||
* 修改公告
|
||||
*
|
||||
* @param announcement 公告
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAnnouncement(Announcement announcement);
|
||||
|
||||
/**
|
||||
* 批量删除公告
|
||||
*
|
||||
* @param announcementIds 需要删除的公告主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAnnouncementByAnnouncementIds(Long[] announcementIds);
|
||||
|
||||
/**
|
||||
* 删除公告信息
|
||||
*
|
||||
* @param announcementId 公告主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAnnouncementByAnnouncementId(Long announcementId);
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.system.mapper.AnnouncementMapper;
|
||||
import com.muyu.system.domain.Announcement;
|
||||
import com.muyu.system.service.IAnnouncementService;
|
||||
|
||||
/**
|
||||
* 公告Service业务层处理
|
||||
*
|
||||
* @author Yy
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
@Service
|
||||
public class AnnouncementServiceImpl implements IAnnouncementService
|
||||
{
|
||||
@Autowired
|
||||
private AnnouncementMapper announcementMapper;
|
||||
|
||||
/**
|
||||
* 查询公告
|
||||
*
|
||||
* @param announcementId 公告主键
|
||||
* @return 公告
|
||||
*/
|
||||
@Override
|
||||
public Announcement selectAnnouncementByAnnouncementId(Long announcementId)
|
||||
{
|
||||
return announcementMapper.selectAnnouncementByAnnouncementId(announcementId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询公告列表
|
||||
*
|
||||
* @param announcement 公告
|
||||
* @return 公告
|
||||
*/
|
||||
@Override
|
||||
public List<Announcement> selectAnnouncementList(Announcement announcement)
|
||||
{
|
||||
return announcementMapper.selectAnnouncementList(announcement);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增公告
|
||||
*
|
||||
* @param announcement 公告
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAnnouncement(Announcement announcement)
|
||||
{
|
||||
return announcementMapper.insertAnnouncement(announcement);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改公告
|
||||
*
|
||||
* @param announcement 公告
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateAnnouncement(Announcement announcement)
|
||||
{
|
||||
return announcementMapper.updateAnnouncement(announcement);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除公告
|
||||
*
|
||||
* @param announcementIds 需要删除的公告主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAnnouncementByAnnouncementIds(Long[] announcementIds)
|
||||
{
|
||||
return announcementMapper.deleteAnnouncementByAnnouncementIds(announcementIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除公告信息
|
||||
*
|
||||
* @param announcementId 公告主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAnnouncementByAnnouncementId(Long announcementId)
|
||||
{
|
||||
return announcementMapper.deleteAnnouncementByAnnouncementId(announcementId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?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.muyu.system.mapper.AnnouncementMapper">
|
||||
|
||||
<resultMap type="com.muyu.system.domain.Announcement" id="AnnouncementResult">
|
||||
<result property="announcementId" column="announcement_id" />
|
||||
<result property="announcementTi" column="announcement_ti" />
|
||||
<result property="announcementType" column="announcement_type" />
|
||||
<result property="announcementState" column="announcement_state" />
|
||||
<result property="name" column="name" />
|
||||
<result property="time" column="time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAnnouncementVo">
|
||||
select announcement_id, announcement_ti, announcement_type, announcement_state, name, time from announcement
|
||||
</sql>
|
||||
|
||||
<select id="selectAnnouncementList" parameterType="com.muyu.system.domain.Announcement" resultMap="AnnouncementResult">
|
||||
<include refid="selectAnnouncementVo"/>
|
||||
<where>
|
||||
<if test="announcementTi != null and announcementTi != ''"> and announcement_ti = #{announcementTi}</if>
|
||||
<if test="announcementType != null "> and announcement_type = #{announcementType}</if>
|
||||
<if test="announcementState != null "> and announcement_state = #{announcementState}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="time != null "> and time = #{time}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAnnouncementByAnnouncementId" parameterType="Long" resultMap="AnnouncementResult">
|
||||
<include refid="selectAnnouncementVo"/>
|
||||
where announcement_id = #{announcementId}
|
||||
</select>
|
||||
|
||||
<insert id="insertAnnouncement" parameterType="com.muyu.system.domain.Announcement" useGeneratedKeys="true" keyProperty="announcementId">
|
||||
insert into announcement
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="announcementTi != null">announcement_ti,</if>
|
||||
<if test="announcementType != null">announcement_type,</if>
|
||||
<if test="announcementState != null">announcement_state,</if>
|
||||
<if test="name != null">name,</if>
|
||||
<if test="time != null">time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="announcementTi != null">#{announcementTi},</if>
|
||||
<if test="announcementType != null">#{announcementType},</if>
|
||||
<if test="announcementState != null">#{announcementState},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="time != null">#{time},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateAnnouncement" parameterType="com.muyu.system.domain.Announcement">
|
||||
update announcement
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="announcementTi != null">announcement_ti = #{announcementTi},</if>
|
||||
<if test="announcementType != null">announcement_type = #{announcementType},</if>
|
||||
<if test="announcementState != null">announcement_state = #{announcementState},</if>
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="time != null">time = #{time},</if>
|
||||
</trim>
|
||||
where announcement_id = #{announcementId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAnnouncementByAnnouncementId" parameterType="Long">
|
||||
delete from announcement where announcement_id = #{announcementId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAnnouncementByAnnouncementIds" parameterType="String">
|
||||
delete from announcement where announcement_id in
|
||||
<foreach item="announcementId" collection="array" open="(" separator="," close=")">
|
||||
#{announcementId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Loading…
Reference in New Issue