Selaa lähdekoodia

消息接口代码提交

xiao547607 3 vuotta sitten
vanhempi
commit
5cea247222

+ 22 - 0
common/src/main/java/com/jpsoft/employment/modules/base/dao/MessageNoticeDAO.java

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

+ 55 - 0
common/src/main/java/com/jpsoft/employment/modules/base/entity/MessageNotice.java

@@ -0,0 +1,55 @@
+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_notice的实体类
+ */
+@Data
+@ApiModel(value = "base_message_notice的实体类")
+public class MessageNotice {
+        @ApiModelProperty(value = "ID")
+    private String id;
+        @ApiModelProperty(value = "标题")
+    private String title;
+        @ApiModelProperty(value = "内容")
+    private String content;
+        @ApiModelProperty(value = "收件人ID")
+    private String recipientId;
+        @ApiModelProperty(value = "审核状态是否")
+    private Boolean status;
+        @ApiModelProperty(value = "是否删除")
+    private Boolean delFlag;
+        @ApiModelProperty(value = "创建人")
+    private String createBy;
+    @ApiModelProperty(value = "创建人")
+    private String createByN;
+        @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+        @ApiModelProperty(value = "更新人")
+    private String updateBy;
+        @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+        @ApiModelProperty(value = "分类(字典:通知分类")
+    private String classify;
+        @ApiModelProperty(value = "类型:1站内通告,2微信")
+    private String type;
+        @ApiModelProperty(value = "点击超链接")
+    private String noticeLink;
+        @ApiModelProperty(value = "是否发送微信消息")
+    private Boolean sendWechat;
+        @ApiModelProperty(value = "消息模板code")
+    private String wechatCode;
+}

+ 21 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/MessageNoticeService.java

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

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

@@ -0,0 +1,86 @@
+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 com.jpsoft.employment.modules.base.dao.MessageNoticeDAO;
+import com.jpsoft.employment.modules.base.entity.MessageNotice;
+import com.jpsoft.employment.modules.base.service.MessageNoticeService;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import com.jpsoft.employment.modules.common.dto.Sort;
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+
+@Transactional
+@Component(value="messageNoticeService")
+public class MessageNoticeServiceImpl implements MessageNoticeService {
+	@Resource(name="messageNoticeDAO")
+	private MessageNoticeDAO messageNoticeDAO;
+
+	@Override
+	public MessageNotice get(String id) {
+		// TODO Auto-generated method stub
+		return messageNoticeDAO.get(id);
+	}
+
+	@Override
+	public int insert(MessageNotice model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return messageNoticeDAO.insert(model);
+	}
+
+	@Override
+	public int update(MessageNotice model) {
+		// TODO Auto-generated method stub
+		return messageNoticeDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return messageNoticeDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = messageNoticeDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<MessageNotice> list() {
+		// TODO Auto-generated method stub
+		return messageNoticeDAO.list();
+	}
+		
+	@Override
+	public Page<MessageNotice> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
+        Page<MessageNotice> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+            messageNoticeDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+
+	@Override
+	public List<MessageNotice> findByUserIdAndClassify(String userId,String classify){
+		return messageNoticeDAO.findByUserIdAndClassify(userId,classify);
+	}
+
+	@Override
+	public List<MessageNotice> findByUserId(String userId){
+		return messageNoticeDAO.findByUserId(userId);
+	}
+
+	@Override
+	public MessageNotice findTopByUserIdAndClassify(String userId,String classify){
+		return messageNoticeDAO.findTopByUserIdAndClassify(userId,classify);
+	}
+}

+ 190 - 0
common/src/main/resources/mapper/base/MessageNotice.xml

@@ -0,0 +1,190 @@
+<?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.MessageNoticeDAO">
+	<resultMap id="MessageNoticeMap" type="com.jpsoft.employment.modules.base.entity.MessageNotice">
+		<id property="id" column="id_" />
+			<result property="title" column="title_" />
+			<result property="content" column="content_" />
+			<result property="recipientId" column="recipient_id" />
+			<result property="status" column="status_" />
+			<result property="delFlag" column="del_flag" />
+			<result property="createBy" column="create_by" />
+			<result property="createByN" column="create_by_name" />
+			<result property="createTime" column="create_time" />
+			<result property="updateBy" column="update_by" />
+			<result property="updateTime" column="update_time" />
+			<result property="classify" column="classify_" />
+			<result property="type" column="type_" />
+			<result property="noticeLink" column="notice_link" />
+			<result property="sendWechat" column="send_wechat" />
+			<result property="wechatCode" column="wechat_code" />
+			</resultMap>
+	<insert id="insert" parameterType="com.jpsoft.employment.modules.base.entity.MessageNotice">
+	<!--
+	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![CDATA[
+		insert into base_message_notice
+	    (id_,title_,content_,recipient_id,status_,del_flag,create_by,create_time,update_by,update_time,classify_,type_,notice_link,send_wechat,wechat_code)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{title,jdbcType=VARCHAR}
+,#{content,jdbcType= NUMERIC }
+,#{recipientId,jdbcType= NUMERIC }
+,#{status,jdbcType= NUMERIC }
+,#{delFlag,jdbcType= NUMERIC }
+,#{createBy,jdbcType=VARCHAR}
+,#{createTime,jdbcType= TIMESTAMP }
+,#{updateBy,jdbcType=VARCHAR}
+,#{updateTime,jdbcType= TIMESTAMP }
+,#{classify,jdbcType=VARCHAR}
+,#{type,jdbcType=VARCHAR}
+,#{noticeLink,jdbcType=VARCHAR}
+,#{sendWechat,jdbcType= NUMERIC }
+,#{wechatCode,jdbcType=VARCHAR}
+		)
+	]]>
+	</insert>
+	<delete id="delete" parameterType="string">
+		delete from base_message_notice where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.employment.modules.base.entity.MessageNotice">
+		update base_message_notice
+		<set>
+				<if test="title!=null">
+		title_=#{title,jdbcType=VARCHAR},
+		</if>
+				<if test="content!=null">
+		content_=#{content,jdbcType= NUMERIC },
+		</if>
+				<if test="recipientId!=null">
+		recipient_id=#{recipientId,jdbcType= NUMERIC },
+		</if>
+				<if test="status!=null">
+		status_=#{status,jdbcType= NUMERIC },
+		</if>
+				<if test="delFlag!=null">
+		del_flag=#{delFlag,jdbcType= NUMERIC },
+		</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="classify!=null">
+		classify_=#{classify,jdbcType=VARCHAR},
+		</if>
+				<if test="type!=null">
+		type_=#{type,jdbcType=VARCHAR},
+		</if>
+				<if test="noticeLink!=null">
+		notice_link=#{noticeLink,jdbcType=VARCHAR},
+		</if>
+				<if test="sendWechat!=null">
+		send_wechat=#{sendWechat,jdbcType= NUMERIC },
+		</if>
+				<if test="wechatCode!=null">
+		wechat_code=#{wechatCode,jdbcType=VARCHAR},
+		</if>
+		</set>
+	where id_=#{id}
+	</update>
+	<select id="get" parameterType="string" resultMap="MessageNoticeMap">
+		select * from base_message_notice where id_=#{0}
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_message_notice where id_=#{0}
+	</select>
+	<select id="list" resultMap="MessageNoticeMap">
+		select * from base_message_notice
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="MessageNoticeMap">
+		<![CDATA[
+			select
+				a.*,
+				b.real_name AS create_by_name
+			from base_message_notice a
+			LEFT JOIN sys_user b ON a.create_by = b.id_
+		]]>
+		<where>
+			a.del_flag=0
+			<if test="searchParams.id != null">
+				and a.ID_ like #{searchParams.id}
+			</if>
+			<if test="searchParams.recipientId != null">
+				and a.recipient_id = #{searchParams.recipientId}
+			</if>
+			<if test="searchParams.recipientIdAndNull != null">
+				and (a.recipient_id = #{searchParams.recipientId}
+				or a.recipient_id is null)
+			</if>
+			<if test="searchParams.classify != null">
+				and a.classify_ = #{searchParams.classify}
+			</if>
+			<if test="searchParams.type != null">
+				and a.type_ = #{searchParams.type}
+			</if>
+			<if test="searchParams.status != null">
+				and a.status_ = #{searchParams.status}
+			</if>
+			<if test="searchParams.title != null">
+				and a.title_ like #{searchParams.title}
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+	        ${sort.name} ${sort.order}
+	 	</foreach>
+	</select>
+	<select id="findByUserIdAndClassify" resultMap="MessageNoticeMap">
+		SELECT
+			*
+		FROM
+			base_message_notice
+		WHERE
+			del_flag = 0
+			AND classify_ = #{classify}
+			AND ( recipient_id = #{userId} OR recipient_id IS NULL )
+			AND status_ = '1'
+			AND type_ = '1'
+	</select>
+
+	<select id="findByUserId" resultMap="MessageNoticeMap">
+		SELECT
+			*
+		FROM
+			base_message_notice
+		WHERE
+			del_flag = 0
+			AND recipient_id = #{userId}
+			AND status_ = '1'
+			AND type_ = '1'
+	</select>
+
+	<select id="findTopByUserIdAndClassify" resultMap="MessageNoticeMap">
+		SELECT
+			*
+		FROM
+			base_message_notice
+		WHERE
+			del_flag = 0
+			AND classify_ = #{classify}
+			AND ( recipient_id = #{userId} OR recipient_id IS NULL )
+			AND status_ = '1'
+			AND type_ = '1'
+		ORDER BY
+			create_time
+		LIMIT 1
+	</select>
+</mapper>

+ 199 - 0
web/src/main/java/com/jpsoft/employment/modules/mobile/controller/MessageNoticeApiController.java

@@ -0,0 +1,199 @@
+package com.jpsoft.employment.modules.mobile.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.Page;
+import com.jpsoft.employment.config.OSSConfig;
+import com.jpsoft.employment.modules.base.entity.MessageNotice;
+import com.jpsoft.employment.modules.base.entity.UserAuthenticationApprove;
+import com.jpsoft.employment.modules.base.service.MessageNoticeService;
+import com.jpsoft.employment.modules.base.service.UserAuthenticationApproveService;
+import com.jpsoft.employment.modules.common.dto.MessageResult;
+import com.jpsoft.employment.modules.common.dto.Sort;
+import com.jpsoft.employment.modules.common.utils.*;
+import com.jpsoft.employment.modules.job.entity.JobUser;
+import com.jpsoft.employment.modules.job.service.JobUserService;
+import com.jpsoft.employment.modules.job.service.ResumeDeliverService;
+import com.jpsoft.employment.modules.job.service.ResumeService;
+import com.jpsoft.employment.modules.job.service.UserCollectionService;
+import com.jpsoft.employment.modules.sys.entity.DataDictionary;
+import com.jpsoft.employment.modules.sys.entity.SysLog;
+import com.jpsoft.employment.modules.sys.entity.User;
+import com.jpsoft.employment.modules.sys.service.DataDictionaryService;
+import com.jpsoft.employment.modules.sys.service.SysLogService;
+import com.jpsoft.employment.modules.sys.service.UserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.joda.time.DateTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import sun.misc.BASE64Decoder;
+
+import java.io.ByteArrayInputStream;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+@RestController
+@RequestMapping("/mobile/messageApi")
+@Api(description = "消息通知接口")
+@Slf4j
+public class MessageNoticeApiController {
+    @Value("${jwt.secret}")
+    private String jwtSecret;
+
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private JobUserService jobUserService;
+
+    @Autowired
+    private ValueOperations<String, Object> valueOperations;
+
+    @Autowired
+    private OSSConfig ossConfig;
+
+    @Autowired
+    private SysLogService sysLogService;
+
+    @Autowired
+    private MessageNoticeService messageNoticeService;
+
+    @Autowired
+    private DataDictionaryService dataDictionaryService;
+
+    @Autowired
+    private UserService userService;
+
+
+    @PostMapping("messageClassify")
+    @ApiOperation(value = "消息分类")
+    public MessageResult<List> messageClassify(
+            String token,
+            @RequestAttribute  String subject) {
+        MessageResult<List> messageResult = new MessageResult<>();
+        List<Map> resultList = new ArrayList<>();
+        try {
+            JobUser jobUser = jobUserService.get(subject);
+
+            if (jobUser == null) {
+                throw new Exception("未登录!");
+            }
+            List<DataDictionary> ddList = dataDictionaryService.findByCatalogName("消息分类");
+
+            for(DataDictionary dd :ddList){
+                Map<String, Object> mnMap = new HashMap<>();
+                MessageNotice mn = messageNoticeService.findTopByUserIdAndClassify(subject,dd.getValue());
+                mnMap.put("classify",dd.getName());
+                mnMap.put("classifyId",dd.getValue());
+                mnMap.put("newMessage",mn);
+                mnMap.put("num",0);
+
+                resultList.add(mnMap);
+            }
+
+            messageResult.setData(resultList);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage());
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @PostMapping("messageList")
+    @ApiOperation(value = "消息列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "classifyId", value = "消息分类ID", required = true, paramType = "query"),
+            @ApiImplicitParam(name = "pageIndex", value = "不传默认1", required = false, paramType = "query"),
+            @ApiImplicitParam(name = "pageSize", value = "不传默认5", required = false, paramType = "query"),
+    })
+    public MessageResult<Map> messageList(
+            String classifyId,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="5") int pageSize,
+            String token,
+            @RequestAttribute  String subject) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+            JobUser jobUser = jobUserService.get(subject);
+
+            if (jobUser == null) {
+                throw new Exception("未登录!");
+            }
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("a.create_time","asc"));
+
+            Map<String,Object> searchParams = new HashMap<>();
+            //List<MessageNotice> mnList = messageNoticeService.findByUserIdAndClassify(subject,classifyId);
+
+            searchParams.put("recipientIdAndNull",subject);
+            searchParams.put("classify",classifyId);
+            searchParams.put("status","1");
+            searchParams.put("type","1");
+
+            Page<MessageNotice> page = messageNoticeService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+            messageResult.setData(PojoUtils.pageWrapper(page));
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage());
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @PostMapping("messageDetail")
+    @ApiOperation(value = "消息详细")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "messageId", value = "消息ID", required = true, paramType = "query"),
+    })
+    public MessageResult<MessageNotice> messageDetail(
+            String messageId,
+            String token,
+            @RequestAttribute  String subject) {
+        MessageResult<MessageNotice> messageResult = new MessageResult<>();
+
+        try {
+            JobUser jobUser = jobUserService.get(subject);
+
+            if (jobUser == null) {
+                throw new Exception("未登录!");
+            }
+
+            MessageNotice mc = messageNoticeService.get(messageId);
+            if(mc == null){
+                throw new Exception("查询错误!");
+            }
+
+            User createUser = userService.get(mc.getCreateBy());
+            mc.setCreateByN(createUser.getRealName());
+
+            messageResult.setData(mc);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage());
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+}