Browse Source

获取我的消息

master
zhaoqifeng 5 years ago
parent
commit
28a0dcae4a
  1. 12
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/UserMessageController.java
  2. 12
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/UserMessageDao.java
  3. 8
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/UserMessageService.java
  4. 28
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/UserMessageServiceImpl.java
  5. 32
      epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/UserMessageDao.xml
  6. 10
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/feign/EpmetMessageFeignClient.java
  7. 8
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/feign/fallback/EpmetMessageFeignClientFallBack.java
  8. 7
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/message/controller/UserMessageController.java
  9. 5
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/message/service/UserMessageService.java
  10. 15
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/message/service/impl/UserMessageServiceImpl.java

12
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/UserMessageController.java

@ -23,9 +23,10 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.UserMessageDTO;
import com.epmet.dto.form.MymessageFormDTO;
import com.epmet.dto.form.UserMessageFormDTO;
import com.epmet.excel.UserMessageExcel;
import com.epmet.service.UserMessageService;
@ -50,8 +51,8 @@ public class UserMessageController {
@Autowired
private UserMessageService userMessageService;
@GetMapping("page")
public Result<PageData<UserMessageDTO>> page(@RequestParam Map<String, Object> params){
@PostMapping("page")
public Result<PageData<UserMessageDTO>> page(@RequestBody Map<String, Object> params){
PageData<UserMessageDTO> page = userMessageService.page(params);
return new Result<PageData<UserMessageDTO>>().ok(page);
}
@ -126,4 +127,9 @@ public class UserMessageController {
ValidatorUtils.validateEntity(formDto);
return userMessageService.saveUserMessage(formDto);
}
@PostMapping("mymsg")
public Result<List<UserMessageDTO>> getMyMessageList(@RequestBody MymessageFormDTO params){
return userMessageService.getMyMessageList(params);
}
}

12
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/UserMessageDao.java

@ -18,9 +18,12 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.MymessageFormDTO;
import com.epmet.entity.UserMessageEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 用户消息表
*
@ -29,11 +32,12 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface UserMessageDao extends BaseDao<UserMessageEntity> {
/**
* 更新阅读状态为已读
*
* @param entity 参数
* 获取消息分页
* @param messageFromDTO
* @return
*/
void updateReadFlag(UserMessageEntity entity);
List<UserMessageEntity> selectMyMessageList(MymessageFormDTO messageFromDTO);
}

8
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/UserMessageService.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UserMessageDTO;
import com.epmet.dto.form.MymessageFormDTO;
import com.epmet.dto.form.UserMessageFormDTO;
import com.epmet.entity.UserMessageEntity;
@ -119,4 +120,11 @@ public interface UserMessageService extends BaseService<UserMessageEntity> {
* @Date 2020/4/7 15:34
**/
Result saveUserMessage(UserMessageFormDTO formDto);
/**
* 获取我的消息列表
* @param param 参数
* @return
*/
Result<List<UserMessageDTO>> getMyMessageList(MymessageFormDTO param);
}

28
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/UserMessageServiceImpl.java

@ -20,13 +20,15 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.UserMessageConstans;
import com.epmet.dao.UserMessageDao;
import com.epmet.dto.UserMessageDTO;
import com.epmet.dto.form.MymessageFormDTO;
import com.epmet.dto.form.UserMessageFormDTO;
import com.epmet.entity.UserMessageEntity;
import com.epmet.redis.UserMessageRedis;
@ -72,13 +74,13 @@ public class UserMessageServiceImpl extends BaseServiceImpl<UserMessageDao, User
String id = (String) params.get(FieldConstant.ID_HUMP);
String customerId = (String) params.get(FieldConstant.CUSTOMER_ID_HUMP);
String gridId = (String) params.get(FieldConstant.GRID_ID_HUMP);
String userId = (String) params.get(FieldConstant.USER_ID_HUMP);
String userId = (String) params.get(FieldConstant.USER_ID_HUMP);
QueryWrapper<UserMessageEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id)
.eq(StringUtils.isNotBlank(customerId), FieldConstant.CUSTOMER_ID, customerId)
.eq(StringUtils.isNotBlank(gridId), FieldConstant.GRID_ID, gridId)
.eq(StringUtils.isNotBlank(userId), FieldConstant.USER_ID, userId);
.eq(StringUtils.isNotBlank(customerId), FieldConstant.CUSTOMER_ID, customerId)
.eq(StringUtils.isNotBlank(gridId), FieldConstant.GRID_ID, gridId)
.eq(StringUtils.isNotBlank(userId), FieldConstant.USER_ID, userId);
return wrapper;
}
@ -121,13 +123,13 @@ public class UserMessageServiceImpl extends BaseServiceImpl<UserMessageDao, User
@Override
@Transactional(rollbackFor = Exception.class)
public Result readAllMessage(UserMessageDTO messageDTO) {
public Result readAllMessage(UserMessageDTO messageDTO) {
UserMessageEntity messageEntity = new UserMessageEntity();
messageEntity.setReadFlag(UserMessageConstans.READ);
messageDTO.setReadFlag(UserMessageConstans.UNREAD);
baseDao.update(messageEntity, getWrapper(messageDTO));
return new Result();
}
return new Result();
}
private QueryWrapper<UserMessageEntity> getWrapper(UserMessageDTO messageDTO) {
String id = messageDTO.getId();
@ -143,7 +145,7 @@ public class UserMessageServiceImpl extends BaseServiceImpl<UserMessageDao, User
.eq(StringUtils.isNotBlank(gridId), FieldConstant.GRID_ID, gridId)
.eq(StringUtils.isNotBlank(userId), FieldConstant.USER_ID, userId)
.eq(StringUtils.isNotBlank(deFlag), FieldConstant.DEL_FLAG, deFlag)
.eq(StringUtils.isNotBlank(readFlag),"read_flag", readFlag);
.eq(StringUtils.isNotBlank(readFlag), "read_flag", readFlag);
return wrapper;
}
@ -155,4 +157,12 @@ public class UserMessageServiceImpl extends BaseServiceImpl<UserMessageDao, User
return new Result();
}
@Override
public Result<List<UserMessageDTO>> getMyMessageList(MymessageFormDTO params) {
int pageIndex = (params.getPageNo() - NumConstant.ONE) * params.getPageSize();
params.setPageNo(pageIndex);
List<UserMessageEntity> myMessageList = baseDao.selectMyMessageList(params);
return new Result<List<UserMessageDTO>>().ok(ConvertUtils.sourceToTarget(myMessageList, UserMessageDTO.class));
}
}

