From f13963f5b8954ac0804cfe95ee9f6f384a0f9ed2 Mon Sep 17 00:00:00 2001 From: b2894lxlx <517289602@qq.com> Date: Fri, 17 Jul 2026 18:23:56 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=B0=83=E6=95=B4IAM=E6=9D=83?= =?UTF-8?q?=E9=99=90=202=E3=80=81=E6=96=B0=E5=A2=9E=E5=B8=B8=E7=94=A8?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/endpoint/IamSsoEndpoint.java | 4 +- .../auth/granter/IamSsoTokenGranter.java | 4 +- .../auth/props/IamSsoProperties.java | 10 + blade-auth/src/main/resources/application.yml | 2 + .../gateway/provider/AuthProvider.java | 3 + .../transport/pojo/entity/CommonAddress.java | 93 +++++ .../pojo/vo/CommonAddressRemoveResultVO.java | 54 +++ .../transport/pojo/vo/CommonAddressVO.java | 66 ++++ blade-service/blade-transport/pom.xml | 4 + .../controller/CommonAddressController.java | 209 +++++++++++ .../transport/excel/CommonAddressExcel.java | 96 +++++ .../transport/mapper/CommonAddressMapper.java | 97 +++++ .../transport/mapper/CommonAddressMapper.xml | 215 +++++++++++ .../service/ICommonAddressService.java | 92 +++++ .../impl/CommonAddressServiceImpl.java | 345 ++++++++++++++++++ .../wrapper/CommonAddressWrapper.java | 52 +++ doc/sql/transport/blade_common_address.sql | 48 +++ doc/sql/transport/transport.sql | 55 +++ 18 files changed, 1445 insertions(+), 4 deletions(-) create mode 100644 blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/CommonAddress.java create mode 100644 blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/vo/CommonAddressRemoveResultVO.java create mode 100644 blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/vo/CommonAddressVO.java create mode 100644 blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CommonAddressController.java create mode 100644 blade-service/blade-transport/src/main/java/org/springblade/transport/excel/CommonAddressExcel.java create mode 100644 blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CommonAddressMapper.java create mode 100644 blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CommonAddressMapper.xml create mode 100644 blade-service/blade-transport/src/main/java/org/springblade/transport/service/ICommonAddressService.java create mode 100644 blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/CommonAddressServiceImpl.java create mode 100644 blade-service/blade-transport/src/main/java/org/springblade/transport/wrapper/CommonAddressWrapper.java create mode 100644 doc/sql/transport/blade_common_address.sql diff --git a/blade-auth/src/main/java/org/springblade/auth/endpoint/IamSsoEndpoint.java b/blade-auth/src/main/java/org/springblade/auth/endpoint/IamSsoEndpoint.java index 1b54103..a428dd6 100644 --- a/blade-auth/src/main/java/org/springblade/auth/endpoint/IamSsoEndpoint.java +++ b/blade-auth/src/main/java/org/springblade/auth/endpoint/IamSsoEndpoint.java @@ -34,8 +34,8 @@ import org.springblade.core.oauth2.provider.OAuth2Response; import org.springblade.core.tool.support.Kv; import org.springblade.core.tool.utils.StringUtil; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; /** @@ -59,7 +59,7 @@ public class IamSsoEndpoint { * @param request 请求信息 * @return token */ - @PostMapping("/token") + @RequestMapping(value = "/token", method = {RequestMethod.GET, RequestMethod.POST}) @Operation(summary = "IAM统一身份认证登录", description = "使用IAM授权码换取本系统Token") public ResponseEntity token(HttpServletRequest request) { String grantType = request.getParameter("grant_type"); diff --git a/blade-auth/src/main/java/org/springblade/auth/granter/IamSsoTokenGranter.java b/blade-auth/src/main/java/org/springblade/auth/granter/IamSsoTokenGranter.java index 1c37272..523fe49 100644 --- a/blade-auth/src/main/java/org/springblade/auth/granter/IamSsoTokenGranter.java +++ b/blade-auth/src/main/java/org/springblade/auth/granter/IamSsoTokenGranter.java @@ -113,8 +113,8 @@ public class IamSsoTokenGranter extends AuthorizationCodeGranter { @Override public OAuth2Client client(OAuth2Request request) { - String clientId = request.getClientId(); - String clientSecret = request.getClientSecret(); + String clientId = StringUtil.isBlank(request.getClientId()) ? properties.getSystemClientId() : request.getClientId(); + String clientSecret = StringUtil.isBlank(request.getClientSecret()) ? properties.getSystemClientSecret() : request.getClientSecret(); OAuth2Client client = clientService.loadByClientId(clientId); if (!clientService.validateClient(client, clientId, clientSecret)) { throw new UserInvalidException(OAuth2TokenConstant.TOKEN_NOT_CORRECT); diff --git a/blade-auth/src/main/java/org/springblade/auth/props/IamSsoProperties.java b/blade-auth/src/main/java/org/springblade/auth/props/IamSsoProperties.java index 7e91b06..ff74ff2 100644 --- a/blade-auth/src/main/java/org/springblade/auth/props/IamSsoProperties.java +++ b/blade-auth/src/main/java/org/springblade/auth/props/IamSsoProperties.java @@ -57,6 +57,16 @@ public class IamSsoProperties { */ private String clientSecret; + /** + * 本系统发放Token使用的客户端ID。IAM回调入口不要求请求携带客户端认证时使用。 + */ + private String systemClientId = "saber3"; + + /** + * 本系统发放Token使用的客户端密钥。IAM回调入口不要求请求携带客户端认证时使用。 + */ + private String systemClientSecret = "saber3_secret"; + /** * IAM回调地址 */ diff --git a/blade-auth/src/main/resources/application.yml b/blade-auth/src/main/resources/application.yml index 07ea608..108eb04 100644 --- a/blade-auth/src/main/resources/application.yml +++ b/blade-auth/src/main/resources/application.yml @@ -71,6 +71,8 @@ iam: profile-url: http://172.16.204.83:38000/gwzh/IAM/IAM_SSO_PROFILE client-id: f0b52f23f71b1649c468 client-secret: 5b3d8575f0899946623ab86523ac3dd8ee98 + system-client-id: saber3 + system-client-secret: saber3_secret redirect-uri: http://172.16.203.228:8000/callback authorization: Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng= profile-authorization: Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng= diff --git a/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java b/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java index 5bc679d..964273a 100644 --- a/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java +++ b/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java @@ -52,6 +52,9 @@ public class AuthProvider { DEFAULT_SKIP_URL.add("/oauth/callback/**"); DEFAULT_SKIP_URL.add("/oauth/revoke/**"); DEFAULT_SKIP_URL.add("/oauth/refresh/**"); + DEFAULT_SKIP_URL.add("/iam/sso/token/**"); + DEFAULT_SKIP_URL.add("/blade-auth/iam/sso/token/**"); + DEFAULT_SKIP_URL.add("/api/blade-auth/iam/sso/token/**"); DEFAULT_SKIP_URL.add("/token/**"); DEFAULT_SKIP_URL.add("/actuator/**"); DEFAULT_SKIP_URL.add("/v3/api-docs/**"); diff --git a/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/CommonAddress.java b/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/CommonAddress.java new file mode 100644 index 0000000..a89c718 --- /dev/null +++ b/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/CommonAddress.java @@ -0,0 +1,93 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.pojo.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.io.Serial; +import java.math.BigDecimal; + +/** + * 常用地址实体类 + * + * @author Chill + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("blade_common_address") +@Schema(description = "常用地址") +public class CommonAddress extends TenantEntity { + + @Serial + private static final long serialVersionUID = 1L; + + @Schema(description = "地址编号") + private String addressCode; + + @Schema(description = "地址名称") + private String addressName; + + @Schema(description = "地址类型") + private String addressType; + + @Schema(description = "来源主数据ID") + private Long sourceId; + + @Schema(description = "站点编码") + private String siteCode; + + @Schema(description = "详细地址") + private String detailAddress; + + @Schema(description = "行政区划编码") + private String regionCode; + + @Schema(description = "行政区划") + private String regionName; + + @Schema(description = "经度") + private BigDecimal longitude; + + @Schema(description = "纬度") + private BigDecimal latitude; + + @Schema(description = "所属组织ID") + private Long deptId; + + @Schema(description = "所属组织") + private String deptName; + + @Schema(description = "联系人") + private String contactName; + + @Schema(description = "联系方式") + private String contactPhone; + + @Schema(description = "备注") + private String remark; + +} diff --git a/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/vo/CommonAddressRemoveResultVO.java b/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/vo/CommonAddressRemoveResultVO.java new file mode 100644 index 0000000..d8531ab --- /dev/null +++ b/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/vo/CommonAddressRemoveResultVO.java @@ -0,0 +1,54 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.pojo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * 常用地址删除结果 + * + * @author Chill + */ +@Data +@Schema(description = "常用地址删除结果") +public class CommonAddressRemoveResultVO implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Schema(description = "成功删除条数") + private Integer successCount = 0; + + @Schema(description = "引用跳过条数") + private Integer skippedCount = 0; + + @Schema(description = "跳过地址编号") + private List skippedAddressCodes = new ArrayList<>(); + +} diff --git a/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/vo/CommonAddressVO.java b/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/vo/CommonAddressVO.java new file mode 100644 index 0000000..e0938b4 --- /dev/null +++ b/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/vo/CommonAddressVO.java @@ -0,0 +1,66 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.pojo.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.transport.pojo.entity.CommonAddress; + +import java.io.Serial; + +/** + * 常用地址视图实体类 + * + * @author Chill + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Schema(description = "常用地址") +public class CommonAddressVO extends CommonAddress { + + @Serial + private static final long serialVersionUID = 1L; + + @TableField(exist = false) + @Schema(description = "站点编码展示值") + private String siteCodeDisplay; + + @TableField(exist = false) + @Schema(description = "是否只读") + private Boolean readonly; + + @TableField(exist = false) + @Schema(description = "更新人姓名") + private String updateUserName; + + @TableField(exist = false) + @Schema(description = "创建人姓名") + private String createUserName; + + @TableField(exist = false) + @Schema(description = "是否查看全部组织") + private Integer allDept; + +} diff --git a/blade-service/blade-transport/pom.xml b/blade-service/blade-transport/pom.xml index 8caaf30..c8853b4 100644 --- a/blade-service/blade-transport/pom.xml +++ b/blade-service/blade-transport/pom.xml @@ -35,6 +35,10 @@ org.springblade blade-user-api + + org.springblade + blade-system-api + diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CommonAddressController.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CommonAddressController.java new file mode 100644 index 0000000..48f2403 --- /dev/null +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CommonAddressController.java @@ -0,0 +1,209 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.excel.util.ExcelUtil; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.secure.annotation.PreAuth; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.transport.excel.CommonAddressExcel; +import org.springblade.transport.pojo.entity.CommonAddress; +import org.springblade.transport.pojo.vo.CommonAddressRemoveResultVO; +import org.springblade.transport.pojo.vo.CommonAddressVO; +import org.springblade.transport.service.ICommonAddressService; +import org.springframework.web.bind.annotation.GetMapping; +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.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Objects; + +/** + * 常用地址 控制器 + * + * @author Chill + */ +@RestController +@AllArgsConstructor +@PreAuth(menu = "common_address") +@RequestMapping("/common-address") +@Tag(name = "常用地址", description = "常用地址") +public class CommonAddressController extends BladeController { + + private static final int DEFAULT_CURRENT = 1; + private static final int DEFAULT_SIZE = 10; + private static final int MAX_SIZE = 100; + private static final String NORMAL_SITE_CODE = "/"; + + private final ICommonAddressService commonAddressService; + + /** + * 详情 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @Operation(summary = "详情", description = "传入id") + public R detail(@Parameter(description = "主键", required = true) @RequestParam Long id) { + return R.data(commonAddressService.detail(id)); + } + + /** + * 分页 + */ + @GetMapping("/list") + @ApiOperationSupport(order = 2) + @Operation(summary = "分页", description = "传入commonAddress") + public R> list(CommonAddressVO commonAddress, Query query) { + IPage pages = commonAddressService.selectCommonAddressPage(Condition.getPage(normalizeQuery(query)), commonAddress); + return R.data(pages); + } + + /** + * 新增或修改 + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 3) + @Operation(summary = "新增或修改", description = "传入commonAddress") + public R submit(@RequestBody CommonAddress commonAddress) { + return R.status(commonAddressService.submit(commonAddress)); + } + + /** + * 删除 + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 4) + @Operation(summary = "逻辑删除", description = "传入ids") + public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) { + return R.data(commonAddressService.removeAddress(ids)); + } + + /** + * 来源地址选项 + */ + @GetMapping("/source-options") + @ApiOperationSupport(order = 5) + @Operation(summary = "来源地址选项", description = "传入addressType和keyword") + public R> sourceOptions(@RequestParam String addressType, + @RequestParam(required = false) String keyword) { + return R.data(commonAddressService.sourceOptions(addressType, keyword)); + } + + /** + * 导出常用地址 + */ + @GetMapping("/export-common-address") + @ApiOperationSupport(order = 6) + @Operation(summary = "导出常用地址") + public void exportCommonAddress(CommonAddressVO commonAddress, + @RequestParam(required = false) String ids, + HttpServletResponse response) { + List list = commonAddressService.exportCommonAddress(buildExportQuery(commonAddress, ids)); + ExcelUtil.export(response, "常用地址" + DateUtil.time(), "常用地址", list, CommonAddressExcel.class); + } + + private Query normalizeQuery(Query query) { + if (query == null) { + query = new Query(); + } + if (query.getCurrent() == null || query.getCurrent() < DEFAULT_CURRENT) { + query.setCurrent(DEFAULT_CURRENT); + } + if (query.getSize() == null || query.getSize() <= 0) { + query.setSize(DEFAULT_SIZE); + } + if (query.getSize() > MAX_SIZE) { + query.setSize(MAX_SIZE); + } + return query; + } + + private LambdaQueryWrapper buildExportQuery(CommonAddressVO commonAddress, String ids) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery() + .eq(CommonAddress::getIsDeleted, 0) + .orderByDesc(CommonAddress::getUpdateTime) + .orderByDesc(CommonAddress::getCreateTime); + if (Func.isNotEmpty(ids)) { + queryWrapper.in(CommonAddress::getId, Func.toLongList(ids)); + } + if (Objects.equals(commonAddress.getAllDept(), 1)) { + if (!AuthUtil.isAdministrator()) { + throw new ServiceException("无权导出全部组织常用地址"); + } + } else { + queryWrapper.eq(CommonAddress::getDeptId, currentDeptId()); + } + if (Objects.equals(commonAddress.getAllDept(), 1) && Func.isNotEmpty(commonAddress.getDeptId())) { + queryWrapper.eq(CommonAddress::getDeptId, commonAddress.getDeptId()); + } + if (Func.isNotEmpty(commonAddress.getAddressName())) { + queryWrapper.like(CommonAddress::getAddressName, commonAddress.getAddressName().trim()); + } + if (Func.isNotEmpty(commonAddress.getAddressType())) { + queryWrapper.eq(CommonAddress::getAddressType, commonAddress.getAddressType().trim()); + } + if (Func.isNotEmpty(commonAddress.getDetailAddress())) { + queryWrapper.like(CommonAddress::getDetailAddress, commonAddress.getDetailAddress().trim()); + } + if (Func.isNotEmpty(commonAddress.getRegionName())) { + queryWrapper.like(CommonAddress::getRegionName, commonAddress.getRegionName().trim()); + } + if (Func.isNotEmpty(commonAddress.getSiteCode()) && !NORMAL_SITE_CODE.equals(commonAddress.getSiteCode().trim())) { + queryWrapper.eq(CommonAddress::getSiteCode, commonAddress.getSiteCode().trim()); + } + if (Func.isNotEmpty(commonAddress.getContactName())) { + queryWrapper.like(CommonAddress::getContactName, commonAddress.getContactName().trim()); + } + if (Func.isNotEmpty(commonAddress.getContactPhone())) { + queryWrapper.like(CommonAddress::getContactPhone, commonAddress.getContactPhone().trim()); + } + return queryWrapper; + } + + private Long currentDeptId() { + Long deptId = Func.firstLong(AuthUtil.getDeptId()); + if (Func.isEmpty(deptId) || deptId <= 0) { + throw new ServiceException("当前用户所属组织为空,无法导出常用地址"); + } + return deptId; + } + +} diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/excel/CommonAddressExcel.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/excel/CommonAddressExcel.java new file mode 100644 index 0000000..420cdca --- /dev/null +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/excel/CommonAddressExcel.java @@ -0,0 +1,96 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.excel; + +import cn.idev.excel.annotation.ExcelIgnore; +import cn.idev.excel.annotation.ExcelProperty; +import cn.idev.excel.annotation.write.style.ColumnWidth; +import cn.idev.excel.annotation.write.style.ContentRowHeight; +import cn.idev.excel.annotation.write.style.HeadRowHeight; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 常用地址 Excel + * + * @author Chill + */ +@Data +@ColumnWidth(18) +@HeadRowHeight(20) +@ContentRowHeight(18) +public class CommonAddressExcel implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @ExcelIgnore + private Long id; + + @ExcelProperty("地址名称") + private String addressName; + + @ExcelProperty("地址编号") + private String addressCode; + + @ExcelProperty("类型") + private String addressType; + + @ExcelProperty("站点编码") + private String siteCodeDisplay; + + @ExcelProperty("详细地址") + private String detailAddress; + + @ExcelProperty("经度") + private BigDecimal longitude; + + @ExcelProperty("纬度") + private BigDecimal latitude; + + @ExcelProperty("行政区划") + private String regionName; + + @ExcelProperty("联系人") + private String contactName; + + @ExcelProperty("联系方式") + private String contactPhone; + + @ExcelProperty("组织") + private String deptName; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("更新时间") + private LocalDateTime updateTime; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CommonAddressMapper.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CommonAddressMapper.java new file mode 100644 index 0000000..58d0bb4 --- /dev/null +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CommonAddressMapper.java @@ -0,0 +1,97 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.apache.ibatis.annotations.Param; +import org.springblade.transport.pojo.entity.CommonAddress; +import org.springblade.transport.pojo.vo.CommonAddressVO; + +import java.util.List; + +/** + * 常用地址 Mapper 接口 + * + * @author Chill + */ +public interface CommonAddressMapper extends BaseMapper { + + /** + * 自定义分页 + * + * @param page 分页参数 + * @param address 查询参数 + * @return 常用地址列表 + */ + List selectCommonAddressPage(IPage page, @Param("address") CommonAddressVO address); + + /** + * 查询当前最大地址编号 + * + * @return 最大地址编号 + */ + String selectMaxAddressCode(); + + /** + * 查询港口码头来源 + * + * @param id 主键 + * @return 来源地址 + */ + CommonAddressVO selectPortTerminalSource(@Param("id") Long id); + + /** + * 查询铁路车站来源 + * + * @param id 主键 + * @return 来源地址 + */ + CommonAddressVO selectRailwayStationSource(@Param("id") Long id); + + /** + * 查询空港机场来源 + * + * @param id 主键 + * @return 来源地址 + */ + CommonAddressVO selectAirportMasterSource(@Param("id") Long id); + + /** + * 查询可选来源地址 + * + * @param addressType 地址类型 + * @param keyword 关键字 + * @return 来源地址 + */ + List selectSourceOptions(@Param("addressType") String addressType, @Param("keyword") String keyword); + + /** + * 查询业务引用数 + * + * @param addressId 常用地址ID + * @return 引用数 + */ + Integer countBusinessReference(@Param("addressId") Long addressId); + +} diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CommonAddressMapper.xml b/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CommonAddressMapper.xml new file mode 100644 index 0000000..ca38c5d --- /dev/null +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CommonAddressMapper.xml @@ -0,0 +1,215 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, + tenant_id, + create_user, + create_dept, + create_time, + update_user, + update_time, + status, + is_deleted, + address_code, + address_name, + address_type, + source_id, + site_code, + detail_address, + region_code, + region_name, + longitude, + latitude, + dept_id, + dept_name, + contact_name, + contact_phone, + remark + + + + is_deleted = 0 + + + AND address_name LIKE #{addressNameLike} + + + AND address_type = #{address.addressType} + + + + AND detail_address LIKE #{detailAddressLike} + + + + AND region_name LIKE #{regionNameLike} + + + AND site_code = #{address.siteCode} + + + AND dept_id = #{address.deptId} + + + + AND contact_name LIKE #{contactNameLike} + + + + AND contact_phone LIKE #{contactPhoneLike} + + + + + + + + + + + + + + + + + + diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/ICommonAddressService.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/ICommonAddressService.java new file mode 100644 index 0000000..8b652f7 --- /dev/null +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/ICommonAddressService.java @@ -0,0 +1,92 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.service; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springblade.core.mp.base.BaseService; +import org.springblade.transport.excel.CommonAddressExcel; +import org.springblade.transport.pojo.entity.CommonAddress; +import org.springblade.transport.pojo.vo.CommonAddressRemoveResultVO; +import org.springblade.transport.pojo.vo.CommonAddressVO; + +import java.util.List; + +/** + * 常用地址 服务类 + * + * @author Chill + */ +public interface ICommonAddressService extends BaseService { + + /** + * 自定义分页 + * + * @param page 分页参数 + * @param address 查询参数 + * @return 常用地址分页 + */ + IPage selectCommonAddressPage(IPage page, CommonAddressVO address); + + /** + * 详情 + * + * @param id 主键 + * @return 常用地址 + */ + CommonAddressVO detail(Long id); + + /** + * 新增或修改 + * + * @param address 常用地址 + * @return 是否成功 + */ + boolean submit(CommonAddress address); + + /** + * 删除常用地址 + * + * @param ids 主键集合 + * @return 删除结果 + */ + CommonAddressRemoveResultVO removeAddress(String ids); + + /** + * 来源地址选项 + * + * @param addressType 地址类型 + * @param keyword 关键字 + * @return 来源地址 + */ + List sourceOptions(String addressType, String keyword); + + /** + * 导出常用地址 + * + * @param queryWrapper 查询条件 + * @return 导出数据 + */ + List exportCommonAddress(Wrapper queryWrapper); + +} diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/CommonAddressServiceImpl.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/CommonAddressServiceImpl.java new file mode 100644 index 0000000..4c47d3f --- /dev/null +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/CommonAddressServiceImpl.java @@ -0,0 +1,345 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.system.cache.SysCache; +import org.springblade.system.cache.UserCache; +import org.springblade.system.pojo.entity.Dept; +import org.springblade.transport.excel.CommonAddressExcel; +import org.springblade.transport.mapper.CommonAddressMapper; +import org.springblade.transport.pojo.entity.CommonAddress; +import org.springblade.transport.pojo.vo.CommonAddressRemoveResultVO; +import org.springblade.transport.pojo.vo.CommonAddressVO; +import org.springblade.transport.service.ICommonAddressService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * 常用地址 服务实现类 + * + * @author Chill + */ +@Service +public class CommonAddressServiceImpl extends BaseServiceImpl implements ICommonAddressService { + + private static final String TYPE_NORMAL = "常规地址"; + private static final String TYPE_PORT = "港口/码头"; + private static final String TYPE_RAILWAY = "铁路车站"; + private static final String TYPE_AIRPORT = "空港机场"; + private static final String NORMAL_SITE_CODE = "/"; + private static final String ADDRESS_CODE_PREFIX = "DZ"; + private static final int ADDRESS_CODE_LENGTH = 5; + private static final int NAME_MAX_LENGTH = 100; + private static final int DETAIL_MAX_LENGTH = 255; + private static final int REGION_MAX_LENGTH = 100; + private static final int CONTACT_MAX_LENGTH = 50; + private static final int PHONE_MAX_LENGTH = 30; + private static final int REMARK_MAX_LENGTH = 200; + private static final BigDecimal MIN_LONGITUDE = new BigDecimal("-180"); + private static final BigDecimal MAX_LONGITUDE = new BigDecimal("180"); + private static final BigDecimal MIN_LATITUDE = new BigDecimal("-90"); + private static final BigDecimal MAX_LATITUDE = new BigDecimal("90"); + + @Override + public IPage selectCommonAddressPage(IPage page, CommonAddressVO address) { + prepareQuery(address); + IPage result = page.setRecords(baseMapper.selectCommonAddressPage(page, address)); + result.getRecords().forEach(this::fillDisplay); + return result; + } + + @Override + public CommonAddressVO detail(Long id) { + if (Func.isEmpty(id)) { + throw new ServiceException("主键不能为空"); + } + CommonAddress address = getById(id); + if (Func.isEmpty(address) || Objects.equals(address.getIsDeleted(), 1)) { + throw new ServiceException("常用地址不存在"); + } + CommonAddressVO addressVO = Objects.requireNonNull(BeanUtil.copyProperties(address, CommonAddressVO.class)); + fillDisplay(addressVO); + return addressVO; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean submit(CommonAddress address) { + boolean created = Func.isEmpty(address.getId()); + if (!created) { + CommonAddress oldAddress = getEditableAddress(address.getId()); + address.setAddressCode(oldAddress.getAddressCode()); + address.setDeptId(oldAddress.getDeptId()); + address.setDeptName(oldAddress.getDeptName()); + } + prepare(address); + validate(address); + if (created) { + address.setAddressCode(nextAddressCode()); + } + return saveOrUpdate(address); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public CommonAddressRemoveResultVO removeAddress(String ids) { + List idList = Func.toLongList(ids); + if (Func.isEmpty(idList)) { + throw new ServiceException("请选择需要删除的数据"); + } + CommonAddressRemoveResultVO result = new CommonAddressRemoveResultVO(); + List deleteIdList = new ArrayList<>(); + for (CommonAddress address : listByIds(idList)) { + validateCurrentDept(address); + Integer referenceCount = baseMapper.countBusinessReference(address.getId()); + if (referenceCount != null && referenceCount > 0) { + result.setSkippedCount(result.getSkippedCount() + 1); + result.getSkippedAddressCodes().add(address.getAddressCode()); + continue; + } + deleteIdList.add(address.getId()); + } + if (Func.isNotEmpty(deleteIdList)) { + deleteLogic(deleteIdList); + } + result.setSuccessCount(deleteIdList.size()); + return result; + } + + @Override + public List sourceOptions(String addressType, String keyword) { + String type = trimToEmpty(addressType); + if (TYPE_NORMAL.equals(type)) { + return new ArrayList<>(); + } + validateAddressType(type); + List sourceList = baseMapper.selectSourceOptions(type, trimToNull(keyword)); + sourceList.forEach(source -> { + source.setAddressType(type); + source.setSiteCodeDisplay(source.getSiteCode()); + }); + return sourceList; + } + + @Override + public List exportCommonAddress(Wrapper queryWrapper) { + return list(queryWrapper).stream().map(address -> { + CommonAddressExcel excel = Objects.requireNonNull(BeanUtil.copyProperties(address, CommonAddressExcel.class)); + excel.setSiteCodeDisplay(TYPE_NORMAL.equals(address.getAddressType()) ? NORMAL_SITE_CODE : address.getSiteCode()); + return excel; + }).toList(); + } + + private void prepareQuery(CommonAddressVO address) { + if (Objects.equals(address.getAllDept(), 1)) { + if (!AuthUtil.isAdministrator()) { + throw new ServiceException("无权查看全部组织常用地址"); + } + } else { + address.setDeptId(currentDeptId()); + } + address.setAddressName(trimToNull(address.getAddressName())); + address.setAddressType(trimToNull(address.getAddressType())); + address.setDetailAddress(trimToNull(address.getDetailAddress())); + address.setRegionName(trimToNull(address.getRegionName())); + address.setSiteCode(trimToNull(address.getSiteCode())); + address.setContactName(trimToNull(address.getContactName())); + address.setContactPhone(trimToNull(address.getContactPhone())); + if (NORMAL_SITE_CODE.equals(address.getSiteCode())) { + address.setSiteCode(null); + } + } + + private void prepare(CommonAddress address) { + address.setAddressName(trimToEmpty(address.getAddressName())); + address.setAddressType(trimToEmpty(address.getAddressType())); + address.setDetailAddress(trimToEmpty(address.getDetailAddress())); + address.setRegionCode(trimToNull(address.getRegionCode())); + address.setRegionName(trimToNull(address.getRegionName())); + address.setContactName(trimToNull(address.getContactName())); + address.setContactPhone(trimToNull(address.getContactPhone())); + address.setRemark(trimToNull(address.getRemark())); + if (address.getStatus() == null) { + address.setStatus(1); + } + if (Func.isEmpty(address.getDeptId())) { + fillCurrentDept(address); + } + if (TYPE_NORMAL.equals(address.getAddressType())) { + address.setSourceId(null); + address.setSiteCode(NORMAL_SITE_CODE); + address.setLongitude(scale(address.getLongitude())); + address.setLatitude(scale(address.getLatitude())); + return; + } + CommonAddressVO source = loadSource(address.getAddressType(), address.getSourceId()); + address.setSourceId(source.getSourceId()); + address.setSiteCode(source.getSiteCode()); + address.setDetailAddress(source.getDetailAddress()); + address.setRegionName(source.getRegionName()); + address.setLongitude(scale(source.getLongitude())); + address.setLatitude(scale(source.getLatitude())); + if (Func.isEmpty(address.getAddressName())) { + address.setAddressName(source.getAddressName()); + } + } + + private void fillCurrentDept(CommonAddress address) { + Long deptId = currentDeptId(); + Dept dept = SysCache.getDept(deptId); + if (Func.isEmpty(dept)) { + throw new ServiceException("当前用户所属组织异常,请重新登录后再试"); + } + address.setDeptId(deptId); + address.setDeptName(dept.getDeptName()); + } + + private CommonAddressVO loadSource(String addressType, Long sourceId) { + if (Func.isEmpty(sourceId)) { + throw new ServiceException(addressType + "主数据不能为空"); + } + CommonAddressVO source; + if (TYPE_PORT.equals(addressType)) { + source = baseMapper.selectPortTerminalSource(sourceId); + } else if (TYPE_RAILWAY.equals(addressType)) { + source = baseMapper.selectRailwayStationSource(sourceId); + } else if (TYPE_AIRPORT.equals(addressType)) { + source = baseMapper.selectAirportMasterSource(sourceId); + } else { + throw new ServiceException("地址类型不正确"); + } + if (Func.isEmpty(source)) { + throw new ServiceException(addressType + "主数据不存在或已停用"); + } + return source; + } + + private void validate(CommonAddress address) { + validateAddressType(address.getAddressType()); + if (Func.isEmpty(address.getAddressName())) { + throw new ServiceException("地址名称不能为空"); + } + if (Func.isEmpty(address.getDetailAddress())) { + throw new ServiceException("详细地址不能为空"); + } + validateLength(address.getAddressName(), NAME_MAX_LENGTH, "地址名称不能超过100字"); + validateLength(address.getDetailAddress(), DETAIL_MAX_LENGTH, "详细地址不能超过255字"); + validateLength(address.getRegionName(), REGION_MAX_LENGTH, "行政区划不能超过100字"); + validateLength(address.getContactName(), CONTACT_MAX_LENGTH, "联系人不能超过50字"); + validateLength(address.getContactPhone(), PHONE_MAX_LENGTH, "联系方式不能超过30字"); + validateLength(address.getRemark(), REMARK_MAX_LENGTH, "备注不能超过200字"); + validateRange(address.getLongitude(), MIN_LONGITUDE, MAX_LONGITUDE, "经度范围为 -180 到 180"); + validateRange(address.getLatitude(), MIN_LATITUDE, MAX_LATITUDE, "纬度范围为 -90 到 90"); + if (!TYPE_NORMAL.equals(address.getAddressType()) && Func.isEmpty(address.getSiteCode())) { + throw new ServiceException("站点编码不能为空"); + } + } + + private void validateAddressType(String addressType) { + if (!TYPE_NORMAL.equals(addressType) && !TYPE_PORT.equals(addressType) + && !TYPE_RAILWAY.equals(addressType) && !TYPE_AIRPORT.equals(addressType)) { + throw new ServiceException("地址类型不正确"); + } + } + + private CommonAddress getEditableAddress(Long id) { + CommonAddress address = getById(id); + if (Func.isEmpty(address) || Objects.equals(address.getIsDeleted(), 1)) { + throw new ServiceException("常用地址不存在"); + } + validateCurrentDept(address); + return address; + } + + private void validateCurrentDept(CommonAddress address) { + if (!Objects.equals(address.getDeptId(), currentDeptId())) { + throw new ServiceException("无权操作其他组织常用地址"); + } + } + + private void fillDisplay(CommonAddressVO address) { + address.setSiteCodeDisplay(TYPE_NORMAL.equals(address.getAddressType()) ? NORMAL_SITE_CODE : address.getSiteCode()); + address.setReadonly(!Objects.equals(address.getDeptId(), currentDeptId())); + address.setCreateUserName(UserCache.getUserRealName(address.getCreateUser())); + address.setUpdateUserName(UserCache.getUserRealName(address.getUpdateUser())); + } + + private Long currentDeptId() { + Long deptId = Func.firstLong(AuthUtil.getDeptId()); + if (Func.isEmpty(deptId) || deptId <= 0) { + throw new ServiceException("当前用户所属组织为空,无法查询常用地址"); + } + return deptId; + } + + private synchronized String nextAddressCode() { + String maxAddressCode = baseMapper.selectMaxAddressCode(); + int next = 1; + if (Func.isNotEmpty(maxAddressCode) && maxAddressCode.length() > ADDRESS_CODE_PREFIX.length()) { + String number = maxAddressCode.substring(ADDRESS_CODE_PREFIX.length()); + if (number.chars().allMatch(Character::isDigit)) { + next = Integer.parseInt(number) + 1; + } + } + return ADDRESS_CODE_PREFIX + String.format("%0" + ADDRESS_CODE_LENGTH + "d", next); + } + + private BigDecimal scale(BigDecimal value) { + return value == null ? null : value.setScale(6, RoundingMode.HALF_UP); + } + + private void validateLength(String value, int maxLength, String message) { + if (Func.isNotEmpty(value) && value.length() > maxLength) { + throw new ServiceException(message); + } + } + + private void validateRange(BigDecimal value, BigDecimal min, BigDecimal max, String message) { + if (Func.isNotEmpty(value) && (value.compareTo(min) < 0 || value.compareTo(max) > 0)) { + throw new ServiceException(message); + } + } + + private String trimToEmpty(String value) { + return value == null ? "" : value.trim(); + } + + private String trimToNull(String value) { + String trimValue = trimToEmpty(value); + return trimValue.isEmpty() ? null : trimValue; + } + +} diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/wrapper/CommonAddressWrapper.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/wrapper/CommonAddressWrapper.java new file mode 100644 index 0000000..a3708cf --- /dev/null +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/wrapper/CommonAddressWrapper.java @@ -0,0 +1,52 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.wrapper; + +import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.system.cache.UserCache; +import org.springblade.transport.pojo.entity.CommonAddress; +import org.springblade.transport.pojo.vo.CommonAddressVO; + +import java.util.Objects; + +/** + * 常用地址包装类 + * + * @author Chill + */ +public class CommonAddressWrapper extends BaseEntityWrapper { + + public static CommonAddressWrapper build() { + return new CommonAddressWrapper(); + } + + @Override + public CommonAddressVO entityVO(CommonAddress address) { + CommonAddressVO addressVO = Objects.requireNonNull(BeanUtil.copyProperties(address, CommonAddressVO.class)); + addressVO.setCreateUserName(UserCache.getUserRealName(address.getCreateUser())); + addressVO.setUpdateUserName(UserCache.getUserRealName(address.getUpdateUser())); + return addressVO; + } + +} diff --git a/doc/sql/transport/blade_common_address.sql b/doc/sql/transport/blade_common_address.sql new file mode 100644 index 0000000..17832d2 --- /dev/null +++ b/doc/sql/transport/blade_common_address.sql @@ -0,0 +1,48 @@ +-- ---------------------------- +-- Table structure for blade_common_address +-- ---------------------------- +DROP TABLE IF EXISTS `blade_common_address`; +CREATE TABLE `blade_common_address` ( + `id` bigint(20) NOT NULL COMMENT '主键', + `tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID', + `address_code` varchar(20) NOT NULL COMMENT '地址编号', + `address_name` varchar(100) NOT NULL COMMENT '地址名称', + `address_type` varchar(20) NOT NULL COMMENT '地址类型:常规地址、港口/码头、铁路车站、空港机场', + `source_id` bigint(20) DEFAULT NULL COMMENT '来源主数据ID', + `site_code` varchar(30) DEFAULT NULL COMMENT '站点编码', + `detail_address` varchar(255) NOT NULL COMMENT '详细地址', + `region_code` varchar(32) DEFAULT NULL COMMENT '行政区划编码', + `region_name` varchar(100) DEFAULT NULL COMMENT '行政区划', + `longitude` decimal(12,6) DEFAULT NULL COMMENT '经度', + `latitude` decimal(12,6) DEFAULT NULL COMMENT '纬度', + `dept_id` bigint(20) NOT NULL COMMENT '所属组织ID', + `dept_name` varchar(100) NOT NULL COMMENT '所属组织', + `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人', + `contact_phone` varchar(30) DEFAULT NULL COMMENT '联系方式', + `remark` varchar(200) DEFAULT NULL COMMENT '备注', + `create_user` bigint(20) DEFAULT NULL COMMENT '创建人', + `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_user` bigint(20) DEFAULT NULL COMMENT '修改人', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `status` int(11) DEFAULT '1' COMMENT '状态', + `is_deleted` int(11) DEFAULT '0' COMMENT '是否已删除', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE KEY `uk_common_address_code` (`address_code`) USING BTREE, + KEY `idx_common_address_type` (`address_type`) USING BTREE, + KEY `idx_common_address_site` (`site_code`) USING BTREE, + KEY `idx_common_address_dept` (`dept_id`) USING BTREE, + KEY `idx_common_address_update` (`update_time`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='常用地址'; + +-- ---------------------------- +-- Menu data for common address +-- ---------------------------- +INSERT IGNORE INTO `blade_menu` (`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `component`, `remark`, `is_deleted`) VALUES +(2080000000000000001, 0, 'base_data', '基础数据', 'base_data', '/base', 'iconfont icon-caidan', 30, 1, 0, 1, NULL, '', 0), +(2080000000000000010, 2080000000000000001, 'common_address', '常用地址', 'common_address', '/base/common-address', 'iconfont icon-dizhi', 10, 1, 0, 1, NULL, '', 0), +(2080000000000000011, 2080000000000000010, 'common_address_view', '查看', 'common_address_view', '', '', 1, 2, 0, 1, NULL, '', 0), +(2080000000000000012, 2080000000000000010, 'common_address_add', '新增', 'common_address_add', '', '', 2, 2, 0, 1, NULL, '', 0), +(2080000000000000013, 2080000000000000010, 'common_address_edit', '编辑', 'common_address_edit', '', '', 3, 2, 0, 1, NULL, '', 0), +(2080000000000000014, 2080000000000000010, 'common_address_delete', '删除', 'common_address_delete', '', '', 4, 2, 0, 1, NULL, '', 0), +(2080000000000000015, 2080000000000000010, 'common_address_export', '批量导出', 'common_address_export', '', '', 5, 2, 0, 1, NULL, '', 0); diff --git a/doc/sql/transport/transport.sql b/doc/sql/transport/transport.sql index 9e90962..ea1bb2a 100644 --- a/doc/sql/transport/transport.sql +++ b/doc/sql/transport/transport.sql @@ -5988,4 +5988,59 @@ CREATE TABLE `blade_other_expense_record` ( BEGIN; COMMIT; +-- ---------------------------- +-- Table structure for blade_common_address +-- ---------------------------- +DROP TABLE IF EXISTS `blade_common_address`; +CREATE TABLE `blade_common_address` ( + `id` bigint(20) NOT NULL COMMENT '主键', + `tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID', + `address_code` varchar(20) NOT NULL COMMENT '地址编号', + `address_name` varchar(100) NOT NULL COMMENT '地址名称', + `address_type` varchar(20) NOT NULL COMMENT '地址类型:常规地址、港口/码头、铁路车站、空港机场', + `source_id` bigint(20) DEFAULT NULL COMMENT '来源主数据ID', + `site_code` varchar(30) DEFAULT NULL COMMENT '站点编码', + `detail_address` varchar(255) NOT NULL COMMENT '详细地址', + `region_code` varchar(32) DEFAULT NULL COMMENT '行政区划编码', + `region_name` varchar(100) DEFAULT NULL COMMENT '行政区划', + `longitude` decimal(12,6) DEFAULT NULL COMMENT '经度', + `latitude` decimal(12,6) DEFAULT NULL COMMENT '纬度', + `dept_id` bigint(20) NOT NULL COMMENT '所属组织ID', + `dept_name` varchar(100) NOT NULL COMMENT '所属组织', + `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人', + `contact_phone` varchar(30) DEFAULT NULL COMMENT '联系方式', + `remark` varchar(200) DEFAULT NULL COMMENT '备注', + `create_user` bigint(20) DEFAULT NULL COMMENT '创建人', + `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_user` bigint(20) DEFAULT NULL COMMENT '修改人', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `status` int(11) DEFAULT '1' COMMENT '状态', + `is_deleted` int(11) DEFAULT '0' COMMENT '是否已删除', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE KEY `uk_common_address_code` (`address_code`) USING BTREE, + KEY `idx_common_address_type` (`address_type`) USING BTREE, + KEY `idx_common_address_site` (`site_code`) USING BTREE, + KEY `idx_common_address_dept` (`dept_id`) USING BTREE, + KEY `idx_common_address_update` (`update_time`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='常用地址'; + +-- ---------------------------- +-- Records of blade_common_address +-- ---------------------------- +BEGIN; +COMMIT; + +-- ---------------------------- +-- Menu data for blade_common_address +-- ---------------------------- +INSERT IGNORE INTO `blade_menu` (`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `component`, `remark`, `is_deleted`) VALUES +(2080000000000000001, 0, 'base_data', '基础数据', 'base_data', '/base', 'iconfont icon-caidan', 30, 1, 0, 1, NULL, '', 0), +(2080000000000000010, 2080000000000000001, 'common_address', '常用地址', 'common_address', '/base/common-address', 'iconfont icon-dizhi', 10, 1, 0, 1, NULL, '', 0), +(2080000000000000011, 2080000000000000010, 'common_address_view', '查看', 'common_address_view', '', '', 1, 2, 0, 1, NULL, '', 0), +(2080000000000000012, 2080000000000000010, 'common_address_add', '新增', 'common_address_add', '', '', 2, 2, 0, 1, NULL, '', 0), +(2080000000000000013, 2080000000000000010, 'common_address_edit', '编辑', 'common_address_edit', '', '', 3, 2, 0, 1, NULL, '', 0), +(2080000000000000014, 2080000000000000010, 'common_address_delete', '删除', 'common_address_delete', '', '', 4, 2, 0, 1, NULL, '', 0), +(2080000000000000015, 2080000000000000010, 'common_address_export', '批量导出', 'common_address_export', '', '', 5, 2, 0, 1, NULL, '', 0); + SET FOREIGN_KEY_CHECKS = 1;