From 09ce7e004eca13bc0e745eb97991ba27dc88e146 Mon Sep 17 00:00:00 2001 From: "zhiyong.ning" <354350178@qq.com> Date: Fri, 24 Jul 2020 15:03:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=A2=E6=88=B7=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CustomerController.java | 44 ++++++++++++++----- .../liuwanr/service/CustomerService.java | 26 +++++------ 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/yipin/liuwanr/controller/CustomerController.java b/src/main/java/com/yipin/liuwanr/controller/CustomerController.java index 5c2be7c..fa09a7f 100644 --- a/src/main/java/com/yipin/liuwanr/controller/CustomerController.java +++ b/src/main/java/com/yipin/liuwanr/controller/CustomerController.java @@ -35,15 +35,39 @@ public class CustomerController { Response addCustomer(@RequestBody Customer customer) { Response resp = new Response(); UserM userm = new UserM(); - userm.setCityId(customer.getCityId()); - userm.setCountries(customer.getCountries()); - userm.setProvinceId(customer.getProvinceId()); - userm.setPhone(customer.getAdminPhone()); - userm.setEmail(customer.getEmail()); + Integer provinceId = customer.getProvinceId(); + Integer cityId = customer.getCityId(); + String countries = customer.getCountries(); + String phone = customer.getAdminPhone(); + String email = customer.getEmail(); + String name = customer.getAdminName(); + Integer schoolId = customer.getSchoolId(); + userm.setSchoolId(schoolId); + userm.setCityId(cityId); + userm.setCountries(countries); + userm.setProvinceId(provinceId); + userm.setPhone(phone); + userm.setEmail(email); + userm.setName(name); userm.setPassword("huoran123"); - if (customer.getCityId()==null) { + if (email==null||email==""){ resp.setStatus(300); - resp.setErrmessage("Parameter Invalid"); + resp.setErrmessage("邮箱不能为空!"); + }if (phone==null||phone==""){ + resp.setStatus(300); + resp.setErrmessage("电话不能为空!"); + }else if (name==null||name==""){ + resp.setStatus(300); + resp.setErrmessage("姓名不能为空!"); + }else if (schoolId==null){ + resp.setStatus(300); + resp.setErrmessage("学校不能为空!"); + }else if (provinceId==null){ + resp.setStatus(300); + resp.setErrmessage("省份不能为空!"); + }else if (cityId==null) { + resp.setStatus(300); + resp.setErrmessage("城市不能为空!"); } else { HashMap ret = customerService.addCustomer(customer); HashMap ret1 = customerService.addAdmin(userm); @@ -121,7 +145,7 @@ public class CustomerController { Response resp = new Response(); if (customer.getCustomer().isEmpty()) { resp.setStatus(300); - resp.setErrmessage("Parameter Invalid"); + resp.setErrmessage("客户不能为空!"); } else { HashMap ret = customerService.deleteCustomer(customer); int status = (int) ret.get("retcode"); @@ -144,7 +168,7 @@ public class CustomerController { Response resp = new Response(); if (customer.getCustomerId()==null) { resp.setStatus(300); - resp.setErrmessage("Parameter Invalid"); + resp.setErrmessage("客户不能为空!"); } else { HashMap ret = customerService.updateCustomer(customer); int status = (int) ret.get("retcode"); @@ -167,7 +191,7 @@ public class CustomerController { Response resp = new Response(); if (schoolId==null) { resp.setStatus(300); - resp.setErrmessage("Parameter Invalid"); + resp.setErrmessage("学校不能为空!"); }else { HashMap ret = customerService.queryCustomerIsExists(schoolId); if (ret.isEmpty()) { diff --git a/src/main/java/com/yipin/liuwanr/service/CustomerService.java b/src/main/java/com/yipin/liuwanr/service/CustomerService.java index 5d40f69..fc490a5 100644 --- a/src/main/java/com/yipin/liuwanr/service/CustomerService.java +++ b/src/main/java/com/yipin/liuwanr/service/CustomerService.java @@ -21,7 +21,7 @@ public class CustomerService { @Autowired private CustomerMapper customerMapper; - + //添加客户 public HashMap addCustomer(Customer customer){ HashMap resp = new HashMap(); try { @@ -30,12 +30,12 @@ public class CustomerService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "添加客户失败!"); return resp; } return resp; } - + //客户管理添加用户 public HashMap addAdmin(UserM userm){ HashMap resp = new HashMap(); try { @@ -44,7 +44,7 @@ public class CustomerService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "客户管理添加用户失败!"); return resp; } return resp; @@ -74,7 +74,7 @@ public class CustomerService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "查询客户失败!"); return resp; } return resp; @@ -88,7 +88,7 @@ public class CustomerService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "查询客户详情失败!"); return resp; } return resp; @@ -102,12 +102,12 @@ public class CustomerService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "查询客户是否存在失败!"); return resp; } return resp; } - + //删除客户 public HashMap deleteCustomer(Customer customer){ HashMap resp = new HashMap(); try { @@ -116,12 +116,12 @@ public class CustomerService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "删除客户失败!"); return resp; } return resp; } - + //更新客户 public HashMap updateCustomer(Customer customer){ HashMap resp = new HashMap(); try { @@ -130,7 +130,7 @@ public class CustomerService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "更新客户失败!"); return resp; } return resp; @@ -145,7 +145,7 @@ public class CustomerService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "查询行业类失败!"); return resp; } return resp; @@ -160,7 +160,7 @@ public class CustomerService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "查询行业失败!"); return resp; } return resp;