Jelajahi Sumber

留言板功能实体类

yanliming 1 tahun lalu
induk
melakukan
e8fe03f3aa

+ 18 - 0
common/src/main/java/com/jpsoft/employment/modules/base/dao/MessageBoardDAO.java

@@ -0,0 +1,18 @@
+package com.jpsoft.employment.modules.base.dao;
+
+import java.util.List;
+import org.springframework.stereotype.Repository;
+import com.jpsoft.employment.modules.base.entity.MessageBoard;
+import java.util.Map;
+import com.jpsoft.employment.modules.common.dto.Sort;
+
+@Repository
+public interface MessageBoardDAO {
+	int insert(MessageBoard entity);
+	int update(MessageBoard entity);
+	int exist(String id);
+	MessageBoard get(String id);
+	int delete(String id);
+	List<MessageBoard> list();
+	List<MessageBoard> search(Map<String, Object> searchParams, List<Sort> sortList);
+}

+ 72 - 0
common/src/main/java/com/jpsoft/employment/modules/base/entity/MessageBoard.java

@@ -0,0 +1,72 @@
+package com.jpsoft.employment.modules.base.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+import java.math.BigDecimal;
+import org.springframework.format.annotation.DateTimeFormat;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+  描述:base_message_board的实体类
+ */
+@Data
+@ApiModel(value = "base_message_board的实体类")
+public class MessageBoard {
+		@ApiModelProperty(value = "ID")
+	private String id;
+	
+				@ApiModelProperty(value = "留言标题")
+	private String title;
+	
+				@ApiModelProperty(value = "留言内容")
+	private String content;
+	
+				@ApiModelProperty(value = "留言人")
+	private String regUserId;
+	
+				@ApiModelProperty(value = "回复内容")
+	private String replyContent;
+	
+				@ApiModelProperty(value = "回复人")
+	private String replyBy;
+	
+					@ApiModelProperty(value = "回复时间")
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	private Date replyTime;
+	
+			@ApiModelProperty(value = "状态(1:审核中,2:已审核)")
+	private String status;
+	
+					@ApiModelProperty(value = "审核时间")
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	private Date auditTime;
+	
+			@ApiModelProperty(value = "审核人")
+	private String auditBy;
+	
+				@ApiModelProperty(value = "创建人")
+	private String createBy;
+	
+					@ApiModelProperty(value = "创建时间")
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	private Date createTime;
+	
+			@ApiModelProperty(value = "更新人")
+	private String updateBy;
+	
+					@ApiModelProperty(value = "更新时间")
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	private Date updateTime;
+	
+			@ApiModelProperty(value = "是否删除")
+	private Boolean delFlag;
+	
+		}

+ 17 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/MessageBoardService.java

@@ -0,0 +1,17 @@
+package com.jpsoft.employment.modules.base.service;
+
+import java.util.List;
+import java.util.Map;
+import com.jpsoft.employment.modules.base.entity.MessageBoard;
+import com.github.pagehelper.Page;
+import com.jpsoft.employment.modules.common.dto.Sort;
+
+public interface MessageBoardService {
+	MessageBoard get(String id);
+	boolean exist(String id);
+	int insert(MessageBoard model);
+	int update(MessageBoard model);
+	int delete(String id);
+	List<MessageBoard> list();
+	Page<MessageBoard> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+}

+ 70 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/impl/MessageBoardServiceImpl.java

