package cn.itheima.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 cn.itcast.utils.Page; import cn.itheima.pojo.BaseDict; import cn.itheima.pojo.Customer; import cn.itheima.pojo.QueryVo; import cn.itheima.service.CustomerService; @Controller @RequestMapping("/customer") public class CustomerController { @Autowired private CustomerService customerService; @Value("${customer.dict.source}") private String source; @Value("${customer.dict.industry}") private String industry; @Value("${customer.dict.level}") private String level; @RequestMapping("/list") public String list(QueryVo vo, Model model) throws Exception{ //客户来源 List<BaseDict> sourceList=customerService.findDictByCode(source); //所属行业 List<BaseDict> industryList=customerService.findDictByCode(industry); //客户级别 List<BaseDict> levelList=customerService.findDictByCode(level); if(vo.getCustName()!=null){ vo.setCustName(new String(vo.getCustName().getBytes("iso8859-1"),"utf-8")); } if(vo.getPage()==null){ vo.setPage(1); } //设置查询的其实记录条数 vo.setStart((vo.getPage() - 1) * vo.getSize()); //查询数据列表和数据总数 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.setPage(vo.getPage()); //当前页数 page.setRows(resultList); //数据列表 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"; } @RequestMapping("/detail") @ResponseBody public Customer detail(Long id) throws Exception{ Customer customer = customerService.findCustomerById(id); return customer; } @RequestMapping("/update") public String update(Customer customer) throws Exception{ customerService.updateCustomerById(customer); return "customer"; } @RequestMapping("/delete") public String delete(long id) throws Exception{ customerService.delCustomerById(id); return "customer"; } @RequestMapping("/insert") public String insert(Customer customer) throws Exception{ customerService.insertCustomerById(customer); return "customer"; } }

xzg123456 LV6
2024年6月19日
moukii LV1
2024年6月13日
wananall LV13
2024年3月13日
GK-MDR LV1
2024年3月7日
微信网友_6808943745421312 LV1
2024年1月5日
微信网友_6802139027345408 LV2
2023年12月31日
taoshen95 LV16
2023年12月25日
周敏国 LV9
2023年9月4日
1379585889 LV11
2023年6月2日
十一 LV4
2023年6月2日

超级无敌神圣大帅比 LV1
3月28日
1969749580
1月1日
暂无贡献等级
ma406805131 LV19
2024年12月9日
神秘人1234
2024年12月2日
暂无贡献等级
zvcbnlk LV2
2024年9月16日
微信网友_7151914139078656 LV2
2024年9月4日
799743530 LV11
2024年7月11日
微信网友_7051335135711232
2024年6月24日
暂无贡献等级
lun123456
2024年6月23日
暂无贡献等级
qiwwwww LV2
2024年6月20日