package com.example.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.Service.CustomerService;
import com.example.pojo.Customer;
import com.example.pojo.Insure;
import com.example.pojo.Report;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@RestController //说明当前类是控制层的类,返回的数据是json
@CrossOrigin //在服务器端支持跨域访问
@RequestMapping("/customer") //设置当前类的请求路径
public class CustomerController {
@Autowired
private CustomerService customerService;
/*
* 响应方法:
* 处理前端显示客户信息的请求方法--显示分页
* */
@RequestMapping("getOnePage") //设置当前方法的请求路径
public Map<String,Object> getOnePage(Integer page,Integer limit){
IPage<Customer> onePage= customerService.getOnePage(page, limit);
//将查到的信息构造成的map格式,以便前端使用
HashMap<String,Object> map=new HashMap<>();
map.put("code",0);
map.put("msg","");
map.put("count",onePage.getTotal()); //getTotal()获取onePage中所有的记录数
map.put("data",onePage.getRecords()); //getRecords()获取onePage中所有记录
return map;
}
@RequestMapping("getOnePagecus_name") //设置当前方法的请求路径
public Map<String,Object> getOnePagecus_name(Integer page,Integer limit,String cus_name){
IPage<Customer> onePage= customerService.getOnePagecus_name(page, limit,cus_name);
//将查到的信息构造成的map格式,以便前端使用
HashMap<String,Object> map=new HashMap<>();
map.put("code",0);
map.put("msg","");
map.put("count",onePage.getTotal()); //getTotal()获取onePage中所有的记录数
map.put("data",onePage.getRecords()); //getRecords()获取onePage中所有记录
return map;
}
@RequestMapping("getOnePagecus_industry") //设置当前方法的请求路径
public Map<String,Object> getOnePagecus_industry(Integer page,Integer limit,Integer cus_industry){
IPage<Customer> onePage= customerService.getOnePagecus_industry(page, limit,cus_industry);
//将查到的信息构造成的map格式,以便前端使用
HashMap<String,Object> map=new HashMap<>();
map.put("code",0);
map.put("msg","");
map.put("count",onePage.getTotal()); //getTotal()获取onePage中所有的记录数
map.put("data",onePage.getRecords()); //getRecords()获取onePage中所有记录
return map;
}
@RequestMapping("getOnePagecus_region") //设置当前方法的请求路径
public Map<String,Object> getOnePagecus_region(Integer page,Integer limit,Integer cus_region){
IPage<Customer> onePage= customerService.getOnePagecus_region(page, limit,cus_region);
//将查到的信息构造成的map格式,以便前端使用
HashMap<String,Object> map=new HashMap<>();
map.put("code",0);
map.put("msg","");
map.put("count",onePage.getTotal()); //getTotal()获取onePage中所有的记录数
map.put("data",onePage.getRecords()); //getRecords()获取onePage中所有记录
return map;
}
@RequestMapping("getOnePagecus_satisfy") //设置当前方法的请求路径
public Map<String,Object> getOnePagecus_satisfy(Integer page,Integer limit,Integer cus_satisfy){
IPage<Customer> onePage= customerService.getOnePagecus_satisfy(page, limit,cus_satisfy);
//将查到的信息构造成的map格式,以便前端使用
HashMap<String,Object> map=new HashMap<>();
map.put("code",0);
map.put("msg","");
map.put("count",onePage.getTotal()); //getTotal()获取onePage中所有的记录数
map.put("data",onePage.getRecords()); //getRecords()获取onePage中所有记录
return map;
}
/*
* 响应前端修改客户信息请求
* */
@RequestMapping("/update")
public Map<String,Object> update(Customer customer){
//1.调用service中的修改方法,并获取修改结果
Boolean flag = customerService.update(customer);
//2.构造返回的数据--修改成功或失败
HashMap<String, Object> map = new HashMap<>();
if(flag){
map.put("msg","修改成功");
}
else {
map.put("msg","修改失败");
}
return map;
}
//响应前端的添加客户信息的请求
@RequestMapping("/add")
public Map<String,Object> add(Customer customer){
//1.调用service中的修改方法,并获取修改结果
Boolean flag = customerService.add(customer);
//2.构造返回的数据--修改成功或失败
HashMap<String, Object> map = new HashMap<>();
if(flag){
map.put("msg","添加成功");
}
else {
map.put("msg","添加失败");
}
return map;
}
/*
* 响应前端删除客户信息的请求
* */
@RequestMapping("/delete")
public Map<String,Object> delete(Integer [] ids){
//Arrays.asList(ids)将ids数组转化为List<Integer>
Boolean flag = customerService.delete(Arrays.asList(ids));
HashMap<String, Object> map = new HashMap<>();
if(flag){
map.put("msg","删除成功");
}
else {
map.put("msg","删除失败");
}
return map;
}
@RequestMapping("/deleteid")
public Map<String,Object> deleteid(Integer cus_id){
//Arrays.asList(ids)将ids数组转化为List<Integer>
Boolean flag = customerService.deleteid(cus_id);
HashMap<String, Object> map = new HashMap<>();
if(flag){
map.put("msg","删除成功");
}
else {
map.put("msg","删除失败");
}
return map;
}
@RequestMapping("/getCusliushi")
public Map<String,Object> getCusliushi(){//流失客户
List<Customer> List = customerService.getCusliushi();
HashMap<String, Object> map = new HashMap<>();
if(!List.isEmpty()) {
map.put("code", 0); //正确
map.put("msg","");
map.put("data", List);
}
else {
map.put("code",1); //错误
map.put("msg", "沒有流失客戶信息");
}
return map;
}
@RequestMapping("/getCuscommon")
public Map<String,Object> getCuscommon(){//正常客户
List<Customer> List = customerService.getCuscommon();
HashMap<String, Object> map = new HashMap<>();
if(!List.isEmpty()) {
map.put("code", 0); //正确
map.put("msg","");
map.put("data", List);
}
else {
map.put("code",1); //错误
map.put("msg", "沒有该信息");
}
return map;
}
/*
* 响应获取客户地区及其客户数量的方法
* */
@RequestMapping("/getCusNumByRegion")
public Map<String,Object> getCusNumByRegion(){
//1.获取reportlist
//2.将reportlist中的item和num分别存放到xdata和ydata中
List<Report> reportList = customerService.getCusNumByRegion();
ArrayList<String> xdata = new ArrayList<>();
ArrayList<Integer> ydata = new ArrayList<>();
for(Report report:reportList){//for循环读取reportList里的数据
String item = report.getItem();
switch (item){
case "1":
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
保险业务与分析系统 IntelliJ IDEA 2022.1.3 Visual Studio Code (310个子文件)
UserController.class 12KB
CustomerController.class 11KB
InsureController.class 8KB
UserService.class 7KB
SalechanceController.class 7KB
CustomerService.class 6KB
InsureService.class 6KB
SalechanceService.class 5KB
Customer.class 4KB
Insure.class 4KB
InfoController.class 4KB
Salechance.class 4KB
UserDao.class 3KB
InsureDao.class 3KB
User.class 3KB
CrmserviceApplication.class 2KB
Contact.class 2KB
InfoService.class 2KB
ContactController.class 2KB
ContactService.class 2KB
Info.class 1KB
CustomerDao.class 1KB
SalechanceDao.class 1KB
Report.class 818B
InfoDao.class 551B
CrmserviceApplicationTests.class 539B
ContactDao.class 371B
mvnw.cmd 7KB
layui_blue.css 106KB
layui.css 106KB
layui_enterprise.css 106KB
layui.css 78KB
font-awesome.css 37KB
font-awesome.min.css 30KB
layer.css 14KB
layer.css 14KB
zyupload-1.0.0.min.css 9KB
laydate.css 7KB
laydate.css 7KB
login.css 4KB
code.css 1KB
code.css 1KB
fontawesome-webfont.eot 162KB
iconfont.eot 46KB
iconfont.eot 46KB
loading-0.gif 6KB
loading-0.gif 6KB
loading-2.gif 2KB
loading-2.gif 2KB
loading-1.gif 701B
loading-1.gif 701B
.gitignore 395B
.gitignore 184B
cuslist .html 84KB
salelist.html 54KB
userlist.html 34KB
zgsalelist.html 32KB
manager_index.html 19KB
myservice.html 19KB
supervisor_index.html 18KB
staff_index.html 17KB
common.html 16KB
userInfo.html 14KB
goonservice.html 13KB
liusi.html 12KB
quitinsure.html 12KB
bgcolor.html 12KB
zgconlist.html 11KB
zgliusi.html 11KB
zgcommon.html 11KB
cusupdate.html 10KB
cusadd.html 10KB
saleadd.html 9KB
saleupdate.html 9KB
details.html 8KB
login.html 8KB
fengpei.html 7KB
work.html 7KB
insuresevice.html 7KB
01.html 7KB
useradd.html 6KB
upassword.html 6KB
details.html 6KB
giveuserid.html 6KB
login-1.html 5KB
timeline.html 5KB
cuscredit.html 4KB
userregistry.html 4KB
info.html 4KB
cuslevel.html 4KB
about.html 3KB
cussatisfy.html 3KB
conlist.html 3KB
1.html 3KB
cusindustry.html 3KB
cusregion.html 2KB
02.html 2KB
test.html 1KB
lipeisure.html 0B
crmservice.iml 12KB
共 310 条
- 1
- 2
- 3
- 4
资源评论
m0_69748516
- 粉丝: 1
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功