Browse Source

办事指南列表返回已读,未读。阅读详情增加记录

dev
yinzuomei 3 years ago
parent
commit
197ad1cdba
  1. 8
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideListFormDTO.java
  2. 6
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/GuideListResultDTO.java
  3. 4
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideController.java
  4. 16
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideReaderDao.java
  5. 44
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/GuideReaderEntity.java
  6. 34
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideReaderService.java
  7. 2
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideService.java
  8. 35
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideReaderServiceImpl.java
  9. 23
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideServiceImpl.java
  10. 14
      epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.12__guide_reader.sql
  11. 5
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideDao.xml
  12. 21
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideReaderDao.xml

8
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideListFormDTO.java

@ -16,7 +16,15 @@ import java.io.Serializable;
public class GuideListFormDTO extends PageFormDTO implements Serializable {
private static final long serialVersionUID = -4471422632936288213L;
/**
* tokenDto.customerId
*/
private String customerId;
/**
* tokenDto.userId
*/
private String userId;
/**
* 组织ID
*/

6
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/GuideListResultDTO.java

@ -32,4 +32,10 @@ public class GuideListResultDTO implements Serializable {
* 更新时间
*/
private Date updatedTime;
/**
* 1已读
* 0未读
*/
private Integer readFlag;
}

4
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideController.java

@ -100,8 +100,10 @@ public class GuideController {
*/
@PostMapping("list")
public Result<PageData<GuideListResultDTO>> guideList(@LoginUser TokenDto tokenDto, @RequestBody GuideListFormDTO formDTO) {
formDTO.setCustomerId(tokenDto.getCustomerId());
formDTO.setUserId(tokenDto.getUserId());
ValidatorUtils.validateEntity(formDTO, PageFormDTO.AddUserInternalGroup.class);
PageData<GuideListResultDTO> page = guideService.guideList(tokenDto, formDTO);
PageData<GuideListResultDTO> page = guideService.guideList(formDTO);
return new Result<PageData<GuideListResultDTO>>().ok(page);
}

16
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideReaderDao.java

@ -0,0 +1,16 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.GuideReaderEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 办事指南阅读记录
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2023-02-02
*/
@Mapper
public interface GuideReaderDao extends BaseDao<GuideReaderEntity> {
}

44
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/GuideReaderEntity.java

@ -0,0 +1,44 @@
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 办事指南阅读记录
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2023-02-02
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("guide_reader")
public class GuideReaderEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 办事指南id
*/
private String guideId;
/**
* 用户id;进入过办事指南详情就算是已读
*/
private String userId;
/**
* 工作端gov居民端resi
*/
private String userType;
}

34
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideReaderService.java

@ -0,0 +1,34 @@
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.GuideReaderEntity;
/**
* 办事指南阅读记录
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2023-02-02
*/
public interface GuideReaderService extends BaseService<GuideReaderEntity> {
/**
* 单条查询
*
* @param guideId
* @param userId
* @return GuideReaderDTO
* @author generator
* @date 2023-02-02
*/
GuideReaderEntity get(String guideId,String userId);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2023-02-02
*/
void save(GuideReaderEntity dto);
}

2
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideService.java

@ -109,7 +109,7 @@ public interface GuideService extends BaseService<GuideEntity> {
* @Author zhaoqifeng
* @Date 2021/9/7 14:00
*/
PageData<GuideListResultDTO> guideList(TokenDto tokenDto, GuideListFormDTO formDTO);
PageData<GuideListResultDTO> guideList(GuideListFormDTO formDTO);
/**
* 添加指南

35
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideReaderServiceImpl.java

@ -0,0 +1,35 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.dao.GuideReaderDao;
import com.epmet.entity.GuideReaderEntity;
import com.epmet.service.GuideReaderService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 办事指南阅读记录
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2023-02-02
*/
@Service
public class GuideReaderServiceImpl extends BaseServiceImpl<GuideReaderDao, GuideReaderEntity> implements GuideReaderService {
@Override
public GuideReaderEntity get(String guideId,String userId) {
LambdaQueryWrapper<GuideReaderEntity> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(GuideReaderEntity::getGuideId,guideId)
.eq(GuideReaderEntity::getUserId,userId);
GuideReaderEntity entity = baseDao.selectOne(queryWrapper);
return entity;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(GuideReaderEntity entity) {
insert(entity);
}
}

23
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideServiceImpl.java

@ -22,6 +22,7 @@ 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.constant.StrConstant;
import com.epmet.commons.tools.dto.form.PageFormDTO;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode;
@ -31,6 +32,7 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.constant.OrgInfoConstant;
import com.epmet.dao.GuideDao;
import com.epmet.dto.GuideDTO;
@ -38,10 +40,7 @@ import com.epmet.dto.form.*;
import com.epmet.dto.result.GuideDetailResultDTO;
import com.epmet.dto.result.GuideListResultDTO;
import com.epmet.dto.result.OrgResultDTO;
import com.epmet.entity.GuideAttachmentEntity;
import com.epmet.entity.GuideEntity;
import com.epmet.entity.GuideExternalLinkEntity;
import com.epmet.entity.GuideModuleEntity;
import com.epmet.entity.*;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.*;
import com.github.pagehelper.PageHelper;
@ -140,15 +139,14 @@ public class GuideServiceImpl extends BaseServiceImpl<GuideDao, GuideEntity> imp
* @Date 2021/9/7 14:00
*/
@Override
public PageData<GuideListResultDTO> guideList(TokenDto tokenDto, GuideListFormDTO formDTO) {
public PageData<GuideListResultDTO> guideList(GuideListFormDTO formDTO) {
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize());
formDTO.setCustomerId(tokenDto.getCustomerId());
List<GuideListResultDTO> list = baseDao.getGuideList(formDTO);
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(item -> {
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), item.getCreatedId());
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), item.getCreatedId());
if (null == staffInfoCache) {
item.setCategoryName("");
item.setCategoryName(StrConstant.EPMETY_STR);
} else {
item.setCreatedName(staffInfoCache.getRealName());
}
@ -390,6 +388,15 @@ public class GuideServiceImpl extends BaseServiceImpl<GuideDao, GuideEntity> imp
if (null != guideCollectionService.getCollection(tokenDto, formDTO.getGuideId())) {
result.setCollectionFlag(NumConstant.ONE_STR);
}
//记录已读未读
if (null == SpringContextUtils.getBean(GuideReaderService.class).get(formDTO.getGuideId(), tokenDto.getUserId())) {
GuideReaderEntity guideReaderEntity=new GuideReaderEntity();
guideReaderEntity.setGuideId(formDTO.getGuideId());
guideReaderEntity.setCustomerId(formDTO.getCustomerId());
guideReaderEntity.setUserId(tokenDto.getUserId());
guideReaderEntity.setUserType(tokenDto.getApp());
SpringContextUtils.getBean(GuideReaderService.class).save(guideReaderEntity);
}
return result;
}

14
epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.12__guide_reader.sql

@ -0,0 +1,14 @@
CREATE TABLE `guide_reader` (
`ID` varchar(64) NOT NULL COMMENT 'ID',
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID',
`GUIDE_ID` varchar(64) NOT NULL COMMENT '办事指南id',
`USER_ID` varchar(64) NOT NULL COMMENT '用户id;进入过办事指南详情就算是已读',
`USER_TYPE` varchar(10) NOT NULL COMMENT '工作端:gov;居民端:resi',
`DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除',
`REVISION` int(11) NOT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='办事指南阅读记录';

5
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideDao.xml

@ -26,7 +26,10 @@
g.TITLE AS "title",
gc.CATEGORY_NAME AS "categoryName",
g.CREATED_BY AS "createdId",
g.UPDATED_TIME AS "updatedTime"
g.UPDATED_TIME AS "updatedTime",
if(exists( select gr.id from guide_reader gr
where gr.del_flag='0'
and gr.GUIDE_ID=g.id),1,0) AS readFlag
FROM
guide g
INNER JOIN guide_category gc ON g.CATEGORY_CODE = gc.CATEGORY_CODE AND gc.DEL_FLAG = 0 AND gc.CUSTOMER_ID = #{customerId}

21
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideReaderDao.xml

@ -0,0 +1,21 @@
<?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.epmet.dao.GuideReaderDao">
<resultMap type="com.epmet.entity.GuideReaderEntity" id="guideReaderMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="guideId" column="GUIDE_ID"/>
<result property="userId" column="USER_ID"/>
<result property="userType" column="USER_TYPE"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
</mapper>
Loading…
Cancel
Save