@@ -0,0 +1,70 @@
+package com.jpsoft.employment.modules.base.service.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.annotation.Resource;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import com.jpsoft.employment.modules.base.dao.MessageBoardDAO;
+import com.jpsoft.employment.modules.base.entity.MessageBoard;
+import com.jpsoft.employment.modules.base.service.MessageBoardService;
+import com.github.pagehelper.Page;
+import com.jpsoft.employment.modules.common.dto.Sort;
+import com.github.pagehelper.PageHelper;
+
+@Transactional
+@Component(value="messageBoardService")
+public class MessageBoardServiceImpl implements MessageBoardService {
+	@Resource(name="messageBoardDAO")
+	private MessageBoardDAO messageBoardDAO;
+
+	@Override
+	public MessageBoard get(String id) {
+		// TODO Auto-generated method stub
+		return messageBoardDAO.get(id);
+	}
+
+	@Override
+	public int insert(MessageBoard model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return messageBoardDAO.insert(model);
+	}
+
+	@Override
+	public int update(MessageBoard model) {
+		// TODO Auto-generated method stub
+		return messageBoardDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return messageBoardDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = messageBoardDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<MessageBoard> list() {
+		// TODO Auto-generated method stub
+		return messageBoardDAO.list();
+	}
+		
+	@Override
+	public Page<MessageBoard> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
+        Page<MessageBoard> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+            messageBoardDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+}

+ 126 - 0
common/src/main/resources/mapper/base/MessageBoard.xml

@@ -0,0 +1,126 @@
+<?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">
+<!-- namespace必须指向DAO接口 -->
+<mapper namespace="com.jpsoft.employment.modules.base.dao.MessageBoardDAO">
+	<resultMap id="MessageBoardMap" type="com.jpsoft.employment.modules.base.entity.MessageBoard">
+		<id property="id" column="id_" />
+			<result property="title" column="title_" />
+			<result property="content" column="content_" />
+			<result property="regUserId" column="reg_user_id" />
+			<result property="replyContent" column="reply_content_" />
+			<result property="replyBy" column="reply_by" />
+			<result property="replyTime" column="reply_time" />
+			<result property="status" column="status_" />
+			<result property="auditTime" column="audit_time" />
+			<result property="auditBy" column="audit_by" />
+			<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="delFlag" column="del_flag" />
+			</resultMap>
+	<insert id="insert" parameterType="com.jpsoft.employment.modules.base.entity.MessageBoard">
+	<!--
+	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![CDATA[
+		insert into base_message_board
+	    (id_,title_,content_,reg_user_id,reply_content_,reply_by,reply_time,status_,audit_time,audit_by,create_by,create_time,update_by,update_time,del_flag)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{title,jdbcType=VARCHAR}
+,#{content,jdbcType=VARCHAR}
+,#{regUserId,jdbcType=VARCHAR}
+,#{replyContent,jdbcType=VARCHAR}
+,#{replyBy,jdbcType=VARCHAR}
+,#{replyTime,jdbcType= TIMESTAMP }
+,#{status,jdbcType=VARCHAR}
+,#{auditTime,jdbcType= TIMESTAMP }
+,#{auditBy,jdbcType=VARCHAR}
+,#{createBy,jdbcType=VARCHAR}
+,#{createTime,jdbcType= TIMESTAMP }
+,#{updateBy,jdbcType=VARCHAR}
+,#{updateTime,jdbcType= TIMESTAMP }
+,#{delFlag,jdbcType= NUMERIC }
+		)
+	]]>
+	</insert>
+	<delete id="delete" parameterType="string">
+		delete from base_message_board where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.employment.modules.base.entity.MessageBoard">
+		update base_message_board
+		<set>
+				<if test="title!=null">
+		title_=#{title,jdbcType=VARCHAR},
+		</if>
+				<if test="content!=null">
+		content_=#{content,jdbcType=VARCHAR},
+		</if>
+				<if test="regUserId!=null">
+		reg_user_id=#{regUserId,jdbcType=VARCHAR},
+		</if>
+				<if test="replyContent!=null">
+		reply_content_=#{replyContent,jdbcType=VARCHAR},
+		</if>
+				<if test="replyBy!=null">
+		reply_by=#{replyBy,jdbcType=VARCHAR},
+		</if>
+				<if test="replyTime!=null">
+		reply_time=#{replyTime,jdbcType= TIMESTAMP },
+		</if>
+				<if test="status!=null">
+		status_=#{status,jdbcType=VARCHAR},
+		</if>
+				<if test="auditTime!=null">
+		audit_time=#{auditTime,jdbcType= TIMESTAMP },
+		</if>
+				<if test="auditBy!=null">
+		audit_by=#{auditBy,jdbcType=VARCHAR},
+		</if>
+				<if test="createBy!=null">
+		create_by=#{createBy,jdbcType=VARCHAR},
+		</if>
+				<if test="createTime!=null">
+		create_time=#{createTime,jdbcType= TIMESTAMP },
+		</if>
+				<if test="updateBy!=null">
+		update_by=#{updateBy,jdbcType=VARCHAR},
+		</if>
+				<if test="updateTime!=null">
+		update_time=#{updateTime,jdbcType= TIMESTAMP },
+		</if>
+				<if test="delFlag!=null">
+		del_flag=#{delFlag,jdbcType= NUMERIC },
+		</if>
+		</set>
+	where id_=#{id}
+	</update>
+	<select id="get" parameterType="string" resultMap="MessageBoardMap">
+		select * from base_message_board where id_=#{0}
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_message_board where id_=#{0}
+	</select>
+	<select id="list" resultMap="MessageBoardMap">
+		select * from base_message_board
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="MessageBoardMap">
+		<![CDATA[
+			select * from base_message_board
+		]]>
+		<where>
+			del_flag = false
+			<if test="searchParams.id != null">
+				and ID_ like #{searchParams.id}
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+	        ${sort.name} ${sort.order}
+	 	</foreach>
+	</select>
+</mapper>

