From 82ffa587049fc037629efe4b6729422c4b2151f6 Mon Sep 17 00:00:00 2001 From: liuchuang <123456> Date: Mon, 26 Oct 2020 14:34:00 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=B7=B2=E8=AF=BB=E8=A1=A8=202=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A6=96=E9=A1=B5=E8=8E=B7=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=95=B0=E9=87=8F=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=B1=85=E6=B0=91=E7=AB=AF=E9=A6=96=E9=A1=B5=E5=90=84?= =?UTF-8?q?=E9=A1=B9=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constant/AppHomePageDataTypeConstant.java | 20 +++ .../dto/result/EpdcAppHomeDataResultDTO.java | 25 ++++ .../controller/v2/ApiNewsV2Controller.java | 16 ++- .../esua/epdc/feign/ActInfoFeignClient.java | 12 +- .../fallback/ActInfoFeignClientFallback.java | 4 + .../elink/esua/epdc/service/NewsService.java | 11 ++ .../epdc/service/impl/NewsServiceImpl.java | 33 +++++ .../esua/epdc/activity/ActUserReadDTO.java | 81 ++++++++++++ .../controller/ActUserReadController.java | 94 ++++++++++++++ .../controller/AppActInfoController.java | 15 +++ .../epdc/modules/activity/dao/ActInfoDao.java | 10 ++ .../modules/activity/dao/ActUserReadDao.java | 33 +++++ .../activity/entity/ActUserReadEntity.java | 51 ++++++++ .../activity/excel/ActUserReadExcel.java | 62 +++++++++ .../activity/redis/ActUserReadRedis.java | 47 +++++++ .../activity/service/ActInfoService.java | 10 ++ .../activity/service/ActUserReadService.java | 105 ++++++++++++++++ .../service/impl/ActInfoServiceImpl.java | 21 +++- .../service/impl/ActUserReadServiceImpl.java | 118 ++++++++++++++++++ .../resources/mapper/activity/ActInfoDao.xml | 13 ++ .../mapper/activity/ActUserReadDao.xml | 19 +++ 21 files changed, 795 insertions(+), 5 deletions(-) create mode 100644 esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/constant/AppHomePageDataTypeConstant.java create mode 100644 esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/result/EpdcAppHomeDataResultDTO.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/ActUserReadDTO.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/ActUserReadController.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActUserReadDao.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/entity/ActUserReadEntity.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/excel/ActUserReadExcel.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/redis/ActUserReadRedis.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActUserReadService.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActUserReadServiceImpl.java create mode 100644 esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserReadDao.xml diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/constant/AppHomePageDataTypeConstant.java b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/constant/AppHomePageDataTypeConstant.java new file mode 100644 index 00000000..613f2a3f --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/constant/AppHomePageDataTypeConstant.java @@ -0,0 +1,20 @@ +package com.elink.esua.epdc.dto.constant; + +/** + * 居民端首页数据统计类型常量 + * + * @author Liuchuang + * @since 2020/10/26 14:19 + */ +public interface AppHomePageDataTypeConstant { + + /** + * 消息数量 + */ + String HOME_DATA_TYPE_INFORMATION = "informationNum"; + + /** + * 未查看报名中活动数量 + */ + String HOME_DATA_TYPE_UNREAD_SIGN_UP_ACT = "unreadSignUpActNum"; +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/result/EpdcAppHomeDataResultDTO.java b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/result/EpdcAppHomeDataResultDTO.java new file mode 100644 index 00000000..b074f962 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/result/EpdcAppHomeDataResultDTO.java @@ -0,0 +1,25 @@ +package com.elink.esua.epdc.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 居民端首页数据统计项 + * + * @author Liuchuang + * @since 2020/10/26 14:04 + */ +@Data +public class EpdcAppHomeDataResultDTO implements Serializable { + + /** + * 数据类型 + */ + private String dataType; + + /** + * 数量 + */ + private Integer num; +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/v2/ApiNewsV2Controller.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/v2/ApiNewsV2Controller.java index a2d309a8..2148756a 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/v2/ApiNewsV2Controller.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/v2/ApiNewsV2Controller.java @@ -7,6 +7,7 @@ import com.elink.esua.epdc.commons.tools.constant.Constant; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.epdc.form.v2.EpdcNoticeListV2FormDTO; import com.elink.esua.epdc.dto.epdc.result.*; +import com.elink.esua.epdc.dto.result.EpdcAppHomeDataResultDTO; import com.elink.esua.epdc.service.NewsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -28,7 +29,7 @@ public class ApiNewsV2Controller { @Autowired private NewsService newsService; - /* + /** * 移动端通知列表接口 - v2 * * @param userDetail @@ -42,4 +43,17 @@ public class ApiNewsV2Controller { return newsService.listV2Notice(userDetail, formDto); } + /** + * 居民端首页数据统计 + * + * @param userDetail + * @return com.elink.esua.epdc.commons.tools.utils.Result> + * @author Liuchuang + * @since 2020/10/26 14:25 + */ + @PostMapping("information/first") + public Result> selectOneFristByUserId(@LoginUser TokenDto userDetail) { + return newsService.selectHomeData(userDetail); + } + } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/ActInfoFeignClient.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/ActInfoFeignClient.java index 0eb24268..3c5a250a 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/ActInfoFeignClient.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/ActInfoFeignClient.java @@ -13,6 +13,7 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @@ -64,6 +65,15 @@ public interface ActInfoFeignClient { @GetMapping(value = "heart/actbanner/bannerlist", consumes = MediaType.APPLICATION_JSON_VALUE) Result> getBannerList(EpdcAppBannerFormDTO dto); - + /** + * 获取用户未查看的报名中的活动数量 + * + * @param userId + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2020/10/26 13:45 + */ + @GetMapping(value = "heart/appactinfo/unreadactnums", consumes = MediaType.APPLICATION_JSON_VALUE) + Result getUserUnreadSignUpActCount(String userId); } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/ActInfoFeignClientFallback.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/ActInfoFeignClientFallback.java index 0f2d1a98..157e85c8 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/ActInfoFeignClientFallback.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/ActInfoFeignClientFallback.java @@ -47,5 +47,9 @@ public class ActInfoFeignClientFallback implements ActInfoFeignClient { return ModuleUtils.feignConError(ServiceConstant.EPDC_HEART_SERVER, "getBannerList", dto); } + @Override + public Result getUserUnreadSignUpActCount(String userId) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_HEART_SERVER, "getUserUnreadSignUpActCount", userId); + } } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java index 0b66eaa9..c67a6a9e 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java @@ -5,6 +5,7 @@ import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.epdc.form.*; import com.elink.esua.epdc.dto.epdc.form.v2.EpdcNoticeListV2FormDTO; import com.elink.esua.epdc.dto.epdc.result.*; +import com.elink.esua.epdc.dto.result.EpdcAppHomeDataResultDTO; import java.util.List; @@ -152,4 +153,14 @@ public interface NewsService { * @return com.elink.esua.epdc.commons.tools.utils.Result **/ Result browsePoints(TokenDto userDetail, EpdcNewsBrowseFromDTO newsBrowseFromDTO); + + /** + * 居民端首页数据统计 + * + * @param userDetail + * @return com.elink.esua.epdc.commons.tools.utils.Result> + * @author Liuchuang + * @since 2020/10/26 14:24 + */ + Result> selectHomeData(TokenDto userDetail); } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java index b527cd83..cce4f12d 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java @@ -1,12 +1,16 @@ package com.elink.esua.epdc.service.impl; import com.elink.esua.epdc.common.token.dto.TokenDto; +import com.elink.esua.epdc.commons.tools.constant.NumConstant; import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; import com.elink.esua.epdc.commons.tools.redis.RedisUtils; import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.constant.AppHomePageDataTypeConstant; import com.elink.esua.epdc.dto.epdc.form.*; import com.elink.esua.epdc.dto.epdc.form.v2.EpdcNoticeListV2FormDTO; import com.elink.esua.epdc.dto.epdc.result.*; +import com.elink.esua.epdc.dto.result.EpdcAppHomeDataResultDTO; +import com.elink.esua.epdc.feign.ActInfoFeignClient; import com.elink.esua.epdc.feign.NewsFeignClient; import com.elink.esua.epdc.service.NewsService; import org.springframework.beans.factory.annotation.Autowired; @@ -31,6 +35,9 @@ public class NewsServiceImpl implements NewsService { @Autowired private RedisUtils redisUtils; + @Autowired + private ActInfoFeignClient actInfoFeignClient; + @Override public Result> listNotice(TokenDto userDetail, EpdcNoticeListFormDTO formDto) { formDto.setDeptId(userDetail.getGridId()); @@ -119,4 +126,30 @@ public class NewsServiceImpl implements NewsService { } return new Result(); } + + @Override + public Result> selectHomeData(TokenDto userDetail) { + String userId = userDetail.getUserId(); + List data = new ArrayList<>(); + // 消息通知数量 + EpdcAppHomeDataResultDTO informationDto = new EpdcAppHomeDataResultDTO(); + informationDto.setDataType(AppHomePageDataTypeConstant.HOME_DATA_TYPE_INFORMATION); + informationDto.setNum(NumConstant.ZERO); + Result information = newsFeignClient.selectOneFristByUserId(userId); + if (null != information && information.success()) { + informationDto.setNum(information.getData().getAmount()); + } + data.add(informationDto); + + // 未查看报名中活动数量 + EpdcAppHomeDataResultDTO actDto = new EpdcAppHomeDataResultDTO(); + actDto.setDataType(AppHomePageDataTypeConstant.HOME_DATA_TYPE_UNREAD_SIGN_UP_ACT); + actDto.setNum(NumConstant.ZERO); + Result act = actInfoFeignClient.getUserUnreadSignUpActCount(userId); + if (null != act && act.success()) { + actDto.setNum(act.getData()); + } + data.add(actDto); + return new Result>().ok(data); + } } diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/ActUserReadDTO.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/ActUserReadDTO.java new file mode 100644 index 00000000..b3d70b52 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/src/main/java/com/elink/esua/epdc/activity/ActUserReadDTO.java @@ -0,0 +1,81 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.activity; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 用户活动已读表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-10-26 + */ +@Data +public class ActUserReadDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 活动ID + */ + private String actId; + + /** + * 用户ID + */ + private String userId; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 删除标记 + */ + private String delFlag; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/ActUserReadController.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/ActUserReadController.java new file mode 100644 index 00000000..9e565946 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/ActUserReadController.java @@ -0,0 +1,94 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.activity.controller; + +import com.elink.esua.epdc.activity.ActUserReadDTO; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.commons.tools.validator.AssertUtils; +import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; +import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; +import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; +import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; +import com.elink.esua.epdc.modules.activity.excel.ActUserReadExcel; +import com.elink.esua.epdc.modules.activity.service.ActUserReadService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 用户活动已读表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-10-26 + */ +@RestController +@RequestMapping("actuserread") +public class ActUserReadController { + + @Autowired + private ActUserReadService actUserReadService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = actUserReadService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + ActUserReadDTO data = actUserReadService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody ActUserReadDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + actUserReadService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody ActUserReadDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + actUserReadService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + actUserReadService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = actUserReadService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, ActUserReadExcel.class); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/AppActInfoController.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/AppActInfoController.java index 4ea76f49..94ee0623 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/AppActInfoController.java +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/controller/AppActInfoController.java @@ -125,4 +125,19 @@ public class AppActInfoController { return this.actInfoService.getCancelDetailByApp(id); } + /** + * 获取用户未查看的报名中的活动数量 + * + * @param userId + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2020/10/26 13:45 + */ + @GetMapping("unreadactnums") + public Result getUserUnreadSignUpActCount(@RequestBody String userId) { + int unreadCount = actInfoService.countUserUnreadSignUpAct(userId); + + return new Result().ok(unreadCount); + } + } diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActInfoDao.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActInfoDao.java index 87accd27..26e35f50 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActInfoDao.java +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActInfoDao.java @@ -123,4 +123,14 @@ public interface ActInfoDao extends BaseDao { * @return void */ void rejectActInfo(@Param("relationId") String relationId); + + /** + * 获取用户未查看的报名中的活动数量 + * + * @param userId + * @return int + * @author Liuchuang + * @since 2020/10/26 13:40 + */ + int selectCountUserUnreadSignUpAct(@Param("userId") String userId); } diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActUserReadDao.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActUserReadDao.java new file mode 100644 index 00000000..3facd676 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/dao/ActUserReadDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.activity.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.modules.activity.entity.ActUserReadEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 用户活动已读表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-10-26 + */ +@Mapper +public interface ActUserReadDao extends BaseDao { + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/entity/ActUserReadEntity.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/entity/ActUserReadEntity.java new file mode 100644 index 00000000..8b429175 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/entity/ActUserReadEntity.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.activity.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 用户活动已读表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-10-26 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_act_user_read") +public class ActUserReadEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 活动ID + */ + private String actId; + + /** + * 用户ID + */ + private String userId; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/excel/ActUserReadExcel.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/excel/ActUserReadExcel.java new file mode 100644 index 00000000..2bf984a3 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/excel/ActUserReadExcel.java @@ -0,0 +1,62 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.activity.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 用户活动已读表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-10-26 + */ +@Data +public class ActUserReadExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "活动ID") + private String actId; + + @Excel(name = "用户ID") + private String userId; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + @Excel(name = "删除标记") + private String delFlag; + + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/redis/ActUserReadRedis.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/redis/ActUserReadRedis.java new file mode 100644 index 00000000..1d592ff9 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/redis/ActUserReadRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.activity.redis; + +import com.elink.esua.epdc.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 用户活动已读表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-10-26 + */ +@Component +public class ActUserReadRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActInfoService.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActInfoService.java index be936903..19ed52b6 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActInfoService.java +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActInfoService.java @@ -214,4 +214,14 @@ public interface ActInfoService extends BaseService { * @return com.elink.esua.epdc.commons.tools.utils.Result */ Result rejectActClockInfo(RejectRecordDTO dto); + + /** + * 获取用户未查看的报名中的活动数量 + * + * @param userId + * @return int + * @author Liuchuang + * @since 2020/10/26 13:42 + */ + int countUserUnreadSignUpAct(String userId); } diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActUserReadService.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActUserReadService.java new file mode 100644 index 00000000..348f69cd --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/ActUserReadService.java @@ -0,0 +1,105 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.activity.service; + +import com.elink.esua.epdc.activity.ActUserReadDTO; +import com.elink.esua.epdc.commons.mybatis.service.BaseService; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.modules.activity.entity.ActUserReadEntity; + +import java.util.List; +import java.util.Map; + +/** + * 用户活动已读表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-10-26 + */ +public interface ActUserReadService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-10-26 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-10-26 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return ActUserReadDTO + * @author generator + * @date 2020-10-26 + */ + ActUserReadDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-10-26 + */ + void save(ActUserReadDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-10-26 + */ + void update(ActUserReadDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-10-26 + */ + void delete(String[] ids); + + /** + * 标记用户已读活动 + * + * @param dto + * @return boolean + * @author Liuchuang + * @since 2020/10/26 11:20 + */ + boolean addActUserReadRecord(ActUserReadDTO dto); +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActInfoServiceImpl.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActInfoServiceImpl.java index c408e3c9..84882c19 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActInfoServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/activity/service/impl/ActInfoServiceImpl.java @@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.elink.esua.epdc.activity.ActBannerDTO; import com.elink.esua.epdc.activity.ActInfoDTO; +import com.elink.esua.epdc.activity.ActUserReadDTO; import com.elink.esua.epdc.activity.ActUserRelationDTO; import com.elink.esua.epdc.activity.form.ActInfoAppFormDTO; import com.elink.esua.epdc.activity.form.ActInfoFormDTO; @@ -58,6 +59,7 @@ import com.elink.esua.epdc.modules.activity.entity.ActUserClockLogEntity; import com.elink.esua.epdc.modules.activity.entity.ActUserRelationEntity; import com.elink.esua.epdc.modules.activity.service.ActBannerService; import com.elink.esua.epdc.modules.activity.service.ActInfoService; +import com.elink.esua.epdc.modules.activity.service.ActUserReadService; import com.elink.esua.epdc.modules.async.NewsTask; import com.elink.esua.epdc.modules.feign.AdminFeignClient; import com.elink.esua.epdc.modules.feign.ContentSecurityFeignClient; @@ -104,6 +106,9 @@ public class ActInfoServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -433,8 +438,8 @@ public class ActInfoServiceImpl extends BaseServiceImpl userVolunteerFlagResult = userInfoFeignClient.queryUserVolunteerFlag(formDto.getUserId()); detailResultDTO.setUserVolunteerFlag(userVolunteerFlagResult.getData()); ActInfoDetailAppResultDTO resultDTO = ConvertUtils.sourceToTarget(detailResultDTO, ActInfoDetailAppResultDTO.class); - //获取活动详情 活动信息表 浏览数+1 banner表 浏览数+1 - this.addActBrowseNumber(resultDTO.getId()); + //获取活动详情 活动信息表 浏览数+1 banner表 浏览数+1 标记用户已读 + this.addActBrowseNumber(resultDTO.getId(), formDto.getUserId()); return new Result().ok(resultDTO); } @@ -626,7 +631,7 @@ public class ActInfoServiceImpl extends BaseServiceImpl + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.modules.activity.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.elink.esua.epdc.activity.ActUserReadDTO; +import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; +import com.elink.esua.epdc.commons.tools.constant.NumConstant; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; +import com.elink.esua.epdc.commons.tools.constant.FieldConstant; +import com.elink.esua.epdc.modules.activity.dao.ActUserReadDao; +import com.elink.esua.epdc.modules.activity.entity.ActUserReadEntity; +import com.elink.esua.epdc.modules.activity.service.ActUserReadService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 用户活动已读表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-10-26 + */ +@Service +public class ActUserReadServiceImpl extends BaseServiceImpl implements ActUserReadService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, ActUserReadDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, ActUserReadDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public ActUserReadDTO get(String id) { + ActUserReadEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, ActUserReadDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(ActUserReadDTO dto) { + ActUserReadEntity entity = ConvertUtils.sourceToTarget(dto, ActUserReadEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(ActUserReadDTO dto) { + ActUserReadEntity entity = ConvertUtils.sourceToTarget(dto, ActUserReadEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean addActUserReadRecord(ActUserReadDTO dto) { + // 判断是否已读 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("ACT_ID", dto.getActId()); + wrapper.eq("USER_ID", dto.getUserId()); + wrapper.eq(FieldConstant.DEL_FLAG, NumConstant.ZERO_STR); + int readCount = baseDao.selectCount(wrapper); + if (readCount > 0) { + return true; + } + + ActUserReadEntity entity = ConvertUtils.sourceToTarget(dto, ActUserReadEntity.class); + return insert(entity); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActInfoDao.xml b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActInfoDao.xml index 302c4dfb..4c62dd06 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActInfoDao.xml +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActInfoDao.xml @@ -518,4 +518,17 @@ UPDATE epdc_act_info SET DEL_FLAG = 1,UPDATED_TIME=NOW() where id=#{relationId} + + diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserReadDao.xml b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserReadDao.xml new file mode 100644 index 00000000..a5c60069 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/resources/mapper/activity/ActUserReadDao.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file