提交 9fd1f397 编写于 作者: 刘兴

对获取所有客户接口添加分页功能,修改部分接口的返回数据格式

上级 f63c5e96
......@@ -9,6 +9,7 @@ import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
......@@ -22,8 +23,20 @@ public class CustomerController {
CustomerService customerService;
@RequestMapping("/getallcus")
@ResponseBody
public Map<String,Object> getAllcus(){
List<Customer> customerList = customerService.queryAll();
public Map<String,Object> getAllCus(@RequestParam("page") Integer pageNumber, @RequestParam("limit")Integer pageSize){
int number;
int size;
if (pageNumber == null){
number = 1;
}else {
number = pageNumber;
}
if (pageSize == null){
size = 10;
}else {
size = pageSize;
}
PageData<Customer> customerList = customerService.queryAll(number,size);
Map<String,Object> customer = new HashMap<>();
if (customerList == null){
customer.put("code",-1);
......@@ -44,15 +57,15 @@ public class CustomerController {
public Map<String,Object> getonecus(String name){
Map<String,Object> customer = new HashMap<>();
if (name==null){
customer.put("code",-1);
customer.put("code",-9);
customer.put("message","查询名不为空");
} else {
List<Customer> customerList = customerService.queryByCusName(name);
if (customerList.size() == 0) {
customer.put("code", 0);
customer.put("message", "没有查询到姓名为:" + name + "的客户信息");
customer.put("code", -1);
customer.put("msg", "没有查询到姓名为:" + name + "的客户信息");
} else {
customer.put("code", 1);
customer.put("code", 0);
customer.put("message", "查询成功");
customer.put("data", customerList);
}
......@@ -66,10 +79,10 @@ public class CustomerController {
Map<String,Object> customermap = new HashMap<>();
if (customernum == 0){
customermap.put("code",-1);
customermap.put("message","修改失败");
customermap.put("message","修改失败");
}else {
customermap.put("code",200);
customermap.put("message","修改成功");
customermap.put("message","修改成功");
}
return customermap;
}
......@@ -80,26 +93,26 @@ public class CustomerController {
Map<String,Object> customermap = new HashMap<>();
if (customernum == 0){
customermap.put("code",-1);
customermap.put("message","插入失败");
customermap.put("message","添加失败!");
}else {
customermap.put("code",200);
customermap.put("message","插入成功");
customermap.put("message","添加成功!");
}
return customermap;
}
//客户信息的删除
@RequestMapping("/deleteHouse")
@RequestMapping("/deleteCustomer")
@ResponseBody
public Map<String,Object> deleteHousei(int customer_id){
Map<String,Object> customermap = new HashMap<>();
public Map<String,Object> deleteCustomer(int customer_id){
Map<String,Object> customerMap = new HashMap<>();
int num = customerService.deleteOneCus(customer_id);
if (num==0){
customermap.put("code",0);
customermap.put("message","删除失败!");
customerMap.put("code",-1);
customerMap.put("message","删除失败!");
}else {
customermap.put("code",200);
customermap.put("message","删除成功!");
customerMap.put("code",200);
customerMap.put("message","删除成功!");
}
return customermap;
return customerMap;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册