小区改造
parent
5e3d43bf29
commit
0e997cfd5a
|
|
@ -9,7 +9,6 @@ import com.fjrcloud.community.framework.excel.core.util.ExcelUtils;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunityPageReqVO;
|
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunityPageReqVO;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunityRespVO;
|
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunityRespVO;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunitySaveReqVO;
|
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunitySaveReqVO;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunityTreeRespVO;
|
|
||||||
import com.fjrcloud.community.module.community.dal.dataobject.community.CommunityDO;
|
import com.fjrcloud.community.module.community.dal.dataobject.community.CommunityDO;
|
||||||
import com.fjrcloud.community.module.community.service.community.CommunityService;
|
import com.fjrcloud.community.module.community.service.community.CommunityService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
@ -64,7 +63,7 @@ public class CommunityController {
|
||||||
@DeleteMapping("/delete-list")
|
@DeleteMapping("/delete-list")
|
||||||
@Parameter(name = "ids", description = "编号", required = true)
|
@Parameter(name = "ids", description = "编号", required = true)
|
||||||
@Operation(summary = "批量删除小区信息主表(comm_community)")
|
@Operation(summary = "批量删除小区信息主表(comm_community)")
|
||||||
@PreAuthorize("@ss.hasPermission('community:community:delete')")
|
@PreAuthorize("@ss.hasPermission('community:community:delete')")
|
||||||
public CommonResult<Boolean> deleteCommunityList(@RequestParam("ids") List<Long> ids) {
|
public CommonResult<Boolean> deleteCommunityList(@RequestParam("ids") List<Long> ids) {
|
||||||
communityService.deleteCommunityListByIds(ids);
|
communityService.deleteCommunityListByIds(ids);
|
||||||
return success(true);
|
return success(true);
|
||||||
|
|
@ -99,13 +98,4 @@ public class CommunityController {
|
||||||
BeanUtils.toBean(list, CommunityRespVO.class));
|
BeanUtils.toBean(list, CommunityRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/street-community-tree")
|
|
||||||
@Operation(summary = "获取街道和社区树形结构")
|
|
||||||
@Parameter(name = "streetId", description = "街道ID,不传则返回所有街道及社区", example = "1024")
|
|
||||||
@PreAuthorize("@ss.hasPermission('community:community:query')")
|
|
||||||
public CommonResult<List<CommunityTreeRespVO>> getStreetCommunityTree(@RequestParam(value = "streetId", required = false) Long streetId) {
|
|
||||||
List<CommunityTreeRespVO> tree = communityService.getStreetCommunityTree(streetId);
|
|
||||||
return success(tree);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -8,13 +8,13 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
public class CommunityPageReqVO extends PageParam {
|
public class CommunityPageReqVO extends PageParam {
|
||||||
|
|
||||||
@Schema(description = "小区名称", example = "芋艿")
|
@Schema(description = "小区名称", example = "阳光小区")
|
||||||
private String communityName;
|
private String communityName;
|
||||||
|
|
||||||
@Schema(description = "所属街道ID", example = "20508")
|
@Schema(description = "所属街道名称", example = "XX街道")
|
||||||
private Long streetId;
|
private String streetName;
|
||||||
|
|
||||||
@Schema(description = "所属社区ID", example = "20551")
|
@Schema(description = "所属社区名称", example = "XX社区")
|
||||||
private Long districtId;
|
private String districtName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,8 +2,6 @@ package com.fjrcloud.community.module.community.controller.admin.community.vo;
|
||||||
|
|
||||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import cn.idev.excel.annotation.ExcelProperty;
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
import com.fjrcloud.community.framework.excel.core.annotations.DictFormat;
|
|
||||||
import com.fjrcloud.community.framework.excel.core.convert.DictConvert;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
@ -15,76 +13,63 @@ import java.time.LocalDateTime;
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
public class CommunityRespVO {
|
public class CommunityRespVO {
|
||||||
|
|
||||||
@Schema(description = "主键ID,和部门id一致", requiredMode = Schema.RequiredMode.REQUIRED, example = "8921")
|
@Schema(description = "主键ID,和租户id一致", requiredMode = Schema.RequiredMode.REQUIRED, example = "8921")
|
||||||
@ExcelProperty("主键ID,和部门id一致")
|
@ExcelProperty("主键ID")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "小区名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
@Schema(description = "小区名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "阳光小区")
|
||||||
@ExcelProperty("小区名称")
|
@ExcelProperty("小区名称")
|
||||||
private String communityName;
|
private String communityName;
|
||||||
|
|
||||||
@Schema(description = "区域类型:0=街道,1=社区,2=小区", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
@Schema(description = "所属街道名称", example = "XX街道")
|
||||||
@ExcelProperty(value = "区域类型:0=街道,1=社区,2=小区", converter = DictConvert.class)
|
|
||||||
@DictFormat("comm_area_type")
|
|
||||||
private Integer areaType;
|
|
||||||
|
|
||||||
@Schema(description = "所属街道ID", example = "20508")
|
|
||||||
@ExcelProperty("所属街道ID")
|
|
||||||
private Long streetId;
|
|
||||||
|
|
||||||
@Schema(description = "所属街道名称", example = "王五")
|
|
||||||
@ExcelProperty("所属街道名称")
|
@ExcelProperty("所属街道名称")
|
||||||
private String streetName;
|
private String streetName;
|
||||||
|
|
||||||
@Schema(description = "所属社区ID", example = "20551")
|
@Schema(description = "所属社区名称", example = "XX社区")
|
||||||
@ExcelProperty("所属社区ID")
|
@ExcelProperty("所属社区名称")
|
||||||
private Long districtId;
|
private String districtName;
|
||||||
|
|
||||||
@Schema(description = "小区详细地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "小区详细地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty("小区详细地址")
|
@ExcelProperty("小区详细地址")
|
||||||
private String communityAddress;
|
private String communityAddress;
|
||||||
|
|
||||||
@Schema(description = "所属社区名称", example = "李四")
|
|
||||||
@ExcelProperty("所属社区名称")
|
|
||||||
private String districtName;
|
|
||||||
|
|
||||||
@Schema(description = "小区经度坐标")
|
@Schema(description = "小区经度坐标")
|
||||||
@ExcelProperty("小区经度坐标")
|
@ExcelProperty("小区经度坐标")
|
||||||
private BigDecimal longitude;
|
private BigDecimal longitude;
|
||||||
|
|
||||||
@Schema(description = "房屋数")
|
|
||||||
@ExcelProperty("房屋数")
|
|
||||||
private Integer houseNum;
|
|
||||||
|
|
||||||
@Schema(description = "小区纬度坐标")
|
@Schema(description = "小区纬度坐标")
|
||||||
@ExcelProperty("小区纬度坐标")
|
@ExcelProperty("小区纬度坐标")
|
||||||
private BigDecimal latitude;
|
private BigDecimal latitude;
|
||||||
|
|
||||||
@Schema(description = "常驻人口数")
|
|
||||||
@ExcelProperty("常驻人口数")
|
|
||||||
private Long residentNum;
|
|
||||||
|
|
||||||
@Schema(description = "小区物业名称")
|
@Schema(description = "小区物业名称")
|
||||||
@ExcelProperty("小区物业名称")
|
@ExcelProperty("小区物业名称")
|
||||||
private String propertyCompany;
|
private String propertyCompany;
|
||||||
|
|
||||||
@Schema(description = "流动人口数")
|
@Schema(description = "来访审核配置:1需要审核,0无需审核", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("来访审核配置")
|
||||||
|
private Boolean visitAudit;
|
||||||
|
|
||||||
|
@Schema(description = "道闸申请配置:1需要审核,0无需审核", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("道闸申请配置")
|
||||||
|
private Boolean gateAudit;
|
||||||
|
|
||||||
|
@Schema(description = "房屋数", example = "0")
|
||||||
|
@ExcelProperty("房屋数")
|
||||||
|
private Integer houseNum;
|
||||||
|
|
||||||
|
@Schema(description = "常驻人口数", example = "0")
|
||||||
|
@ExcelProperty("常驻人口数")
|
||||||
|
private Long residentNum;
|
||||||
|
|
||||||
|
@Schema(description = "流动人口数", example = "0")
|
||||||
@ExcelProperty("流动人口数")
|
@ExcelProperty("流动人口数")
|
||||||
private Long floatingNum;
|
private Long floatingNum;
|
||||||
|
|
||||||
@Schema(description = "来访审核配置:1需要审核,0无需审核", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "物业人数", example = "0")
|
||||||
@ExcelProperty("来访审核配置:1需要审核,0无需审核")
|
|
||||||
private Boolean visitAudit;
|
|
||||||
|
|
||||||
@Schema(description = "物业人数")
|
|
||||||
@ExcelProperty("物业人数")
|
@ExcelProperty("物业人数")
|
||||||
private Integer propertyNum;
|
private Integer propertyNum;
|
||||||
|
|
||||||
@Schema(description = "道闸申请配置:1需要审核,0无需审核", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "业委会人数", example = "0")
|
||||||
@ExcelProperty("道闸申请配置:1需要审核,0无需审核")
|
|
||||||
private Boolean gateAudit;
|
|
||||||
|
|
||||||
@Schema(description = "业委会人数")
|
|
||||||
@ExcelProperty("业委会人数")
|
@ExcelProperty("业委会人数")
|
||||||
private Integer committeeNum;
|
private Integer committeeNum;
|
||||||
|
|
||||||
|
|
@ -93,3 +78,4 @@ public class CommunityRespVO {
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,31 +2,29 @@ package com.fjrcloud.community.module.community.controller.admin.community.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 小区信息主表(comm_community)新增/修改 Request VO")
|
@Schema(description = "管理后台 - 小区信息主表(comm_community)新增/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class CommunitySaveReqVO {
|
public class CommunitySaveReqVO {
|
||||||
|
|
||||||
@Schema(description = "主键ID,和部门id一致", requiredMode = Schema.RequiredMode.REQUIRED, example = "8921")
|
@Schema(description = "主键ID,和租户id一致", requiredMode = Schema.RequiredMode.REQUIRED, example = "8921")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "小区名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
@Schema(description = "小区名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "阳光小区")
|
||||||
@NotEmpty(message = "小区名称不能为空")
|
@NotEmpty(message = "小区名称不能为空")
|
||||||
private String communityName;
|
private String communityName;
|
||||||
|
|
||||||
@Schema(description = "区域类型:0=街道,1=社区,2=小区", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
@Schema(description = "所属街道名称", example = "XX街道")
|
||||||
@NotNull(message = "区域类型:0=街道,1=社区,2=小区不能为空")
|
private String streetName;
|
||||||
private Integer areaType;
|
|
||||||
|
|
||||||
@Schema(description = "所属街道ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "20508")
|
@Schema(description = "所属社区名称", example = "XX社区")
|
||||||
private Long streetId;
|
private String districtName;
|
||||||
|
|
||||||
@Schema(description = "所属社区ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "20551")
|
|
||||||
private Long districtId;
|
|
||||||
|
|
||||||
@Schema(description = "详细地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "详细地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotEmpty(message = "详细地址不能为空")
|
@NotEmpty(message = "详细地址不能为空")
|
||||||
|
|
@ -47,4 +45,13 @@ public class CommunitySaveReqVO {
|
||||||
@Schema(description = "道闸申请配置:1需要审核,0无需审核", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "道闸申请配置:1需要审核,0无需审核", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private Boolean gateAudit;
|
private Boolean gateAudit;
|
||||||
|
|
||||||
|
@Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "admin")
|
||||||
|
@Pattern(regexp = "^[a-zA-Z0-9]{4,30}$", message = "用户名由 数字、字母 组成")
|
||||||
|
@Size(min = 4, max = 30, message = "用户名长度为 4-30 个字符")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "admin123")
|
||||||
|
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||||
|
private String password;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package com.fjrcloud.community.module.community.controller.admin.community.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 街道社区树形结构 Response VO")
|
|
||||||
@Data
|
|
||||||
public class CommunityTreeRespVO {
|
|
||||||
|
|
||||||
@Schema(description = "节点ID", example = "1024")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Schema(description = "节点名称", example = "XX街道")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@Schema(description = "区域类型:0=街道,1=社区,2=小区", example = "0")
|
|
||||||
private Integer areaType;
|
|
||||||
|
|
||||||
@Schema(description = "父节点ID", example = "0")
|
|
||||||
private Long parentId;
|
|
||||||
|
|
||||||
@Schema(description = "子节点列表")
|
|
||||||
private List<CommunityTreeRespVO> children;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fjrcloud.community.framework.mybatis.core.dataobject.BaseDO;
|
import com.fjrcloud.community.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
import com.fjrcloud.community.framework.tenant.core.aop.TenantIgnore;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
@ -14,89 +15,65 @@ import java.math.BigDecimal;
|
||||||
* @author zzy
|
* @author zzy
|
||||||
*/
|
*/
|
||||||
@TableName("comm_community")
|
@TableName("comm_community")
|
||||||
@KeySequence("comm_community_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
@KeySequence("comm_community_seq")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@TenantIgnore
|
||||||
public class CommunityDO extends BaseDO {
|
public class CommunityDO extends BaseDO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键ID,和部门id一致
|
* 主键ID,和租户id一致
|
||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小区名称
|
* 小区名称
|
||||||
*/
|
*/
|
||||||
private String communityName;
|
private String communityName;
|
||||||
/**
|
|
||||||
* 区域类型:0=街道,1=社区,2=小区
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private Integer areaType;
|
|
||||||
/**
|
|
||||||
* 所属街道ID
|
|
||||||
*/
|
|
||||||
private Long streetId;
|
|
||||||
/**
|
/**
|
||||||
* 所属街道名称
|
* 所属街道名称
|
||||||
*/
|
*/
|
||||||
private String streetName;
|
private String streetName;
|
||||||
/**
|
|
||||||
* 所属社区ID
|
|
||||||
*/
|
|
||||||
private Long districtId;
|
|
||||||
/**
|
|
||||||
* 小区详细地址
|
|
||||||
*/
|
|
||||||
private String communityAddress;
|
|
||||||
/**
|
/**
|
||||||
* 所属社区名称
|
* 所属社区名称
|
||||||
*/
|
*/
|
||||||
private String districtName;
|
private String districtName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小区详细地址
|
||||||
|
*/
|
||||||
|
private String communityAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小区经度坐标
|
* 小区经度坐标
|
||||||
*/
|
*/
|
||||||
private BigDecimal longitude;
|
private BigDecimal longitude;
|
||||||
/**
|
|
||||||
* 房屋数
|
|
||||||
*/
|
|
||||||
private Integer houseNum;
|
|
||||||
/**
|
/**
|
||||||
* 小区纬度坐标
|
* 小区纬度坐标
|
||||||
*/
|
*/
|
||||||
private BigDecimal latitude;
|
private BigDecimal latitude;
|
||||||
/**
|
|
||||||
* 常驻人口数
|
|
||||||
*/
|
|
||||||
private Long residentNum;
|
|
||||||
/**
|
/**
|
||||||
* 小区物业名称
|
* 小区物业名称
|
||||||
*/
|
*/
|
||||||
private String propertyCompany;
|
private String propertyCompany;
|
||||||
/**
|
|
||||||
* 流动人口数
|
|
||||||
*/
|
|
||||||
private Long floatingNum;
|
|
||||||
/**
|
/**
|
||||||
* 来访审核配置:1需要审核,0无需审核
|
* 来访审核配置:1需要审核,0无需审核
|
||||||
*/
|
*/
|
||||||
private Boolean visitAudit;
|
private Boolean visitAudit;
|
||||||
/**
|
|
||||||
* 物业人数
|
|
||||||
*/
|
|
||||||
private Integer propertyNum;
|
|
||||||
/**
|
/**
|
||||||
* 道闸申请配置:1需要审核,0无需审核
|
* 道闸申请配置:1需要审核,0无需审核
|
||||||
*/
|
*/
|
||||||
private Boolean gateAudit;
|
private Boolean gateAudit;
|
||||||
/**
|
|
||||||
* 业委会人数
|
|
||||||
*/
|
|
||||||
private Integer committeeNum;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -18,8 +18,8 @@ public interface CommunityMapper extends BaseMapperX<CommunityDO> {
|
||||||
default PageResult<CommunityDO> selectPage(CommunityPageReqVO reqVO) {
|
default PageResult<CommunityDO> selectPage(CommunityPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<CommunityDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<CommunityDO>()
|
||||||
.likeIfPresent(CommunityDO::getCommunityName, reqVO.getCommunityName())
|
.likeIfPresent(CommunityDO::getCommunityName, reqVO.getCommunityName())
|
||||||
.eqIfPresent(CommunityDO::getStreetId, reqVO.getStreetId())
|
.likeIfPresent(CommunityDO::getStreetName, reqVO.getStreetName())
|
||||||
.eqIfPresent(CommunityDO::getDistrictId, reqVO.getDistrictId())
|
.likeIfPresent(CommunityDO::getDistrictName, reqVO.getDistrictName())
|
||||||
.orderByDesc(CommunityDO::getId));
|
.orderByDesc(CommunityDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package com.fjrcloud.community.module.community.service.community;
|
||||||
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunityPageReqVO;
|
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunityPageReqVO;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunitySaveReqVO;
|
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunitySaveReqVO;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunityTreeRespVO;
|
|
||||||
import com.fjrcloud.community.module.community.dal.dataobject.community.CommunityDO;
|
import com.fjrcloud.community.module.community.dal.dataobject.community.CommunityDO;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
@ -61,12 +60,4 @@ public interface CommunityService {
|
||||||
*/
|
*/
|
||||||
PageResult<CommunityDO> getCommunityPage(CommunityPageReqVO pageReqVO);
|
PageResult<CommunityDO> getCommunityPage(CommunityPageReqVO pageReqVO);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取街道和社区树形结构
|
|
||||||
*
|
|
||||||
* @param streetId 街道ID,为null时返回所有街道及其下的社区
|
|
||||||
* @return 树形结构列表
|
|
||||||
*/
|
|
||||||
List<CommunityTreeRespVO> getStreetCommunityTree(Long streetId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -3,26 +3,20 @@ package com.fjrcloud.community.module.community.service.community;
|
||||||
import com.fjrcloud.community.framework.common.enums.CommonStatusEnum;
|
import com.fjrcloud.community.framework.common.enums.CommonStatusEnum;
|
||||||
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
||||||
import com.fjrcloud.community.framework.common.util.object.BeanUtils;
|
import com.fjrcloud.community.framework.common.util.object.BeanUtils;
|
||||||
import com.fjrcloud.community.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
||||||
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunityPageReqVO;
|
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunityPageReqVO;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunitySaveReqVO;
|
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunitySaveReqVO;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunityTreeRespVO;
|
|
||||||
import com.fjrcloud.community.module.community.dal.dataobject.community.CommunityDO;
|
import com.fjrcloud.community.module.community.dal.dataobject.community.CommunityDO;
|
||||||
import com.fjrcloud.community.module.community.dal.mysql.community.CommunityMapper;
|
import com.fjrcloud.community.module.community.dal.mysql.community.CommunityMapper;
|
||||||
import com.fjrcloud.community.module.system.api.dept.DeptApi;
|
import com.fjrcloud.community.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
|
||||||
import com.fjrcloud.community.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
|
import com.fjrcloud.community.module.system.service.tenant.TenantService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static com.fjrcloud.community.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.fjrcloud.community.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.fjrcloud.community.framework.common.util.collection.CollectionUtils.convertList;
|
|
||||||
import static com.fjrcloud.community.module.community.enums.ErrorCodeConstants.COMMUNITY_NOT_EXISTS;
|
import static com.fjrcloud.community.module.community.enums.ErrorCodeConstants.COMMUNITY_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -38,45 +32,34 @@ public class CommunityServiceImpl implements CommunityService {
|
||||||
private CommunityMapper communityMapper;
|
private CommunityMapper communityMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DeptApi deptApi;
|
private TenantService tenantService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户套餐ID,固定使用111
|
||||||
|
*/
|
||||||
|
private static final Long TENANT_PACKAGE_ID = 111L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createCommunity(CommunitySaveReqVO createReqVO) {
|
public Long createCommunity(CommunitySaveReqVO createReqVO) {
|
||||||
DeptSaveReqVO deptReqVO = new DeptSaveReqVO();
|
// 创建租户
|
||||||
deptReqVO.setName(createReqVO.getCommunityName());
|
TenantSaveReqVO tenantReqVO = new TenantSaveReqVO();
|
||||||
deptReqVO.setSort(0);
|
tenantReqVO.setName(createReqVO.getCommunityName());
|
||||||
deptReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
tenantReqVO.setContactName(createReqVO.getCommunityName());
|
||||||
|
tenantReqVO.setContactMobile("");
|
||||||
|
tenantReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
tenantReqVO.setPackageId(TENANT_PACKAGE_ID);
|
||||||
|
tenantReqVO.setExpireTime(LocalDateTime.now().plusYears(100));
|
||||||
|
tenantReqVO.setAccountCount(9999);
|
||||||
|
|
||||||
Integer areaType = createReqVO.getAreaType();
|
// 使用传入的用户名和密码创建租户管理员
|
||||||
if (areaType == 0) {
|
tenantReqVO.setUsername(createReqVO.getUsername());
|
||||||
deptReqVO.setParentId(0L);
|
tenantReqVO.setPassword(createReqVO.getPassword());
|
||||||
} else if (areaType == 1) {
|
|
||||||
deptReqVO.setParentId(createReqVO.getStreetId());
|
|
||||||
} else if (areaType == 2) {
|
|
||||||
deptReqVO.setParentId(createReqVO.getDistrictId());
|
|
||||||
}
|
|
||||||
|
|
||||||
Long deptId = deptApi.saveDept(deptReqVO);
|
Long tenantId = tenantService.createTenant(tenantReqVO);
|
||||||
|
|
||||||
|
// 创建小区记录,ID与租户ID一致
|
||||||
CommunityDO community = BeanUtils.toBean(createReqVO, CommunityDO.class);
|
CommunityDO community = BeanUtils.toBean(createReqVO, CommunityDO.class);
|
||||||
community.setId(deptId);
|
community.setId(tenantId);
|
||||||
|
|
||||||
if (areaType == 1) {
|
|
||||||
CommunityDO street = communityMapper.selectById(createReqVO.getStreetId());
|
|
||||||
if (street != null) {
|
|
||||||
community.setStreetName(street.getCommunityName());
|
|
||||||
}
|
|
||||||
} else if (areaType == 2) {
|
|
||||||
CommunityDO street = communityMapper.selectById(createReqVO.getStreetId());
|
|
||||||
if (street != null) {
|
|
||||||
community.setStreetName(street.getCommunityName());
|
|
||||||
}
|
|
||||||
CommunityDO district = communityMapper.selectById(createReqVO.getDistrictId());
|
|
||||||
if (district != null) {
|
|
||||||
community.setDistrictName(district.getCommunityName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
communityMapper.insert(community);
|
communityMapper.insert(community);
|
||||||
|
|
||||||
return community.getId();
|
return community.getId();
|
||||||
|
|
@ -84,56 +67,43 @@ public class CommunityServiceImpl implements CommunityService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateCommunity(CommunitySaveReqVO updateReqVO) {
|
public void updateCommunity(CommunitySaveReqVO updateReqVO) {
|
||||||
DeptSaveReqVO deptReqVO = new DeptSaveReqVO();
|
// 校验小区存在
|
||||||
deptReqVO.setId(updateReqVO.getId());
|
validateCommunityExists(updateReqVO.getId());
|
||||||
deptReqVO.setName(updateReqVO.getCommunityName());
|
|
||||||
deptReqVO.setSort(0);
|
|
||||||
deptReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
|
||||||
|
|
||||||
Integer areaType = updateReqVO.getAreaType();
|
// 更新租户信息
|
||||||
if (areaType == 0) {
|
TenantSaveReqVO tenantReqVO = new TenantSaveReqVO();
|
||||||
deptReqVO.setParentId(0L);
|
tenantReqVO.setId(updateReqVO.getId());
|
||||||
} else if (areaType == 1) {
|
tenantReqVO.setName(updateReqVO.getCommunityName());
|
||||||
deptReqVO.setParentId(updateReqVO.getStreetId());
|
tenantReqVO.setContactName(updateReqVO.getCommunityName());
|
||||||
} else if (areaType == 2) {
|
tenantReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
deptReqVO.setParentId(updateReqVO.getDistrictId());
|
tenantReqVO.setPackageId(TENANT_PACKAGE_ID);
|
||||||
}
|
tenantReqVO.setExpireTime(LocalDateTime.now().plusYears(100));
|
||||||
|
tenantReqVO.setAccountCount(9999);
|
||||||
|
|
||||||
deptApi.saveDept(deptReqVO);
|
tenantService.updateTenant(tenantReqVO);
|
||||||
|
|
||||||
|
// 更新小区信息
|
||||||
CommunityDO updateObj = BeanUtils.toBean(updateReqVO, CommunityDO.class);
|
CommunityDO updateObj = BeanUtils.toBean(updateReqVO, CommunityDO.class);
|
||||||
|
|
||||||
if (areaType == 1) {
|
|
||||||
CommunityDO street = communityMapper.selectById(updateReqVO.getStreetId());
|
|
||||||
if (street != null) {
|
|
||||||
updateObj.setStreetName(street.getCommunityName());
|
|
||||||
}
|
|
||||||
} else if (areaType == 2) {
|
|
||||||
CommunityDO street = communityMapper.selectById(updateReqVO.getStreetId());
|
|
||||||
if (street != null) {
|
|
||||||
updateObj.setStreetName(street.getCommunityName());
|
|
||||||
}
|
|
||||||
CommunityDO district = communityMapper.selectById(updateReqVO.getDistrictId());
|
|
||||||
if (district != null) {
|
|
||||||
updateObj.setDistrictName(district.getCommunityName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
communityMapper.updateById(updateObj);
|
communityMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteCommunity(Long id) {
|
public void deleteCommunity(Long id) {
|
||||||
deptApi.deleteDept(id);
|
// 校验小区存在
|
||||||
|
validateCommunityExists(id);
|
||||||
|
// 删除小区
|
||||||
communityMapper.deleteById(id);
|
communityMapper.deleteById(id);
|
||||||
|
// 同步删除租户
|
||||||
|
tenantService.deleteTenant(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteCommunityListByIds(List<Long> ids) {
|
public void deleteCommunityListByIds(List<Long> ids) {
|
||||||
ids.forEach(id -> deptApi.deleteDept(id));
|
// 批量删除小区
|
||||||
communityMapper.deleteByIds(ids);
|
communityMapper.deleteByIds(ids);
|
||||||
}
|
// 同步删除租户
|
||||||
|
ids.forEach(id -> tenantService.deleteTenant(id));
|
||||||
|
}
|
||||||
|
|
||||||
private void validateCommunityExists(Long id) {
|
private void validateCommunityExists(Long id) {
|
||||||
if (communityMapper.selectById(id) == null) {
|
if (communityMapper.selectById(id) == null) {
|
||||||
|
|
@ -151,65 +121,4 @@ public class CommunityServiceImpl implements CommunityService {
|
||||||
return communityMapper.selectPage(pageReqVO);
|
return communityMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取街道和社区树形结构
|
|
||||||
*
|
|
||||||
* @param streetId 街道ID,为null时返回所有街道及其下的社区,不为null时返回指定街道及其下的社区
|
|
||||||
* @return 树形结构列表,每个节点包含街道或社区的基本信息及子节点列表
|
|
||||||
*/
|
|
||||||
public List<CommunityTreeRespVO> getStreetCommunityTree(Long streetId) {
|
|
||||||
List<CommunityDO> streets;
|
|
||||||
List<CommunityDO> communities;
|
|
||||||
|
|
||||||
if (streetId != null) {
|
|
||||||
CommunityDO street = communityMapper.selectById(streetId);
|
|
||||||
if (street == null || street.getAreaType() != 0) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
streets = Collections.singletonList(street);
|
|
||||||
communities = communityMapper.selectList(CommunityDO::getStreetId, streetId,
|
|
||||||
CommunityDO::getAreaType, 1);
|
|
||||||
} else {
|
|
||||||
streets = communityMapper.selectList(CommunityDO::getAreaType, 0);
|
|
||||||
List<Long> streetIds = convertList(streets, CommunityDO::getId);
|
|
||||||
if (streetIds.isEmpty()) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
communities = communityMapper.selectList(new LambdaQueryWrapperX<CommunityDO>()
|
|
||||||
.eq(CommunityDO::getAreaType, 1)
|
|
||||||
.in(CommunityDO::getStreetId, streetIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<Long, List<CommunityDO>> communityMap = communities.stream()
|
|
||||||
.collect(Collectors.groupingBy(CommunityDO::getStreetId));
|
|
||||||
|
|
||||||
List<CommunityTreeRespVO> result = new ArrayList<>();
|
|
||||||
|
|
||||||
for (CommunityDO street : streets) {
|
|
||||||
CommunityTreeRespVO streetNode = new CommunityTreeRespVO();
|
|
||||||
streetNode.setId(street.getId());
|
|
||||||
streetNode.setName(street.getCommunityName());
|
|
||||||
streetNode.setAreaType(street.getAreaType());
|
|
||||||
streetNode.setParentId(0L);
|
|
||||||
|
|
||||||
List<CommunityDO> children = communityMap.getOrDefault(street.getId(), Collections.emptyList());
|
|
||||||
List<CommunityTreeRespVO> childNodes = children.stream()
|
|
||||||
.map(community -> {
|
|
||||||
CommunityTreeRespVO childNode = new CommunityTreeRespVO();
|
|
||||||
childNode.setId(community.getId());
|
|
||||||
childNode.setName(community.getCommunityName());
|
|
||||||
childNode.setAreaType(community.getAreaType());
|
|
||||||
childNode.setParentId(community.getStreetId());
|
|
||||||
childNode.setChildren(new ArrayList<>());
|
|
||||||
return childNode;
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
streetNode.setChildren(childNodes);
|
|
||||||
result.add(streetNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue