springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/constants/Constants.java
@@ -251,4 +251,5 @@ public static final String INSERT="insert"; public static final String QUERY="query"; public static final String DELETE="delete"; public static final String VILLAGE="村"; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/AreaVOS.java
New file @@ -0,0 +1,21 @@ package com.panzhihua.common.model.vos.user; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; import java.util.List; @Data @ApiModel public class AreaVOS implements Serializable { @ApiModelProperty("区县名") private String name; @ApiModelProperty("区县code") private Integer id; @ApiModelProperty("下属街道列表") private List<StreetVOS> childList; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/CommunityVO.java
New file @@ -0,0 +1,18 @@ package com.panzhihua.common.model.vos.user; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; @Data @ApiModel public class CommunityVO implements Serializable { @ApiModelProperty("社区/村落名") private String name; @ApiModelProperty("社区/村落id") private String id; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/StreetVO.java
@@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serializable; import java.util.List; @Data @ApiModel @@ -15,4 +16,7 @@ @ApiModelProperty("街道名") private String name; @ApiModelProperty("下属社区列表") private List<CommunityVO> communityList; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/StreetVOS.java
New file @@ -0,0 +1,20 @@ package com.panzhihua.common.model.vos.user; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; @Data @ApiModel public class StreetVOS { @ApiModelProperty("街道id") private Integer id; @ApiModelProperty("街道名") private String name; @ApiModelProperty("下属社区列表") private List<CommunityVO> childList; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java
@@ -1264,4 +1264,7 @@ */ @GetMapping("/uuPush") R uuPush(@RequestParam("washPhone")String washPhone,@RequestParam("phone")String phone,@RequestParam("washName")String washName,@RequestParam("orderStatus")Integer orderStatus); @GetMapping("/communityList") R communityList(@RequestParam("type") Integer type); } springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/IndexApi.java
@@ -3,8 +3,15 @@ import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import cn.hutool.core.util.StrUtil; import com.panzhihua.common.constants.Constants; import com.panzhihua.common.constants.TokenConstant; import com.panzhihua.common.model.vos.user.IndexDataAnalysisVO; import com.panzhihua.common.model.vos.user.StreetVO; import com.panzhihua.common.utlis.AES; import com.panzhihua.common.utlis.StringUtils; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import org.springframework.util.ObjectUtils; @@ -26,6 +33,8 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; /** * @program: springcloud_k8s_panzhihuazhihuishequ @@ -75,4 +84,39 @@ } return r; } @GetMapping("/communityList") @ApiOperation(value = "获取当前账号下的社区/村落列表",response = StreetVO.class) public R communityList(){ //获取当前登录用户的信息 RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); // 从获取RequestAttributes中获取HttpServletRequest的信息 HttpServletRequest request = (HttpServletRequest)requestAttributes.resolveReference(RequestAttributes.REFERENCE_REQUEST); // 登录对象信息 String userInfo = request.getHeader(TokenConstant.TOKEN_USERINFO); boolean empty = ObjectUtils.isEmpty(userInfo); if (empty) { log.error("获取登录用户信息失败【{}】"); } byte[] bytes = AES.parseHexStr2Byte(userInfo); byte[] decrypt = AES.decrypt(bytes, Constants.AES_KEY); userInfo = new String(decrypt); LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(userInfo, LoginUserInfoVO.class); //截取社区名 if (StringUtils.isEmpty(loginUserInfoVO.getCommunityName())) { R<LoginUserInfoVO> userInfoByUserId = userService.getUserInfoByUserId(loginUserInfoVO.getUserId().toString()); loginUserInfoVO = userInfoByUserId.getData(); } Integer type=null; if (loginUserInfoVO.getAccount().equals("pannongyenongcunju")){ type=2; }else if (loginUserInfoVO.getAccount().equals("pandashujuzhongxin")){ type=1; }else if (loginUserInfoVO.getAccount().equals("fangyipingtai")){ type=3; } return userService.communityList(type); } } springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java
@@ -4,6 +4,7 @@ import javax.annotation.Resource; import cn.hutool.core.util.StrUtil; import com.panzhihua.common.model.dtos.DataKanBansDto; import com.panzhihua.common.model.dtos.community.convenient.ConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.DisableOrEnableConvenientMerchantDTO; @@ -1430,4 +1431,10 @@ public R getAreaAndStreet(){ return userService.getAreaAndStreet(); } @GetMapping("/communityList") public R getCommunityList(@RequestParam(value = "type") Integer type){ return userService.getCommunityList(type); } } springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java
@@ -323,5 +323,9 @@ * */ Integer getMonthUsers(@Param("streetId") Long streetId,@Param("areaCode") Long areaCode,@Param("range") String range); /** * 获取街道下属村/社区 * */ List<CommunityVO> selectCommunityByStreetId(@Param("id") Integer streetId,@Param("type") Integer type); } springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/UserService.java
@@ -899,4 +899,9 @@ * @return */ R uuPush(@RequestParam("washPhone")String washPhone,@RequestParam("phone")String phone,@RequestParam("washName")String washName,@RequestParam("orderStatus")Integer orderStatus); /** * 获取城镇或村落列表 * */ R getCommunityList(Integer type); } springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java
@@ -13,6 +13,8 @@ import javax.annotation.Resource; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; @@ -41,6 +43,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -3567,7 +3570,6 @@ return R.ok(vo); } @Override public R uuPush(String washPhone,String phone,String washName,Integer orderStatus) { if(StringUtils.isNotEmpty(phone)){ @@ -3599,6 +3601,40 @@ } return R.ok(); } @Override public R getCommunityList(Integer type) { List<Integer> areaList = areaCodeList(); List<AreaVOS> areaVOList=new ArrayList<>(); for (Integer code : areaList) { AreaVOS areaVO=new AreaVOS(); areaVO.setId(code); areaVO.setName(areaCodeToName(code.longValue())); List<StreetVO> streetVOS = userDao.selectStreetByAreaCode(code); Iterator<StreetVO> iterator = streetVOS.listIterator(); while (iterator.hasNext()){ StreetVO vo = iterator.next(); List<CommunityVO> communityVOS = userDao.selectCommunityByStreetId(vo.getId(), type); vo.setCommunityList(communityVOS); if (type!=3){ if (communityVOS==null || communityVOS.size()==0){ iterator.remove(); } } } List<StreetVOS> list=new ArrayList<>(); for (StreetVO streetVO : streetVOS) { StreetVOS vo=new StreetVOS(); vo.setId(streetVO.getId()); vo.setName(streetVO.getName()); vo.setChildList(streetVO.getCommunityList()); list.add(vo); } areaVO.setChildList(list); areaVOList.add(areaVO); } return R.ok(areaVOList); } @Override public R getAreaAndStreet() { List<Integer> areaCodeList=areaCodeList(); @@ -3739,6 +3775,9 @@ case "510422": name="盐边县"; break; case "510424": name="钒钛新区"; break; } return name; } @@ -3779,11 +3818,12 @@ * */ private List<Integer> areaCodeList(){ List<Integer> list=new ArrayList<>(); list.add(510423); list.add(510402); list.add(510423); list.add(510411); list.add(510421); list.add(510422); list.add(510424); return list; } springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/resources/mapper/UserDao.xml
@@ -707,5 +707,13 @@ and t.create_at >= #{range} </if> </select> <select id="selectCommunityByStreetId" resultType="com.panzhihua.common.model.vos.user.CommunityVO"> select community_id as id,name from com_act where street_id =#{id} <if test="type == 1"> and name like concat('%','社区') </if> <if test="type == 2"> and name like concat('%','村') </if> </select> </mapper>