运维社区运维论坛贴子和发表帖子功能

This commit is contained in:
zhangjunwen 2024-04-30 15:57:56 +08:00
parent 77f1a78e65
commit 6a9c997c5c
9 changed files with 726 additions and 1 deletions

View File

@ -84,7 +84,12 @@
<version>3.8.7</version> <version>3.8.7</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.inspur</groupId>
<artifactId>inspur-community</artifactId>
<version>3.8.7</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -0,0 +1,118 @@
package com.inspur.web.controller.community;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.inspur.community.domain.vo.CommunityPostInfoVO;
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.inspur.common.annotation.Log;
import com.inspur.common.core.controller.BaseController;
import com.inspur.common.core.domain.AjaxResult;
import com.inspur.common.enums.BusinessType;
import com.inspur.community.domain.CommunityPostInfo;
import com.inspur.community.service.ICommunityPostInfoService;
import com.inspur.common.utils.poi.ExcelUtil;
import com.inspur.common.core.page.TableDataInfo;
/**
* 社区帖子信息Controller
*
* @author inspur
* @date 2024-04-26
*/
@RestController
@RequestMapping("/community/info")
public class CommunityPostInfoController extends BaseController
{
@Autowired
private ICommunityPostInfoService communityPostInfoService;
/**
* 查询社区帖子信息列表
*/
@PreAuthorize("@ss.hasPermi('community:info:list')")
@GetMapping("/list")
public TableDataInfo list(CommunityPostInfo communityPostInfo)
{
startPage();
List<CommunityPostInfoVO> list = communityPostInfoService.selectCommunityPostInfoList(communityPostInfo);
return getDataTable(list);
}
/**
* 导出社区帖子信息列表
*/
@PreAuthorize("@ss.hasPermi('community:info:export')")
@Log(title = "社区帖子信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CommunityPostInfo communityPostInfo)
{
List<CommunityPostInfoVO> list = communityPostInfoService.selectCommunityPostInfoList(communityPostInfo);
ExcelUtil<CommunityPostInfoVO> util = new ExcelUtil<CommunityPostInfoVO>(CommunityPostInfoVO.class);
util.exportExcel(response, list, "社区帖子信息数据");
}
/**
* 获取社区帖子信息详细信息
*/
@PreAuthorize("@ss.hasPermi('community:info:query')")
@GetMapping(value = "/{postId}")
public AjaxResult getInfo(@PathVariable("postId") String postId)
{
return success(communityPostInfoService.selectCommunityPostInfoByPostId(postId));
}
/**
* 新增社区帖子信息
*/
@PreAuthorize("@ss.hasPermi('community:info:add')")
@Log(title = "社区帖子信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CommunityPostInfo communityPostInfo)
{
return toAjax(communityPostInfoService.insertCommunityPostInfo(communityPostInfo));
}
/**
* 修改社区帖子信息
*/
@PreAuthorize("@ss.hasPermi('community:info:edit')")
@Log(title = "社区帖子信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CommunityPostInfo communityPostInfo)
{
return toAjax(communityPostInfoService.updateCommunityPostInfo(communityPostInfo));
}
/**
* 添加浏览量
*/
@Log(title = "社区帖子信息", businessType = BusinessType.UPDATE)
@PutMapping("/addViews/{postId}")
public AjaxResult addViews(@PathVariable("postId") String postId)
{
return toAjax(communityPostInfoService.addViews(postId));
}
/**
* 删除社区帖子信息
*/
@PreAuthorize("@ss.hasPermi('community:info:remove')")
@Log(title = "社区帖子信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{postIds}")
public AjaxResult remove(@PathVariable String[] postIds)
{
return toAjax(communityPostInfoService.deleteCommunityPostInfoByPostIds(postIds));
}
}

View File

@ -0,0 +1,183 @@
package com.inspur.community.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.inspur.common.annotation.Excel;
import com.inspur.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 社区帖子信息对象 community_post_info
*
* @author zhangjunwen
* @date 2024-04-26
*/
public class CommunityPostInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private String postId;
/** 帖子类型0 经验交流 1 困难求助 2 观点吐槽 3 其他 */
@Excel(name = "帖子类型0 经验交流 1 困难求助 2 观点吐槽 3 其他")
private String postType;
/** 运维领域0故障机理、1信号采集方案、2信号处理方法、3维保策略 */
@Excel(name = "运维领域0故障机理、1信号采集方案、2信号处理方法、3维保策略")
private String omField;
/** 运维行业0 纺织1 陶瓷2 化工 */
@Excel(name = "运维行业0 纺织1 陶瓷2 化工")
private String omIndustry;
/** 帖子标题 */
@Excel(name = "帖子标题")
private String postTitle;
/** 帖子内容 */
@Excel(name = "帖子内容")
private String postContent;
/** 发布时间 */
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
@Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd hh:mm:ss")
private Date postTime;
/** 发布人 */
@Excel(name = "发布人")
private Long userId;
/** 最后编辑时间 */
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
@Excel(name = "最后编辑时间", width = 30, dateFormat = "yyyy-MM-dd hh:mm:ss")
private Date lastEditTime;
/**
* 浏览量
*/
private String views;
/** 状态0 正常1 封禁2 删除 */
@Excel(name = "状态0 正常1 封禁2 删除")
private String status;
public void setPostId(String postId)
{
this.postId = postId;
}
public String getPostId()
{
return postId;
}
public void setPostType(String postType)
{
this.postType = postType;
}
public String getPostType()
{
return postType;
}
public void setOmField(String omField)
{
this.omField = omField;
}
public String getOmField()
{
return omField;
}
public void setOmIndustry(String omIndustry)
{
this.omIndustry = omIndustry;
}
public String getOmIndustry()
{
return omIndustry;
}
public void setPostTitle(String postTitle)
{
this.postTitle = postTitle;
}
public String getPostTitle()
{
return postTitle;
}
public void setPostContent(String postContent)
{
this.postContent = postContent;
}
public String getPostContent()
{
return postContent;
}
public void setPostTime(Date postTime)
{
this.postTime = postTime;
}
public Date getPostTime()
{
return postTime;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setLastEditTime(Date lastEditTime)
{
this.lastEditTime = lastEditTime;
}
public Date getLastEditTime()
{
return lastEditTime;
}
public String getViews() {
return views;
}
public void setViews(String views) {
this.views = views;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("postId", getPostId())
.append("postType", getPostType())
.append("omField", getOmField())
.append("omIndustry", getOmIndustry())
.append("postTitle", getPostTitle())
.append("postContent", getPostContent())
.append("postTime", getPostTime())
.append("userId", getUserId())
.append("lastEditTime", getLastEditTime())
.append("views", getViews())
.append("status", getStatus())
.toString();
}
}

View File

@ -0,0 +1,43 @@
package com.inspur.community.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.inspur.common.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* @Author zhangjunwen
* @create 2024/4/30
*/
@Data
public class CommunityPostInfoVO {
private String postId;
private String postType;
private String omField;
private String omIndustry;
private String postTitle;
private String postContent;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date postTime;
private Long userId;
private String userName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date lastEditTime;
private long views;
private String status;
}

View File

@ -0,0 +1,70 @@
package com.inspur.community.mapper;
import java.util.List;
import com.inspur.community.domain.CommunityPostInfo;
import com.inspur.community.domain.vo.CommunityPostInfoVO;
/**
* 社区帖子信息Mapper接口
*
* @author inspur
* @date 2024-04-26
*/
public interface CommunityPostInfoMapper
{
/**
* 查询社区帖子信息
*
* @param postId 社区帖子信息主键
* @return 社区帖子信息
*/
public CommunityPostInfoVO selectCommunityPostInfoByPostId(String postId);
/**
* 查询社区帖子信息列表
*
* @param communityPostInfo 社区帖子信息
* @return 社区帖子信息集合
*/
public List<CommunityPostInfoVO> selectCommunityPostInfoList(CommunityPostInfo communityPostInfo);
/**
* 新增社区帖子信息
*
* @param communityPostInfo 社区帖子信息
* @return 结果
*/
public int insertCommunityPostInfo(CommunityPostInfo communityPostInfo);
/**
* 修改社区帖子信息
*
* @param communityPostInfo 社区帖子信息
* @return 结果
*/
public int updateCommunityPostInfo(CommunityPostInfo communityPostInfo);
/**
* 添加浏览量
* @param postId
* @return
*/
public int addViews(String postId);
/**
* 删除社区帖子信息
*
* @param postId 社区帖子信息主键
* @return 结果
*/
public int deleteCommunityPostInfoByPostId(String postId);
/**
* 批量删除社区帖子信息
*
* @param postIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteCommunityPostInfoByPostIds(String[] postIds);
}

View File

@ -0,0 +1,70 @@
package com.inspur.community.service;
import java.util.List;
import com.inspur.community.domain.CommunityPostInfo;
import com.inspur.community.domain.vo.CommunityPostInfoVO;
/**
* 社区帖子信息Service接口
*
* @author zhangjunwen
* @date 2024-04-26
*/
public interface ICommunityPostInfoService
{
/**
* 查询社区帖子信息
*
* @param postId 社区帖子信息主键
* @return 社区帖子信息
*/
public CommunityPostInfoVO selectCommunityPostInfoByPostId(String postId);
/**
* 查询社区帖子信息列表
*
* @param communityPostInfo 社区帖子信息
* @return 社区帖子信息集合
*/
public List<CommunityPostInfoVO> selectCommunityPostInfoList(CommunityPostInfo communityPostInfo);
/**
* 新增社区帖子信息
*
* @param communityPostInfo 社区帖子信息
* @return 结果
*/
public int insertCommunityPostInfo(CommunityPostInfo communityPostInfo);
/**
* 修改社区帖子信息
*
* @param communityPostInfo 社区帖子信息
* @return 结果
*/
public int updateCommunityPostInfo(CommunityPostInfo communityPostInfo);
/**
* 添加浏览量
* @param postId
* @return
*/
public int addViews(String postId);
/**
* 批量删除社区帖子信息
*
* @param postIds 需要删除的社区帖子信息主键集合
* @return 结果
*/
public int deleteCommunityPostInfoByPostIds(String[] postIds);
/**
* 删除社区帖子信息信息
*
* @param postId 社区帖子信息主键
* @return 结果
*/
public int deleteCommunityPostInfoByPostId(String postId);
}

View File

@ -0,0 +1,113 @@
package com.inspur.community.service.impl;
import java.util.Date;
import java.util.List;
import com.inspur.common.utils.SecurityUtils;
import com.inspur.common.utils.uuid.IdUtils;
import com.inspur.community.domain.vo.CommunityPostInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.inspur.community.mapper.CommunityPostInfoMapper;
import com.inspur.community.domain.CommunityPostInfo;
import com.inspur.community.service.ICommunityPostInfoService;
/**
* 社区帖子信息Service业务层处理
*
* @author zhangjunwen
* @date 2024-04-26
*/
@Service
public class CommunityPostInfoServiceImpl implements ICommunityPostInfoService
{
@Autowired
private CommunityPostInfoMapper communityPostInfoMapper;
/**
* 查询社区帖子信息
*
* @param postId 社区帖子信息主键
* @return 社区帖子信息
*/
@Override
public CommunityPostInfoVO selectCommunityPostInfoByPostId(String postId)
{
return communityPostInfoMapper.selectCommunityPostInfoByPostId(postId);
}
/**
* 查询社区帖子信息列表
*
* @param communityPostInfo 社区帖子信息
* @return 社区帖子信息
*/
@Override
public List<CommunityPostInfoVO> selectCommunityPostInfoList(CommunityPostInfo communityPostInfo)
{
return communityPostInfoMapper.selectCommunityPostInfoList(communityPostInfo);
}
/**
* 新增社区帖子信息
*
* @param communityPostInfo 社区帖子信息
* @return 结果
*/
@Override
public int insertCommunityPostInfo(CommunityPostInfo communityPostInfo)
{
communityPostInfo.setPostId(IdUtils.simpleUUID());
communityPostInfo.setPostTime(new Date());
communityPostInfo.setUserId(SecurityUtils.getUserId());
return communityPostInfoMapper.insertCommunityPostInfo(communityPostInfo);
}
/**
* 修改社区帖子信息
*
* @param communityPostInfo 社区帖子信息
* @return 结果
*/
@Override
public int updateCommunityPostInfo(CommunityPostInfo communityPostInfo)
{
communityPostInfo.setLastEditTime(new Date());
return communityPostInfoMapper.updateCommunityPostInfo(communityPostInfo);
}
/**
* 添加浏览量
* @param postId
* @return
*/
@Override
public int addViews(String postId){
return communityPostInfoMapper.addViews(postId);
}
/**
* 批量删除社区帖子信息
*
* @param postIds 需要删除的社区帖子信息主键
* @return 结果
*/
@Override
public int deleteCommunityPostInfoByPostIds(String[] postIds)
{
return communityPostInfoMapper.deleteCommunityPostInfoByPostIds(postIds);
}
/**
* 删除社区帖子信息信息
*
* @param postId 社区帖子信息主键
* @return 结果
*/
@Override
public int deleteCommunityPostInfoByPostId(String postId)
{
return communityPostInfoMapper.deleteCommunityPostInfoByPostId(postId);
}
}

View File

@ -0,0 +1,111 @@
<?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.inspur.community.mapper.CommunityPostInfoMapper">
<resultMap type="CommunityPostInfoVO" id="CommunityPostInfoResult">
<result property="postId" column="post_id" />
<result property="postType" column="post_type" />
<result property="omField" column="om_field" />
<result property="omIndustry" column="om_industry" />
<result property="postTitle" column="post_title" />
<result property="postContent" column="post_content" />
<result property="postTime" column="post_time" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="lastEditTime" column="last_edit_time" />
<result property="views" column="views"/>
<result property="status" column="status" />
</resultMap>
<sql id="selectCommunityPostInfoVo">
select post_id, post_type, om_field, om_industry, post_title, post_content, post_time, a.user_id, last_edit_time,views, a.status, b.nick_name as user_name from community_post_info a
left join sys_user b on a.user_id = b.user_id
</sql>
<select id="selectCommunityPostInfoList" parameterType="CommunityPostInfo" resultMap="CommunityPostInfoResult">
<include refid="selectCommunityPostInfoVo"/>
<where>
<if test="postType != null and postType != ''"> and post_type = #{postType}</if>
<if test="omField != null and omField != ''"> and om_field = #{omField}</if>
<if test="omIndustry != null and omIndustry != ''"> and om_industry = #{omIndustry}</if>
<if test="postTitle != null and postTitle != ''"> and post_title = #{postTitle}</if>
<if test="postContent != null and postContent != ''"> and post_content = #{postContent}</if>
<if test="postTime != null "> and post_time = #{postTime}</if>
<if test="userId != null "> and a.user_id = #{userId}</if>
<if test="lastEditTime != null "> and last_edit_time = #{lastEditTime}</if>
<if test="views != null "> and views = #{views}</if>
<if test="status != null and status != ''"> and a.status = #{status}</if>
</where>
order by post_time desc
</select>
<select id="selectCommunityPostInfoByPostId" parameterType="String" resultMap="CommunityPostInfoResult">
<include refid="selectCommunityPostInfoVo"/>
where post_id = #{postId}
</select>
<insert id="insertCommunityPostInfo" parameterType="CommunityPostInfo">
insert into community_post_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="postId != null">post_id,</if>
<if test="postType != null">post_type,</if>
<if test="omField != null">om_field,</if>
<if test="omIndustry != null">om_industry,</if>
<if test="postTitle != null">post_title,</if>
<if test="postContent != null">post_content,</if>
<if test="postTime != null">post_time,</if>
<if test="userId != null">user_id,</if>
<if test="lastEditTime != null">last_edit_time,</if>
<if test="views != null">views,</if>
<if test="status != null">mstatus,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="postId != null">#{postId},</if>
<if test="postType != null">#{postType},</if>
<if test="omField != null">#{omField},</if>
<if test="omIndustry != null">#{omIndustry},</if>
<if test="postTitle != null">#{postTitle},</if>
<if test="postContent != null">#{postContent},</if>
<if test="postTime != null">#{postTime},</if>
<if test="userId != null">#{userId},</if>
<if test="lastEditTime != null">#{lastEditTime},</if>
<if test="views != null">#{views},</if>
<if test="status != null">#{status},</if>
</trim>
</insert>
<update id="updateCommunityPostInfo" parameterType="CommunityPostInfo">
update community_post_info
<trim prefix="SET" suffixOverrides=",">
<if test="postType != null">post_type = #{postType},</if>
<if test="omField != null">om_field = #{omField},</if>
<if test="omIndustry != null">om_industry = #{omIndustry},</if>
<if test="postTitle != null">post_title = #{postTitle},</if>
<if test="postContent != null">post_content = #{postContent},</if>
<if test="postTime != null">post_time = #{postTime},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="lastEditTime != null">last_edit_time = #{lastEditTime},</if>
<if test="views != null">views = #{views},</if>
<if test="status != null">status = #{status},</if>
</trim>
where post_id = #{postId}
</update>
<!--添加浏览量-->
<update id="addViews" parameterType="String">
update community_post_info set views = views + 1 where post_id = #{postId}
</update>
<delete id="deleteCommunityPostInfoByPostId" parameterType="String">
delete from community_post_info where post_id = #{postId}
</delete>
<delete id="deleteCommunityPostInfoByPostIds" parameterType="String">
delete from community_post_info where post_id in
<foreach item="postId" collection="array" open="(" separator="," close=")">
#{postId}
</foreach>
</delete>
</mapper>

View File

@ -174,6 +174,17 @@
<artifactId>inspur-order</artifactId> <artifactId>inspur-order</artifactId>
<version>${inspur.version}</version> <version>${inspur.version}</version>
</dependency> </dependency>
<!--论坛社区模块-->
<dependency>
<groupId>com.inspur</groupId>
<artifactId>inspur-community</artifactId>
<version>${inspur.version}</version>
</dependency>
<dependency>
<groupId>com.inspur</groupId>
<artifactId>inspur-knowledgeBase</artifactId>
<version>${inspur.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -186,6 +197,7 @@
<module>inspur-common</module> <module>inspur-common</module>
<module>inspur-om</module> <module>inspur-om</module>
<module>inspur-order</module> <module>inspur-order</module>
<module>inspur-community</module>
<module>inspur-knowledgeBase</module> <module>inspur-knowledgeBase</module>
<module>inspur-operations</module> <module>inspur-operations</module>
</modules> </modules>