Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-csf
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-csf
Commits
d42b3c97
Commit
d42b3c97
authored
Sep 16, 2025
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fna接口32
parent
94ed1f70
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
302 additions
and
30 deletions
+302
-30
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiCustomerController.java
+10
-22
yd-csf-service/src/main/java/com/yd/csf/service/dto/CustomerUpdateRequest.java
+242
-7
yd-csf-service/src/main/java/com/yd/csf/service/service/CustomerService.java
+5
-0
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CustomerServiceImpl.java
+45
-1
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiCustomerController.java
View file @
d42b3c97
...
...
@@ -7,6 +7,7 @@ import com.yd.common.utils.RandomStringGenerator;
import
com.yd.csf.service.common.ErrorCode
;
import
com.yd.csf.service.dto.CustomerAddRequest
;
import
com.yd.csf.service.dto.CustomerQueryRequest
;
import
com.yd.csf.service.dto.CustomerUpdateRequest
;
import
com.yd.csf.service.dto.FnaQueryRequest
;
import
com.yd.csf.service.model.Customer
;
import
com.yd.csf.service.model.CustomerExpand
;
...
...
@@ -93,31 +94,18 @@ public class ApiCustomerController {
// }
/**
* 更新
fna(仅管理员可用)
* 更新
客户
*
* @param
fna
UpdateRequest
* @param
customer
UpdateRequest
* @return
*/
// @PostMapping("/update")
// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
// public Result<Boolean> updateFna(@RequestBody FnaUpdateRequest fnaUpdateRequest) {
// if (fnaUpdateRequest == null || fnaUpdateRequest.getId() <= 0) {
// throw new BusinessException(ErrorCode.PARAMS_ERROR);
// }
// // todo 在此处将实体类和 DTO 进行转换
// Customer customer = new Customer();
// BeanUtils.copyProperties(fnaUpdateRequest, customer);
// // 数据校验
// customerService.validFna(customer, false);
// // 判断是否存在
// long id = fnaUpdateRequest.getId();
// Customer oldFna = customerService.getById(id);
// ThrowUtils.throwIf(oldFna == null, ErrorCode.NOT_FOUND_ERROR);
// // 操作数据库
// boolean result = customerService.updateById(customer);
// ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
// return Result.success(true);
// }
@PostMapping
(
"/update"
)
public
Result
<
Boolean
>
updateCustomer
(
@RequestBody
CustomerUpdateRequest
customerUpdateRequest
)
{
if
(
customerUpdateRequest
==
null
||
customerUpdateRequest
.
getCustomerBizId
()
==
null
)
{
throw
new
BusinessException
(
ErrorCode
.
PARAMS_ERROR
.
getCode
(),
ErrorCode
.
PARAMS_ERROR
.
getMessage
());
}
return
Result
.
success
(
customerService
.
updateCustomer
(
customerUpdateRequest
));
}
/**
* 根据 customerBizId 获取客户(封装类)
...
...
yd-csf-service/src/main/java/com/yd/csf/service/dto/CustomerUpdateRequest.java
View file @
d42b3c97
package
com
.
yd
.
csf
.
service
.
dto
;
import
com.yd.csf.service.vo.AddressVO
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
/**
...
...
@@ -13,24 +17,254 @@ import java.util.List;
public
class
CustomerUpdateRequest
implements
Serializable
{
/**
* id
*
客户主表业务唯一
id
*/
private
Long
id
;
@Schema
(
description
=
"客户主表业务唯一id"
)
private
String
customerBizId
;
/**
*
标题
*
姓氏
*/
@Schema
(
description
=
"姓氏"
)
private
String
lastName
;
/**
* 名字
*/
@Schema
(
description
=
"名字"
)
private
String
firstName
;
/**
* 姓名
*/
@Schema
(
description
=
"姓名"
)
private
String
name
;
/**
* 姓氏拼音
*/
@Schema
(
description
=
"姓氏拼音"
)
private
String
lastNamePinyin
;
/**
* 名字拼音
*/
@Schema
(
description
=
"名字-英文"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
String
firstNamePinyin
;
/**
* 拼音全称
*/
@Schema
(
description
=
"姓名拼音"
)
private
String
pinyin
;
/**
* 称谓
*/
@Schema
(
description
=
"称谓 字典值: csf_customer_title"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
String
title
;
/**
* 内容
* 性别
*/
@Schema
(
description
=
"性别 字典值: sys_gender"
)
private
Object
gender
;
/**
* 生日
*/
@Schema
(
description
=
"生日"
)
private
Date
birthday
;
/**
* 出生日期
*/
@Schema
(
description
=
"客户出生日期"
)
private
Date
birthdate
;
/**
* 异常信息
*/
@Schema
(
description
=
"客户异常信息"
)
private
String
abnormal
;
/**
* 年龄
*/
@Schema
(
description
=
"年龄"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
String
age
;
/**
* 地区代码
*/
@Schema
(
description
=
"地区代码"
)
private
String
areaCode
;
/**
* 电话号码
*/
@Schema
(
description
=
"电话号码"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
String
phone
;
/**
* 电子邮箱
*/
@Schema
(
description
=
"电子邮箱"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
String
email
;
/**
* 是否吸烟
*/
@Schema
(
description
=
"是否吸烟 字典值: sys_no_yes"
)
private
String
smoke
;
/**
* 吸烟数量
*/
@Schema
(
description
=
"吸烟数量"
)
private
String
smokeQuantity
;
/**
* 行业
*/
@Schema
(
description
=
"行业"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
String
companyType
;
/**
* 固定电话
*/
@Schema
(
description
=
"固定电话"
)
private
String
fixedPhone
;
/**
* 来源
*/
@Schema
(
description
=
"客户来源"
)
private
String
source
;
/**
* 证件类型
*/
private
String
content
;
@Schema
(
description
=
"证件类型 字典值: csf_id_type"
)
private
String
idType
;
/**
*
标签列表
*
证件号码
*/
private
List
<
String
>
tags
;
@Schema
(
description
=
"证件号码"
)
private
String
idCard
;
/**
* 护照号
*/
@Schema
(
description
=
"护照号"
)
private
String
passport
;
/**
* 往来港澳通行证号码
*/
@Schema
(
description
=
"往来港澳通行证号码"
)
private
String
eepCode
;
/**
* 婚姻状况
*/
@Schema
(
description
=
"婚姻状况 字典值: csf_marriage"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
Object
marriage
;
/**
* 出生地
*/
@Schema
(
description
=
"出生地"
)
private
String
birthplace
;
/**
* 教育程度
*/
@Schema
(
description
=
"教育程度 字典值: csf_education"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
Object
education
;
/**
* 国籍 (国家/地区)
*/
@Schema
(
description
=
"国籍 (国家/地区)"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
String
country
;
/**
* 国籍 (国家/地区) 名称
*/
@Schema
(
description
=
"国籍 (国家/地区) 名称"
)
private
String
countryName
;
// region 客户扩展信息
/**
* 客户类型
*/
@Schema
(
description
=
"客户类型 字典值: csf_customer_type"
)
private
String
customerType
;
/**
* 居住地区代码
*/
@Schema
(
description
=
"居住地区代码"
)
private
String
residenceAreaCode
;
/**
* 住宅电话
*/
@Schema
(
description
=
"住宅电话"
)
private
String
residenceTelephone
;
/**
* 是否长期出国
*/
@Schema
(
description
=
"是否长期出国 字典值: sys_no_yes"
)
private
String
longtimeAbroad
;
/**
* 地址
*/
@Schema
(
description
=
"地址列表"
)
private
List
<
AddressVO
>
addressList
;
/**
* 公司名称
*/
@Schema
(
description
=
"公司名称"
)
private
String
companyName
;
/**
* 公司地区代码
*/
@Schema
(
description
=
"公司地区代码"
)
private
String
companyAreaCode
;
/**
* 公司电话
*/
@Schema
(
description
=
"公司电话"
)
private
String
companyTelephone
;
/**
* 职位
*/
@Schema
(
description
=
"职位"
)
private
String
position
;
/**
* 工作年限
*/
@Schema
(
description
=
"工作年限"
)
private
String
workYear
;
/**
* 薪资
*/
@Schema
(
description
=
"薪资"
)
private
BigDecimal
salary
;
// endregion
private
static
final
long
serialVersionUID
=
1L
;
}
\ No newline at end of file
yd-csf-service/src/main/java/com/yd/csf/service/service/CustomerService.java
View file @
d42b3c97
...
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yd.csf.service.dto.CustomerAddRequest
;
import
com.yd.csf.service.dto.CustomerQueryRequest
;
import
com.yd.csf.service.dto.CustomerUpdateRequest
;
import
com.yd.csf.service.dto.FnaQueryRequest
;
import
com.yd.csf.service.model.Customer
;
import
com.baomidou.mybatisplus.extension.service.IService
;
...
...
@@ -32,4 +33,8 @@ public interface CustomerService extends IService<Customer> {
Customer
getByCustomerBizId
(
String
customerBizId
);
Map
<
String
,
Object
>
addCustomer
(
CustomerAddRequest
customerAddRequest
);
void
validCustomer
(
Customer
customer
);
Boolean
updateCustomer
(
CustomerUpdateRequest
customerUpdateRequest
);
}
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CustomerServiceImpl.java
View file @
d42b3c97
...
...
@@ -15,6 +15,7 @@ import com.yd.csf.service.common.ErrorCode;
import
com.yd.csf.service.dao.CustomerMapper
;
import
com.yd.csf.service.dto.CustomerAddRequest
;
import
com.yd.csf.service.dto.CustomerQueryRequest
;
import
com.yd.csf.service.dto.CustomerUpdateRequest
;
import
com.yd.csf.service.dto.FnaQueryRequest
;
import
com.yd.csf.service.model.Customer
;
import
com.yd.csf.service.model.CustomerExpand
;
...
...
@@ -29,6 +30,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
import
java.util.*
;
...
...
@@ -180,7 +182,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
return
map
;
}
private
void
validCustomer
(
Customer
customer
)
{
@Override
public
void
validCustomer
(
Customer
customer
)
{
String
firstNamePinyin
=
customer
.
getFirstNamePinyin
();
if
(
StringUtils
.
isBlank
(
firstNamePinyin
))
{
throw
new
BusinessException
(
ErrorCode
.
PARAMS_ERROR
.
getCode
(),
"名字-英文不能为空"
);
...
...
@@ -215,6 +218,47 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
}
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
updateCustomer
(
CustomerUpdateRequest
customerUpdateRequest
)
{
// 判断是否存在
String
customerBizId
=
customerUpdateRequest
.
getCustomerBizId
();
Customer
oldCustomer
=
customerService
.
getByCustomerBizId
(
customerBizId
);
if
(
oldCustomer
==
null
)
{
throw
new
BusinessException
(
ErrorCode
.
NOT_FOUND_ERROR
.
getCode
(),
ErrorCode
.
NOT_FOUND_ERROR
.
getMessage
());
}
BeanUtils
.
copyProperties
(
customerUpdateRequest
,
oldCustomer
,
"customerBizId"
);
// 数据校验
customerService
.
validCustomer
(
oldCustomer
);
// 更新主表
boolean
result
=
customerService
.
updateById
(
oldCustomer
);
// 获取扩展表信息
CustomerExpand
customerExpand
=
customerExpandService
.
getByCustomerBizId
(
customerBizId
);
String
addressListJSON
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
customerUpdateRequest
.
getAddressList
()))
{
addressListJSON
=
GSON
.
toJson
(
customerUpdateRequest
.
getAddressList
());
}
if
(
customerExpand
!=
null
)
{
// 更新扩展表
BeanUtils
.
copyProperties
(
customerUpdateRequest
,
customerExpand
,
"customerBizId, customerExpandBizId"
);
customerExpand
.
setAddressList
(
addressListJSON
);
customerExpandService
.
updateById
(
customerExpand
);
}
else
{
// 扩展表不存在,创建扩展表
CustomerExpand
newCustomerExpand
=
new
CustomerExpand
();
BeanUtils
.
copyProperties
(
customerUpdateRequest
,
newCustomerExpand
,
"customerBizId"
);
newCustomerExpand
.
setAddressList
(
addressListJSON
);
newCustomerExpand
.
setCustomerExpandBizId
(
RandomStringGenerator
.
generateBizId16
(
"customer_expand"
));
newCustomerExpand
.
setCustomerBizId
(
customerBizId
);
customerExpandService
.
save
(
newCustomerExpand
);
}
return
true
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment