zhangyang 2 gadi atpakaļ
vecāks
revīzija
30674315c0

+ 156 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PoNewsController.java

@@ -0,0 +1,156 @@
+package com.ruoyi.web.controller.system;
+
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.constant.UserConstants;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.system.domain.PoNews;
+import com.ruoyi.system.service.IPoNewsService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.repository.query.Param;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 消息模块Controller
+ *
+ * @date 2023-01-15
+ */
+@RestController
+@RequestMapping("/system/news")
+public class PoNewsController extends BaseController
+{
+    @Autowired
+    private IPoNewsService poNewsService;
+    /**
+     * 查看详情
+     * 点击详情获取一个消息详细内容根据newsId
+     */
+    @ApiOperation("点击详情获取一个消息详细内容根据newsId")
+    @Log(title = "获取一个消息详细内容")
+    @PreAuthorize("@ss.hasPermi('system:news:querycontent')")
+    @GetMapping("/content/{newsId}")
+    public AjaxResult getContent(@PathVariable("newsId")String newsId){
+        return success(poNewsService.selectContentByNewsId(newsId));
+    }
+
+    /**
+     * 标题和时间搜索消息列表
+     */
+    @ApiOperation("标题和时间搜索消息列表")
+    @Log(title = "标题和时间搜索")
+    @PreAuthorize("@ss.hasPermi('system:news:querynews')")
+    @GetMapping("/queryNews")
+    public TableDataInfo list(@RequestParam(value="title",required = false)String title,
+                              @RequestParam(value="newsTimeStart",required = false)Date newsTimeStart,
+                              @RequestParam(value="newsTimeEnd",required = false) Date newsTimeEnd)
+    {
+        startPage();
+        List<PoNews> list= poNewsService.selectListByTitleAndTime(title,newsTimeStart,newsTimeEnd);
+        return getDataTable(list);
+    }
+
+    /**
+     * 查询消息列表
+     */
+    @ApiOperation("查询消息列表")
+    @Log(title = "分页查询消息列表")
+    @PreAuthorize("@ss.hasPermi('system:news:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(PoNews poNews)
+    {
+        startPage();
+        List<PoNews> list = poNewsService.selectPoNewsList(poNews);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出消息列表
+     */
+    @ApiOperation("导出消息列表")
+    @PreAuthorize("@ss.hasPermi('system:news:export')")
+    @Log(title = "导出消息列表", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, PoNews poNews)
+    {
+        List<PoNews> list = poNewsService.selectPoNewsList(poNews);
+        ExcelUtil<PoNews> util = new ExcelUtil<PoNews>(PoNews.class);
+        util.exportExcel(response, list, "消息数据");
+    }
+
+    /**
+     * 获取消息详细信息
+     */
+    @ApiOperation("获取消息详细内容")
+    @Log(title = "获取所有消息详情")
+    @PreAuthorize("@ss.hasPermi('system:news:query')")
+    @GetMapping(value = "/{newsId}")
+    public AjaxResult getInfo(@PathVariable("newsId") String newsId)
+    {
+        return success(poNewsService.selectPoNewsByNewsId(newsId));
+    }
+
+    /**
+     * 新增消息
+     */
+    @ApiOperation("新增消息")
+    @PreAuthorize("@ss.hasPermi('system:news:add')")
+    @Log(title = "新增消息", businessType = BusinessType.INSERT)
+    @PostMapping("/add")
+    public AjaxResult add(@RequestBody @Param("poNews") PoNews poNews)
+    {
+        if (!getUsername().equals("admin")){
+            return AjaxResult.error("新增消息失败当前用户不是管理员");
+        }
+        if (UserConstants.NOT_UNIQUE.equals(poNewsService.checkPostNewsTitleUnique(poNews))){
+            return AjaxResult.error("新增失败"+poNews.getNewsTitle()+"已经存在");
+        }
+        if(UserConstants.NOT_UNIQUE.equals(poNewsService.checkPostNewsImageUnique(poNews))){
+            return AjaxResult.error("新增失败"+poNews.getImage()+"已经存在");
+        }
+        return toAjax(poNewsService.insertPoNews(poNews));
+    }
+
+    /**
+     * 修改消息
+     */
+    @ApiOperation("修改消息")
+    @PreAuthorize("@ss.hasPermi('system:news:edit')")
+    @Log(title = "修改消息", businessType = BusinessType.UPDATE)
+    @PutMapping("/edit")
+    public AjaxResult edit(@RequestBody PoNews poNews)
+    {
+        if (!getUsername().equals("admin")){
+            return AjaxResult.error("修改消息失败当前用户不是管理员");
+        }
+        if (UserConstants.NOT_UNIQUE.equals(poNewsService.checkPostNewsTitleUnique(poNews))
+            ){
+            return AjaxResult.error("修改失败"+poNews.getNewsTitle()+"已经存在");
+        }
+        return toAjax(poNewsService.updatePoNews(poNews));
+    }
+
+    /**
+     * 删除消息
+     */
+    @ApiOperation("删除消息")
+    @PreAuthorize("@ss.hasPermi('system:news:remove')")
+    @Log(title = "删除消息", businessType = BusinessType.DELETE)
+    @DeleteMapping("/remove/{newsIds}")
+    public AjaxResult remove(@PathVariable String[] newsIds)
+    {
+        if (!getUsername().equals("admin")){
+            return AjaxResult.error("删除消息失败当前用户不是管理员");
+        }
+        return toAjax(poNewsService.deletePoNewsByNewsIds(newsIds));
+    }
+}
+

+ 163 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/PoNews.java

@@ -0,0 +1,163 @@
+package com.ruoyi.system.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.util.Date;
+
+
+/**
+ * 消息对象 po_news
+ * @date 2023-01-15
+ */
+public class PoNews extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 消息Id */
+    private String newsId;
+
+    /** 消息标题 */
+    @Excel(name = "消息标题")
+    private String newsTitle;
+
+    /** 消息内容 */
+    @Excel(name = "消息内容")
+    private String newsContent;
+
+    /** 状态(0正常 1关闭) */
+    @Excel(name = "状态", readConverterExp = "0=正常,1=关闭")
+    private String status;
+
+    /** 逻辑删除(0未删除 2删除) */
+    @Excel(name = "逻辑删除", readConverterExp = "0=未删除,2=删除")
+    private String delFlag;
+
+    /** 排序 */
+    @Excel(name = "排序")
+    private Long sort;
+
+    /** 发布人员 */
+    @Excel(name = "发布人员")
+    private String publisherId;
+
+    /** 接收人电话 */
+    @Excel(name = "接收人")
+    private String userId;
+
+    @Excel(name = "图片")
+    private String image;
+
+    @Excel(name = "发布信息时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date newsTime;
+
+    public void setNewsTime(Date newsTime){
+        this.newsTime = newsTime;
+    }
+    public Date getNewsTime(){
+        return newsTime;
+    }
+
+    public void setImage(String image){
+        this.image = image;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public void setNewsId(String newsId)
+    {
+        this.newsId = newsId;
+    }
+
+    public String getNewsId()
+    {
+        return newsId;
+    }
+    public void setNewsTitle(String newsTitle)
+    {
+        this.newsTitle = newsTitle;
+    }
+
+    public String getNewsTitle()
+    {
+        return newsTitle;
+    }
+    public void setNewsContent(String newsContent)
+    {
+        this.newsContent = newsContent;
+    }
+
+    public String getNewsContent()
+    {
+        return newsContent;
+    }
+    public void setStatus(String status)
+    {
+        this.status = status;
+    }
+
+    public String getStatus()
+    {
+        return status;
+    }
+    public void setDelFlag(String delFlag){
+        this.delFlag = delFlag;
+    }
+    public String getDelFlag(){
+        return delFlag;
+    }
+    public void setSort(Long sort)
+    {
+        this.sort = sort;
+    }
+
+    public Long getSort()
+    {
+        return sort;
+    }
+    public void setPublisherId(String publisherId)
+    {
+        this.publisherId = publisherId;
+    }
+
+    public String getPublisherId()
+    {
+        return publisherId;
+    }
+    public void setUserId(String userId)
+    {
+        this.userId = userId;
+    }
+
+    public String getUserId()
+    {
+        return userId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+                .append("newsId", getNewsId())
+                .append("newsTitle", getNewsTitle())
+                .append("newsContent", getNewsContent())
+                .append("status", getStatus())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .append("sort", getSort())
+                .append("publisherId", getPublisherId())
+                .append("userId", getUserId())
+                .append("delFlag",getDelFlag())
+                .append("image",getImage())
+                .append("newsTime",getNewsTime())
+                .toString();
+    }
+}

+ 120 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PoNewsMapper.java

@@ -0,0 +1,120 @@
+package com.ruoyi.system.mapper;
+
+import com.ruoyi.system.domain.PoNews;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 消息Mapper接口
+ * @date 2023-01-15
+ */
+public interface PoNewsMapper
+{
+    /**
+     * 根据Id查询
+     * @param newsId
+     * @return
+     */
+    public PoNews selectPoNewsByNewsId(String newsId);
+
+    /**
+     * 分页查询
+     * @param poNews
+     * @return
+     */
+    public List<PoNews> selectPoNewsList(PoNews poNews);
+
+    /**
+     * 新增
+     * @param poNews
+     * @return
+     */
+    public int insertPoNews(PoNews poNews);
+
+    /**
+     * 修改
+     * @param poNews
+     * @return
+     */
+    public int updatePoNews(PoNews poNews);
+
+    /**
+     * 删除
+     * @param newsId
+     * @return
+     */
+    public int deletePoNewsByNewsId(String newsId);
+
+    /**
+     * 批量删除
+     * @param newsIds
+     * @return
+     */
+    public int deletePoNewsByNewsIds(String[] newsIds);
+
+    /**
+     * 标题时间都不为空
+     * @param title
+     * @param newsTimeStart
+     * @param newsTimeEnd
+     * @return
+     */
+    List<PoNews> selectPoNewsListByTitleAndNewsTimeStartAndNewsTimeEnd(String title, Date newsTimeStart, Date newsTimeEnd);
+
+    /**
+     * 标题不为空时间为空
+     * @param title
+     * @return
+     */
+    List<PoNews> selectPoNewsListByTitle(String title);
+
+    /**
+     * 标题为空时间不为空
+     * @param newsTimeStart
+     * @param newsTimeEnd
+     * @return
+     */
+    List<PoNews> selectPoNewsByTime(Date newsTimeStart, Date newsTimeEnd);
+
+    /**
+     * 获取详细消息内容
+     * @param newsId
+     * @return
+     */
+    PoNews selectContentByNewsId(String newsId);
+
+    /**
+     * 检验消息标题是否重复
+     * @param newsTitle
+     * @return
+     */
+    PoNews checkPostNewsTitleUnique(String newsTitle);
+
+    /**
+     * 检验消息图片是否重复
+     * @param image
+     * @return
+     */
+    PoNews checkPostNewsImageUnique(String image);
+
+
+
+    /**
+     * 查询用户Id
+     *
+     * @param newsId
+     * @return
+     */
+    List<PoNews> selectUserByNewsId(String newsId);
+
+
+    /**
+     * 校验时间是否相同
+     * @param createTime
+     * @return
+     */
+    PoNews checkPostNewsTimeUnique(Date createTime);
+
+}
+

+ 95 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IPoNewsService.java

@@ -0,0 +1,95 @@
+package com.ruoyi.system.service;
+
+import com.ruoyi.system.domain.PoNews;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 消息接口
+ */
+public interface IPoNewsService
+{
+    /**
+     * 根据Id查询
+     *
+     * @param newsId
+     * @return
+     */
+    public List<PoNews> selectPoNewsByNewsId(String newsId);
+
+    /**
+     * 分页查询
+     * @param poNews
+     * @return
+     */
+    public List<PoNews> selectPoNewsList(PoNews poNews);
+
+    /**
+     * 增加
+     * @param poNews
+     * @return
+     */
+    public int insertPoNews(PoNews poNews);
+
+    /**
+     * 修改
+     * @param poNews
+     * @return
+     */
+    public int updatePoNews(PoNews poNews);
+
+    /**
+     * 批量删除
+     * @param newsIds
+     * @return
+     */
+    public int deletePoNewsByNewsIds(String[] newsIds);
+
+    /**
+     * 删除
+     * @param newsId
+     * @return
+     */
+    public int deletePoNewsByNewsId(String newsId);
+
+    /**
+     * 校验标题是否重复
+     * @param poNews
+     * @return
+     */
+    String checkPostNewsTitleUnique(PoNews poNews);
+
+    /**
+     * 标题时间都不为空
+     * @param title
+     * @param newsTimeStart
+     * @param newsTimeEnd
+     * @return
+     */
+    List<PoNews> selectListByTitleAndTime(String title, Date newsTimeStart, Date newsTimeEnd);
+
+    /**
+     * 获取详细内容
+     * @param newsId
+     * @return
+     */
+    PoNews selectContentByNewsId(String newsId);
+
+    /**
+     * 校验图片是否为空
+     * @param poNews
+     * @return
+     */
+    String checkPostNewsImageUnique(PoNews poNews);
+
+
+    /**
+     * 校验时间是否相等
+     * @param poNews
+     * @return
+     */
+    String checkPostNewsTimeUnique(PoNews poNews);
+
+}
+

+ 208 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PoNewsServiceImpl.java

@@ -0,0 +1,208 @@
+package com.ruoyi.system.service.impl;
+
+import com.ruoyi.common.constant.UserConstants;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.bean.BeanUtils;
+import com.ruoyi.system.domain.PoNews;
+import com.ruoyi.system.mapper.PoNewsMapper;
+import com.ruoyi.system.service.IPoNewsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 消息Service业务层处理
+ * @date 2023-01-15
+ */
+@Service
+public class PoNewsServiceImpl implements IPoNewsService {
+    @Autowired
+    private PoNewsMapper poNewsMapper;
+
+    /**
+     * 根据Id查询
+     *
+     * @param newsId
+     * @return
+     */
+    @Override
+    public List<PoNews> selectPoNewsByNewsId(String newsId) {
+
+        List list = new ArrayList();
+        List<PoNews> poNewsList  =new ArrayList<>();
+        poNewsList.add(poNewsMapper.selectPoNewsByNewsId(newsId));
+        List<PoNews> collect = poNewsList.stream().map((item) -> {
+            PoNews poNews = new PoNews();
+            //将所有消息数据拷贝到消息用户链接对象实例
+            BeanUtils.copyProperties(item, poNews);
+            List<PoNews> newsAndUserVos = poNewsMapper.selectUserByNewsId(newsId);
+            list.add(newsAndUserVos);
+            poNews.setUserId(list.toString());
+            return poNews;
+        }).collect(Collectors.toList());
+           return collect;
+    }
+
+    /**
+     * 分页查询
+     *
+     * @param poNews
+     * @return
+     */
+    @Override
+    public List<PoNews> selectPoNewsList(PoNews poNews) {
+        return poNewsMapper.selectPoNewsList(poNews);
+    }
+
+    /**
+     * 新增
+     *
+     * @param poNews
+     * @return
+     */
+    @Override
+    public int insertPoNews(PoNews poNews) {
+        poNews.setCreateTime(DateUtils.getNowDate());
+        return poNewsMapper.insertPoNews(poNews);
+    }
+
+    /**
+     * 修改
+     *
+     * @param poNews
+     * @return
+     */
+    @Override
+    public int updatePoNews(PoNews poNews) {
+        poNews.setUpdateTime(DateUtils.getNowDate());
+        return poNewsMapper.updatePoNews(poNews);
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param newsIds
+     * @return
+     */
+    @Override
+    public int deletePoNewsByNewsIds(String[] newsIds) {
+        return poNewsMapper.deletePoNewsByNewsIds(newsIds);
+    }
+
+    /**
+     * 删除
+     *
+     * @param newsId
+     * @return
+     */
+    @Override
+    public int deletePoNewsByNewsId(String newsId) {
+        return poNewsMapper.deletePoNewsByNewsId(newsId);
+    }
+
+    /**
+     * 校验标题是否重复
+     *
+     * @param poNews
+     * @return
+     */
+    @Override
+    public String checkPostNewsTitleUnique(PoNews poNews) {
+        String poNewsId = StringUtils.isNull(poNews.getNewsId()) ? "消息不存在" : poNews.getNewsId();
+        PoNews info = poNewsMapper.checkPostNewsTitleUnique(poNews.getNewsTitle());
+        if (StringUtils.isNotNull(info) && info.getNewsId() != poNewsId) {
+            return UserConstants.NOT_UNIQUE;
+        }
+        return UserConstants.UNIQUE;
+    }
+
+    /**
+     * 搜索消息
+     * @param title
+     * @param newsTimeStart
+     * @param newsTimeEnd
+     * @return
+     */
+
+    @Override
+    public List<PoNews> selectListByTitleAndTime(String title, Date newsTimeStart, Date newsTimeEnd) {
+        if (title != null) {
+            //标题不为空且开始时间和结束时间都不为空
+            if (newsTimeStart != null && newsTimeEnd != null) {
+
+                if (newsTimeStart.before(newsTimeEnd)) {
+                    return poNewsMapper.selectPoNewsListByTitleAndNewsTimeStartAndNewsTimeEnd(title, newsTimeStart, newsTimeEnd);
+                }
+                else if((newsTimeStart != null && newsTimeEnd == null) || (newsTimeStart == null && newsTimeEnd != null)) {
+                    //有一个时间不为空返回提示信息
+                    List list = new ArrayList();
+                    list.add("请选择正确的时间段");
+                    return list;
+                }
+            }
+            else {//时间都为空
+                    return poNewsMapper.selectPoNewsListByTitle(title);
+                }
+            }
+        //标题为空
+        else {
+            //时间不为空
+            if (newsTimeStart != null && newsTimeEnd != null) {
+                return poNewsMapper.selectPoNewsByTime(newsTimeStart, newsTimeEnd);
+            }
+        }
+        //都为空执行分页查询
+        PoNews poNews = new PoNews();
+        return poNewsMapper.selectPoNewsList(poNews);
+    }
+
+    /**
+     * 获取详细消息内容
+     * @param newsId
+     * @return
+     */
+    @Override
+    public PoNews selectContentByNewsId(String newsId) {
+        return poNewsMapper.selectContentByNewsId(newsId);
+    }
+
+    /**
+     * 校验图片是否重复
+     * @param poNews
+     * @return
+     */
+    @Override
+    public String checkPostNewsImageUnique(PoNews poNews) {
+
+        String poNewsId = StringUtils.isNull(poNews.getNewsId()) ? "图片不存在" : poNews.getNewsId();
+
+        PoNews info = poNewsMapper.checkPostNewsImageUnique(poNews.getImage());
+        if (StringUtils.isNotNull(info) && info.getNewsId() != poNewsId) {
+            return UserConstants.NOT_UNIQUE;
+        }
+        return UserConstants.UNIQUE;
+    }
+
+    /**
+     * 校验时间是否相等
+     * @param poNews
+     * @return
+     */
+    @Override
+    public String checkPostNewsTimeUnique(PoNews poNews) {
+        String poNewsId = StringUtils.isNull(poNews.getNewsId())? "图片不存在" : poNews.getNewsId();
+        PoNews info = poNewsMapper.checkPostNewsTimeUnique(poNews.getCreateTime());
+        if (StringUtils.isNotNull(info) && info.getNewsId() != poNewsId){
+            return UserConstants.NOT_UNIQUE;
+        }
+            return UserConstants.UNIQUE;
+    }
+
+
+}
+

+ 179 - 0
ruoyi-system/src/main/resources/mapper/system/PoNewsMapper.xml

@@ -0,0 +1,179 @@
+<?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.PoNewsMapper">
+
+    <resultMap type="PoNews" id="PoNewsResult">
+        <result property="newsId"    column="news_id"    />
+        <result property="newsTitle"    column="news_title"    />
+        <result property="newsContent"    column="news_content"    />
+        <result property="status"    column="status"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+        <result property="sort"    column="sort"    />
+        <result property="publisherId"    column="publisher_id"    />
+        <result property="userId"    column="user_id"  />
+        <result property="delFlag" column="del_flag"/>
+        <result property="image"   column="image"/>
+        <result property="newsTime" column="news_time"/>
+    </resultMap>
+<!--查询po_news表所有-->
+    <sql id="selectPoNewsVo">
+        select news_id, news_title, news_content, status, create_by, create_time, update_by, update_time,
+               remark, sort, publisher_id, user_id ,del_flag ,image ,news_time from po_news
+    </sql>
+
+<!--    分页查询-->
+    <select id="selectPoNewsList" parameterType="PoNews" resultMap="PoNewsResult">
+        <include refid="selectPoNewsVo"/>
+        <where>
+            <if test="newsTitle != null  and newsTitle != ''"> and news_title = #{newsTitle}</if>
+            <if test="newsContent != null  and newsContent != ''"> and news_content = #{newsContent}</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+            <if test="sort != null "> and sort = #{sort}</if>
+            <if test="publisherId != null "> and publisher_id = #{publisherId}</if>
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="delFlag != null and delFlag != ''">and del_flag = #{delFlag}</if>
+            <if test="image != null and image != ''">and image = #{image}</if>
+            <if test="newsTime != null ">and news_time = #{newsTime}</if>
+        </where>
+    </select>
+
+<!--    通过Id查询-->
+    <select id="selectPoNewsByNewsId" parameterType="String" resultMap="PoNewsResult">
+        <include refid="selectPoNewsVo"/>
+        where news_id = #{newsId}
+    </select>
+
+<!--    增加-->
+    <insert id="insertPoNews" parameterType="PoNews">
+        insert into po_news
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="newsId != null">news_id,</if>
+            <if test="newsTitle != null and newsTitle != ''">news_title,</if>
+            <if test="newsContent != null and newsContent != ''">news_content,</if>
+            <if test="status != null">status,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+            <if test="sort != null">sort,</if>
+            <if test="publisherId != null">publisher_id,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="delFlag != null and delFlag != ''">del_flag,</if>
+            <if test="image != null and image != ''">image,</if>
+            <if test="newsTime != null">news_time,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="newsId != null">#{newsId},</if>
+            <if test="newsTitle != null and newsTitle != ''">#{newsTitle},</if>
+            <if test="newsContent != null and newsContent != ''">#{newsContent},</if>
+            <if test="status != null">#{status},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+            <if test="sort != null">#{sort},</if>
+            <if test="publisherId != null">#{publisherId},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="delFlag != null and delFlag != '' ">#{delFlag},</if>
+            <if test="image != null and image != ''">#{image},</if>
+            <if test="newsTime != null">#{newsTime},</if>
+        </trim>
+    </insert>
+
+<!--    修改-->
+    <update id="updatePoNews" parameterType="PoNews">
+        update po_news
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="newsTitle != null and newsTitle != ''">news_title = #{newsTitle},</if>
+            <if test="newsContent != null and newsContent != ''">news_content = #{newsContent},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+            <if test="sort != null">sort = #{sort},</if>
+            <if test="publisherId != null">publisher_id = #{publisherId},</if>
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag}</if>
+            <if test="image != null and image != ''">image = #{image}</if>
+            <if test="newsTime != null">news_time = #{newsTime}</if>
+        </trim>
+        where news_id = #{newsId}
+    </update>
+
+<!--    删除-->
+    <delete id="deletePoNewsByNewsId" parameterType="Long">
+        delete from po_news where news_id = #{newsId}
+    </delete>
+
+<!--    批量删除-->
+    <delete id="deletePoNewsByNewsIds" parameterType="String">
+        delete from po_news where news_id in
+        <foreach item="newsId" collection="array" open="(" separator="," close=")">
+            #{newsId}
+        </foreach>
+    </delete>
+
+
+    <!--    标题时间都不为空-->
+    <select id="selectPoNewsListByTitleAndNewsTimeStartAndNewsTimeEnd"
+            resultType="PoNews" resultMap="PoNewsResult">
+    <include refid="selectPoNewsVo"></include>
+    <where>
+        <if test="newsTitle != null  and newsTitle != ''"> and news_title like concat('%', #{newsTitle}, '%')</if>
+        <if test="newsTimeStart != null and newsTimeEnd != null "> and news_time between #{newsTimeStart} and #{newsTimeEnd}</if>
+    </where>
+    </select>
+
+<!--    标题不为空时间为空-->
+    <select id="selectPoNewsListByTitle" resultType="PoNews" resultMap="PoNewsResult">
+        <include refid="selectPoNewsVo"></include>
+        <where>
+            <if test="newsTitle != null and newsTitle != ''">and news_title like concat('%', #{newsTitle}, '%')</if>
+        </where>
+    </select>
+
+<!--    标题为空时间不为空-->
+    <select id="selectPoNewsByTime" resultType="PoNews" resultMap="PoNewsResult">
+        <include refid="selectPoNewsVo"></include>
+        <where>
+            <if test="newsTimeStart != null and newsTimeEnd != null "> and news_time between #{newsTimeStart} and #{newsTimeEnd}</if>
+        </where>
+    </select>
+
+<!--    查询详细内容-->
+    <select id="selectContentByNewsId" resultType="PoNews" resultMap="PoNewsResult">
+         select news_content from po_news where news_id = #{newsId}
+    </select>
+
+<!--    校验标题是否重复-->
+    <select id="checkPostNewsTitleUnique" resultType="String" resultMap="PoNewsResult">
+        select news_id, news_title from po_news where news_title = #{newsTitle} and del_flag = '0' limit 1
+    </select>
+
+    <!--    校验图片是否重复-->
+    <select id="checkPostNewsImageUnique" resultType="String" resultMap="PoNewsResult">
+        select news_id,image from po_news where image = #{image} and del_flag = '0' limit 1
+    </select>
+
+    <!--    通过消息Id查询用户Id-->
+    <select id="selectUserByNewsId" resultType="String">
+            select u.user_id from po_news n LEFT JOIN po_user u ON n.user_id = u.user_id
+            where n.news_id = #{newsId}
+    </select>
+<!--    校验时间是否相同-->
+    <select id="checkPostNewsTimeUnique" resultType="String" resultMap="PoNewsResult">
+        select news_id,create_time from po_news where create_time = #{createTime} and del_flag = '0' limit 1
+    </select>
+
+
+</mapper>