Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9722a4ccf0 | |||
| 03a4fab114 |
@@ -111,6 +111,7 @@
|
||||
code AS site_code,
|
||||
name AS address_name,
|
||||
CONCAT_WS('', country, city) AS region_name,
|
||||
NULL AS region_code,
|
||||
city AS detail_address,
|
||||
longitude,
|
||||
latitude
|
||||
@@ -124,6 +125,7 @@
|
||||
code AS site_code,
|
||||
name AS address_name,
|
||||
CONCAT_WS('', province_name, city_name) AS region_name,
|
||||
city_code AS region_code,
|
||||
CONCAT_WS('', province_name, city_name, name) AS detail_address,
|
||||
longitude,
|
||||
latitude
|
||||
@@ -137,6 +139,7 @@
|
||||
code AS site_code,
|
||||
name AS address_name,
|
||||
CONCAT_WS('', province_name, city_name) AS region_name,
|
||||
city_code AS region_code,
|
||||
CONCAT_WS('', province_name, city_name, name) AS detail_address,
|
||||
longitude,
|
||||
latitude
|
||||
@@ -152,6 +155,7 @@
|
||||
code AS site_code,
|
||||
name AS address_name,
|
||||
CONCAT_WS('', country, city) AS region_name,
|
||||
NULL AS region_code,
|
||||
city AS detail_address,
|
||||
longitude,
|
||||
latitude
|
||||
@@ -170,6 +174,7 @@
|
||||
code AS site_code,
|
||||
name AS address_name,
|
||||
CONCAT_WS('', province_name, city_name) AS region_name,
|
||||
city_code AS region_code,
|
||||
CONCAT_WS('', province_name, city_name, name) AS detail_address,
|
||||
longitude,
|
||||
latitude
|
||||
@@ -188,6 +193,7 @@
|
||||
code AS site_code,
|
||||
name AS address_name,
|
||||
CONCAT_WS('', province_name, city_name) AS region_name,
|
||||
city_code AS region_code,
|
||||
CONCAT_WS('', province_name, city_name, name) AS detail_address,
|
||||
longitude,
|
||||
latitude
|
||||
@@ -202,6 +208,7 @@
|
||||
</when>
|
||||
<otherwise>
|
||||
SELECT NULL AS source_id, NULL AS site_code, NULL AS address_name, NULL AS region_name,
|
||||
NULL AS region_code,
|
||||
NULL AS detail_address, NULL AS longitude, NULL AS latitude
|
||||
WHERE 1 = 0
|
||||
</otherwise>
|
||||
|
||||
@@ -64,6 +64,7 @@ public class CommonAddressServiceImpl extends BaseServiceImpl<CommonAddressMappe
|
||||
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_CODE_MAX_LENGTH = 32;
|
||||
private static final int REGION_MAX_LENGTH = 100;
|
||||
private static final int CONTACT_MAX_LENGTH = 50;
|
||||
private static final int PHONE_MAX_LENGTH = 30;
|
||||
@@ -90,6 +91,7 @@ public class CommonAddressServiceImpl extends BaseServiceImpl<CommonAddressMappe
|
||||
if (Func.isEmpty(address) || Objects.equals(address.getIsDeleted(), 1)) {
|
||||
throw new ServiceException("常用地址不存在");
|
||||
}
|
||||
validateReadableDept(address);
|
||||
CommonAddressVO addressVO = Objects.requireNonNull(BeanUtil.copyProperties(address, CommonAddressVO.class));
|
||||
fillDisplay(addressVO);
|
||||
return addressVO;
|
||||
@@ -99,7 +101,10 @@ public class CommonAddressServiceImpl extends BaseServiceImpl<CommonAddressMappe
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean submit(CommonAddress address) {
|
||||
boolean created = Func.isEmpty(address.getId());
|
||||
if (!created) {
|
||||
if (created) {
|
||||
fillCurrentDept(address);
|
||||
address.setAddressCode(null);
|
||||
} else {
|
||||
CommonAddress oldAddress = getEditableAddress(address.getId());
|
||||
address.setAddressCode(oldAddress.getAddressCode());
|
||||
address.setDeptId(oldAddress.getDeptId());
|
||||
@@ -209,6 +214,7 @@ public class CommonAddressServiceImpl extends BaseServiceImpl<CommonAddressMappe
|
||||
address.setSourceId(source.getSourceId());
|
||||
address.setSiteCode(source.getSiteCode());
|
||||
address.setDetailAddress(source.getDetailAddress());
|
||||
address.setRegionCode(source.getRegionCode());
|
||||
address.setRegionName(source.getRegionName());
|
||||
address.setLongitude(scale(source.getLongitude()));
|
||||
address.setLatitude(scale(source.getLatitude()));
|
||||
@@ -255,8 +261,18 @@ public class CommonAddressServiceImpl extends BaseServiceImpl<CommonAddressMappe
|
||||
if (Func.isEmpty(address.getDetailAddress())) {
|
||||
throw new ServiceException("详细地址不能为空");
|
||||
}
|
||||
if (Func.isEmpty(address.getRegionName())) {
|
||||
throw new ServiceException("行政区划不能为空");
|
||||
}
|
||||
if (Func.isEmpty(address.getLongitude())) {
|
||||
throw new ServiceException("经度不能为空");
|
||||
}
|
||||
if (Func.isEmpty(address.getLatitude())) {
|
||||
throw new ServiceException("纬度不能为空");
|
||||
}
|
||||
validateLength(address.getAddressName(), NAME_MAX_LENGTH, "地址名称不能超过100字");
|
||||
validateLength(address.getDetailAddress(), DETAIL_MAX_LENGTH, "详细地址不能超过255字");
|
||||
validateLength(address.getRegionCode(), REGION_CODE_MAX_LENGTH, "行政区划编码不能超过32字");
|
||||
validateLength(address.getRegionName(), REGION_MAX_LENGTH, "行政区划不能超过100字");
|
||||
validateLength(address.getContactName(), CONTACT_MAX_LENGTH, "联系人不能超过50字");
|
||||
validateLength(address.getContactPhone(), PHONE_MAX_LENGTH, "联系方式不能超过30字");
|
||||
@@ -290,6 +306,12 @@ public class CommonAddressServiceImpl extends BaseServiceImpl<CommonAddressMappe
|
||||
}
|
||||
}
|
||||
|
||||
private void validateReadableDept(CommonAddress address) {
|
||||
if (!AuthUtil.isAdministrator() && !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()));
|
||||
|
||||
@@ -12,9 +12,9 @@ CREATE TABLE `blade_common_address` (
|
||||
`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 '纬度',
|
||||
`region_name` varchar(100) NOT NULL COMMENT '行政区划',
|
||||
`longitude` decimal(12,6) NOT NULL COMMENT '经度',
|
||||
`latitude` decimal(12,6) NOT NULL COMMENT '纬度',
|
||||
`dept_id` bigint(20) NOT NULL COMMENT '所属组织ID',
|
||||
`dept_name` varchar(100) NOT NULL COMMENT '所属组织',
|
||||
`contact_name` varchar(50) DEFAULT NULL COMMENT '联系人',
|
||||
@@ -39,8 +39,7 @@ CREATE TABLE `blade_common_address` (
|
||||
-- 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),
|
||||
(2080000000000000010, 1164733399668962201, '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),
|
||||
|
||||
@@ -6002,9 +6002,9 @@ CREATE TABLE `blade_common_address` (
|
||||
`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 '纬度',
|
||||
`region_name` varchar(100) NOT NULL COMMENT '行政区划',
|
||||
`longitude` decimal(12,6) NOT NULL COMMENT '经度',
|
||||
`latitude` decimal(12,6) NOT NULL COMMENT '纬度',
|
||||
`dept_id` bigint(20) NOT NULL COMMENT '所属组织ID',
|
||||
`dept_name` varchar(100) NOT NULL COMMENT '所属组织',
|
||||
`contact_name` varchar(50) DEFAULT NULL COMMENT '联系人',
|
||||
@@ -6035,8 +6035,7 @@ 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),
|
||||
(2080000000000000010, 1164733399668962201, '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),
|
||||
|
||||
Reference in New Issue
Block a user