+ 227 - 0
web/src/main/java/com/jpsoft/employment/modules/base/controller/MessageBoardController.java

@@ -0,0 +1,227 @@
+package com.jpsoft.employment.modules.base.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.employment.modules.common.dto.MessageResult;
+import com.jpsoft.employment.modules.common.utils.PojoUtils;
+import com.jpsoft.employment.modules.common.dto.Sort;
+import com.jpsoft.employment.modules.base.entity.MessageBoard;
+import com.jpsoft.employment.modules.base.service.MessageBoardService;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@RestController
+@RequestMapping("/base/messageBoard")
+public class MessageBoardController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private MessageBoardService messageBoardService;
+	
+	
+	@ApiOperation(value="创建空记录")
+    @GetMapping("create")
+    public MessageResult<MessageBoard> create(){
+        MessageResult<MessageBoard> msgResult = new MessageResult<>();
+
+        MessageBoard messageBoard = new MessageBoard();
+
+        msgResult.setData(messageBoard);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="添加信息")
+    @PostMapping("add")
+    public MessageResult<MessageBoard> add(@RequestBody MessageBoard messageBoard,@RequestAttribute String subject){
+        MessageResult<MessageBoard> msgResult = new MessageResult<>();
+
+        try {
+            messageBoard.setId(UUID.randomUUID().toString());
+			messageBoard.setDelFlag(false);
+            messageBoard.setCreateBy(subject);
+            messageBoard.setCreateTime(new Date());
+
+            int affectCount = messageBoardService.insert(messageBoard);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(messageBoard);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="获取信息")
+    @GetMapping("edit/{id}")
+    public MessageResult<MessageBoard> edit(@PathVariable("id") String id){
+        MessageResult<MessageBoard> msgResult = new MessageResult<>();
+
+        try {
+            MessageBoard messageBoard = messageBoardService.get(id);
+
+            if (messageBoard != null) {
+                msgResult.setResult(true);
+                msgResult.setData(messageBoard);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="更新用户")
+    @PostMapping("update")
+    public MessageResult<MessageBoard> update(@RequestBody MessageBoard messageBoard,@RequestAttribute String subject){
+        MessageResult<MessageBoard> msgResult = new MessageResult<>();
+
+        try {
+		    messageBoard.setUpdateBy(subject);
+            messageBoard.setUpdateTime(new Date());
+		
+            int affectCount = messageBoardService.update(messageBoard);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(messageBoard);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="删除用户")
+    @PostMapping("delete/{id}")
+    public MessageResult<MessageBoard> delete(@PathVariable("id") String id,@RequestAttribute String subject){
+        MessageResult<MessageBoard> msgResult = new MessageResult<>();
+
+        try {
+			
+			MessageBoard messageBoard = messageBoardService.get(id);
+            messageBoard.setDelFlag(true);
+            messageBoard.setUpdateBy(subject);
+            messageBoard.setUpdateTime(new Date());
+			
+			int affectCount = messageBoardService.update(messageBoard);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value="批量删除")
+    @PostMapping("batchDelete")
+    public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            for (String id : idList) {
+                MessageBoard messageBoard = messageBoardService.get(id);
+                messageBoard.setDelFlag(true);
+                messageBoard.setUpdateBy(subject);
+                messageBoard.setUpdateTime(new Date());
+
+                affectCount += messageBoardService.update(messageBoard);
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="列表")
+    @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    public MessageResult<Map> pageList(
+            String id,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            HttpServletRequest request){
+        String subject = (String)request.getAttribute("subject");
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("create_time","desc"));
+
+        if (StringUtils.isNotEmpty(id)) {
+            searchParams.put("id","%" + id + "%");
+        }
+
+
+        Page<MessageBoard> page = messageBoardService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+}

+ 1 - 1
web/src/main/java/com/jpsoft/employment/modules/base/controller/ParticipateProjectInfoController.java

@@ -229,7 +229,7 @@ public class ParticipateProjectInfoController {
         Map<String,Object> searchParams = new HashMap<>();
 
         List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("create_time","desc"));
+        sortList.add(new Sort("a.create_time","desc"));
 
         if (StringUtils.isNotEmpty(regUserName)) {
             searchParams.put("regUserName",regUserName + "%");