1、调整IAM权限
2、新增常用地址模块
This commit is contained in:
@@ -34,8 +34,8 @@ import org.springblade.core.oauth2.provider.OAuth2Response;
|
|||||||
import org.springblade.core.tool.support.Kv;
|
import org.springblade.core.tool.support.Kv;
|
||||||
import org.springblade.core.tool.utils.StringUtil;
|
import org.springblade.core.tool.utils.StringUtil;
|
||||||
import org.springframework.http.ResponseEntity;
|
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.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +59,7 @@ public class IamSsoEndpoint {
|
|||||||
* @param request 请求信息
|
* @param request 请求信息
|
||||||
* @return token
|
* @return token
|
||||||
*/
|
*/
|
||||||
@PostMapping("/token")
|
@RequestMapping(value = "/token", method = {RequestMethod.GET, RequestMethod.POST})
|
||||||
@Operation(summary = "IAM统一身份认证登录", description = "使用IAM授权码换取本系统Token")
|
@Operation(summary = "IAM统一身份认证登录", description = "使用IAM授权码换取本系统Token")
|
||||||
public ResponseEntity<Kv> token(HttpServletRequest request) {
|
public ResponseEntity<Kv> token(HttpServletRequest request) {
|
||||||
String grantType = request.getParameter("grant_type");
|
String grantType = request.getParameter("grant_type");
|
||||||
|
|||||||
@@ -113,8 +113,8 @@ public class IamSsoTokenGranter extends AuthorizationCodeGranter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OAuth2Client client(OAuth2Request request) {
|
public OAuth2Client client(OAuth2Request request) {
|
||||||
String clientId = request.getClientId();
|
String clientId = StringUtil.isBlank(request.getClientId()) ? properties.getSystemClientId() : request.getClientId();
|
||||||
String clientSecret = request.getClientSecret();
|
String clientSecret = StringUtil.isBlank(request.getClientSecret()) ? properties.getSystemClientSecret() : request.getClientSecret();
|
||||||
OAuth2Client client = clientService.loadByClientId(clientId);
|
OAuth2Client client = clientService.loadByClientId(clientId);
|
||||||
if (!clientService.validateClient(client, clientId, clientSecret)) {
|
if (!clientService.validateClient(client, clientId, clientSecret)) {
|
||||||
throw new UserInvalidException(OAuth2TokenConstant.TOKEN_NOT_CORRECT);
|
throw new UserInvalidException(OAuth2TokenConstant.TOKEN_NOT_CORRECT);
|
||||||
|
|||||||
@@ -57,6 +57,16 @@ public class IamSsoProperties {
|
|||||||
*/
|
*/
|
||||||
private String clientSecret;
|
private String clientSecret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本系统发放Token使用的客户端ID。IAM回调入口不要求请求携带客户端认证时使用。
|
||||||
|
*/
|
||||||
|
private String systemClientId = "saber3";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本系统发放Token使用的客户端密钥。IAM回调入口不要求请求携带客户端认证时使用。
|
||||||
|
*/
|
||||||
|
private String systemClientSecret = "saber3_secret";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IAM回调地址
|
* IAM回调地址
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ iam:
|
|||||||
profile-url: http://172.16.204.83:38000/gwzh/IAM/IAM_SSO_PROFILE
|
profile-url: http://172.16.204.83:38000/gwzh/IAM/IAM_SSO_PROFILE
|
||||||
client-id: f0b52f23f71b1649c468
|
client-id: f0b52f23f71b1649c468
|
||||||
client-secret: 5b3d8575f0899946623ab86523ac3dd8ee98
|
client-secret: 5b3d8575f0899946623ab86523ac3dd8ee98
|
||||||
|
system-client-id: saber3
|
||||||
|
system-client-secret: saber3_secret
|
||||||
redirect-uri: http://172.16.203.228:8000/callback
|
redirect-uri: http://172.16.203.228:8000/callback
|
||||||
authorization: Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=
|
authorization: Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=
|
||||||
profile-authorization: Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=
|
profile-authorization: Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ public class AuthProvider {
|
|||||||
DEFAULT_SKIP_URL.add("/oauth/callback/**");
|
DEFAULT_SKIP_URL.add("/oauth/callback/**");
|
||||||
DEFAULT_SKIP_URL.add("/oauth/revoke/**");
|
DEFAULT_SKIP_URL.add("/oauth/revoke/**");
|
||||||
DEFAULT_SKIP_URL.add("/oauth/refresh/**");
|
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("/token/**");
|
||||||
DEFAULT_SKIP_URL.add("/actuator/**");
|
DEFAULT_SKIP_URL.add("/actuator/**");
|
||||||
DEFAULT_SKIP_URL.add("/v3/api-docs/**");
|
DEFAULT_SKIP_URL.add("/v3/api-docs/**");
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* 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<String> skippedAddressCodes = new ArrayList<>();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -35,6 +35,10 @@
|
|||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-user-api</artifactId>
|
<artifactId>blade-user-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springblade</groupId>
|
||||||
|
<artifactId>blade-system-api</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -0,0 +1,209 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* 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<CommonAddressVO> 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<IPage<CommonAddressVO>> list(CommonAddressVO commonAddress, Query query) {
|
||||||
|
IPage<CommonAddressVO> 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<CommonAddressRemoveResultVO> 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<List<CommonAddressVO>> 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<CommonAddressExcel> 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<CommonAddress> buildExportQuery(CommonAddressVO commonAddress, String ids) {
|
||||||
|
LambdaQueryWrapper<CommonAddress> queryWrapper = Wrappers.<CommonAddress>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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* 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<CommonAddress> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义分页
|
||||||
|
*
|
||||||
|
* @param page 分页参数
|
||||||
|
* @param address 查询参数
|
||||||
|
* @return 常用地址列表
|
||||||
|
*/
|
||||||
|
List<CommonAddressVO> selectCommonAddressPage(IPage<CommonAddressVO> 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<CommonAddressVO> selectSourceOptions(@Param("addressType") String addressType, @Param("keyword") String keyword);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询业务引用数
|
||||||
|
*
|
||||||
|
* @param addressId 常用地址ID
|
||||||
|
* @return 引用数
|
||||||
|
*/
|
||||||
|
Integer countBusinessReference(@Param("addressId") Long addressId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="org.springblade.transport.mapper.CommonAddressMapper">
|
||||||
|
|
||||||
|
<resultMap id="commonAddressResultMap" type="org.springblade.transport.pojo.vo.CommonAddressVO">
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="tenant_id" property="tenantId"/>
|
||||||
|
<result column="create_user" property="createUser"/>
|
||||||
|
<result column="create_dept" property="createDept"/>
|
||||||
|
<result column="create_time" property="createTime"/>
|
||||||
|
<result column="update_user" property="updateUser"/>
|
||||||
|
<result column="update_time" property="updateTime"/>
|
||||||
|
<result column="status" property="status"/>
|
||||||
|
<result column="is_deleted" property="isDeleted"/>
|
||||||
|
<result column="address_code" property="addressCode"/>
|
||||||
|
<result column="address_name" property="addressName"/>
|
||||||
|
<result column="address_type" property="addressType"/>
|
||||||
|
<result column="source_id" property="sourceId"/>
|
||||||
|
<result column="site_code" property="siteCode"/>
|
||||||
|
<result column="detail_address" property="detailAddress"/>
|
||||||
|
<result column="region_code" property="regionCode"/>
|
||||||
|
<result column="region_name" property="regionName"/>
|
||||||
|
<result column="longitude" property="longitude"/>
|
||||||
|
<result column="latitude" property="latitude"/>
|
||||||
|
<result column="dept_id" property="deptId"/>
|
||||||
|
<result column="dept_name" property="deptName"/>
|
||||||
|
<result column="contact_name" property="contactName"/>
|
||||||
|
<result column="contact_phone" property="contactPhone"/>
|
||||||
|
<result column="remark" property="remark"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="BaseColumn">
|
||||||
|
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
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sql id="QueryCondition">
|
||||||
|
is_deleted = 0
|
||||||
|
<if test="address.addressName != null and address.addressName != ''">
|
||||||
|
<bind name="addressNameLike" value="'%' + address.addressName + '%'"/>
|
||||||
|
AND address_name LIKE #{addressNameLike}
|
||||||
|
</if>
|
||||||
|
<if test="address.addressType != null and address.addressType != ''">
|
||||||
|
AND address_type = #{address.addressType}
|
||||||
|
</if>
|
||||||
|
<if test="address.detailAddress != null and address.detailAddress != ''">
|
||||||
|
<bind name="detailAddressLike" value="'%' + address.detailAddress + '%'"/>
|
||||||
|
AND detail_address LIKE #{detailAddressLike}
|
||||||
|
</if>
|
||||||
|
<if test="address.regionName != null and address.regionName != ''">
|
||||||
|
<bind name="regionNameLike" value="'%' + address.regionName + '%'"/>
|
||||||
|
AND region_name LIKE #{regionNameLike}
|
||||||
|
</if>
|
||||||
|
<if test="address.siteCode != null and address.siteCode != ''">
|
||||||
|
AND site_code = #{address.siteCode}
|
||||||
|
</if>
|
||||||
|
<if test="address.deptId != null">
|
||||||
|
AND dept_id = #{address.deptId}
|
||||||
|
</if>
|
||||||
|
<if test="address.contactName != null and address.contactName != ''">
|
||||||
|
<bind name="contactNameLike" value="'%' + address.contactName + '%'"/>
|
||||||
|
AND contact_name LIKE #{contactNameLike}
|
||||||
|
</if>
|
||||||
|
<if test="address.contactPhone != null and address.contactPhone != ''">
|
||||||
|
<bind name="contactPhoneLike" value="'%' + address.contactPhone + '%'"/>
|
||||||
|
AND contact_phone LIKE #{contactPhoneLike}
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectCommonAddressPage" resultMap="commonAddressResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="BaseColumn"/>
|
||||||
|
FROM
|
||||||
|
blade_common_address
|
||||||
|
WHERE
|
||||||
|
<include refid="QueryCondition"/>
|
||||||
|
ORDER BY update_time DESC, create_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectMaxAddressCode" resultType="java.lang.String">
|
||||||
|
SELECT MAX(address_code)
|
||||||
|
FROM blade_common_address
|
||||||
|
WHERE address_code LIKE 'DZ%'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectPortTerminalSource" resultMap="commonAddressResultMap">
|
||||||
|
SELECT
|
||||||
|
id AS source_id,
|
||||||
|
code AS site_code,
|
||||||
|
name AS address_name,
|
||||||
|
CONCAT_WS('', country, city) AS region_name,
|
||||||
|
city AS detail_address,
|
||||||
|
longitude,
|
||||||
|
latitude
|
||||||
|
FROM blade_port_terminal
|
||||||
|
WHERE id = #{id} AND status = 1 AND is_deleted = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectRailwayStationSource" resultMap="commonAddressResultMap">
|
||||||
|
SELECT
|
||||||
|
id AS source_id,
|
||||||
|
code AS site_code,
|
||||||
|
name AS address_name,
|
||||||
|
CONCAT_WS('', province_name, city_name) AS region_name,
|
||||||
|
CONCAT_WS('', province_name, city_name, name) AS detail_address,
|
||||||
|
longitude,
|
||||||
|
latitude
|
||||||
|
FROM blade_railway_station
|
||||||
|
WHERE id = #{id} AND status = 1 AND is_deleted = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAirportMasterSource" resultMap="commonAddressResultMap">
|
||||||
|
SELECT
|
||||||
|
id AS source_id,
|
||||||
|
code AS site_code,
|
||||||
|
name AS address_name,
|
||||||
|
CONCAT_WS('', province_name, city_name) AS region_name,
|
||||||
|
CONCAT_WS('', province_name, city_name, name) AS detail_address,
|
||||||
|
longitude,
|
||||||
|
latitude
|
||||||
|
FROM blade_airport_master
|
||||||
|
WHERE id = #{id} AND status = 1 AND is_deleted = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectSourceOptions" resultMap="commonAddressResultMap">
|
||||||
|
<choose>
|
||||||
|
<when test="addressType == '港口/码头'">
|
||||||
|
SELECT
|
||||||
|
id AS source_id,
|
||||||
|
code AS site_code,
|
||||||
|
name AS address_name,
|
||||||
|
CONCAT_WS('', country, city) AS region_name,
|
||||||
|
city AS detail_address,
|
||||||
|
longitude,
|
||||||
|
latitude
|
||||||
|
FROM blade_port_terminal
|
||||||
|
WHERE status = 1 AND is_deleted = 0
|
||||||
|
<if test="keyword != null and keyword != ''">
|
||||||
|
<bind name="keywordLike" value="'%' + keyword + '%'"/>
|
||||||
|
AND (name LIKE #{keywordLike} OR code LIKE #{keywordLike})
|
||||||
|
</if>
|
||||||
|
ORDER BY code ASC
|
||||||
|
LIMIT 50
|
||||||
|
</when>
|
||||||
|
<when test="addressType == '铁路车站'">
|
||||||
|
SELECT
|
||||||
|
id AS source_id,
|
||||||
|
code AS site_code,
|
||||||
|
name AS address_name,
|
||||||
|
CONCAT_WS('', province_name, city_name) AS region_name,
|
||||||
|
CONCAT_WS('', province_name, city_name, name) AS detail_address,
|
||||||
|
longitude,
|
||||||
|
latitude
|
||||||
|
FROM blade_railway_station
|
||||||
|
WHERE status = 1 AND is_deleted = 0
|
||||||
|
<if test="keyword != null and keyword != ''">
|
||||||
|
<bind name="keywordLike" value="'%' + keyword + '%'"/>
|
||||||
|
AND (name LIKE #{keywordLike} OR code LIKE #{keywordLike})
|
||||||
|
</if>
|
||||||
|
ORDER BY code ASC
|
||||||
|
LIMIT 50
|
||||||
|
</when>
|
||||||
|
<when test="addressType == '空港机场'">
|
||||||
|
SELECT
|
||||||
|
id AS source_id,
|
||||||
|
code AS site_code,
|
||||||
|
name AS address_name,
|
||||||
|
CONCAT_WS('', province_name, city_name) AS region_name,
|
||||||
|
CONCAT_WS('', province_name, city_name, name) AS detail_address,
|
||||||
|
longitude,
|
||||||
|
latitude
|
||||||
|
FROM blade_airport_master
|
||||||
|
WHERE status = 1 AND is_deleted = 0
|
||||||
|
<if test="keyword != null and keyword != ''">
|
||||||
|
<bind name="keywordLike" value="'%' + keyword + '%'"/>
|
||||||
|
AND (name LIKE #{keywordLike} OR code LIKE #{keywordLike} OR iata_code LIKE #{keywordLike})
|
||||||
|
</if>
|
||||||
|
ORDER BY code ASC
|
||||||
|
LIMIT 50
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
SELECT NULL AS source_id, NULL AS site_code, NULL AS address_name, NULL AS region_name,
|
||||||
|
NULL AS detail_address, NULL AS longitude, NULL AS latitude
|
||||||
|
WHERE 1 = 0
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="countBusinessReference" resultType="java.lang.Integer">
|
||||||
|
SELECT 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* 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<CommonAddress> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义分页
|
||||||
|
*
|
||||||
|
* @param page 分页参数
|
||||||
|
* @param address 查询参数
|
||||||
|
* @return 常用地址分页
|
||||||
|
*/
|
||||||
|
IPage<CommonAddressVO> selectCommonAddressPage(IPage<CommonAddressVO> 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<CommonAddressVO> sourceOptions(String addressType, String keyword);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出常用地址
|
||||||
|
*
|
||||||
|
* @param queryWrapper 查询条件
|
||||||
|
* @return 导出数据
|
||||||
|
*/
|
||||||
|
List<CommonAddressExcel> exportCommonAddress(Wrapper<CommonAddress> queryWrapper);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,345 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* 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<CommonAddressMapper, CommonAddress> 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<CommonAddressVO> selectCommonAddressPage(IPage<CommonAddressVO> page, CommonAddressVO address) {
|
||||||
|
prepareQuery(address);
|
||||||
|
IPage<CommonAddressVO> 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<Long> idList = Func.toLongList(ids);
|
||||||
|
if (Func.isEmpty(idList)) {
|
||||||
|
throw new ServiceException("请选择需要删除的数据");
|
||||||
|
}
|
||||||
|
CommonAddressRemoveResultVO result = new CommonAddressRemoveResultVO();
|
||||||
|
List<Long> 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<CommonAddressVO> sourceOptions(String addressType, String keyword) {
|
||||||
|
String type = trimToEmpty(addressType);
|
||||||
|
if (TYPE_NORMAL.equals(type)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
validateAddressType(type);
|
||||||
|
List<CommonAddressVO> sourceList = baseMapper.selectSourceOptions(type, trimToNull(keyword));
|
||||||
|
sourceList.forEach(source -> {
|
||||||
|
source.setAddressType(type);
|
||||||
|
source.setSiteCodeDisplay(source.getSiteCode());
|
||||||
|
});
|
||||||
|
return sourceList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CommonAddressExcel> exportCommonAddress(Wrapper<CommonAddress> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* 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<CommonAddress, CommonAddressVO> {
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
48
doc/sql/transport/blade_common_address.sql
Normal file
48
doc/sql/transport/blade_common_address.sql
Normal file
@@ -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);
|
||||||
@@ -5988,4 +5988,59 @@ CREATE TABLE `blade_other_expense_record` (
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
COMMIT;
|
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;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user