首页>代码>ssm实现简单的crm客户管理系统>/客户管理系统/SSMBoot/src/com/rainnie/controller/CustomerController.java
package com.rainnie.controller;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpSession;

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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.rainnie.po.BaseDict;
import com.rainnie.po.Customer;
import com.rainnie.po.User;
import com.rainnie.service.BaseDictService;
import com.rainnie.service.CustomerService;
import com.rainnie.utils.Page;

@Controller
public class CustomerController {
	
	@Autowired
	private CustomerService customerService;
	
	@Autowired
	private BaseDictService baseDictService;
	
	/*
	 * 下面是加载并读取属性配置文件
	 */
	
	//客户来源
	@Value("${customer.from.type}")
	private String FROM_TYPE;
	// 客户所属行业
	@Value("${customer.industry.type}")
	private String INDUSTRY_TYPE;
	// 客户级别
	@Value("${customer.level.type}")
	private String LEVEL_TYPE;
	
	@RequestMapping("customer/list.action")
	public String list(@RequestParam(defaultValue="1")Integer page,@RequestParam(defaultValue="10")Integer rows,
			String custName, String custSource, String custIndustry,String custLevel, Model model) {
		Page<Customer> customers=customerService.findCustomerList(page, rows, custName, custSource, custIndustry, custLevel);	
		
		model.addAttribute("page",customers);
		
		List<BaseDict> fromType=baseDictService.selectBaseDictByTypeCode(FROM_TYPE);
		List<BaseDict> industryType=baseDictService.selectBaseDictByTypeCode(INDUSTRY_TYPE);
		List<BaseDict>  levelType=baseDictService.selectBaseDictByTypeCode(LEVEL_TYPE);
		
		model.addAttribute("fromType", fromType);
		model.addAttribute("industryType", industryType);
		model.addAttribute("levelType", levelType);
		model.addAttribute("custName", custName);
		model.addAttribute("custSource", custSource);
		model.addAttribute("custIndustry", custIndustry);
		model.addAttribute("custLevel", custLevel);
		
		return "customer";
		
	}
	
	/**
	 * 创建客户
	 */
	@RequestMapping("customer/create.action")
	@ResponseBody
	public String customerCreate(Customer customer,HttpSession session) {
		
		User user=(User) session.getAttribute("USER_SESSION");
		customer.setCust_create_id(user.getUser_id());
		
		Date date=new Date();
		Timestamp timeStamp=new Timestamp(date.getTime());
		customer.setCust_createtime(timeStamp);
		
		int rows=customerService.createCustomer(customer);
		if(rows>0) {
			return "OK";
		}else {
			return "FAIL";
		}
		
	}
	/**
	 * 通过id获取客户
	 */
	@RequestMapping("customer/getCustomerById.action")
	@ResponseBody
	public Customer getCustomerById(Integer id) {
	    Customer customer = customerService.getCustomerById(id);
	    return customer;
	}
	
	/**
	 * 更新客户
	 */
	@RequestMapping("customer/update.action")
	@ResponseBody
	public String customerUpdate(Customer customer) {
	    int rows = customerService.updateCustomer(customer);
	    if(rows > 0){
	        return "OK";
	    }else{
	        return "FAIL";
	    }
	}
	
	/**
	 * 删除客户
	 */
	@RequestMapping("customer/delete.action")
	@ResponseBody
	public String customerDelete(Integer id) {
	    int rows = customerService.deleteCustomer(id);
	    if(rows > 0){			
	        return "OK";
	    }else{
	        return "FAIL";			
	    }
	}
	
	
	
}
最近下载更多
微信网友_7151914139078656  LV2 2024年9月4日
pangzhihui  LV14 2024年6月7日
wananall  LV13 2024年3月13日
wuge123  LV8 2023年12月19日
枫林与爱00  LV1 2023年10月11日
周敏国  LV9 2023年9月4日
zcx12345678  LV6 2023年5月16日
Peri_qxy  LV2 2023年3月29日
 LV7 2023年3月29日
taoshen95  LV16 2022年12月11日
最近浏览更多
xiuele 2024年12月26日
暂无贡献等级
今天的我也很辛苦 2024年12月25日
暂无贡献等级
微信网友_7290996505972736  LV4 2024年12月11日
bluerstar  LV1 2024年10月23日
微信网友_7151914139078656  LV2 2024年9月4日
897258976  LV8 2024年8月29日
xzg123456  LV6 2024年6月18日
李俊雄  LV3 2024年4月30日
hmf1989 2024年4月26日
暂无贡献等级
yhe107  LV3 2024年4月7日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友