java ssm客户关系系统_ssm客户管理系统的设计与实现

ssm客户管理系统

1     需求

1.1   添加客户

客户填写信息,提交,将信息保存到数据库中。

1.2   删除客户

在每条查询出来的客户信息设置删除操作,点击即可删除。更新数据库。

1.3   更新客户信息

在每条查询出来的客户信息设置修改操作,点击进入修改界面,提交,更新数据库。

1.4   查询客户

查询所有的客户信息;根据客户名称进行模糊查询;根据客户类型进行查询。

2     编写思路

从后端向前端开始编写的思路。首先,编写dao层的增删改查的方法,这里大部分利用逆向工程生成的mapper接口中的crud的方法,模糊查询和根据客户类型查询则是重新自定义mapper和xml文件。其次,编写service接口和service实现类,通过spring注解开发,在service实现类中注入mapper接口类,在service实现类中调用mapper中的方法,实现crud操作。然后,开发controller层,注入service接口类,调用service接口中的方法,查询到的数据通过视图解析器解析modelAndView传到jsp界面。修改、删除和更新后通过redirect重定向到查询页面,查看操作后的客户信息。

2.1   dao层

2.1.1  逆向工程中mapper接口中的crud的方法。

运用到逆向工程中mapper接口的以下四个方法:

45e1a12adf771f68f6c53f9b85e48e57.png

2.1.2  模糊查询的mapper接口和xml

Mapper接口:

public interfaceCustomMapper {public List findAllCustom(HhCustomVo hhCustomVo)throwsException;

}

Mapper.xml:

/p>

PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

name like '%${hhCustom.name}%'

and category = #{hhCustom.category}

SELECT

* FROM hh_custom

2.2   service层

2.2.1  service接口

public interfaceCustomService {//根据客户id查询

public HhCustom findCustomById(Integer id)throwsException;//模糊查询客户信息

public List findAllCustom(HhCustomVo hhCustomVo)throwsException;//根据客户id删除客户

public void deleteCustomById(Integer id)throwsException;//添加用户

public void addCustom(HhCustom hhCustom)throwsException;//更新用户信息

public void updateCustom(Integer id,HhCustom hhCustom)throwsException;

}

2.2.2  service实现类

public class CustomServiceImpl implementsCustomService{

@Autowired

HhCustomMapper hhCustomMapper;

@Autowired

CustomMapper customMapper;

@Overridepublic HhCustom findCustomById(Integer id) throwsException {returnhhCustomMapper.selectByPrimaryKey(id);

}

@Overridepublic List findAllCustom(HhCustomVo hhCustomVo) throwsException {returncustomMapper.findAllCustom(hhCustomVo);

}

@Overridepublic void deleteCustomById(Integer id) throwsException {int row =hhCustomMapper.deleteByPrimaryKey(id);

}

@Overridepublic void addCustom(HhCustom hhCustom) throwsException {

hhCustomMapper.insertSelective(hhCustom);

}

@Overridepublic void updateCustom(Integer id, HhCustom hhCustom) throwsException {

hhCustom.setId(id);

hhCustomMapper.updateByPrimaryKeySelective(hhCustom);

}

}

2.3   controller层

@Controllerpublic classCustomController {

@Autowired

CustomService customService;//客户分类//customTypes表示最终将方法返回值放在request域中的key

@ModelAttribute("customTypes")public MapgetcustomTypes() {

Map customTypes = new HashMap();

customTypes.put("101", "普通客户");

customTypes.put("102", "意向客户");

customTypes.put("103", "活跃客户");

customTypes.put("104", "Vip客户");returncustomTypes;

}//模糊查询客户

@RequestMapping("/findAllCustom")public ModelAndView findAllCustom(HhCustomVo hhCustomVo) throwsException {

List customlist =customService.findAllCustom(hhCustomVo);

ModelAndView modelAndView= newModelAndView();

modelAndView.addObject("customlist", customlist);

modelAndView.setViewName("customlist");returnmodelAndView;

}//根据客户id查询

@RequestMapping("/findCustomByid")public ModelAndView findCustomByid(Integer id) throwsException {

HhCustom hhCustom=customService.findCustomById(id);

ModelAndView modelAndView= newModelAndView();

modelAndView.addObject("hhCustom", hhCustom);

modelAndView.setViewName("customlist");returnmodelAndView;

}//添加客户//String返回逻辑视图名,在springmvc中配置的视图解析器中配置jsp文件前后缀

@RequestMapping("/addCustom")public String addCustom() throwsException {return "add_custom";

}//添加客户submit

@RequestMapping("/addCustomSubmit")public String addCustomSubmit(HhCustom hhCustom) throwsException {

customService.addCustom(hhCustom);//重定向

return "redirect:findAllCustom.action";

}//删除客户

@RequestMapping("/deleteCustom")public String deleteCustom(Integer id) throwsException {

customService.deleteCustomById(id);return "redirect:findAllCustom.action";

}//更新客户信息

@RequestMapping("/updateCustom")public String updateCustom(Model model, Integer id) throwsException {

HhCustom hhCustom=customService.findCustomById(id);

model.addAttribute("hhCustom", hhCustom);return "update_custom";

}//更新客户信息submit

@RequestMapping("/updateCustomSubmit")public String updateCustomSubmit(Integer id, HhCustom hhCustom) throwsException {

customService.updateCustom(id, hhCustom);return "redirect:findAllCustom.action";

}

}

2.4   jsp界面

2.4.1  customlist.jsp

functionaddCustom(){

document.customForm.action="${pageContext.request.contextPath}/addCustom.action";

document.customForm.submit();

}

客戶列表

查询条件:

客戶名称:客戶类型:

${customType.value}

查询

客戶列表:

客戶名称客戶邮箱客戶电话客户类型操作

--%>

${custom.name }${custom.mail }${custom.phoneNumber }${custom.category }

--%>

修改

删除

2.4.2  add_custom.jsp

添加客户

添加客户信息:

客户名称客户邮箱客户电话号码客户类型

${customType.value} --%>

${customType.value}

2.4.3  update_custom.jsp

修改客户信息

修改客户信息:

客户名称客户邮箱客户电话号码客户类型

${customType.value} --%>

${customType.value }

${customType.value}

--%>

3     视图展示

3.1   查询

e1a88e09738d2e5139497f2e980b68d3.png

3.2   模糊查询

fd2e37a550a887d94060cda40ec6b98b.png

模糊查询加客户类型

9998a2ed6409ed08da936670f72ce4ca.png

3.3   添加

1c6ee406ee2f67d3d35510182a016a44.png

3.4   修改

1e6d362586399e1e87ba50bed0451d62.png

3.5   删除

616bb367c74959865736c36fe25f3b10.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值