ssm框架客户管理系统代码
时间: 2023-12-20 21:31:08 浏览: 101
Java开发基于SSM框架开发的客户管理系统源码.zip
5星 · 资源好评率100%
基于SSM框架的客户管理系统源码可以实现用户管理和客户管理两大功能模块。其中,用户管理模块包括用户登录、注册、修改密码等功能;客户管理模块包括客户信息的增删改查功能。以下是客户管理系统的代码示例:
1. 用户登录功能代码示例:
```java
@RequestMapping(value = "/login", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> login(String username, String password, HttpSession session) {
Map<String, Object> resultMap = new HashMap<>();
User user = userService.login(username, password);
if (user != null) {
session.setAttribute("user", user);
resultMap.put("status", "success");
} else {
resultMap.put("status", "fail");
resultMap.put("msg", "用户名或密码错误!");
}
return resultMap;
}
```
2. 客户信息查询功能代码示例:
```java
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Map<String, Object> list(Integer page, Integer limit, String keyword) {
Map<String, Object> resultMap = new HashMap<>();
List<Customer> customerList = customerService.getCustomerList(page, limit, keyword);
Long count = customerService.getCustomerCount(keyword);
resultMap.put("code", 0);
resultMap.put("msg", "");
resultMap.put("count", count);
resultMap.put("data", customerList);
return resultMap;
}
```
3. 客户信息添加功能代码示例:
```java
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> add(Customer customer) {
Map<String, Object> resultMap = new HashMap<>();
int result = customerService.addCustomer(customer);
if (result > 0) {
resultMap.put("status", "success");
} else {
resultMap.put("status", "fail");
resultMap.put("msg", "添加客户信息失败!");
}
return resultMap;
}
```
阅读全文