From 59cce5e2e2d809946c0aec613951155a6a73b97e Mon Sep 17 00:00:00 2001 From: yinzuomei <57602893@qq.com> Date: Mon, 30 Mar 2020 11:48:03 +0800 Subject: [PATCH] =?UTF-8?q?resi-group=E6=96=B0=E5=A2=9Einitapplygroup?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3,epmet-user=E6=96=B0=E5=A2=9E=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E5=AE=A2=E6=88=B7id=E3=80=81=E7=94=A8=E6=88=B7id?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=B1=85=E6=B0=91=E6=B3=A8=E5=86=8C=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resi-group/resi-group-server/pom.xml | 6 ++++ .../modules/feign/EpmetUserFeignClient.java | 29 +++++++++++++++++++ .../com/epmet/modules/feign/fallback/.gitkeep | 0 .../EpmetUserFeignClientFallback.java | 23 +++++++++++++++ .../group/controller/ResiGroupController.java | 28 ++++++++++++++---- .../group/service/ResiGroupService.java | 10 +++++++ .../service/impl/ResiGroupServiceImpl.java | 19 +++++++++++- .../epmet/modules/utils/ModuleConstant.java | 7 +++++ .../epmet/dto/form/UserResiInfoFormDTO.java | 29 +++++++++++++++++++ .../controller/UserResiInfoController.java | 17 +++++++++-- .../java/com/epmet/dao/UserResiInfoDao.java | 14 +++++++-- .../epmet/service/UserResiInfoService.java | 13 ++++++++- .../service/impl/UserResiInfoServiceImpl.java | 17 ++++++++++- .../main/resources/mapper/UserResiInfoDao.xml | 24 ++++++++++++++- 14 files changed, 222 insertions(+), 14 deletions(-) create mode 100644 epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/EpmetUserFeignClient.java delete mode 100644 epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/.gitkeep create mode 100644 epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/EpmetUserFeignClientFallback.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserResiInfoFormDTO.java diff --git a/epmet-module/resi-group/resi-group-server/pom.xml b/epmet-module/resi-group/resi-group-server/pom.xml index aec9ad4f52..93733b4749 100644 --- a/epmet-module/resi-group/resi-group-server/pom.xml +++ b/epmet-module/resi-group/resi-group-server/pom.xml @@ -58,6 +58,12 @@ feign-httpclient 10.3.0 + + com.epmet + epmet-user-client + 2.0.0 + compile + diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/EpmetUserFeignClient.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/EpmetUserFeignClient.java new file mode 100644 index 0000000000..79619e945e --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/EpmetUserFeignClient.java @@ -0,0 +1,29 @@ +package com.epmet.modules.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.UserResiInfoDTO; +import com.epmet.dto.form.UserResiInfoFormDTO; +import com.epmet.modules.feign.fallback.EpmetUserFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; + +/** + * @Description epmet_user服务fegin + * @Author yinzuomei + * @Date 2020/3/16 14:48 + */ +@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallback.class ) +public interface EpmetUserFeignClient { + + /** + * @param userResiInfoFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 查询用户注册信息 + * @Date 2020/3/30 10:45 + **/ + @PostMapping(value = "epmetuser/userresiinfo/getUserResiInfoDTO", consumes = MediaType.APPLICATION_JSON_VALUE) + Result getUserResiInfoDTO(UserResiInfoFormDTO userResiInfoFormDTO); +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/.gitkeep b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/EpmetUserFeignClientFallback.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/EpmetUserFeignClientFallback.java new file mode 100644 index 0000000000..88765a0624 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/EpmetUserFeignClientFallback.java @@ -0,0 +1,23 @@ +package com.epmet.modules.feign.fallback; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.UserResiInfoDTO; +import com.epmet.dto.form.UserResiInfoFormDTO; +import com.epmet.modules.feign.EpmetUserFeignClient; +import org.springframework.stereotype.Component; + +/** + * @Description epmet_user服务fegin + * @Author yinzuomei + * @Date 2020/3/16 14:53 + */ +@Component +public class EpmetUserFeignClientFallback implements EpmetUserFeignClient { + + @Override + public Result getUserResiInfoDTO(UserResiInfoFormDTO userResiInfoFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getUserResiInfoDTO", userResiInfoFormDTO); + } +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java index 55a2722429..7e5e1f1a57 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java @@ -21,18 +21,17 @@ import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.UserResiInfoFormDTO; +import com.epmet.dto.form.UserResiInfoFormDTO; import com.epmet.modules.group.service.ResiGroupService; +import com.epmet.modules.utils.ModuleConstant; import com.epmet.resi.group.dto.group.form.*; import com.epmet.resi.group.dto.group.result.CreatedResultDTO; import com.epmet.resi.group.dto.group.result.GroupSummarizeResultDTO; import com.epmet.resi.group.dto.group.result.MyGroupResultDTO; import com.epmet.resi.group.dto.group.result.RecommendGroupResultDTO; -import oracle.jdbc.proxy.annotation.Post; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -159,6 +158,23 @@ public class ResiGroupController { ValidatorUtils.validateEntity(applyJoinGroupFormDTO); return resiGroupService.applyJoinGroup(applyJoinGroupFormDTO); } - //加入小组界面初始化 + /** + * @param tokenDto + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 加入小组界面初始化 + * 只有已经注册过的居民才可以加入小组 + * @Date 2020/3/30 10:11 + **/ + @PostMapping("initapplygroup") + public Result initApplyGroup(@LoginUser TokenDto tokenDto,@RequestParam("customerId") String customerId) { + if (null == tokenDto) { + return new Result().error(ModuleConstant.USER_NOT_NULL); + } + UserResiInfoFormDTO resiUserInfoFormDTO = new UserResiInfoFormDTO(); + resiUserInfoFormDTO.setUserId(tokenDto.getUserId()); + resiUserInfoFormDTO.setCustomerId(customerId); + return resiGroupService.initApplyGroup(resiUserInfoFormDTO); + } } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java index 1c7023e8d5..b54189a237 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java @@ -21,6 +21,7 @@ package com.epmet.modules.group.service; 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.form.UserResiInfoFormDTO; import com.epmet.modules.group.entity.ResiGroupEntity; import com.epmet.resi.group.dto.group.ResiGroupDTO; import com.epmet.resi.group.dto.group.form.*; @@ -162,4 +163,13 @@ public interface ResiGroupService extends BaseService { * @Date 2020/3/29 20:01 **/ Result applyJoinGroup(ApplyJoinGroupFormDTO applyJoinGroupFormDTO); + + /** + * @param resiUserInfoFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 加入小组界面初始化 + * @Date 2020/3/30 10:17 + **/ + Result initApplyGroup(UserResiInfoFormDTO resiUserInfoFormDTO); } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java index 4e1bacdf17..51dc8bdec1 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java @@ -25,9 +25,11 @@ 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.utils.Result; +import com.epmet.dto.UserResiInfoDTO; +import com.epmet.dto.form.UserResiInfoFormDTO; +import com.epmet.modules.feign.EpmetUserFeignClient; import com.epmet.modules.group.dao.ResiGroupDao; import com.epmet.modules.group.entity.ResiGroupEntity; -import com.epmet.modules.group.entity.ResiGroupOperationEntity; import com.epmet.modules.group.service.ResiGroupOperationService; import com.epmet.modules.group.service.ResiGroupService; import com.epmet.modules.member.service.GroupMemeberOperationService; @@ -76,6 +78,9 @@ public class ResiGroupServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -265,6 +270,18 @@ public class ResiGroupServiceImpl extends BaseServiceImpl result = epmetUserFeignClient.getUserResiInfoDTO(resiUserInfoFormDTO); + if (!result.success() || null == result.getData()) { + return new Result().error(ModuleConstant.NOT_REGISTERED); + } + return new Result(); + } + return new Result().error(ModuleConstant.USER_NOT_NULL); + } + private ResiGroupEntity structureResiGroupEntity(ApplyCreateGroupFormDTO applyCreateGroupFormDTO) { ResiGroupEntity resiGroupEntity = new ResiGroupEntity(); resiGroupEntity.setCustomerId(applyCreateGroupFormDTO.getCustomerId()); diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java index 02f45bd177..f560eedb65 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java @@ -58,6 +58,13 @@ public interface ModuleConstant extends Constant { */ String REJECT_MODIFYGROUPINFO="只有群主才能修改群信息"; + /** + * 申请加入小组时,需要根据groupId查询组信息 + */ String QUERY_GROUPINFO_FAILED="查询组信息失败"; + /** + * 申请加入小组时,需要根据groupId查询组信息 + */ + String NOT_REGISTERED="为注册的居民不能加入小组"; } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserResiInfoFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserResiInfoFormDTO.java new file mode 100644 index 0000000000..9a46fd7e06 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserResiInfoFormDTO.java @@ -0,0 +1,29 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 居民注册信息查询入参DTO + * @Author yinzuomei + * @Date 2020/3/30 10:26 + */ +@Data +public class UserResiInfoFormDTO implements Serializable { + private static final long serialVersionUID = 2802831913959599147L; + + /** + * 用户当前网格所属客户不能为空 + */ + @NotBlank(message = "客户id不能为空") + private String customerId; + + /** + * 用户id + */ + @NotBlank(message="用户id不能为空") + private String userId; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserResiInfoController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserResiInfoController.java index c2820c30ec..9a032ce2b2 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserResiInfoController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserResiInfoController.java @@ -26,6 +26,7 @@ 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.dto.UserResiInfoDTO; +import com.epmet.dto.form.UserResiInfoFormDTO; import com.epmet.excel.UserResiInfoExcel; import com.epmet.service.UserResiInfoService; import org.springframework.beans.factory.annotation.Autowired; @@ -45,7 +46,7 @@ import java.util.Map; @RestController @RequestMapping("userresiinfo") public class UserResiInfoController { - + @Autowired private UserResiInfoService userResiInfoService; @@ -91,4 +92,16 @@ public class UserResiInfoController { ExcelUtils.exportExcelToTarget(response, null, list, UserResiInfoExcel.class); } -} \ No newline at end of file + /** + * @param userResiInfoFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 查询用户注册信息 + * @Date 2020/3/30 10:49 + **/ + @PostMapping("getUserResiInfoDTO") + public Result getUserResiInfoDTO(@RequestBody UserResiInfoFormDTO userResiInfoFormDTO) { + ValidatorUtils.validateEntity(userResiInfoFormDTO); + return userResiInfoService.getUserResiInfoDTO(userResiInfoFormDTO); + } +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserResiInfoDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserResiInfoDao.java index caee07c493..f4b9ac73d0 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserResiInfoDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserResiInfoDao.java @@ -18,6 +18,8 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.UserResiInfoDTO; +import com.epmet.dto.form.UserResiInfoFormDTO; import com.epmet.entity.UserResiInfoEntity; import org.apache.ibatis.annotations.Mapper; @@ -29,5 +31,13 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface UserResiInfoDao extends BaseDao { - -} \ No newline at end of file + + /** + * @return com.epmet.dto.UserResiInfoDTO + * @param userResiInfoFormDTO + * @Author yinzuomei + * @Description 查询用户注册信息 + * @Date 2020/3/30 11:10 + **/ + UserResiInfoDTO selectUserResiInfoDTO(UserResiInfoFormDTO userResiInfoFormDTO); +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserResiInfoService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserResiInfoService.java index 9fa753553c..8049e21039 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserResiInfoService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserResiInfoService.java @@ -19,7 +19,9 @@ package com.epmet.service; 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.UserResiInfoDTO; +import com.epmet.dto.form.UserResiInfoFormDTO; import com.epmet.entity.UserResiInfoEntity; import java.util.List; @@ -92,4 +94,13 @@ public interface UserResiInfoService extends BaseService { * @date 2020-03-30 */ void delete(String[] ids); -} \ No newline at end of file + + /** + * @param userResiInfoFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 查询用户注册信息 + * @Date 2020/3/30 11:07 + **/ + Result getUserResiInfoDTO(UserResiInfoFormDTO userResiInfoFormDTO); +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java index dddb27e558..999de6f549 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java @@ -23,8 +23,10 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; 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.dao.UserResiInfoDao; import com.epmet.dto.UserResiInfoDTO; +import com.epmet.dto.form.UserResiInfoFormDTO; import com.epmet.entity.UserResiInfoEntity; import com.epmet.redis.UserResiInfoRedis; import com.epmet.service.UserResiInfoService; @@ -101,4 +103,17 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl + * @Author yinzuomei + * @Description 查询用户注册信息 + * @Date 2020/3/30 11:07 + **/ + @Override + public Result getUserResiInfoDTO(UserResiInfoFormDTO userResiInfoFormDTO) { + UserResiInfoDTO userResiInfoDTO=baseDao.selectUserResiInfoDTO(userResiInfoFormDTO); + return new Result().ok(userResiInfoDTO); + } + +} diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserResiInfoDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserResiInfoDao.xml index 1523dbfd20..ef208b2df9 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserResiInfoDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserResiInfoDao.xml @@ -20,5 +20,27 @@ + + - \ No newline at end of file +