用户支付信息录入代码优化

master
yangkai 6 years ago
parent 90e17cc5b8
commit 6929b209fa

@ -16,7 +16,7 @@ public class CustomerPaymentInfoImpl implements CustomerPaymentInfoService {
@Override @Override
public void saveCustomerPaymentInfo(JSONObject paymentInfo) { public void saveCustomerPaymentInfo(JSONObject paymentInfo) {
if (sysCustomerPaymentInfoMapper.selectPaymentInfo(paymentInfo.getString("wechat_openid")) != null) { if (sysCustomerPaymentInfoMapper.selectPaymentInfo(paymentInfo.getString("wechat_openid")) != null) {
throw new BadRequestException("openid exists"); throw new BadRequestException("openid already exists");
} }
sysCustomerPaymentInfoMapper.save(paymentInfo); sysCustomerPaymentInfoMapper.save(paymentInfo);
} }
@ -24,10 +24,7 @@ public class CustomerPaymentInfoImpl implements CustomerPaymentInfoService {
@Override @Override
public void updateCustomerPaymentInfo(JSONObject paymentInfo) { public void updateCustomerPaymentInfo(JSONObject paymentInfo) {
if (paymentInfo.getString("id") == null) { if (paymentInfo.getString("id") == null) {
throw new BadRequestException("ID is not empty"); throw new BadRequestException("ID is empty");
}
if (sysCustomerPaymentInfoMapper.selectById(paymentInfo.getString("id")) == null) {
throw new BadRequestException("ID:" + paymentInfo.getString("id") + " not exists!");
} }
sysCustomerPaymentInfoMapper.update(paymentInfo); sysCustomerPaymentInfoMapper.update(paymentInfo);
} }

@ -13,18 +13,18 @@ public class CustomerPaymentInfoController {
@Resource @Resource
private CustomerPaymentInfoService customerPaymentInfoService; private CustomerPaymentInfoService customerPaymentInfoService;
@RequestMapping(value = "/save", method = RequestMethod.POST) @RequestMapping(value = "/update", method = RequestMethod.POST)
public void saveTest(@RequestBody JSONObject paymentInfo) { public void savePaymentInfo(@RequestBody JSONObject paymentInfo) {
customerPaymentInfoService.saveCustomerPaymentInfo(paymentInfo); customerPaymentInfoService.saveCustomerPaymentInfo(paymentInfo);
} }
@RequestMapping(value = "/update", method = RequestMethod.PUT) @RequestMapping(value = "/update", method = RequestMethod.PUT)
public void updateTest(@RequestBody JSONObject paymentInfo) { public void updatePaymentInfo(@RequestBody JSONObject paymentInfo) {
customerPaymentInfoService.updateCustomerPaymentInfo(paymentInfo); customerPaymentInfoService.updateCustomerPaymentInfo(paymentInfo);
} }
@RequestMapping(value = "/{openid}/check", method = RequestMethod.GET) @RequestMapping(value = "/{openid}/check", method = RequestMethod.GET)
public JSONObject selectTest(@PathVariable String openid) { public JSONObject selectPaymentInfo(@PathVariable String openid) {
return customerPaymentInfoService.selectPaymentInfoByOpenId(openid); return customerPaymentInfoService.selectPaymentInfoByOpenId(openid);
} }
} }

Loading…
Cancel
Save