优化客户管理

master
zhiyong.ning 4 years ago
parent f4db9bcf02
commit 09ce7e004e
  1. 44
      src/main/java/com/yipin/liuwanr/controller/CustomerController.java
  2. 26
      src/main/java/com/yipin/liuwanr/service/CustomerService.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<String, Object> ret = customerService.addCustomer(customer);
HashMap<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> ret = customerService.queryCustomerIsExists(schoolId);
if (ret.isEmpty()) {

@ -21,7 +21,7 @@ public class CustomerService {
@Autowired
private CustomerMapper customerMapper;
//添加客户
public HashMap<String, Object> addCustomer(Customer customer){
HashMap<String, Object> resp = new HashMap<String, Object>();
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<String, Object> addAdmin(UserM userm){
HashMap<String, Object> resp = new HashMap<String, Object>();
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<String, Object> deleteCustomer(Customer customer){
HashMap<String, Object> resp = new HashMap<String, Object>();
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<String, Object> updateCustomer(Customer customer){
HashMap<String, Object> resp = new HashMap<String, Object>();
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;

Loading…
Cancel
Save