diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/pom.xml b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/pom.xml index 43a03bffa..c7d3f1614 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/pom.xml +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-client/pom.xml @@ -18,6 +18,13 @@ epdc-demo-client 1.0.0 + + com.esua.epdc + epdc-user-client + 1.0.0 + + + \ 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/feign/UserFeignClient.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/feign/UserFeignClient.java new file mode 100644 index 000000000..db53ec93c --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/feign/UserFeignClient.java @@ -0,0 +1,30 @@ +package com.elink.esua.epdc.modules.feign; + +import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.epdc.result.EpdcGetVolunteerRankDTO; +import com.elink.esua.epdc.modules.feign.fallback.UserFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; + +import java.util.List; + +/** + * + * 调用用户模块 + * + * @Author:wanggongfeng + * @Date:2019/12/16 17:36 + */ +@FeignClient(name = ServiceConstant.EPDC_USER_SERVER, fallback = UserFeignClientFallback.class) +public interface UserFeignClient { + + /** + * 获取排行榜 + * + * @return + */ + @GetMapping("app-user/epdc-app/volunteerinfo/getRankingList") + Result> getRankingList(); + +} diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/feign/fallback/UserFeignClientFallback.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/feign/fallback/UserFeignClientFallback.java new file mode 100644 index 000000000..caacee3a3 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/feign/fallback/UserFeignClientFallback.java @@ -0,0 +1,29 @@ +package com.elink.esua.epdc.modules.feign.fallback; + +import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; +import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.epdc.result.EpdcGetVolunteerRankDTO; +import com.elink.esua.epdc.modules.feign.UserFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @Author:wanggongfeng + * @Date:2019/12/16 15:11 + */ +@Component +public class UserFeignClientFallback implements UserFeignClient { + + /** + * 获取排行榜 + * + * @return + */ + @Override + public Result> getRankingList() { + return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "getRankingList"); + } + +} diff --git a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/volunteer/service/VolunteerRankService.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/volunteer/service/VolunteerRankService.java index 053a21ad5..3ca1f2fe4 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/volunteer/service/VolunteerRankService.java +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/volunteer/service/VolunteerRankService.java @@ -19,6 +19,7 @@ package com.elink.esua.epdc.modules.volunteer.service; import com.elink.esua.epdc.commons.mybatis.service.BaseService; import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.modules.volunteer.entity.VolunteerRankEntity; import com.elink.esua.epdc.volunteer.EpdcVolunteerRankDTO; import com.elink.esua.epdc.volunteer.VolunteerRankDTO; @@ -100,4 +101,13 @@ public interface VolunteerRankService extends BaseService { * @return */ List leaderboard(); + + /** + * 生成排行榜 + * @Author wanggongfeng + * @return + */ + Result generateRankingList(); + + } \ 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/volunteer/service/impl/VolunteerRankServiceImpl.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/volunteer/service/impl/VolunteerRankServiceImpl.java index f8bc7dcf0..1bd8fc3b5 100644 --- a/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/volunteer/service/impl/VolunteerRankServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/volunteer/service/impl/VolunteerRankServiceImpl.java @@ -23,6 +23,9 @@ import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.tools.constant.FieldConstant; 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.utils.Result; +import com.elink.esua.epdc.dto.epdc.result.EpdcGetVolunteerRankDTO; +import com.elink.esua.epdc.modules.feign.UserFeignClient; import com.elink.esua.epdc.modules.volunteer.dao.VolunteerRankDao; import com.elink.esua.epdc.modules.volunteer.entity.VolunteerRankEntity; import com.elink.esua.epdc.modules.volunteer.redis.VolunteerRankRedis; @@ -50,6 +53,9 @@ public class VolunteerRankServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -113,4 +119,24 @@ public class VolunteerRankServiceImpl extends BaseServiceImpl> result = userFeignClient.getRankingList(); + List list = result.getData(); + if(list != null && list.size() > 0){ + for(int i = 0 ; i < list.size(); i++ ){ + EpdcGetVolunteerRankDTO epdcGetVolunteerRankDTO = list.get(i); + VolunteerRankEntity entity = ConvertUtils.sourceToTarget(epdcGetVolunteerRankDTO, VolunteerRankEntity.class); + insert(entity); + } + return new Result().ok("排名更新成功"); + } + return new Result().error("更新排名错误"); + } + } \ 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/volunteer/task/UpdateVolunteerRankTask.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/volunteer/task/UpdateVolunteerRankTask.java new file mode 100644 index 000000000..0a9fda3a3 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/volunteer/task/UpdateVolunteerRankTask.java @@ -0,0 +1,31 @@ +/** + * 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.volunteer.task; + +/** + * 志愿者排名 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-19 + */ +public interface UpdateVolunteerRankTask { + + void run(); + + +} \ 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/volunteer/task/UpdateVolunteerRankTaskImpl.java b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/volunteer/task/UpdateVolunteerRankTaskImpl.java new file mode 100644 index 000000000..7bbae2c17 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-heart/epdc-heart-server/src/main/java/com/elink/esua/epdc/modules/volunteer/task/UpdateVolunteerRankTaskImpl.java @@ -0,0 +1,42 @@ +/** + * 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.volunteer.task; + +import com.elink.esua.epdc.modules.volunteer.service.VolunteerRankService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 志愿者排名 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-19 + */ +@Component("UpdateVolunteerRank") +public class UpdateVolunteerRankTaskImpl implements UpdateVolunteerRankTask { + + @Autowired + private VolunteerRankService volunteerRankService; + + @Override + public void run(){ + volunteerRankService.generateRankingList(); + } + + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcGetVolunteerRankDTO.java b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcGetVolunteerRankDTO.java new file mode 100644 index 000000000..5de780bd1 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcGetVolunteerRankDTO.java @@ -0,0 +1,122 @@ +/** + * 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.dto.epdc.result; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 志愿者排名 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-19 + */ +@Data +public class EpdcGetVolunteerRankDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 排名 + */ + private Integer sort; + + /** + * 志愿者ID + */ + private String volunteerId; + + /** + * 用户ID + */ + private String userId; + + /** + * 头像 + */ + private String faceImg; + + /** + * 用户名 + */ + private String nickname; + + /** + * 是否党员(0-否,1-是) + */ + private String partyFlag; + + /** + * 爱心时长(单位:小时) + */ + private BigDecimal kindnessTime; + + /** + * 参加次数 + */ + private Integer participationNum; + + /** + * 排行生成日期 + */ + private Date generateDate; + + /** + * 是否显示(0-不显示,1-显示) + */ + private String showFlag; + + /** + * 乐观锁 + */ + 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-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppVolunteerInfoController.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppVolunteerInfoController.java index e82ef2bfb..7e42ed6d5 100644 --- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppVolunteerInfoController.java +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppVolunteerInfoController.java @@ -6,6 +6,7 @@ import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; import com.elink.esua.epdc.dto.epdc.form.EpdcCompleteVolunteerInfoFormDTO; +import com.elink.esua.epdc.dto.epdc.result.EpdcGetVolunteerRankDTO; import com.elink.esua.epdc.service.VolunteerInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -13,6 +14,8 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * 对移动端开放 * @@ -50,6 +53,16 @@ public class EpdcAppVolunteerInfoController { return result; } + /** + * 获取排行榜数据 + * + * @return + */ + @GetMapping("getRankingList") + public Result> getRankingList() { + return volunteerInfoService.getRankingList(); + } + } diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/VolunteerInfoDao.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/VolunteerInfoDao.java index f959d6e65..c6c4bea0f 100644 --- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/VolunteerInfoDao.java +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/VolunteerInfoDao.java @@ -21,6 +21,7 @@ import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; import com.elink.esua.epdc.dto.UserTagDTO; import com.elink.esua.epdc.dto.VolunteerInfoDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO; +import com.elink.esua.epdc.dto.epdc.result.EpdcGetVolunteerRankDTO; import com.elink.esua.epdc.entity.VolunteerInfoEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -99,5 +100,11 @@ public interface VolunteerInfoDao extends BaseDao { **/ EpdcAdjustVolunteerPointsDTO selectAdjustVolunteerPointsDTO(String id); + /** + * 获取排行榜 + * @author wanggongfeng + * @return + */ + List getRankingList(); } diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/VolunteerInfoService.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/VolunteerInfoService.java index c232613ae..968ace726 100644 --- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/VolunteerInfoService.java +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/VolunteerInfoService.java @@ -24,6 +24,7 @@ import com.elink.esua.epdc.dto.UserTagDTO; import com.elink.esua.epdc.dto.VolunteerInfoDTO; import com.elink.esua.epdc.dto.epdc.form.EpdcCompleteVolunteerInfoFormDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO; +import com.elink.esua.epdc.dto.epdc.result.EpdcGetVolunteerRankDTO; import com.elink.esua.epdc.entity.VolunteerInfoEntity; import java.util.List; @@ -163,6 +164,12 @@ public interface VolunteerInfoService extends BaseService { **/ Result getAdjustVolunteerPointsDTO(String userId); + /** + * 获取排行榜 + * @author wanggongfeng + * @return + */ + Result> getRankingList(); } diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/VolunteerInfoServiceImpl.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/VolunteerInfoServiceImpl.java index feb505e17..2b4a164bf 100644 --- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/VolunteerInfoServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/VolunteerInfoServiceImpl.java @@ -32,6 +32,7 @@ import com.elink.esua.epdc.dto.VolunteerInfoDTO; import com.elink.esua.epdc.dto.epdc.form.EpdcCompleteVolunteerInfoFormDTO; import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO; +import com.elink.esua.epdc.dto.epdc.result.EpdcGetVolunteerRankDTO; import com.elink.esua.epdc.entity.VolunteerInfoEntity; import com.elink.esua.epdc.redis.VolunteerInfoRedis; import com.elink.esua.epdc.service.UserService; @@ -242,4 +243,15 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl().ok(adjustVolunteerPointsDTO); } + /** + * 获取排行榜 + * @author wanggongfeng + * @return + */ + @Override + public Result> getRankingList() { + List list = baseDao.getRankingList(); + return new Result>().ok(list); + } + } diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/VolunteerInfoDao.xml b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/VolunteerInfoDao.xml index c1ebce521..90e66801b 100644 --- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/VolunteerInfoDao.xml +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/VolunteerInfoDao.xml @@ -168,4 +168,23 @@ AND m.ID = #{id} + +