首页>代码>Spring+Spring MVC+Mybatis+Bootstrap整合开发crm客户关系管理系统>/CRM/src/com/gjp/controller/CustomerController.java
package com.gjp.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.gjp.bean.BaseDict;
import com.gjp.bean.Customer;
import com.gjp.bean.Page;
import com.gjp.bean.QueryVo;
import com.gjp.service.CustomerService;
@Controller
@RequestMapping("/customer")
public class CustomerController {
@Autowired
private CustomerService customerService;
/**
* 高级查询列表信息
*/
@Value("${customer.dict.from}") //客户信息来源 002
private String from;
@Value("${customer.dict.industry}") //所属行业 001
private String industry;
@Value("${customer.dict.level}") //所属级别 006
private String level;
/**
* 客户列表
* @param model
* @return
* @throws Exception
*/
@RequestMapping("/list")
public String list(QueryVo vo,Model model) throws Exception {
//客户信息来源 002
List<BaseDict> sourceList = customerService.findDictByCode(from);
//所属行业 001
List<BaseDict> industryList = customerService.findDictByCode(industry);
//所属级别 006
List<BaseDict> levelList = customerService.findDictByCode(level);
//查询数据列表和数据总数
List<Customer> resultList = customerService.findCustomerByVo(vo);
Integer count = customerService.findCustomerByVoCount(vo);
//分页对象
Page<Customer> page = new Page<Customer>();
page.setTotal(count); //数据总数
page.setSize(vo.getSize()); //每页显示个数
page.setCurrentPage(vo.getPage()); //当前页数
page.setRows(resultList); //列表数据
//计算总页数
int pageCount = page.getTotal() / page.getSize();
if (page.getTotal() % page.getSize() > 0) {
pageCount++;
}
page.setPageCount(pageCount);//总页数
//分页查询数据
model.addAttribute("page",page);
//高级查询数据
model.addAttribute("fromType",sourceList);
model.addAttribute("industryType",industryList);
model.addAttribute("levelType",levelList);
//高级查询数据回显
model.addAttribute("custName",vo.getCustName());
model.addAttribute("custSource",vo.getCustSource());
model.addAttribute("custIndustry",vo.getCustIndustry());
model.addAttribute("custLevel",vo.getCustLevel());
return "customer";
}
/**
* 客户详情信息
* @param id
* @return
* @throws Exception
*/
@RequestMapping("/detail")
@ResponseBody
public Customer detail(Long id) throws Exception{
Customer customer = customerService.findCustomerById(id);
return customer;
}
/**
* 更新客户
* @param customer
* @throws Exception
*/
@RequestMapping("/update")
public String update(Customer customer) throws Exception{
customerService.updateCustomerById(customer);
return "customer";
}
/**
* 删除客户
* @param id
* @throws Exception
*/
@RequestMapping("/delete")
public String delete(Long id) throws Exception{
customerService.deleteCustomerById(id);
return "customer";
}
/**
* 添加客户
* @param customer
* @return
* @throws Exception
*/
@RequestMapping("/add")
public String add(Customer customer) throws Exception{
customerService.addCustomer(customer);
return "customer";
}
}
最近下载更多
xiaoaitx LV8
1月2日
森sdfgf LV8
2024年2月8日
zhunishimian LV6
2023年5月22日
and123456 LV11
2022年7月12日
testuser1234567 LV24
2022年5月23日
Justice_Eternal LV14
2022年4月12日
wanglinddad LV55
2022年4月11日
543666826 LV34
2021年11月28日
haiwen LV19
2021年9月9日
vNOCTISv LV4
2021年7月27日
最近浏览更多
xiaoaitx LV8
1月2日
bluerstar LV1
2024年10月23日
微信网友_7151914139078656 LV2
2024年9月4日
sunlea LV20
2024年5月22日
educationAAA LV11
2024年5月11日
shenghaer LV1
2024年2月9日
森sdfgf LV8
2024年2月8日
阿凡达 LV9
2024年1月29日
admin_z LV22
2024年1月29日
binlong520
2024年1月10日
暂无贡献等级

