Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qa-platform
Commits
0b6dcb8c
Commit
0b6dcb8c
authored
Oct 12, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化清除数据接口
parent
2f71ddc1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
108 deletions
+86
-108
ClearDataController.java
.../cn/qg/qaplatform/controller/yxm/ClearDataController.java
+86
-5
ClearDataService.java
...n/java/cn/qg/qaplatform/service/yxm/ClearDataService.java
+0
-8
ClearDataServiceImpl.java
.../qg/qaplatform/service/yxm/impl/ClearDataServiceImpl.java
+0
-95
No files found.
src/main/java/cn/qg/qaplatform/controller/yxm/ClearDataController.java
View file @
0b6dcb8c
package
cn
.
qg
.
qaplatform
.
controller
.
yxm
;
import
cn.qg.qaplatform.service.yxm.ClearDataService
;
import
cn.qg.qaplatform.utils.JsonResult
;
import
cn.qg.qaplatform.config.SwitchDataSource
;
import
cn.qg.qaplatform.entity.xyqbuser.User
;
import
cn.qg.qaplatform.service.xyqbUser.UserService
;
import
cn.qg.qaplatform.utils.Result
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@CrossOrigin
@RestController
public
class
ClearDataController
{
@Autowired
ClearDataService
clearDataService
;
JdbcTemplate
jdbcTemplate
;
@Autowired
UserService
userService
;
/**
* 清除用户数据
...
...
@@ -21,7 +33,76 @@ public class ClearDataController {
* @return
*/
@GetMapping
(
"/cleardata"
)
public
JsonResult
clearData
(
String
namespace
,
String
phoneNo
)
{
return
JsonResult
.
success
(
clearDataService
.
clearData
(
namespace
,
phoneNo
));
public
Result
clearData
(
String
namespace
,
String
phoneNo
)
{
User
user
=
userService
.
getUserInfoByPhoneNo
(
namespace
,
phoneNo
);
if
(
user
==
null
)
{
return
Result
.
buildErrorStateResult
(
String
.
format
(
"%s环境,用户%s不存在,无需清除!"
,
namespace
,
phoneNo
),
false
);
}
String
userId
=
String
.
valueOf
(
user
.
getId
());
String
uuid
=
user
.
getUuid
();
log
.
info
(
"开始删除{}环境{}用户kdsp中的数据!"
,
namespace
,
phoneNo
);
SwitchDataSource
.
dataSourceSwitch
(
namespace
,
"kdsp"
);
List
<
Map
<
String
,
Object
>>
orderList
=
jdbcTemplate
.
queryForList
(
"SELECT * FROM `t_order_info` WHERE user_id = "
+
userId
);
if
(
orderList
.
size
()
>
0
)
{
for
(
Map
<
String
,
Object
>
map:
orderList
)
{
String
orderNo
=
map
.
get
(
"order_no"
).
toString
();
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `t_order_sku` WHERE order_no = '%s'"
,
orderNo
));
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `t_order_coupon` WHERE order_no = '%s'"
,
orderNo
));
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `t_order_refund_apply` WHERE order_no = '%s'"
,
orderNo
));
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `t_order_refund_proof` WHERE order_no = '%s'"
,
orderNo
));
}
}
jdbcTemplate
.
execute
(
"DELETE FROM `t_user_shop_cart` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_user_receiver_addr` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_user_points_detail` WHERE `user_id` = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_user_points` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_order_info` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_order_sku_coupon` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_order_sku_activity` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_ka_process_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_coupon_user` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_comment_info` WHERE user_id = "
+
userId
);
log
.
info
(
"开始删除{}环境{}用户vcc_talos中的数据!"
,
namespace
,
phoneNo
);
SwitchDataSource
.
dataSourceSwitch
(
namespace
,
"vcc_talos"
);
jdbcTemplate
.
execute
(
"DELETE FROM `account` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `risk_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `auth_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `contract_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `credit_trade_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `debit_account` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `debit_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `msg_record` WHERE phone_no = '%s'"
,
phoneNo
));
jdbcTemplate
.
execute
(
"DELETE FROM `order_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `trade_record` WHERE user_id = "
+
userId
);
log
.
info
(
"开始删除{}环境{}用户acsdb中的数据!"
,
namespace
,
phoneNo
);
SwitchDataSource
.
dataSourceSwitch
(
namespace
,
"acsdb"
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_account` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_bill` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_cash_account` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_cash_account_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_commodity` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `acs_customer` WHERE uuid = '%s'"
,
uuid
));
jdbcTemplate
.
execute
(
"DELETE FROM `acs_pay_order` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_payment_order` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_plan` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `acs_sms` WHERE mobile_no = ''"
,
phoneNo
));
jdbcTemplate
.
execute
(
"DELETE FROM `acs_trans` WHERE user_id = "
+
userId
);
log
.
info
(
"开始删除{}环境{}用户vcc_quota中的数据!"
,
namespace
,
phoneNo
);
SwitchDataSource
.
dataSourceSwitch
(
namespace
,
"vcc_quota"
);
jdbcTemplate
.
execute
(
"DELETE FROM `user_quota_locker` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `user_quota_log` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `user_quota_record` WHERE user_id = "
+
userId
);
log
.
info
(
"开始删除{}环境{}用户xyqb_user中的数据!"
,
namespace
,
phoneNo
);
SwitchDataSource
.
dataSourceSwitch
(
namespace
,
"xyqb_user"
);
jdbcTemplate
.
execute
(
"DELETE FROM `user` WHERE id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `user_detail` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `wechat_userinfo` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `address` WHERE user_id = "
+
userId
);
return
Result
.
buildSuccessResult
(
String
.
format
(
"%s环境,用户%s数据清除成功"
,
namespace
,
phoneNo
),
true
);
}
}
src/main/java/cn/qg/qaplatform/service/yxm/ClearDataService.java
deleted
100644 → 0
View file @
2f71ddc1
package
cn
.
qg
.
qaplatform
.
service
.
yxm
;
/**
* 清除羊小咩数据
*/
public
interface
ClearDataService
{
boolean
clearData
(
String
namespace
,
String
phoneNo
);
}
src/main/java/cn/qg/qaplatform/service/yxm/impl/ClearDataServiceImpl.java
deleted
100644 → 0
View file @
2f71ddc1
package
cn
.
qg
.
qaplatform
.
service
.
yxm
.
impl
;
import
cn.qg.qaplatform.config.SwitchDataSource
;
import
cn.qg.qaplatform.entity.xyqbuser.User
;
import
cn.qg.qaplatform.service.xyqbUser.UserService
;
import
cn.qg.qaplatform.service.yxm.ClearDataService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@Service
public
class
ClearDataServiceImpl
implements
ClearDataService
{
@Autowired
UserService
userService
;
@Autowired
JdbcTemplate
jdbcTemplate
;
@Override
public
boolean
clearData
(
String
namespace
,
String
phoneNo
)
{
User
user
=
userService
.
getUserInfoByPhoneNo
(
namespace
,
phoneNo
);
String
userId
=
String
.
valueOf
(
user
.
getId
());
String
uuid
=
user
.
getUuid
();
log
.
info
(
"开始删除{}环境{}用户kdsp中的数据!"
,
namespace
,
phoneNo
);
SwitchDataSource
.
dataSourceSwitch
(
namespace
,
"kdsp"
);
List
<
Map
<
String
,
Object
>>
orderList
=
jdbcTemplate
.
queryForList
(
"SELECT * FROM `t_order_info` WHERE user_id = "
+
userId
);
if
(
orderList
.
size
()
>
0
)
{
for
(
Map
<
String
,
Object
>
map:
orderList
)
{
String
orderNo
=
map
.
get
(
"order_no"
).
toString
();
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `t_order_sku` WHERE order_no = '%s'"
,
orderNo
));
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `t_order_coupon` WHERE order_no = '%s'"
,
orderNo
));
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `t_order_refund_apply` WHERE order_no = '%s'"
,
orderNo
));
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `t_order_refund_proof` WHERE order_no = '%s'"
,
orderNo
));
}
}
jdbcTemplate
.
execute
(
"DELETE FROM `t_user_shop_cart` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_user_receiver_addr` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_user_points_detail` WHERE `user_id` = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_user_points` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_order_info` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_order_sku_coupon` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_order_sku_activity` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_ka_process_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_coupon_user` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `t_comment_info` WHERE user_id = "
+
userId
);
log
.
info
(
"开始删除{}环境{}用户vcc_talos中的数据!"
,
namespace
,
phoneNo
);
SwitchDataSource
.
dataSourceSwitch
(
namespace
,
"vcc_talos"
);
jdbcTemplate
.
execute
(
"DELETE FROM `account` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `risk_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `auth_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `contract_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `credit_trade_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `debit_account` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `debit_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `msg_record` WHERE phone_no = '%s'"
,
phoneNo
));
jdbcTemplate
.
execute
(
"DELETE FROM `order_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `trade_record` WHERE user_id = "
+
userId
);
log
.
info
(
"开始删除{}环境{}用户acsdb中的数据!"
,
namespace
,
phoneNo
);
SwitchDataSource
.
dataSourceSwitch
(
namespace
,
"acsdb"
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_account` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_bill` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_cash_account` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_cash_account_record` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_commodity` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `acs_customer` WHERE uuid = '%s'"
,
uuid
));
jdbcTemplate
.
execute
(
"DELETE FROM `acs_pay_order` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_payment_order` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `acs_plan` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
String
.
format
(
"DELETE FROM `acs_sms` WHERE mobile_no = ''"
,
phoneNo
));
jdbcTemplate
.
execute
(
"DELETE FROM `acs_trans` WHERE user_id = "
+
userId
);
log
.
info
(
"开始删除{}环境{}用户vcc_quota中的数据!"
,
namespace
,
phoneNo
);
SwitchDataSource
.
dataSourceSwitch
(
namespace
,
"vcc_quota"
);
jdbcTemplate
.
execute
(
"DELETE FROM `user_quota_locker` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `user_quota_log` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `user_quota_record` WHERE user_id = "
+
userId
);
log
.
info
(
"开始删除{}环境{}用户xyqb_user中的数据!"
,
namespace
,
phoneNo
);
SwitchDataSource
.
dataSourceSwitch
(
namespace
,
"xyqb_user"
);
jdbcTemplate
.
execute
(
"DELETE FROM `user` WHERE id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `user_detail` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `wechat_userinfo` WHERE user_id = "
+
userId
);
jdbcTemplate
.
execute
(
"DELETE FROM `address` WHERE user_id = "
+
userId
);
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