32
epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/UserMessageDao.xml

@ -3,7 +3,7 @@
<mapper namespace="com.epmet.dao.UserMessageDao">
<resultMap type="com.epmet.entity.UserMessageEntity" id="userMessageMap">
<resultMap id="userMessageMap" type="com.epmet.entity.UserMessageEntity">
<result property="id" column="ID"/>
<result property="customerId" column="customer_id"/>
<result property="gridId" column="grid_id"/>
@ -19,9 +19,35 @@
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<update id="updateReadFlag" parameterType="com.epmet.entity.UserMessageEntity">
</update>
<select id="selectMyMessageList" resultType="com.epmet.entity.UserMessageEntity">
SELECT
id,
app,
updated_time,
updated_by,
read_flag,
title,
del_flag,
user_id,
revision,
created_by,
customer_id,
created_time,
grid_id,
message_content
FROM
epmet_message.user_message
WHERE
del_flag = '0'
AND (
CUSTOMER_ID = #{customerId}
AND GRID_ID = #{gridId}
AND USER_ID = #{userId})
ORDER BY
CREATED_TIME DESC
LIMIT #{pageNo}, #{pageSize}
</select>
</mapper>

10
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/feign/EpmetMessageFeignClient.java

@ -1,17 +1,15 @@
package com.epmet.modules.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UserMessageDTO;
import com.epmet.dto.form.MymessageFormDTO;
import com.epmet.modules.feign.fallback.EpmetMessageFeignClientFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map;
import java.util.List;
/**
* @author zhaoqifeng
@ -27,8 +25,8 @@ public interface EpmetMessageFeignClient {
* @param params 参数
* @return Result<PageData<UserMessageDTO>>
*/
@GetMapping("/message/usermessage/page")
Result<PageData<UserMessageDTO>> page(@RequestParam Map<String, Object> params);
@PostMapping("/message/usermessage/mymsg")
Result<List<UserMessageDTO>> getMyMessageList(@RequestBody MymessageFormDTO params);
/**
* 单条消息已读

8
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/feign/fallback/EpmetMessageFeignClientFallBack.java

@ -1,14 +1,14 @@
package com.epmet.modules.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UserMessageDTO;
import com.epmet.dto.form.MymessageFormDTO;
import com.epmet.modules.feign.EpmetMessageFeignClient;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.List;
/**
* @author zhaoqifeng
@ -18,8 +18,8 @@ import java.util.Map;
@Component
public class EpmetMessageFeignClientFallBack implements EpmetMessageFeignClient {
@Override
public Result<PageData<UserMessageDTO>> page(Map<String, Object> params) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "page", params);
public Result<List<UserMessageDTO>> getMyMessageList(MymessageFormDTO params) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "getMyMessageList", params);
}
@Override

7
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/message/controller/UserMessageController.java

@ -1,7 +1,6 @@
package com.epmet.modules.message.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@ -11,6 +10,8 @@ import com.epmet.modules.message.service.UserMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Description 我的消息
* @Author yinzuomei
@ -30,8 +31,8 @@ public class UserMessageController {
* @Date 2020/3/29 20:53
**/
@PostMapping("getmymessage")
public Result<PageData<UserMessageDTO>> getMyMessage(@LoginUser TokenDto tokenDto,
@RequestBody MymessageFormDTO mymessageFormDTO) {
public Result<List<UserMessageDTO>> getMyMessage(@LoginUser TokenDto tokenDto,
@RequestBody MymessageFormDTO mymessageFormDTO) {
mymessageFormDTO.setUserId(tokenDto.getUserId());
ValidatorUtils.validateEntity(mymessageFormDTO);
//逻辑待实现

5
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/message/service/UserMessageService.java

@ -1,11 +1,12 @@
package com.epmet.modules.message.service;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UserMessageDTO;
import com.epmet.dto.form.MymessageFormDTO;
import java.util.List;
/**
* @Description 我的消息
* @Author yinzuomei
@ -20,7 +21,7 @@ public interface UserMessageService {
* @param messageFromDTO 参数
* @return Result<PageData < MymessageResultDTO>>
*/
Result<PageData<UserMessageDTO>> getMessageList(TokenDto tokenDto, MymessageFormDTO messageFromDTO);
Result<List<UserMessageDTO>> getMessageList(TokenDto tokenDto, MymessageFormDTO messageFromDTO);
/**
* 单条消息标记为已读

15
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/message/service/impl/UserMessageServiceImpl.java

@ -1,6 +1,5 @@
package com.epmet.modules.message.service.impl;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UserMessageDTO;
@ -10,8 +9,7 @@ import com.epmet.modules.message.service.UserMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
/**
* @Description 我的消息
@ -24,14 +22,9 @@ public class UserMessageServiceImpl implements UserMessageService {
private EpmetMessageFeignClient messageFeignClient;
@Override
public Result<PageData<UserMessageDTO>> getMessageList(TokenDto tokenDto, MymessageFormDTO messageFromDTO) {
Map<String, Object> param = new HashMap<String, Object>();
param.put("customerId", messageFromDTO.getCustomerId());
param.put("gridId", messageFromDTO.getGridId());
param.put("userId", tokenDto.getUserId());
param.put("pageNo", messageFromDTO.getPageNo());
param.put("pageSize", messageFromDTO.getPageSize());
Result<PageData<UserMessageDTO>> result = messageFeignClient.page(param);
public Result<List<UserMessageDTO>> getMessageList(TokenDto tokenDto, MymessageFormDTO messageFromDTO) {
messageFromDTO.setUserId(tokenDto.getUserId());
Result<List<UserMessageDTO>> result = messageFeignClient.getMyMessageList(messageFromDTO);
return result;
}

Loading…
Cancel
Save